跳至內容

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 個回答
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/

AWS
專家

已回答 2 年前

  • 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', 
      }
    });
    

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。