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.44k stars 2.13k forks source link

Unable to create Analytics identifyUser with EMAIL or SMS or Push notification channel #12721

Open pascalito007 opened 11 months ago

pascalito007 commented 11 months ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Analytics

Amplify Categories

analytics

Environment information

``` # Put output below this line ```

Describe the bug

When using identifyUser from Analytics, I have no options for channel and optout. This is available in the In-App aws-amplify/in-app-messaging but not in @aws-amplify/analytics. Before migrating to V6 it was working in V5.

Expected behavior

I should be able to specify channelType and optout in order to identify an analytics pinpoint user.

Reproduction steps

  1. import identifyUser from @aws-amplify/analytics
  2. create an EMAIL segment in pinpoint console
  3. create a journey that send email to users created using identifyUser based on an event
  4. The email is never sent and the user never enter the journey

Code Snippet

import { record, identifyUser } from "@aws-amplify/analytics";

await identifyUser({
          userId: user.userId,
          userProfile: {
            email: "xxxxxxxxx@gmail.com",
          },
        });

        record({ name: "TestEvent" });

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

cwomack commented 11 months ago

@pascalito007, confirmed this is a feature we don't have in v6 out of the box. I'll label this as a feature request and will review it with our team internally! Thank you for creating this issue and just want to confirm the context here. It sounds like you're basically wanting to send an email when an event is recorded, right?

pascalito007 commented 11 months ago

Yes correct @cwomack I have a pinpoint journey which send EMAIL to EMAIL channel type segment and SMS to sms channel type segment. This is triggered previously in v5 when using updateEndpoint+Analytics event record. I want the same behavior with identifyUser from Analytics + Analytics Event record.

soplan commented 6 months ago

Yeah this is stupid that it's not in v6.. I started a new project but am now considering switching back to v5 because this is a very important missing piece of the puzzle. Can we have an estimate?

To give you some context. I use it for Journeys but also for marketing campaigns. I use it to send emails to inactive users or users who are on a specific subscription plan and user subscribed to product update newletters... So pretty much everything in Pinpoint I use to send email to the users in a specific segment (filtered on whether they want to receive newsletters)

mohammedsahl commented 6 months ago

+1 We use email as our channel. It's crucial for us. Can't upgrade to v6 without it :/

monholm commented 4 months ago

This is also an issue when it comes to push notifications.

We use Pinpoint for push notifications, but don't use aws-amplify/push-notifications to handle said notifications on the (react-native) client side (for various reasons outside the scope of this issue).

Not exposing options such as optOut, address and channelType in identifyUser from aws-amplify/analytics forces us to install @aws-amplify/rtn-push-notification.

If all @aws-amplify/rtn-push-notification did was to provide us a version of identifyUser with the correct interface and maybe some other js functions that we could just ignore, we probably wouldn't care. But @aws-amplify/rtn-push-notification comes with a range of native functionality, that breaks our existing setup.

This includes registering an android service with an intent-filter for the com.google.firebase.MESSAGING_EVENT action and depending on old kotlin-specific firebase dependencies. Long story short, we can't just install @aws-amplify/rtn-push-notification and call it a day.

@cwomack since this was labelled as a feature-request, would you accept a PR that aligns the different identifyUser functions? We're currently patching amplify-js to include the options in analytics, but would really prefer to "fix" it upstream.

renso3x commented 1 week ago

Facing similar issue with v6

  1. Using IdentifyUser to update the endpoint:
await identifyUser({
  userId: email,
  userProfile: {
    name: (user?.given_name ?? userProfile?.givenName) as string,
    email,
    customProperties: {
      organizationName: [staffSession.oName],
      product: [PRODUCT],
    },
  },
  options: {
    userAttributes: {
      role: [userProfile?.role as string],
    },
  },
});

record({
  name: `${PRODUCT}_USER_SIGNIN`,
});
  1. This should trigger an event in the journey where the user activity is _USER_SIGNIN, and an email should be sent. However, none of the journey events were triggered.

I was only able to trigger the event by using the following command:

aws pinpoint put-events --application-id 7149cbb8XXXXXXXX --events-request file://PutEvents.json

Downgrading to v5, is also a pain.

Screenshot 2024-11-14 at 1 12 59 PM

cwomack commented 1 week ago

@renso3x, thank you for the additional context here.

@monholm, let me review this again with our team internally and get back as soon as possible. Appreciate the patience from everyone following this issue.