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

イベントを記録する

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.

カスタムイベントを記録する

カスタムイベントを記録するには、record APIを呼び出します:

src/index.js
import { record } from 'aws-amplify/analytics';
record({
name: 'albumVisit',
});

アナリティクスイベントはメモリにバッファリングされ、定期的にサービスに送信されます。アプリケーションセッション間でローカルに保存されません。バッファリングされたイベントが送信される前にセッションが終了した場合、そのイベントは失われます。flushEvents APIを使用してバッファリングされたイベントをサービスに手動で送信してください。

属性付きのカスタムイベントを記録する

record APIを使用すると、イベントに追加の属性を追加できます。たとえば、_albumVisit_イベントで_artist_情報を記録するには:

src/index.js
import { record } from 'aws-amplify/analytics';
record({
name: 'albumVisit',
attributes: { genre: '', artist: '' },
});

記録されたイベントはバッファリングされ、定期的にAmazon Pinpointに送信されます。

エンゲージメントメトリクスを記録する

メトリクスをイベントに追加することもできます:

src/index.js
import { record } from 'aws-amplify/analytics';
record({
name: 'albumVisit',
metrics: { minutesListened: 30 },
});

メトリクス値は、floatやintegerなどのNumber型である必要があります。

Amazon Pinpointのイベント数は、イベントを記録してから数分以内に更新されます。

ただし、フィルターセクションにイベントが表示されたり、カスタム属性がAmazon Pinpointに表示されたりするには、最大30分かかる場合があります。

イベントをフラッシュする

記録されたイベントはバッファに保存され、定期的にリモートサーバーに送信されます。必要に応じて、'flushEvents' APIを使用してバッファからすべてのイベントを手動でクリアできます。

src/index.js
import { flushEvents } from 'aws-amplify/analytics';
flushEvents();