Amplify analytics (Pinpoint) do not tracking Cognito Authentication metrics

0

Hello there! I am using AWS Amplify Analytics with Pinpoint to track my application's metrics.

  • I am using Amplify Gen 1 and V6.
  • My Pinpoint and Cognito user pool is in the same region us-east-1 (N. Virginia).
  • I am not using Amplify Authenticator. Instead, I am calling the direct API from amplify:

      const { isSignUpComplete, userId, nextStep } = await signUp({
        ...data,
      });

      const { isSignUpComplete, nextStep } = await confirmSignUp({
        username: signUpInfo.userId,
        confirmationCode: data.code,
      });

      const { isSignedIn, nextStep } = await signIn({
        username: email,
        password,
      });
  • And recording the metrics from a useEffect hook:

  useEffect(() => {
    const addRecords = async () => {
      try {
        record({
          name: "homepage_visited",
        });
        if (!userData.data) return;
        await identifyUser({
          userId: userData.data.email!,
          userProfile: {
            ...userData.data,
          },
        });
      } catch (error) {
        console.log(error);
      }
    };
    addRecords();
  }, []);
  • I haven't changed any permissions. All permissions are set by amplify.

Now, Daily active users, Daily active endpoints, and other metrics are working fine.

My Question: But, Authentication metrics are not working correctly. Sign-ins, sign-ups, and authentication failures always show as empty. Is there any way to fix it?

1 Answer
0

I think since you're calling the authentication APIs directly, you need to manually record these authentication events to Pinpoint. You can do this by using the record function from the Analytics module. These events you record, will then show on Pinpoint under Analytics of your project.

Check this source: https://docs.amplify.aws/gen1/javascript/build-a-backend/more-features/analytics/record-events/

profile pictureAWS
EXPERT
AmerO
answered 2 months ago
  • Is it possible to provide a code example of how to record these auth events? Because I haven't found anything like this in docs. Thank you!

  • const handleSignUp = async (data) => { try { const { isSignUpComplete, userId, nextStep } = await signUp({ ...data, });

    // Record the sign-up event to Pinpoint
    Analytics.record({
      name: 'SignUp',
      attributes: {
        userId: userId,
        status: isSignUpComplete ? 'Success' : 'Pending', 
      }
    });
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions