LoginSignup
0
0

More than 1 year has passed since last update.

Angular + Amplify 〜Analytics編

Last updated at Posted at 2022-02-08

目次

  1. Angular + Amplify 〜準備編
  2. Angular + Amplify 〜Analytics編
  3. Angular + Amplify 〜トラブルシュート編

前提条件

Angular v12 + Amplify 〜準備編が完了していること

Amplify Analyticsでできること

公式ドキュメント
- カスタムイベントの記録( Amazon Pinpoint )
- セッション追跡、ページビューの追跡、ページイベントの追跡( Amazon Pinpoint )
- 分析データのストリーミング( Amazon Kinesis Data Streams )
- 分析データの保存( Amazon Kinesis Firehose )
- Amazon Personalize へのイベントデータの送信

今回やること

カスタムイベントの記録( Amazon Pinpoint )

セットアップ

Analyticsカテゴリを追加する。

% amplify add analytics
Initializing new Amplify CLI version...
Done initializing new version.
Scanning for plugins...
Plugin scan successful
? Select an Analytics provider Amazon Pinpoint
? Provide your pinpoint resource name: angularamplify
Adding analytics would add the Auth category to the project if not already added.
? Apps need authorization to send analytics events. Do you wan
t to allow guests and unauthenticated users to send analytics 
events? (we recommend you allow this when getting started) Yes


Successfully added auth resource locally.
Successfully added resource angularamplify locally

Some next steps:
"amplify push" builds all of your local backend resources and provisions them in the cloud
"amplify publish" builds all your local backend and front-end resources (if you have hosting category added) and provisions them in the cloud

Authカテゴリが未追加だった場合は、同時に追加されます。
また、デフォルトだとPinpointのリージョンがus-west-2になっています。(amplify-cliのバグ?)
変更したい場合は、amplify/backend/analytics/resourcename/pinpoint-cloudformation-template.jsonRegionMappingを修正してください。

amplify pushしてバックエンドにデプロイ。

% amplify push
✔ Successfully pulled backend environment dev from the cloud.

Current Environment: dev

| Category  | Resource name   | Operation | Provider plugin   |
| --------- | --------------- | --------- | ----------------- |
| Auth      | cognitoda374191 | Create    | awscloudformation |
| Analytics | angularamplify  | Create    | awscloudformation |
? Are you sure you want to continue? Yes
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS amplify-angularamplify-dev-232821 AWS::CloudFormation::Stack Fri May 28 2021 11:09:11 GMT+0900 (日本標準⠋ Updating resources in the cloud. This may take a few minutes...

(省略)

UPDATE_COMPLETE                     amplify-angularamplify-dev-232821 AWS::CloudFormation::Stack Fri May 28 2021 11:10:39 GM✔ All resources are updated in the cloud
Pinpoint URL to track events https://ap-northeast-1.console.aws.amazon.com/pinpoint/home/?region=ap-northeast-1#/apps/838a715982f04efd9a64cd1201d13ad2/analytics/overview

カスタムイベントの記録

これだけ。

Analytics.record({ name: 'albumVisit' });

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0