UNPKG

@aicore/core-analytics-client-lib

Version:

Analytics client library for https://github.com/aicore/Core-Analytics-Server

92 lines (86 loc) 2.86 kB
# Client schema The `analytics client js lib` client periodically sends data to the analytics backend as JSON aggregated over a time period. The JSON format is as follows: schema: ```json { "schemaVersion" : 1, "appName" : "app1", "uuid": "u1", "sessionID": "s1", "unixTimestampUTC" : 1643043376, "numEventsTotal": 8, "events":{ "eventType":{ "category":{ "subCategory": { "time": [0,2], "valueCount": [ 1, [{ "1": 5, "3": 2 }] ] } } } } } ``` ## Fileds for schema version:1 1. `schemaVersion` : The version number for schema followed by the client. Currently, only 1 schema exists. 1. `appName`: The application name for which the event is being raised. 2. `uuid`: The unique id for the user. or the string `default` if there is no UUID/anonymous analytics is used from client. 3. `sessionID`: The unique session-id autogenerated by the client lib for each session. Will be reset for every session. 5. `unixTimestampUTC`: The start Unix time from which the client time is being recorded. 5. `numEventsTotal`: The sum total of all events raised from the client. This aggregates all count values `c` 6. `events` : A map of events that took place from `unixTimestampUTC`. The keys are nested in order `eventType` > `category` > `subCategory` * Within a subcategory, `time` array specifies the `time drift` in seconds from the `unixTimestampUTC` for which the current event is raised. * `valueCount` array specifies the `values` and/or related counts. If the array item is a number, then it signifies count. If it is an object, then it indicates values and the corresponding counts. ## sample analytics event Schema ```json { "schemaVersion": 1, "appName": "brackets", "uuid": "u1", "sessionID": "s1", "unixTimestampUTC": 1643043376, "numEventsTotal": 5, "events": { "platform": { "os": { "win": { "time": [0], "valueCount": [1] } }, "performance": { "fileOpenTimeMs": { "time": [0, 2, 5], "valueCount": [ [{ "121": 1 }], [{ "100": 1, "300": 1 }], [{ "100": 5 }] ] } } } } } ``` The above event raises two event types : 1. (platform, os, win) 2. (platform, performance, fileOpenTimeMs) * at time `1643043376 + 0`, a value of `121` is registered and count is 1. * at time `1643043376 + 3000`, two values `[100,300]` are registered with a count each of 1. * at time `1643043376 + 6000`, a value of `500` is registered with a count of 5.