APIs & services / sync-service

Upload screen/action analytics.

Endpointtoday's app
Call
POST /sync-service/api/v1/data/clickstream
Service
sync-service
Features
Sync error log
When
Periodic 12 h
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Uploads screen and button analytics recorded locally by AnalyticsManager into the user_analytics table. SendUserAnalyticsWorker is a periodic job every 12 hours (network required) set up in HomeActivity. It sends all stored rows only when the ref-data switch PORTFOLIO_APP_CONFIG.CLICKSTREAM_EXTERNAL_SWITCH is 1. On success the table is cleared. On failure the rows stay for the next run.

Headers

HeaderValueNotes
X-SESSIONID<session id>Passed explicitly as a @Header by the caller (AndroidSessionManager.sessionId). AuthInterceptor also fills it when missing, and on a 401 or 400 it invalidates the token, fetches a new one and retries once.
Content-Typeapplication/jsonSet by the HTTP client for JSON bodies.

Request

Example request body (synthetic data)
[
  {
    "uniqueIdentifier": 1,
    "sessionIdAnonymized": "<redacted: raw session id>",
    "role": "CADRE",
    "screenModule": "LAND_ASSET",
    "button": null,
    "eventType": null,
    "eventData": null,
    "eventAction": "CREATED_LAND",
    "appVersion": "3.2.1 (125)",
    "isAndroidApp": true,
    "isWebApp": false,
    "deviceId": null,
    "IEID": "880001",
    "uuid": "ie-uuid-0001",
    "osVersion": "14",
    "deviceDetails": "Model X / DEVICE-XXXX",
    "isOnline": true,
    "isOffline": false,
    "networkType": "WIFI",
    "eventTimestamp": 1748859300000,
    "eventAPIEndpoint": "/gateway/asset-service/api/v1/assets/",
    "voName": "VO A",
    "shgName": "SHG A",
    "voCode": "VO-01",
    "shgCode": "SHG-0012",
    "loginDetails": "cadre_a"
  }
]
FieldTypeRequiredNotes
[].sessionIdAnonymizedstringNoPII/secret: despite the name, this is the raw session token (sessionManager.sessionId).
[].rolestringNoCADRE or UIC.
[].screenModule / eventActionstringYesScreen and user action constants (AppConstants.UserActionsConstants).
[].eventAPIEndpointstringNoAPI path mapped from the action (for example the assets path for CREATED_LAND).
[].IEID / uuidstringNoFarmer ids for the action.
[].voName, shgName, voCode, shgCodestringNoFrom the farmer's IE flat row.
[].loginDetailsstringNoPII: cadre login id.
[].deviceDetails / osVersion / networkType / isOnline / isOfflinestring/booleanNoPII: device model and device id.
[].appVersion, isAndroidApp, isWebApp, eventTimestampmixedYesMetadata.
[].uniqueIdentifier, button, eventType, eventData, deviceIdmixedNoRoom key / not populated by AnalyticsManager.

Response

Example response body (synthetic data)
{
  "status": "ok"
}
FieldTypeRequiredNotes
(body)JsonObjectNot read. Only isSuccessful is checked.

Errors

StatusWhenWhat the app does
non-2xxUpload failsRows are kept. Note that the worker still returns Result.success() because the failure() value is discarded.
exceptionNetwork errorResult.failure().

Source

  • app/src/main/java/org/platformcommons/urvi/datasource/network/URLInjector.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/network/retrofit/APIInterface.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/service/SendUserAnalyticsWorker.kt
  • app/src/main/java/org/platformcommons/urvi/utility/AnalyticsManager.kt
  • app/src/main/java/org/platformcommons/urvi/utility/AppUtils.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/Analytics.kt