The SDK can periodically push playback analytics to an endpoint you configure in the Inkrypt Dashboard. This feature is called App Push Live Analytics and is controlled entirely server-side, no additional code is required in your app.
How It Works
When a video loads successfully, the SDK checks the video metadata returned by the Inkrypt API for a live analytics configuration. If the feature is enabled for a given video, the SDK will automatically:
- Start a repeating timer at the configured interval.
- On each tick, send a
POSTrequest to the configured analytics URL with the current playback state. - Stop sending analytics if the server responds with an error code
>= 400.
This all happens transparently, there is nothing you need to call or configure in your integration code.
Payload
Each analytics push includes the following data:
| Field | Type | Description |
|---|---|---|
userId | String | An identifier derived from the video's watermark label (Base64 encoded). |
videoId | String | The unique ID of the video being played. |
otp | String | The OTP used to authenticate the current session. |
totalPlayedTimeInSeconds | Long | Total number of seconds the user has actively played the video during this session (paused time is excluded). |
currentPositionInSeconds | Long | Current playhead position in seconds at the time of the push. |
Server-Side Responses
The SDK handles the following HTTP response codes from the analytics endpoint:
| Code | Behavior |
|---|---|
2xx | Analytics accepted. Timer continues. |
403 | The server has forcibly ended the session. The player is reset and an error is displayed to the user. |
405 | Reserved for future handling (currently a no-op). |
Other 4xx / 5xx | Analytics pushes are stopped for the remainder of the session. |
Configuration (Dashboard)
The following settings are configured from the Inkrypt Dashboard and are returned per-video in the API response:
| Setting | Description |
|---|---|
app_push_live_analytics_enabled | Enables or disables the feature for a specific video. |
app_push_live_analytics_url | The POST endpoint that receives the analytics payload. |
app_push_live_analytics_interval | How often (in milliseconds) the SDK pushes analytics data. |
Lifecycle
- Analytics start when the video info is successfully loaded and the player session begins.
- Analytics are paused when the app goes to the background (the Fragment's lifecycle is in a state other than
RESUMED). - Analytics stop permanently if the server returns an error code
>= 400, or when a newsetParams()call resets the session.