Live Analytics

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:

  1. Start a repeating timer at the configured interval.
  2. On each tick, send a POST request to the configured analytics URL with the current playback state.
  3. 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:

FieldTypeDescription
userIdStringAn identifier derived from the video's watermark label (Base64 encoded).
videoIdStringThe unique ID of the video being played.
otpStringThe OTP used to authenticate the current session.
totalPlayedTimeInSecondsLongTotal number of seconds the user has actively played the video during this session (paused time is excluded).
currentPositionInSecondsLongCurrent 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:

CodeBehavior
2xxAnalytics accepted. Timer continues.
403The server has forcibly ended the session. The player is reset and an error is displayed to the user.
405Reserved for future handling (currently a no-op).
Other 4xx / 5xxAnalytics 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:

SettingDescription
app_push_live_analytics_enabledEnables or disables the feature for a specific video.
app_push_live_analytics_urlThe POST endpoint that receives the analytics payload.
app_push_live_analytics_intervalHow 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 new setParams() call resets the session.