aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Add endpointID to UpdateEndpoinT analytics API #4573

Open sarkuma opened 4 years ago

sarkuma commented 4 years ago

Is your feature request related to a problem? Please describe. Can you please add endpointID as part of https://aws-amplify.github.io/amplify-js/api/classes/analyticsclass.html#updateendpoint like in pinpoint

Describe the solution you'd like In this way I can update an existing endpoint and also create multiple endpoints in AWS Pinpoint

mynameisguy commented 4 years ago

+1

cloudspeak commented 3 years ago

I'd just like to expand on why this is a useful feature for some of us. Our system has a signup form with attributes such as email address, location etc., which we wish to add to the new user's Pinpoint endpoint. However, they are not actually logged in after signing up, so we do not want to set the global endpoint ID through configure until they have done so. But, since the endpoint ID cannot be overridden in updateEndpoint, we have to call configure to set it to the newly created user's endpoint ID, call updateEndpoint, and then set it back to the unauthenticated endpoint ID. This is messy and feels unecessary given that Pinpoint itself does allow passing the endpointID into updateEndpoint, and Amplify has actively removed it.

KevinToala commented 2 years ago

Reviewing the aws amplify code. I managed to update the endpointId with the following code.

// @ts-ignore
Analytics._pluggables.forEach(pluggable => {
  if (pluggable.getProviderName() === 'AWSPinpoint') {
    const endpointId = `email-endpoint-${USER_ID}`;
    pluggable._config.endpointId = endpointId;
    this.setCachePinpointEndpointId(endpointId);
  }
});

in this case our USER_ID is the SUB property of the user returned by cognito.

The code above should always be called before calling the updateEndpoint() function.

cwomack commented 1 year ago

Hello @sarkuma. I know this feature request has been outstanding for a while, but curious if you saw the comment above by @KevinToala to implement a workaround utilizing the property within a user returned by Cognito.

CC: @cloudspeak and @mynameisguy