내용으로 건너뛰기

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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.