UNPKG

@aws-amplify/analytics

Version:

Analytics category of aws-amplify

1 lines 3.28 kB
{"version":3,"file":"identifyUser.mjs","sources":["../../../../../src/providers/pinpoint/apis/identifyUser.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AnalyticsAction } from '@aws-amplify/core/internals/utils';\nimport { updateEndpoint, } from '@aws-amplify/core/internals/providers/pinpoint';\nimport { getAnalyticsUserAgentString } from '../../../utils';\nimport { resolveConfig, resolveCredentials } from '../utils';\n/**\n * Sends information about a user to Pinpoint. Sending user information allows you to associate a user to their user\n * profile and activities or actions in your application. Activity can be tracked across devices & platforms by using\n * the same `userId`.\n *\n * @param {IdentifyUserInput} params The input object used to construct requests sent to Pinpoint's UpdateEndpoint\n * API.\n *\n * @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.\n * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect.\n *\n * @returns A promise that will resolve when the operation is complete.\n *\n * @example\n * ```ts\n * // Identify a user with Pinpoint\n * await identifyUser({\n * userId,\n * userProfile: {\n * email: 'userEmail@example.com'\n * customProperties: {\n * phoneNumber: ['555-555-5555'],\n * },\n * }\n * });\n * ```\n *\n * @example\n * ```ts\n * // Identify a user with Pinpoint with some additional demographics\n * await identifyUser({\n * userId,\n * userProfile: {\n * email: 'userEmail@example.com'\n * customProperties: {\n * phoneNumber: ['555-555-5555'],\n * },\n * demographic: {\n * platform: 'ios',\n * timezone: 'America/Los_Angeles'\n * }\n * }\n * });\n */\nexport const identifyUser = async ({ userId, userProfile, options, }) => {\n const { credentials, identityId } = await resolveCredentials();\n const { appId, region } = resolveConfig();\n const { userAttributes } = options ?? {};\n await updateEndpoint({\n appId,\n category: 'Analytics',\n credentials,\n identityId,\n region,\n userAttributes,\n userId,\n userProfile,\n userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.IdentifyUser),\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,KAAK;AACzE,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,kBAAkB,EAAE;AAClE,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE;AAC7C,IAAI,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,IAAI,EAAE;AAC5C,IAAI,MAAM,cAAc,CAAC;AACzB,QAAQ,KAAK;AACb,QAAQ,QAAQ,EAAE,WAAW;AAC7B,QAAQ,WAAW;AACnB,QAAQ,UAAU;AAClB,QAAQ,MAAM;AACd,QAAQ,cAAc;AACtB,QAAQ,MAAM;AACd,QAAQ,WAAW;AACnB,QAAQ,cAAc,EAAE,2BAA2B,CAAC,eAAe,CAAC,YAAY,CAAC;AACjF,KAAK,CAAC;AACN;;;;"}