Reporting
The POST/report endpoint allows you to report usage data to Tggl from your server, proxy, and clients. You can then find this data directly in the Tggl dashboard to track which flags are being used, how often, by which client...
The body should be a JSON object with the properties you want to report as described in the following sections. When successful, the response will be a 200 OK with a JSON body:
Flag evaluation
Both client and server keys can be used to report flag evaluation metrics. You can add a clients
array to the body to report metrics:
You may pass multiple clients at once and add an id
for each client to identify them in the dashboard:
For each client, you can specify which flags were evaluated and the result of those evaluations. The flags
object should contain the flag key as the key and an array of evaluation results as the value:
Each flag evaluation result is an object where all keys are optional and follows the following schema:
The value the flag was evaluated to. Can by any type. Should provide the default value if it was used.
The default value that was used in the code. Can by any type.
The number of times the flag was evaluated to that specific value. Default to 1 if not specified.
Context
Only the server API key can be used to report context related metrics. You can report both the properties you received for each context, and the values each of those properties had.
Received properties
You can add a receivedProperties
object to the body of the request to report the properties you received for each context:
The keys of the receivedProperties
object are the properties you received, and the values are a tuple of two timestamps in seconds (not milliseconds) that represent the first and last time each property was received.
Received values
You can add a receivedValues
object to the body of the request to report the values you received for each property:
The keys of the receivedValues
object are the properties, and the values are an array of received values. Each received value is a tuple of the value itself, and an optional label associated.
For instance, if you want to associate a user's name to its user ID, you can do so like this:
To match a value with a label, the SDKs looks for keys that end with "Id" and "Name" and automatically associate them. For instance, if you have a userId
and a userName
property, the SDK will automatically associate the values. This also works with company_id
and company_name
, product-id
and product-name
, etc.
Reporting everything at once
You can report as much data as you want in a single API call. Here is an example of a complete request body:
Error handling
If you API key is invalid or missing, you will receive a 401 Unauthorized response.
If the request body is invalid, you will receive a 400 Bad Request response with either an error
or errors
key.