|
1 | 1 | openapi: 3.1.0 |
2 | 2 | info: |
3 | 3 | title: Trophy |
4 | | - version: '1.18.0' |
| 4 | + version: '1.19.0' |
5 | 5 | x-fern-global-headers: |
6 | 6 | - header: X-SDK-VERSION |
7 | 7 | name: sdkVersion |
8 | | - x-fern-default: '1.18.0' |
| 8 | + x-fern-default: '1.19.0' |
9 | 9 | paths: |
10 | 10 | /attributes: |
11 | 11 | servers: |
@@ -1161,6 +1161,162 @@ paths: |
1161 | 1161 | security: |
1162 | 1162 | - ApiKeyAuth: [] |
1163 | 1163 |
|
| 1164 | + /metrics/events: |
| 1165 | + servers: |
| 1166 | + - url: https://admin.trophy.so/v1 |
| 1167 | + description: Admin API |
| 1168 | + parameters: |
| 1169 | + - $ref: '#/components/parameters/TenantId' |
| 1170 | + post: |
| 1171 | + description: > |
| 1172 | + Submit up to 1,000 metric events for asynchronous processing. |
| 1173 | + operationId: admin_metrics_batch_events |
| 1174 | + x-fern-server-name: admin |
| 1175 | + x-fern-sdk-group-name: |
| 1176 | + - admin |
| 1177 | + - metrics |
| 1178 | + x-fern-sdk-method-name: batchEvents |
| 1179 | + tags: |
| 1180 | + - Admin |
| 1181 | + x-codeSamples: |
| 1182 | + - lang: javascript |
| 1183 | + source: | |
| 1184 | + import { TrophyApiClient } from '@trophyso/node'; |
| 1185 | +
|
| 1186 | + const trophy = new TrophyApiClient({ |
| 1187 | + apiKey: 'YOUR_API_KEY' |
| 1188 | + }); |
| 1189 | +
|
| 1190 | + const response = await trophy.admin.metrics.batchEvents([ |
| 1191 | + { |
| 1192 | + key: 'words-written', |
| 1193 | + user: { |
| 1194 | + id: 'user-id', |
| 1195 | + email: 'user@example.com', |
| 1196 | + tz: 'Europe/London' |
| 1197 | + }, |
| 1198 | + value: 750, |
| 1199 | + idempotencyKey: 'e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f', |
| 1200 | + attributes: { |
| 1201 | + category: 'writing' |
| 1202 | + } |
| 1203 | + } |
| 1204 | + ]); |
| 1205 | + - lang: python |
| 1206 | + source: | |
| 1207 | + from trophy import TrophyApi |
| 1208 | +
|
| 1209 | + client = TrophyApi(api_key='YOUR_API_KEY') |
| 1210 | +
|
| 1211 | + response = client.admin.metrics.batch_events( |
| 1212 | + [ |
| 1213 | + { |
| 1214 | + "key": "words-written", |
| 1215 | + "user": { |
| 1216 | + "id": "user-id", |
| 1217 | + "email": "user@example.com", |
| 1218 | + "tz": "Europe/London" |
| 1219 | + }, |
| 1220 | + "value": 750, |
| 1221 | + "idempotencyKey": "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f", |
| 1222 | + "attributes": { |
| 1223 | + "category": "writing" |
| 1224 | + } |
| 1225 | + } |
| 1226 | + ] |
| 1227 | + ) |
| 1228 | + - lang: go |
| 1229 | + source: | |
| 1230 | + import ( |
| 1231 | + "context" |
| 1232 | +
|
| 1233 | + api "github.com/trophyso/trophy-go" |
| 1234 | + trophyclient "github.com/trophyso/trophy-go/client" |
| 1235 | + "github.com/trophyso/trophy-go/option" |
| 1236 | + ) |
| 1237 | +
|
| 1238 | + client := trophyclient.NewClient( |
| 1239 | + option.WithApiKey("YOUR_API_KEY"), |
| 1240 | + ) |
| 1241 | +
|
| 1242 | + response, err := client.Admin.Metrics.BatchEvents( |
| 1243 | + context.TODO(), |
| 1244 | + []*api.BatchMetricEvent{ |
| 1245 | + { |
| 1246 | + Key: "words-written", |
| 1247 | + User: &api.BatchMetricEventUser{Id: "user-id"}, |
| 1248 | + Value: 750, |
| 1249 | + Attributes: map[string]string{ |
| 1250 | + "category": "writing", |
| 1251 | + }, |
| 1252 | + }, |
| 1253 | + }, |
| 1254 | + ) |
| 1255 | + responses: |
| 1256 | + '202': |
| 1257 | + description: Events accepted into the processing queue |
| 1258 | + content: |
| 1259 | + application/json: |
| 1260 | + schema: |
| 1261 | + $ref: '#/components/schemas/BatchEventsResponse' |
| 1262 | + examples: |
| 1263 | + Successful operation: |
| 1264 | + value: |
| 1265 | + accepted: 1 |
| 1266 | + '400': |
| 1267 | + description: 'Bad Request' |
| 1268 | + content: |
| 1269 | + application/json: |
| 1270 | + schema: |
| 1271 | + $ref: '#/components/schemas/AdminErrorBody' |
| 1272 | + '401': |
| 1273 | + description: 'Unauthorized' |
| 1274 | + content: |
| 1275 | + application/json: |
| 1276 | + schema: |
| 1277 | + $ref: '#/components/schemas/AdminErrorBody' |
| 1278 | + '404': |
| 1279 | + description: 'Metric not found' |
| 1280 | + content: |
| 1281 | + application/json: |
| 1282 | + schema: |
| 1283 | + $ref: '#/components/schemas/AdminErrorBody' |
| 1284 | + '422': |
| 1285 | + description: 'Unprocessible Entity' |
| 1286 | + content: |
| 1287 | + application/json: |
| 1288 | + schema: |
| 1289 | + $ref: '#/components/schemas/AdminErrorBody' |
| 1290 | + summary: Submit a batch of metric events |
| 1291 | + security: |
| 1292 | + - ApiKeyAuth: [] |
| 1293 | + requestBody: |
| 1294 | + required: true |
| 1295 | + content: |
| 1296 | + application/json: |
| 1297 | + schema: |
| 1298 | + type: array |
| 1299 | + minItems: 1 |
| 1300 | + maxItems: 1000 |
| 1301 | + items: |
| 1302 | + $ref: '#/components/schemas/BatchMetricEvent' |
| 1303 | + examples: |
| 1304 | + Successful operation: |
| 1305 | + value: |
| 1306 | + - key: words-written |
| 1307 | + user: |
| 1308 | + email: user@example.com |
| 1309 | + tz: Europe/London |
| 1310 | + id: '18' |
| 1311 | + attributes: |
| 1312 | + department: engineering |
| 1313 | + role: developer |
| 1314 | + value: 750 |
| 1315 | + idempotencyKey: e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f |
| 1316 | + attributes: |
| 1317 | + category: writing |
| 1318 | + source: mobile-app |
| 1319 | + |
1164 | 1320 | /points: |
1165 | 1321 | servers: |
1166 | 1322 | - url: https://admin.trophy.so/v1 |
@@ -5103,6 +5259,103 @@ components: |
5103 | 5259 | type: string |
5104 | 5260 | required: |
5105 | 5261 | - error |
| 5262 | + BatchMetricEventUser: |
| 5263 | + title: BatchMetricEventUser |
| 5264 | + type: object |
| 5265 | + description: The user that triggered a batch metric event. |
| 5266 | + properties: |
| 5267 | + id: |
| 5268 | + type: string |
| 5269 | + description: The ID of the user in your database. Must be a string. |
| 5270 | + example: user-id |
| 5271 | + email: |
| 5272 | + type: string |
| 5273 | + description: The user's email address. Required if subscribeToEmails is true. |
| 5274 | + example: user@example.com |
| 5275 | + name: |
| 5276 | + type: string |
| 5277 | + description: The name to refer to the user by in emails. |
| 5278 | + example: User |
| 5279 | + tz: |
| 5280 | + type: |
| 5281 | + - string |
| 5282 | + - 'null' |
| 5283 | + description: The user's timezone (used for email scheduling). |
| 5284 | + example: Europe/London |
| 5285 | + deviceTokens: |
| 5286 | + type: |
| 5287 | + - array |
| 5288 | + - 'null' |
| 5289 | + description: The user's device tokens, used for push notifications. |
| 5290 | + items: |
| 5291 | + type: string |
| 5292 | + description: The device token. |
| 5293 | + example: ['token1', 'token2'] |
| 5294 | + subscribeToEmails: |
| 5295 | + type: boolean |
| 5296 | + default: true |
| 5297 | + description: Whether the user should receive Trophy-powered emails. If false, Trophy will not store the user's email address. |
| 5298 | + example: true |
| 5299 | + attributes: |
| 5300 | + type: object |
| 5301 | + additionalProperties: |
| 5302 | + type: string |
| 5303 | + description: User attributes as key-value pairs. Keys must match existing user attributes set up in the Trophy dashboard. |
| 5304 | + example: |
| 5305 | + department: engineering |
| 5306 | + role: developer |
| 5307 | + required: |
| 5308 | + - id |
| 5309 | + BatchMetricEvent: |
| 5310 | + title: BatchMetricEvent |
| 5311 | + type: object |
| 5312 | + description: > |
| 5313 | + A metric event submitted as part of a batch. Same shape as a single |
| 5314 | + metric event, with the metric key included in the body. |
| 5315 | + properties: |
| 5316 | + key: |
| 5317 | + type: string |
| 5318 | + description: Unique reference of the metric as set when created. |
| 5319 | + example: words-written |
| 5320 | + user: |
| 5321 | + $ref: '#/components/schemas/BatchMetricEventUser' |
| 5322 | + description: The user that triggered the event. |
| 5323 | + value: |
| 5324 | + type: number |
| 5325 | + format: double |
| 5326 | + description: >- |
| 5327 | + The value to add to the user's current total for the given metric. |
| 5328 | + example: 750 |
| 5329 | + attributes: |
| 5330 | + type: object |
| 5331 | + additionalProperties: |
| 5332 | + type: string |
| 5333 | + description: Event attributes as key-value pairs. Keys must match existing event attributes set up in the Trophy dashboard. |
| 5334 | + example: |
| 5335 | + category: writing |
| 5336 | + source: mobile-app |
| 5337 | + idempotencyKey: |
| 5338 | + type: string |
| 5339 | + description: > |
| 5340 | + Optional idempotency key for this event. When provided, the event is |
| 5341 | + ignored if another event with the same idempotency key has already |
| 5342 | + been processed. |
| 5343 | + example: e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f |
| 5344 | + required: |
| 5345 | + - key |
| 5346 | + - user |
| 5347 | + - value |
| 5348 | + BatchEventsResponse: |
| 5349 | + title: BatchEventsResponse |
| 5350 | + type: object |
| 5351 | + description: Response returned when a batch of metric events is accepted. |
| 5352 | + properties: |
| 5353 | + accepted: |
| 5354 | + type: integer |
| 5355 | + description: The number of events accepted into the processing queue. |
| 5356 | + example: 1 |
| 5357 | + required: |
| 5358 | + - accepted |
5106 | 5359 | CreateStreakFreezesRequest: |
5107 | 5360 | title: CreateStreakFreezesRequest |
5108 | 5361 | type: object |
@@ -6661,7 +6914,7 @@ components: |
6661 | 6914 | message: |
6662 | 6915 | type: string |
6663 | 6916 | description: A human-readable description of the issue. |
6664 | | - example: Description of the issue. |
| 6917 | + example: Would exceed maximum freeze limit |
6665 | 6918 | required: |
6666 | 6919 | - severity |
6667 | 6920 | - message |
|
0 commit comments