amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

V6 is missing updateEndpoint()

Open bergmorten opened this issue 1 year ago • 8 comments

Before opening, please confirm:

JavaScript Framework

Vue

Amplify APIs

Analytics

Amplify Categories

analytics

Environment information

# Put output below this line
Not relevevant

Describe the bug

Update endpoint in V5 is not included in V6. Is this a bug or is the a reason why it has been removed?

I can see that V6 uses updateEndpoint() internally in the function identifyUser() so is should be possible to expose updateEndpoint() ?

This is the a relevant pull request for V5? #11330

Expected behavior

Have the same methods and options as in V5 to make migration more easy

Reproduction steps

Compare doc and code for analytics V5 vs v6

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

bergmorten avatar Nov 23 '23 08:11 bergmorten

Update

identifyUser in package aws-amplify/in-app-messaging has all we need, except that channel is locked to CHANNEL_TYPE which is IN_APP

bergmorten avatar Nov 23 '23 09:11 bergmorten

Hi @bergmorten thank you for opening this issue. In V6 of the aws-amplify library, the updateEndpoint method of Analytics has been deprecated and you should instead use identifyUser as you mentioned. I'm curious to hear if there are any issues or limitations you are facing with this?

nadetastic avatar Nov 28 '23 01:11 nadetastic

We need a function to add FCM/GCM tokens in order to send push messages. We do not want to use the in app messages because it is not supported in our region and we need a better control of the messages.

Analytics->identifyUser only stores userAttributes from options, we need the address and channel field.

export const identifyUser = async ({
	userId,
	userProfile,
	options,
}: IdentifyUserInput): Promise<void> => {
	const { credentials, identityId } = await resolveCredentials();
	const { appId, region } = resolveConfig();
	const { userAttributes } = options ?? {}; // Does not destruct channel or address
	updateEndpoint({
		appId,
		category: 'Analytics',
		credentials,
		identityId,
		region,
		userAttributes,
		userId,
		userProfile,
		userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.IdentifyUser),
	});
};

Notification->identifyUser stores address, but channel is fixed to IN_APP.

export const identifyUser = async ({
	userId,
	userProfile,
	options,
}: IdentifyUserInput): Promise<void> => {
	assertIsInitialized();
	const { credentials, identityId } = await resolveCredentials();
	const { appId, region } = resolveConfig();
	const { address, optOut, userAttributes } = options ?? {};
	updateEndpoint({
		address,
		channelType: CHANNEL_TYPE,
		optOut,
		appId,
		category: CATEGORY,
		credentials,
		identityId,
		region,
		userAttributes,
		userId,
		userProfile,
		userAgentValue: getInAppMessagingUserAgentString(
			InAppMessagingAction.IdentifyUser
		),
	});
};

PushNotifications->identifyUser is probably what we should have used, but this is disabled (Only native apps?)

export const identifyUser: IdentifyUser = async () => {
	throw new PlatformNotSupportedError();
};

And last:

https://github.com/aws-amplify/amplify-js/blob/main/packages/core/src/providers/pinpoint/apis/updateEndpoint.ts has all the option but is not exposed.

bergmorten avatar Nov 28 '23 12:11 bergmorten

@bergmorten, thank you for the detailed follow up. We've marked this as a bug due to the regression from a feature-parity standpoint migrating from v5. We'll update this issue with progress as we make it!

cwomack avatar Dec 05 '23 21:12 cwomack

any update on this ?

pascalito007 avatar Dec 16 '23 01:12 pascalito007

Updating this issue to be a feature request, since the removal of the updateEndpoint method was intentional going to v6. However, we didn't fully consider the use case outlined by @bergmorten's comment above. We're still reviewing this for a fix/feature implementation, but wanted to at least give this update.

cwomack avatar Feb 12 '24 20:02 cwomack

@cwomack any update on this?

soplan avatar May 15 '24 14:05 soplan

We use pinpoint to send marketing e-mails so having the ability to set Address, ChannelType to EMAIL and OptOut to NONE would be great. Else we need to migrate back to v5.

soplan avatar May 15 '24 17:05 soplan