You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When flushing events, a [Hub event](/[platform]/build-a-backend/auth/connect-your-frontend/listen-to-auth-events/) is sent containing the events which were successfully sent to the Pinpoint service. To receive a list of these events, subscribe to the `HubChannel.ANALYTICS` channel and handle an event of the type `AnalyticsChannelEventName.FLUSH_EVENTS`.
132
132
133
-
## Authentication events
134
-
135
-
Authentication events indicate how frequently users authenticate with your application.
136
-
137
-
On the **Analytics** page, the **Users** tab displays charts for **Sign-ins, Sign-ups, and Authentication failures**.
138
-
139
-
To learn how frequently users authenticate with your app, update your application code so that Amazon Pinpoint receives the following standard event types for authentication:
140
-
141
-
-`_userauth.sign_in`
142
-
-`_userauth.sign_up`
143
-
-`_userauth.auth_fail`
144
-
145
-
You can report authentication events by doing either of the following:
146
-
147
-
- Managing user sign-up and sign-in with Amazon Cognito user pools.
148
-
149
-
Cognito user pools are user directories that make it easier to add sign-up and sign-in to your app. As users authenticate with your app, Cognito reports authentication events to Pinpoint. For more information, see [Using Amazon Pinpoint Analytics with Amazon Cognito User Pools](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-pinpoint-integration.html) in the _Amazon Cognito Developer Guide_. Also update **amplify_outputs.json** by adding the `PinpointAppId` key under `CognitoUserPool`.
150
-
151
-
```json
152
-
"CognitoUserPool": {
153
-
"Default": {
154
-
"PoolId": "<your-user-pool-id>",
155
-
"AppClientId": "<your-app-client-id>",
156
-
"Region": "<your-app-region>",
157
-
"PinpointAppId": "<your-pinpoint-app-id>"
158
-
}
159
-
}
160
-
```
161
-
162
-
- Manually recording events using the `recordEvent()` API.
163
-
164
-
If you don't want to use Cognito user pools, you can use the Pinpoint client to record and submit authentication events, as shown in the following examples. In these examples, the event type is set to `_userauth.sign_in`, but you can substitute any authentication event type.
165
-
166
-
<BlockSwitcher>
167
-
<Blockname="Java">
168
-
169
-
```java
170
-
/**
171
-
* Call this method to log an authentication event to the analytics client.
172
-
*/
173
-
publicvoid logAuthenticationEvent() {
174
-
AnalyticsEvent event =AnalyticsEvent.builder()
175
-
.name("_userauth.sign_in")
176
-
.build();
177
-
Amplify.Analytics.recordEvent(event);
178
-
}
179
-
```
180
-
181
-
</Block>
182
-
<Blockname="Kotlin">
183
-
184
-
```kotlin
185
-
/**
186
-
* Call this method to log an authentication event to the analytics client.
187
-
*/
188
-
funlogAuthenticationEvent() {
189
-
val event =AnalyticsEvent.builder()
190
-
.name("_userauth.sign_in")
191
-
.build()
192
-
Amplify.Analytics.recordEvent(event)
193
-
}
194
-
```
195
-
</Block>
196
-
<Blockname="RxJava">
197
-
198
-
```java
199
-
200
-
/**
201
-
* Call this method to log an authentication event to the analytics client.
0 commit comments