首页 > 解决方案 > Amplify/Cognito 没有在 Pinpoint 中显示分析数据

问题描述

我的用户事件中的任何数据都没有精确显示。

我有一个前端反应原生应用程序,它使用配置为的 Amplify Auth 库:

    Amplify.configure({
      Analytics: {
        AWSPinpoint: {
          region: ENV.REGION,
          appId: ENV.PINPOINT_APP_ID,
        },
      },
      Auth: {
        region: ENV.REGION,
        userPoolId: ENV.USER_POOL_ID,
        userPoolWebClientId: ENV.USER_POOL_CLIENT_ID,
        authenticationFlowType: ENV.AUTHENTICATION_FLOW_TYPE,
        oauth: {
          domain: ENV.OAUTH_DOMAIN,
          scope: ["email", "openid", "profile"],
          redirectSignIn: appConfig.scheme,
          redirectSignOut: appConfig.scheme,
          responseType: "code",
          urlOpener,
        },
        federationTarget: "COGNITO_USER_POOLS",
      },
..

在后端,我将 Cognito 与 pinpoint 连接起来,并使用具有以下策略的 IAM 角色:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "cognito-idp:Describe*"
            ],
            "Resource": "*"
        }
    ]
}

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:UpdateEndpoint",
                "mobiletargeting:PutEvents"
            ],
            "Resource": [
                "arn:aws:mobiletargeting:eu-west-1:73463623453:apps/my-pinpoint-project-id/*"
            ]
        }
    ]
}

当我使用该应用程序登录时。精确无数据出现。

但是,当我使用 cli 执行相同操作时,数据确实会精确显示:

AWS_DEFAULT_PROFILE=novasport-dev aws cognito-idp initiate-auth --auth-flow USER_PASSWORD_AUTH --auth-parameters USERNAME=05ac342c-2134-48f9-b124-b1favc5d0bb1,PASSWORD=myPwd --client-id myWebClienId --analytics-metadata AnalyticsEndpointId=my-pinpoint-project-id

在我的 FE 应用程序中,Amplify 库似乎Auth无法将数据发送到精确位置。当我跟踪网络请求时,我也没有看到正在执行的代表分析数据的调用。

如何将分析数据从我的 FE 应用程序获取到 Pinpoint?我错过了一些配置吗?

编辑

我们正在使用 Amplify 的模块化导入

import Amplify from "@aws-amplify/core";

package.json

    "@aws-amplify/api": "4.0.3",
    "@aws-amplify/api-graphql": "2.0.3",
    "@aws-amplify/auth": "4.0.3",
    "@aws-amplify/core": "4.1.1",

标签: amazon-cognitoamplifyaws-pinpoint

解决方案


推荐阅读