Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create a dynamic segment using identifyUser #14024

Closed
3 tasks done
renso3x opened this issue Nov 19, 2024 · 6 comments
Closed
3 tasks done

Unable to create a dynamic segment using identifyUser #14024

renso3x opened this issue Nov 19, 2024 · 6 comments
Assignees
Labels
Analytics Related to analytics question General question

Comments

@renso3x
Copy link

renso3x commented Nov 19, 2024

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Analytics

Amplify Version

v6

Amplify Categories

analytics

Backend

None

Environment information

Describe the bug

I was creating a dynamic segment in AWS Pinpoint to filter users based on the organizationName. Initially, I encountered an issue where supplying only customProperties resulted in no endpoints being filtered. Additionally, it appears that triggering an event is required to apply the segment criteria.

Upon further investigation, I found that including options.userAttributes allows segments to be filtered based on this attribute. However, the documentation provided here is unclear about how to create segments effectively. Furthermore, version 6 of the library seems to have limited features for this purpose.

Expected behavior

I expect that when I trigger the identifyUser I can create a Segment based on those user criteria

Reproduction steps

npm install aws-amplify @aws-amplify/analytics

Code Snippet

// Put your code below this line.

await identifyUser({
    userId,
    userProfile: {
      customProperties: {
        organizationName: 'ABC',
      },
    },
    options: {
      userAttributes: {
        organizationName: 'ABC',
      },
    },
  });

record({
  event: EventTrackerType.USER_SIGNIN,
  eventData: { email: userId },
});

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

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Nov 19, 2024
@renso3x renso3x changed the title Creating a dynamic segment in identifyUser Unable to create a dynamic segment using identifyUser Nov 19, 2024
@cwomack
Copy link
Member

cwomack commented Nov 19, 2024

Hello, @renso3x 👋 and thanks for opening this issue. Pinpoint's updateEndpoint API is called under the hood when identifyUser() is called by Amplify, so we'll look into this further to determine if there's a bug in how the attributes are being passed. Can you confirm if you see the organizationName attribute being updated properly when you make the identifyUser() call?

If you create a Segment in Pinpoint console (see here), are you trying to then use this attribute to add user to an existing one? Or is the goal to have a new segment made when the identifyUser() API is called from the client side?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 19, 2024
@cwomack cwomack added question General question pending-community-response Issue is pending a response from the author or community. Analytics Related to analytics and removed pending-triage Issue is pending triage labels Nov 19, 2024
@cwomack cwomack self-assigned this Nov 19, 2024
@renso3x
Copy link
Author

renso3x commented Nov 20, 2024

Hi @cwomack,

Yes I am seeing the organizationName after an hour or so. I’m working on creating a segment using identifyUser(). Should I only use identifyUser() and skip calling record()?

In v5, it was necessary to call both identifyUser() with updated user attributes and record() for events. Could you confirm if this step is still required, or does identifyUser() alone suffice for updating the segment in the current implementation?

@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Nov 20, 2024
@cwomack
Copy link
Member

cwomack commented Nov 20, 2024

@renso3x, thanks for the additional context here. That delay you see for the organizationName being around 45 min to an hour is expected behavior within the Pinpoint console (and a subject we can't really control on the Amplify side). Same thing happens for events being record I'm sure as well. You can somewhat speed up the recording of events by flushing them so that they aren't stored in the buffer and only sent periodically.

Let me know if I'm understanding your goal properly, but it sounds like the intent is to have the Dynamic Segment created programmatically. If that's the case, then there's no Amplify API that can be called on the client side to do this simultaneously when the organizationName attribute is sent off to Pinpoint. However, this could be done using a Lambda function that would set up to create/modify a segment possibly when the organizationName attribute is updated or given a value.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 20, 2024
@cwomack cwomack added the pending-community-response Issue is pending a response from the author or community. label Nov 20, 2024
@renso3x
Copy link
Author

renso3x commented Nov 20, 2024

Hi @cwomack,

Yes, my goal is to create the dynamic segment in Amplify. Generally, I trigger the identifyUser function only once when the user signs in to the app. However, if my goal is to update the user endpoint, would it be better to use a Lambda function instead?

@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Nov 20, 2024
@cwomack
Copy link
Member

cwomack commented Nov 25, 2024

@renso3x, appreciate the clarity. I think the best way to achieve this then would be to use the Lambda function then to create the dynamic segment when there are changes to the attribute recorded by Pinpoint. Any type of client side implementation runs the risk of potentially allowing a malicious user to create a large amount of segments that could then complicate or drive up costs on our campaigns or messages that use them. Because of this, it wouldn't be a feature that we'd consider implementing on the Amplify side at this time (and it's also not something Pinpoint supports at this time even if we could).

Hope that helps clear things up, but let us know if there's further questions here!

@cwomack cwomack added pending-community-response Issue is pending a response from the author or community. and removed pending-maintainer-response Issue is pending a response from the Amplify team. labels Nov 25, 2024
@cwomack
Copy link
Member

cwomack commented Dec 11, 2024

Closing this issue as we have not heard back from you. If there's further questions or guidance needed, please feel free to reply back and we'd be happy to re-open the issue.

Thank you!

@cwomack cwomack closed this as completed Dec 11, 2024
@github-actions github-actions bot removed the pending-community-response Issue is pending a response from the author or community. label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analytics Related to analytics question General question
Projects
None yet
Development

No branches or pull requests

2 participants