Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Choose your framework/language

Gen1 DocsLegacy

Page updated Mar 26, 2026

Amplify Analytics のセットアップ

AWS will end support for Amazon Pinpoint on October 30, 2026,, and is no longer accepting any new users as of May 20 (see the linked doc). The guidance is to use AWS End User Messaging for push notifications and SMS, Amazon Simple Email Service for sending emails, Amazon Connect for campaigns, journeys, endpoints, and engagement analytics. Pinpoint recommends Amazon Kinesis for event collection and mobile analytics.

Amplify を使用すると、アプリのアナリティクスデータを収集できます。Analytics を使用するには、AWS Cloud Development Kit (AWS CDK) を使用して Amazon Kinesis または Amazon Pinpoint を有効にする必要があります。Analytics カテゴリは Amazon Cognito ID プールを使用してアプリのユーザーを_識別_します。Cognito により、アプリの認証済みユーザーと未認証ユーザーからデータを受け取ることができます。

Analytics バックエンドのセットアップ

AWS CDK を使用して、Amazon Pinpoint を搭載するアナリティクスリソースを作成します。

amplify/backend.ts
import { defineBackend } from "@aws-amplify/backend"
import { auth } from "./auth/resource";
import { data } from "./data/resource";
import { Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
import { CfnApp } from "aws-cdk-lib/aws-pinpoint";
import { Stack } from "aws-cdk-lib/core";
const backend = defineBackend({
auth,
data,
// additional resources
});
const analyticsStack = backend.createStack("analytics-stack");
// create a Pinpoint app
const pinpoint = new CfnApp(analyticsStack, "Pinpoint", {
name: "myPinpointApp",
});
// create an IAM policy to allow interacting with Pinpoint
const pinpointPolicy = new Policy(analyticsStack, "PinpointPolicy", {
policyName: "PinpointPolicy",
statements: [
new PolicyStatement({
actions: ["mobiletargeting:UpdateEndpoint", "mobiletargeting:PutEvents"],
resources: [pinpoint.attrArn + "/*"],
}),
],
});
// apply the policy to the authenticated and unauthenticated roles
backend.auth.resources.authenticatedUserIamRole.attachInlinePolicy(pinpointPolicy);
backend.auth.resources.unauthenticatedUserIamRole.attachInlinePolicy(pinpointPolicy);
// patch the custom Pinpoint resource to the expected output configuration
backend.addOutput({
analytics: {
amazon_pinpoint: {
app_id: pinpoint.ref,
aws_region: Stack.of(pinpoint).region,
}
},
});

Amplify ライブラリのインストール

まず、aws-amplify ライブラリをインストールします:

Terminal
npm add aws-amplify

Amplify Analytics の初期化

設定ファイルをインポートしてアプリに読み込みます。Amplify 設定ステップをアプリのルートエントリポイントに追加することをお勧めします。

src/index.js
import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';
Amplify.configure(outputs);

次のステップ:

おめでとうございます! これで Analytics バックエンドがプロビジョニングされ、Analytics ライブラリがインストールされました。次のリンクをチェックして、Amplify Analytics のユースケースを確認してください:

リファレンス

Amazon Pinpoint Construct ライブラリ

既知の問題

Amazon Kinesis (aws-amplify/analytics/kinesis)、Amazon Kinesis Data Firehose (aws-amplify/analytics/kinesis-firehose)、Personalize Event (aws-amplify/analytics/personalize) を使用する場合、バンドラーを起動するときに次のエラーが発生する可能性があります:

Error: Unable to resolve module stream from /path/to/node_modules/@aws-sdk/... これは 既知の問題です。この問題を解決するには、そこで概説されている手順に従ってください。