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

Page updated Apr 30, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

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.

Analytics カテゴリでは、アプリ用の分析データを収集できます。Analytics カテゴリは Amazon PinpointAmazon Kinesis(Kinesis サポートは現在のところ Amplify JavaScript ライブラリでのみ利用可能)の組み込みサポートで提供されています。Analytics カテゴリは Amazon Cognito Identity プールを使用してアプリ内のユーザーを識別します。Cognito により、アプリ内の認証済みユーザーと非認証ユーザーの両方からデータを受け取ることができます。

目的

Amplify Analytics でアプリケーションをセットアップおよび設定し、分析イベントを記録します。

前提条件

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

プロジェクトのルートフォルダで以下のコマンドを実行します。CLI は Analytics カテゴリの設定オプション(Amazon Pinpoint リソース名と分析イベント設定など)のプロンプトを表示します。

Analytics カテゴリは、アプリが分析イベントを送信することを認可するために、バックグラウンドで Authentication カテゴリを利用しています。

amplify add analytics
? Select an Analytics provider (Use arrow keys)
`Amazon Pinpoint`
? Provide your pinpoint resource name:
`yourPinpointResourceName`
? Apps need authorization to send analytics events. Do you want to allow guests and unauthenticated users to send analytics events? (we recommend you allow this when getting started)
`Yes`

バックエンドをデプロイするには、以下を実行します:

amplify push

A configuration file called amplifyconfiguration.json will be copied to your configured source directory, for example ./src. The CLI will also print the URL for Amazon Pinpoint console to track your app events.

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

To install the Amplify library to use the analytics features, run the following command in your project’s root folder:

npm install aws-amplify

Amplify Analytics を初期化

Import and load the configuration file in your app. It's recommended you add the Amplify configuration step to your app's root entry point. For example, App.js (Expo) or index.js (React Native CLI).

import { record } from 'aws-amplify/analytics';
import amplifyconfig from './amplifyconfiguration.json';
Amplify.configure(amplifyconfig);

Make sure you call Amplify.configure as early as possible in your application’s life-cycle. A missing configuration or NoCredentials error is thrown if Amplify.configure has not been called before other Amplify JavaScript APIs. Review the Library Not Configured Troubleshooting guide for possible causes of this issue.

User session data is automatically collected unless you disabled analytics. To see the results visit the Amazon Pinpoint console.

Analytics コンソールを表示

以前にリンクを保存していない場合でも、ターミナルからアクセスできます。コンソールを開くには、以下のコマンドを実行します。

amplify console analytics

次のステップ:

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

既知の問題

デフォルトの Pinpoint プロバイダーの代わりに、以下のリストされた代替サービスプロバイダーをインポートする場合:

  • Kinesis (aws-amplify/analytics/kinesis)
  • 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/... これは既知の問題です。この問題で説明されている手順に従ってエラーを解決してください。