amplify add analytics
Configure:
? 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
Install Amplify Libraries
` dependencies { // Add these lines in dependencies implementation ‘com.amplifyframework:aws-analytics-pinpoint:1.17.1’ implementation ‘com.amplifyframework:aws-auth-cognito:1.17.1’ }`
Add the following code to onCreate():
Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(this));
Record Events:
AnalyticsEvent event = AnalyticsEvent.builder()
.name("PasswordReset")
.addProperty("Channel", "SMS")
.addProperty("Successful", true)
.addProperty("ProcessDuration", 792)
.addProperty("UserAge", 120.3)
.build();
Amplify.Analytics.recordEvent(event);
View Analytics console with the following command:
amplify console analytics