Pinpoint - new endpoints are created for the user without deleting the old ones, which causes the number of endpoints to reach 10 (which is the max)
See original GitHub issueDescribe the bug In my React Native app I call the updateEndpoint function whenever the app starts so that it creates an endpoint for my user if it doesn’t exist, and update data if the endpoint already exists (Demographic, Location etc). What I think happens is that it creates an endpoint every time, and using the AWS CLI to list endpoints for my user I can see a lot of endpoints that have the INACTIVE status, and then an endpoint with the same address that has an ACTIVE status, according to the docs -
Amazon Pinpoint automatically sets this value to ACTIVE when you create an endpoint or update an existing endpoint. Amazon Pinpoint automatically sets this value to INACTIVE if you update another endpoint that has the same address specified by the Address property.
Maybe is there a way that Amplify can check if there are INACTIVE endpoints for the user then delete them? And if there are active endpoints for the user then use them and do not create new ones.
To Reproduce Call Analytics.updateEndpoint with the notification token of the device when the app starts, after a few times (some re-installs, different app builds) you will see you have a lot of endpoint even though you are only using a single device.
Expected behavior Analytics.updateEndpoint() function knows how to handle existing endpoints, new endpoints, old endpoints…
Code Snippet
await Analytics.updateEndpoint({
address: pushToken,
userId: userId,
userAttributes: {
...userAttributes,
},
optOut: 'NONE',
});
What is Configured? the fields that exist in the aws-exports file are
aws_project_region
aws_cognito_identity_pool_id
aws_cognito_region
aws_user_pools_id
aws_user_pools_web_client_id
aws_appsync_graphqlEndpoint
aws_appsync_region
aws_appsync_authenticationType
aws_user_files_s3_bucket
aws_user_files_s3_bucket_region
aws_mobile_analytics_app_id
aws_mobile_analytics_app_region
and the custom config for Amplify.configure looks like this
const config = {
...aws_exports,
graphql_headers: async () => {
try {
const token = (await Auth.currentSession()).getIdToken().getJwtToken();
return { Authorization: token };
} catch (e) {
console.error(e);
return {};
}
},
Auth: {
storage: AmplifyCommunityAsyncStorage,
},
PushNotification: {
appId: aws_exports.aws_mobile_analytics_app_id,
requestIOSPermissions: false,
},
};
Additional context Maybe I am using Analytics.updateEndpoint() wrong… I would be happy to see what the recommended usage it, because the docs don’t say anything about usage - they just show a very simple example and no real usage which is disappointing.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top GitHub Comments
So @hkjpotato committed #8992 to set the channel type to PUSH for web analytics but then, seemingly, undid that commit with #8999.
Does that mean we still don’t have a fix for web analytics?
We’re using AWS Amplify only with web browsers, so we don’t have “devices” to worry about. All of our endpoints are set to the logged-in user’s email address but because the RequestId value changes each time, new endpoints are being created over and over again for the same user.
For web analytics, I just want one endpoint per user. Is that really so hard to achieve?
Thank you for providing this feedback. Since Amplify JS is a proxy to the Amazon Pinpoint service, I have marked this as a feature request and will let the Pinpoint service team know about this feature request. Thanks!