Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(auth,analytics): adding in-line docs for public apis #12882

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ import { ConsoleLogger } from '@aws-amplify/core';

const logger = new ConsoleLogger('KinesisFirehose');

/**
* Record one analytic event and send it to Kinesis Data Firehose. Events will be buffered and periodically sent to
* Kinesis Data Firehose.
*
* @param params The input object used to construct the request.
*
* @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
* configuration is incorrect.
*
* @example
* ```ts
* record({
* streamName: 'myFirehoseStream',
* data: { } // The data blob to put into the record
* });
* ```
*/
export const record = ({ streamName, data }: RecordInput): void => {
if (!isAnalyticsEnabled()) {
logger.debug('Analytics is disabled, event will not be recorded.');
Expand Down
21 changes: 21 additions & 0 deletions packages/analytics/src/providers/kinesis/apis/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ import { ConsoleLogger } from '@aws-amplify/core';

const logger = new ConsoleLogger('Kinesis');

/**
* Record one analytic event and send it to Kinesis. Events will be buffered and periodically sent to
* Kinesis.
*
* @param params The input object used to construct the request.
*
* @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
* configuration is incorrect.
*
* @example
* ```ts
* record({
* streamName: 'myKinesisStream',
* partitionKey: 'myPartitionKey',
* data: { } // The data blob to put into the record
* });
* ```
* @param input - The event to record.
*
* @returns void
*/
export const record = ({
streamName,
partitionKey,
Expand Down
25 changes: 25 additions & 0 deletions packages/analytics/src/providers/personalize/apis/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ import {

const logger = new ConsoleLogger('Personalize');

/**
* Record one analytic event and send it to Personalize. Events will be buffered and periodically sent to Amazon
* Personalize.
*
* For more examples, you can refer to {@link https://docs.amplify.aws/javascript/build-a-backend/more-features/analytics/personalize-recommendations/#working-with-the-api the API usage guidance.}
*
* @param input The input object used to construct the request.
*
* @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
* configuration is incorrect.
*
* @example
* ```ts
* // Record an `Identify` event to Personalize.
* record({
* eventType: "Identify",
* properties: {
* userId: "<USER_ID>"
* }
* });
* ```
* @param input - The event to record.
*
* @returns void
*/
export const record = ({
userId,
eventId,
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/src/providers/pinpoint/apis/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const logger = new ConsoleLogger('Analytics');
/**
* Records an Analytic event to Pinpoint. Events will be buffered and periodically sent to Pinpoint.
*
* @param {RecordInput} params The input object used to construct the request.
* @param params The input object used to construct the request.
*
* @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
* configuration is incorrect.
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"jsRules": {},
"rules": {
"prefer-const": true,
"max-line-length": [true, 120],
"max-line-length": [true, { "limit": 120, "ignore-pattern": "\\s\\*" }],
"no-empty-interface": true,
"no-var-keyword": true,
"object-literal-shorthand": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

import { CognitoUserPoolsTokenProvider } from './CognitoUserPoolsTokenProvider';

/**
* The default provider for the JWT access token and ID token issued from the configured Cognito user pool. It manages
* the refresh and storage of the tokens. It stores the tokens in `window.localStorage` if available, and falls back to
* in-memory storage if not.
*/
export const cognitoUserPoolsTokenProvider =
new CognitoUserPoolsTokenProvider();

Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/singleton/Auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export class AuthClass {
this.authOptions = authOptions;
}

/**
* Fetch the auth tokens, and the temporary AWS credentials and identity if they are configured. By default it
* does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
* with `{ forceRefresh: true }` input.
*
* @param options - Options configuring the fetch behavior.
*
* @returns Promise of current auth session {@link AuthSession}.
*/
async fetchAuthSession(
options: FetchAuthSessionOptions = {}
): Promise<AuthSession> {
Expand Down
Loading