feat(analytics): add Amazon Connect Customer Profiles provider for identifyUser#14864
Draft
soberm wants to merge 3 commits into
Draft
feat(analytics): add Amazon Connect Customer Profiles provider for identifyUser#14864soberm wants to merge 3 commits into
soberm wants to merge 3 commits into
Conversation
…ovider
Add a new client-side Analytics provider that backs identifyUser with an
Amazon Connect Customer Profiles REST endpoint (typically fronted by a
Lambda). Additive only - the existing Pinpoint provider is untouched.
Core:
- Add ConnectCustomerProfilesProviderConfig (Analytics.CustomerProfiles =
{ endpoint, region }) composed into ResourcesConfig.Analytics
- Parse amazon_connect_customer_profiles in parseAnalytics (additive)
Analytics:
- New providers/customer-profiles provider mirroring the pinpoint structure
(apis/identifyUser, utils/resolveConfig, utils/resolveCredentials, types)
- identifyUser resolves config + Cognito user-pool access token, POSTs
{ userId, userProfile, options } to ${endpoint}/identify-user with a
Bearer token; 2xx -> void, non-2xx -> typed AnalyticsError
- Reuses AnalyticsIdentifyUserInput / UserProfile; plain fetch, no new deps
- Exposed via stable subpath @aws-amplify/analytics/customer-profiles
(kept out of the top-level public barrel)
- Unit tests for token attach, body shape, config/credential resolution
…d add changeset Expose the Amazon Connect Customer Profiles provider through the umbrella package subpath 'aws-amplify/analytics/customer-profiles' (mirroring the pinpoint/personalize subpaths) and add the release changeset (minor bump for @aws-amplify/analytics, @aws-amplify/core, aws-amplify). Additive only.
🦋 Changeset detectedLatest commit: f8139ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Please ensure that this PR:
A repository administrator is required to review this change. |
…es identifyUser
Extend the Amazon Connect Customer Profiles `identifyUser` provider to support
unauthenticated guest callers via Cognito Identity Pool credentials.
When no Cognito user-pool token is present, `resolveCredentials` now returns the
guest `credentials` + `identityId` and the request is SigV4-signed (`execute-api`)
and sent to `POST {endpoint}/identify-user-guest` using the shared core signer.
Authenticated callers continue to use `POST {endpoint}/identify-user` with a
bearer token.
Adds optional `options` fields (`deviceId`, `platform`, `appVersion`, and
`previousGuestIdentityId`); passing `previousGuestIdentityId` on an authenticated
call folds the prior guest profile into the authenticated one (merge-on-sign-in).
Route paths are centralized as `IDENTIFY_USER_PATH` / `GUEST_IDENTIFY_USER_PATH`
constants.
Additive and non-breaking: the public `IdentifyUserInput`/`UserProfile`
signatures are preserved and Pinpoint is untouched. Adds unit tests for the guest
identify + SigV4 attach, merge-on-sign-in, and error-mapping paths.
Open
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Adds a new, additive Analytics provider that backs
identifyUserwith an Amazon Connect Customer Profiles REST endpoint (typically fronted by a Lambda). Scoped strictly to the analyticsidentifyUserpath. Supports both authenticated (Cognito user pool) and guest / unauthenticated (Cognito Identity Pool) callers.What's included
packages/analytics/src/providers/customer-profiles/mirroring the existing Pinpoint provider structure (apis/identifyUser,utils/resolveConfig,utils/resolveCredentials,types).identifyUserresolves config + the caller's auth session andPOSTs{ userId, userProfile, options }to the endpoint (2xx →void; non-2xx / network error → typedAnalyticsError). Plainfetchfor the authenticated path; the shared core signer for the guest path — no new dependencies.POST ${endpoint}/identify-userwith anAuthorization: Bearer <accessToken>header. The profile is keyed on the caller'scognitoSub.resolveCredentialsreturns the guestcredentials+identityId, and the request is SigV4-signed (serviceexecute-api, viasignRequestfrom@aws-amplify/core/internals/aws-client-utils) and sent toPOST ${endpoint}/identify-user-guest. The profile is keyed on the caller's Identity PoolidentityId, enabling pre-sign-in use cases such as registering a device token before login. The auth mode is selected automatically from the resolved session.optionsfieldsdeviceId,platform,appVersion, andpreviousGuestIdentityId. PassingpreviousGuestIdentityIdon an authenticated call folds the prior guest profile (and its devices) into the authenticated profile. Route paths are centralized as theIDENTIFY_USER_PATH/GUEST_IDENTIFY_USER_PATHconstants.analytics.amazon_connect_customer_profileskey inamplify_outputs({ aws_region, endpoint }) is parsed byparseAnalyticsintoResourcesConfig.Analytics.CustomerProfiles { endpoint, region }. New exported typeConnectCustomerProfilesProviderConfig. Pinpoint parsing is untouched.aws-amplify/analytics/customer-profiles(and@aws-amplify/analytics/customer-profiles), mirroring how thepinpoint/personalizesubpaths are exposed. Kept out of the top-level public barrel.amplify_outputsparsing, and the guest flow — guest SigV4 signing/attach to/identify-user-guest,previousGuestIdentityIdmerge-on-sign-in, and error mapping.Backward compatibility
IdentifyUserInput = AnalyticsIdentifyUserInput<IdentifyUserOptions>, reusing the sharedUserProfilefrom@aws-amplify/core. The newoptionsfields are all optional..changeset/analytics-connect-customer-profiles-identify-user.md).Issue #, if available
N/A
Description of how you validated changes
tsc --noEmittype-checks pass for@aws-amplify/core,@aws-amplify/analytics, and theaws-amplifyumbrella (after building analytics so the new subpath.d.tsresolves).changeset statusconfirms the intended minor bumps for@aws-amplify/analytics,@aws-amplify/core, andaws-amplify.nodetest environment.jsdomenvironment currently fails at test-suite setup with a pre-existing, environmentalERR_REQUIRE_ESM(jsdom →http-proxy-agent→@tootallnate/once) on Node v18.20.2 — a pre-existing Pinpoint test fails identically, confirming it is unrelated to these changes. The DOM-free customer-profiles tests were therefore run with--testEnvironment=node; CI is expected to run the full suite normally.Checklist
yarn testpasses (the customer-profiles suite passes 16/16 under--testEnvironment=node; the defaultjsdomenv is blocked locally by the pre-existing environmentalERR_REQUIRE_ESMdescribed above; CI expected to pass)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.