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 カテゴリは、アプリがアナリティクスイベントを送信することを許可するために、バックグラウンドで認証カテゴリを使用します。

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

aws-exports.js という設定ファイルが、設定されたソースディレクトリ (例: ./src) にコピーされます。CLI は、アプリイベントを追跡するための Amazon Pinpoint コンソールの URL も出力します。

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@^5

Amplify Analytics を初期化

import { Amplify, Analytics } from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);

アナリティクスコンソールを表示

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

amplify console analytics

次のステップ:

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