WARNING - This endpoint can return significantly sized payloads. Raw event data is included with the response, resulting in large payloads. If you are looking for computed analytics, without the raw event data (and without requiring the need to uncompress the payload), see here.

This endpoint returns event data (that can be used as an Audit Logging source) and compiled analytical data derived from these raw events.

curl --location --request POST 'https://sux.chatsight.ai/api/properties/analytics' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "tag": <ANALYTICS_TARGET_TAG>
}'

What is <ANALYTICS_TARGET_TAG>?

When you call the route Fetch Available Analytics, you'll receive a set of tags to fetch analytics data. These tags are serialized in the format:

<PROPERTY_ID>::<DATE>

Analytics tags are available for up to 30 days.

Compression

Analytics data can be large. To account for this, if the returned data was to exceed 1MB, it will be compressed with the DEFLATE method using zlib, and then base64 encoded. This route will return a Boolean as to whether this has occurred at the path data.isDeflateCompressed.

To read this data, you convert the base64 encoded data to a Buffer in your native language, and then uncompress the value at data.payload, and then JSON parse from the resulting String. An example, using NodeJS is reproduced below.

Data Flow:
Base64 => Buffer => Inflate => Buffer => String => JSON

// Import native NodeJS libraries, no external libraries required.
// This assumes async/await for ease of use.
const zlib = require('node:zlib');
const util = require('util');
const inflate = util.promisify(zlib.inflate);

...

var response = /* API response */
// Create a buffer for zlib, and then specify the encoding as Base64.
var payload_as_buffer = Buffer.from(response.data.payload,'base64')
// Decompress the data. Resulting in a Buffer of uncompressed data.
response.data.payload = await inflate(payload_as_buffer)
// Finally, Convert the Buffer to a string and then parse it as JSON.
response.data.payload = JSON.parse(response.data.payload.toString('utf-8'))

If data.isDeflateCompressed is false, then the value at data.payload will be an already parsed JSON object at this path.

Data Availability

You should ensure that you do not rely on the presence of any keys returned in the response. If there are no events of a specific type, the related key will not be present.