diff --git a/admin-api/endpoints/streaks/create-pauses.mdx b/admin-api/endpoints/streaks/create-pauses.mdx new file mode 100644 index 00000000..b04d06d7 --- /dev/null +++ b/admin-api/endpoints/streaks/create-pauses.mdx @@ -0,0 +1,10 @@ +--- +title: Create streak pauses for multiple users +openapi: "/openapi/admin.json POST /streaks/pauses" +--- + +import { RateLimitBadge } from "../../../components/rate-limit-badge.jsx"; + +**Rate Limits** + + diff --git a/admin-api/endpoints/streaks/delete-pauses.mdx b/admin-api/endpoints/streaks/delete-pauses.mdx new file mode 100644 index 00000000..5947ae51 --- /dev/null +++ b/admin-api/endpoints/streaks/delete-pauses.mdx @@ -0,0 +1,10 @@ +--- +title: Delete streak pauses +openapi: "/openapi/admin.json DELETE /streaks/pauses" +--- + +import { RateLimitBadge } from "../../../components/rate-limit-badge.jsx"; + +**Rate Limits** + + diff --git a/docs.json b/docs.json index 1674147a..07ef75ce 100644 --- a/docs.json +++ b/docs.json @@ -260,6 +260,8 @@ "group": "Streaks", "pages": [ "admin-api/endpoints/streaks/grant-freezes", + "admin-api/endpoints/streaks/create-pauses", + "admin-api/endpoints/streaks/delete-pauses", "admin-api/endpoints/streaks/restore-streaks" ] }, @@ -646,6 +648,8 @@ "group": "Rachas", "pages": [ "es/admin-api/endpoints/streaks/grant-freezes", + "es/admin-api/endpoints/streaks/create-pauses", + "es/admin-api/endpoints/streaks/delete-pauses", "es/admin-api/endpoints/streaks/restore-streaks" ] }, diff --git a/es/admin-api/endpoints/streaks/create-pauses.mdx b/es/admin-api/endpoints/streaks/create-pauses.mdx new file mode 100644 index 00000000..7e0c2d18 --- /dev/null +++ b/es/admin-api/endpoints/streaks/create-pauses.mdx @@ -0,0 +1,10 @@ +--- +title: Crear pausas de racha para múltiples usuarios +openapi: "/openapi/admin.json POST /streaks/pauses" +--- + +import { RateLimitBadge } from "../../../components/rate-limit-badge.jsx"; + +**Límites de velocidad** + + diff --git a/es/admin-api/endpoints/streaks/delete-pauses.mdx b/es/admin-api/endpoints/streaks/delete-pauses.mdx new file mode 100644 index 00000000..50cc1916 --- /dev/null +++ b/es/admin-api/endpoints/streaks/delete-pauses.mdx @@ -0,0 +1,10 @@ +--- +title: Eliminar pausas de racha +openapi: "/openapi/admin.json DELETE /streaks/pauses" +--- + +import { RateLimitBadge } from "../../../components/rate-limit-badge.jsx"; + +**Límites de velocidad** + + diff --git a/es/features/streaks.mdx b/es/features/streaks.mdx index 05c40166..6afd94f2 100644 --- a/es/features/streaks.mdx +++ b/es/features/streaks.mdx @@ -76,6 +76,32 @@ Si has [configurado zonas horarias](/es/features/users#param-tz) para tus usuari En Trophy también configuras el número máximo de congelaciones que cada usuario puede tener, hasta un límite de 100. La [acumulación de congelaciones](#freeze-accumulation) solo otorgará congelaciones hasta este límite. +## Pausas de Racha {#streak-pauses} + +Las pausas de racha protegen la racha de un usuario durante un rango de fechas conocido, como unas vacaciones u otra pausa planificada. Mientras una pausa cubre un período, Trophy mantiene la duración de la racha del usuario en lugar de terminarla si no cumple sus [condiciones de racha](#streak-conditions). + +### Crear Pausas {#creating-pauses} + +Crea pausas con la [API de administración para crear pausas de racha](/es/admin-api/endpoints/streaks/create-pauses). Puedes crear pausas para hasta 100 usuarios en una sola solicitud. + +Cada pausa requiere: + +- `userId`: el usuario para el que crear una pausa +- `start`: la primera fecha que cubre la pausa +- `end`: la última fecha que cubre la pausa + +Las fechas de inicio en el pasado se rechazan. Si has [configurado zonas horarias](/es/features/users#param-tz) para tus usuarios, Trophy evalúa `start` contra el día de hoy en la zona horaria local de cada usuario. + +### Eliminar Pausas {#deleting-pauses} + +Para dejar de aplicar una pausa, elimínala con la [API de administración para eliminar pausas de racha](/es/admin-api/endpoints/streaks/delete-pauses). + +### Leer Pausas {#reading-pauses} + +La [API de rachas de usuario](/es/api-reference/endpoints/users/get-a-users-streak) devuelve las pausas próximas y actualmente activas en el campo `pauses`. Se omiten las pausas pasadas y eliminadas. + +Cada período en `streakHistory` incluye `usedPause`, que es `true` cuando la racha del usuario estuvo en pausa durante ese período. + ## Seguimiento de Rachas {#tracking-streaks} Trophy calcula automáticamente las rachas para todos los usuarios en función de los [eventos de métrica](/es/features/events#tracking-metric-events) que reportes a Trophy. @@ -116,6 +142,10 @@ Para obtener más información sobre cómo establecer preferencias de usuario pa Esta sección describe algunas de las operaciones que puedes realizar para administrar las rachas de los usuarios en tu aplicación. +### Pausar la Racha de un Usuario {#pausing-a-users-streak} + +Para pausar la racha de un usuario durante un rango de fechas específico, usa la [API de administración para crear pausas de racha](/es/admin-api/endpoints/streaks/create-pauses). Consulta [pausas de racha](#streak-pauses) para saber cómo funcionan las pausas, incluyendo cómo eliminarlas. + ### Restaurar la Racha de un Usuario {#restoring-a-users-streak} Para restaurar la racha de un usuario, dirígete a la página de detalles del usuario y usa la acción 'Restaurar Racha'. Restaurar la racha de un usuario la establece en la duración que tenía cuando la perdió por última vez. @@ -156,7 +186,7 @@ Esto puede usarse para activar transaccionalmente elementos de UI/UX incluyendo: ### API de Rachas de Usuario {#user-streaks-api} -La [API de rachas de usuario](/es/api-reference/endpoints/users/get-a-users-streak) devuelve la racha actual de un usuario individual, junto con su historial reciente de rachas. Usa el parámetro de consulta `historyPeriods` para controlar cuántos períodos devolver. +La [API de rachas de usuario](/es/api-reference/endpoints/users/get-a-users-streak) devuelve la racha actual de un usuario individual, junto con su historial reciente de rachas y cualquier [pausa de racha](#streak-pauses) próxima o activa. Usa el parámetro de consulta `historyPeriods` para controlar cuántos períodos devolver. {/* vale off */} @@ -169,41 +199,55 @@ La [API de rachas de usuario](/es/api-reference/endpoints/users/get-a-users-stre "periodEnd": "2025-04-05", "expires": "2025-04-12", "rank": 5, + "pauses": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "start": "2026-08-20", + "end": "2026-08-27" + } + ], "streakHistory": [ { "periodStart": "2025-03-02", "periodEnd": "2025-03-08", - "length": 9 + "length": 9, + "usedPause": false }, { "periodStart": "2025-03-09", "periodEnd": "2025-03-15", - "length": 0 + "length": 0, + "usedPause": false }, { "periodStart": "2025-03-16", "periodEnd": "2025-03-22", - "length": 0 + "length": 0, + "usedPause": false }, { "periodStart": "2025-03-23", "periodEnd": "2025-03-29", - "length": 1 + "length": 1, + "usedPause": false }, { "periodStart": "2025-03-30", "periodEnd": "2025-04-05", - "length": 2 + "length": 2, + "usedPause": false }, { "periodStart": "2025-04-06", "periodEnd": "2025-04-12", - "length": 3 + "length": 3, + "usedPause": false }, { "periodStart": "2025-04-13", "periodEnd": "2025-04-19", - "length": 4 + "length": 4, + "usedPause": false } ] } diff --git a/es/guides/how-to-build-a-streaks-feature.mdx b/es/guides/how-to-build-a-streaks-feature.mdx index f30e44f4..37101679 100644 --- a/es/guides/how-to-build-a-streaks-feature.mdx +++ b/es/guides/how-to-build-a-streaks-feature.mdx @@ -198,6 +198,12 @@ Trophy también admite congelación de rachas, lo que puede ayudar a evitar que Obtén más información sobre la congelación de rachas en la [documentación dedicada de congelación de rachas](/es/features/streaks#streak-freezes). +## Pausas de Racha {#streak-pauses} + +Trophy también admite pausas de racha, que protegen la racha de un usuario durante un rango de fechas conocido en lugar de terminarla. + +Obtén más información sobre las pausas de racha en la [documentación dedicada de pausas de racha](/es/features/streaks#streak-pauses). + ## Obtener Soporte {#get-support} ¿Quieres ponerte en contacto con el equipo de Trophy? Contáctanos por [correo electrónico](mailto:support@trophy.so). ¡Estamos aquí para ayudar! diff --git a/features/streaks.mdx b/features/streaks.mdx index 04405887..503949ac 100644 --- a/features/streaks.mdx +++ b/features/streaks.mdx @@ -76,6 +76,32 @@ If you've [configured time zones](/features/users#param-tz) for your users, Trop In Trophy you also configure the maximum number of freezes that each user can have, up to a limit of 100. [Freeze accumulation](#freeze-accumulation) will only ever grant freezes up to this limit. +## Streak Pauses {#streak-pauses} + +Streak pauses protect a user's streak over a known date range, such as a vacation or other planned break. While a pause covers a period, Trophy maintains the user's streak length instead of ending the streak if they miss their [streak conditions](#streak-conditions). + +### Creating Pauses {#creating-pauses} + +Create pauses with the [create streak pauses admin API](/admin-api/endpoints/streaks/create-pauses). You can create pauses for up to 100 users in a single request. + +Each pause requires: + +- `userId`: the user to create a pause for +- `start`: the first date the pause covers +- `end`: the last date the pause covers + +Start dates in the past are rejected. If you've [configured time zones](/features/users#param-tz) for your users, Trophy evaluates `start` against today in each user's local timezone. + +### Deleting Pauses {#deleting-pauses} + +To stop a pause from applying, delete it with the [delete streak pauses admin API](/admin-api/endpoints/streaks/delete-pauses). + +### Reading Pauses {#reading-pauses} + +The [user streaks API](/api-reference/endpoints/users/get-a-users-streak) returns upcoming and currently active pauses in the `pauses` field. Past and deleted pauses are omitted. + +Each period in `streakHistory` includes `usedPause`, which is `true` when the user's streak was paused during that period. + ## Tracking Streaks {#tracking-streaks} Trophy automatically calculates streaks for all users based on the [metric events](/features/events#tracking-metric-events) you report to Trophy. @@ -116,7 +142,11 @@ To learn more about how to set user preferences for a specific user, read the de This section outlines some of the operations you can perform to manage user's streaks in your application. -### Restoring A Users Streak {#restoring-a-users-streak} +### Pausing A User's Streak {#pausing-a-users-streak} + +To pause a user's streak for a specific date range, use the [create streak pauses admin API](/admin-api/endpoints/streaks/create-pauses). See [streak pauses](#streak-pauses) for how pauses work, including how to delete them. + +### Restoring A User's Streak {#restoring-a-users-streak} To restore a user's streak, head to the user details page and use the 'Restore Streak' action. Restoring a user's streak sets it to the length it was when they last lost it. @@ -158,7 +188,7 @@ This can be used to transactionally trigger UI/UX elements including: ### User Streaks API {#user-streaks-api} -The [user streaks API](/api-reference/endpoints/users/get-a-users-streak) returns the current streak for a single user, along with their recent streak history. Use the `historyPeriods` query parameter to control how many periods to return. +The [user streaks API](/api-reference/endpoints/users/get-a-users-streak) returns the current streak for a single user, along with their recent streak history and any upcoming or active [streak pauses](#streak-pauses). Use the `historyPeriods` query parameter to control how many periods to return. {/* vale off */} @@ -171,41 +201,55 @@ The [user streaks API](/api-reference/endpoints/users/get-a-users-streak) return "periodEnd": "2025-04-05", "expires": "2025-04-12", "rank": 5, + "pauses": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "start": "2026-08-20", + "end": "2026-08-27" + } + ], "streakHistory": [ { "periodStart": "2025-03-02", "periodEnd": "2025-03-08", - "length": 9 + "length": 9, + "usedPause": false }, { "periodStart": "2025-03-09", "periodEnd": "2025-03-15", - "length": 0 + "length": 0, + "usedPause": false }, { "periodStart": "2025-03-16", "periodEnd": "2025-03-22", - "length": 0 + "length": 0, + "usedPause": false }, { "periodStart": "2025-03-23", "periodEnd": "2025-03-29", - "length": 1 + "length": 1, + "usedPause": false }, { "periodStart": "2025-03-30", "periodEnd": "2025-04-05", - "length": 2 + "length": 2, + "usedPause": false }, { "periodStart": "2025-04-06", "periodEnd": "2025-04-12", - "length": 3 + "length": 3, + "usedPause": false }, { "periodStart": "2025-04-13", "periodEnd": "2025-04-19", - "length": 4 + "length": 4, + "usedPause": false } ] } diff --git a/guides/how-to-build-a-streaks-feature.mdx b/guides/how-to-build-a-streaks-feature.mdx index e603803b..70a987f7 100644 --- a/guides/how-to-build-a-streaks-feature.mdx +++ b/guides/how-to-build-a-streaks-feature.mdx @@ -204,6 +204,12 @@ Trophy also supports streak freezes which can help prevent users from losing the Learn more about streak freezes in the dedicated [streak freezes docs](/features/streaks#streak-freezes). +## Streak Pauses {#streak-pauses} + +Trophy also supports streak pauses, which protect a user's streak over a known date range instead of ending it. + +Learn more about streak pauses in the dedicated [streak pauses docs](/features/streaks#streak-pauses). + ## Get Support {#get-support} Want to get in touch with the Trophy team? Reach out to us via [email](mailto:support@trophy.so). We're here to help! diff --git a/i18n.lock b/i18n.lock index 6731c8d9..5c23640a 100644 --- a/i18n.lock +++ b/i18n.lock @@ -973,8 +973,11 @@ checksums: content/52: 889ae336e820bf64bf9a9e718e398b69 content/53: a64f63364045ef5cee1f72d5d5310c8a content/54: 5a2429a79da0c233105c776147a1aa84 - content/55: 10e8e9a59847ddd720c6d06b12c7b120 - content/56: 9799b973234bf2d10d5c971b267f55a5 + content/55: f54eca2e48f83b23715d4e024a2f4718 + content/56: 853ad7a01d8b9fc073508f8df84d974a + content/57: 3df147fc937d53be81b9eda333476936 + content/58: 10e8e9a59847ddd720c6d06b12c7b120 + content/59: 9799b973234bf2d10d5c971b267f55a5 f22316048205b16e3a434589e803e82b: meta/title: 16a229352e4e4bb5b14f38574c8f2723 meta/description: ffe37cf89d34043b5629a64d0263f83a @@ -3057,42 +3060,56 @@ checksums: content/22: 3a5b1b80506797525441e85460ee2a51 content/23: d300b0f0f9a24dac347eeddaef7c82a3 content/24: f1afe4d72b108602b3a93450760788f5 - content/25: 2b47756439adf8f9b38b04085a709a03 - content/26: b6f909922cc9e10746ea84ce96827b16 - content/27: 0b45597750a093259a241cf3c4da862e - content/28: d6facb51881f25f097fe04dbf2e5103f - content/29: 43ad0b6ea6fbeef69ece943e165a168e - content/30: fdefaf43995cd4efa70dfcaf981fd697 - content/31: 524454ff831052b4331a56d6f674ccaa - content/32: 2214e876e97977bf5cebec45dcdcd1c8 - content/33: fbdc0fc1e117f4e5cfeae94fc771c993 - content/34: 20bdf64fd91ed2bc4687a1657bbfae8a - content/35: 2dacfcc9d13a93d2965ca6051ee62fde - content/36: 4caecadc2bf024da1773cf2b612aa8cb - content/37: 3cfd18a2975ad68bef9d67e350e8c463 - content/38: 9e4d09a957ca66f58d4248300fbe2662 - content/39: 758ecef4a7a0b5d55fb97febe4184ec2 - content/40: 9aec72901fcecb0cdf45f729387b9742 - content/41: 71d6882b2ae9220e3bb0c6abc98fc236 - content/42: bfa82570db14cd44d636f90e20080898 - content/43: 59f82b2e0dbec73340a007cb020ab2ce - content/44: 54e6b1cb90e203d05d06a5d188238cd4 - content/45: 4f72e470a0dbe75e396f57952f29901a - content/46: 380be3ed5af370f2d36a66f4c55f7f0b - content/47: 5a5f6f25f2b2cf4ebbb5f018bb0d5824 - content/48: ed7cd0fb6f61c823f39fe089a7f62e1f - content/49: b3bc9605c19967a6162e1c72333251a9 - content/50: 6a5bc8b31ffa32876914a59c0882a336 - content/51: 40a3888d076524edcb9716f64683c5b3 - content/52: ca8396af4c4ecc5a806c42187204d877 - content/53: 98200505f691d3dcb12fa6833d0e88ad - content/54: df90d3b6267199a3dd86d820374aa785 - content/55: 286a2716711641435b4b996d8b22e881 - content/56: 29e769123cc029c8c9657dcd8d384b83 - content/57: 08345a94bd6f9b9539d128e5db15184a - content/58: 47770b5654a1f47d56eba81273ff08d9 - content/59: 10e8e9a59847ddd720c6d06b12c7b120 - content/60: 9799b973234bf2d10d5c971b267f55a5 + content/25: f54eca2e48f83b23715d4e024a2f4718 + content/26: 436aa442c7d61808162bfd9b5fd28a8b + content/27: b75955d955dac9b43a659941bff4e9d2 + content/28: 0a308129fbd6cbc11825b5535d16121f + content/29: 75fc66d4cd183160c472887b94158023 + content/30: c7564d1e160d174268defdbc3f3e5ecd + content/31: 6c2e152e0502c6e1ba03425956c939c1 + content/32: 2a2ec04319e0d097d6bfd0a59f866447 + content/33: 7f514b74b42a9c9b39dfbfa6323bb450 + content/34: f34dda0acf61e6e574b8809e7753ae0f + content/35: 7b6f98aeeee6661aef43d14eb0f19071 + content/36: 000f69acf39db68262e439f9ca2dcfa2 + content/37: 2b47756439adf8f9b38b04085a709a03 + content/38: b6f909922cc9e10746ea84ce96827b16 + content/39: 0b45597750a093259a241cf3c4da862e + content/40: d6facb51881f25f097fe04dbf2e5103f + content/41: 43ad0b6ea6fbeef69ece943e165a168e + content/42: fdefaf43995cd4efa70dfcaf981fd697 + content/43: 524454ff831052b4331a56d6f674ccaa + content/44: 2214e876e97977bf5cebec45dcdcd1c8 + content/45: fbdc0fc1e117f4e5cfeae94fc771c993 + content/46: 20bdf64fd91ed2bc4687a1657bbfae8a + content/47: 2dacfcc9d13a93d2965ca6051ee62fde + content/48: 4caecadc2bf024da1773cf2b612aa8cb + content/49: b1704d9be89cf0327f93e58b1b278c06 + content/50: b2781293b2faf65a1eee51baca384490 + content/51: 91ffb03304d0dc66f9fc2357aa39346f + content/52: 9e4d09a957ca66f58d4248300fbe2662 + content/53: 758ecef4a7a0b5d55fb97febe4184ec2 + content/54: 9aec72901fcecb0cdf45f729387b9742 + content/55: 71d6882b2ae9220e3bb0c6abc98fc236 + content/56: bfa82570db14cd44d636f90e20080898 + content/57: 59f82b2e0dbec73340a007cb020ab2ce + content/58: 54e6b1cb90e203d05d06a5d188238cd4 + content/59: 4f72e470a0dbe75e396f57952f29901a + content/60: 380be3ed5af370f2d36a66f4c55f7f0b + content/61: 5a5f6f25f2b2cf4ebbb5f018bb0d5824 + content/62: ed7cd0fb6f61c823f39fe089a7f62e1f + content/63: b3bc9605c19967a6162e1c72333251a9 + content/64: ac3267698b45c30fea7622d6f38767b5 + content/65: 40a3888d076524edcb9716f64683c5b3 + content/66: f8bc90b1b7d0108fdfad2e3bd7641dbf + content/67: 98200505f691d3dcb12fa6833d0e88ad + content/68: df90d3b6267199a3dd86d820374aa785 + content/69: 286a2716711641435b4b996d8b22e881 + content/70: 29e769123cc029c8c9657dcd8d384b83 + content/71: 08345a94bd6f9b9539d128e5db15184a + content/72: 47770b5654a1f47d56eba81273ff08d9 + content/73: 10e8e9a59847ddd720c6d06b12c7b120 + content/74: 9799b973234bf2d10d5c971b267f55a5 9f5464896b543cfd1d607b30a9997155: meta/title: e771f23130f9aab4f3e2e99acacf5d5a meta/description: 8539ebe90ff733bef6498db1933f3a57 @@ -7023,3 +7040,21 @@ checksums: content/26: e815c435234e61991573554f3b017fe1 content/27: 10e8e9a59847ddd720c6d06b12c7b120 content/28: 9799b973234bf2d10d5c971b267f55a5 + b15fa1c26da90316f7e8951e1ce18470: + meta/title: 1a0643dc8057fe771da3366044fdee76 + meta/openapi: 63b1e6a9c74af0e1c92c182d3cee355d + content/0: c3d96e3528a55b20b8fbcae10af25b02 + content/1: 264d832bc605beaf5168c080bfed567c + content/2: 580af53aa9812f2ec29a632e145669a5 + b0fce8448e0e09224983fe6dc137a18c: + meta/title: 81ff989f5182157d37a38620eb9c9b84 + meta/openapi: 77443e4bbca3e94947607a45397e6bb4 + content/0: c3d96e3528a55b20b8fbcae10af25b02 + content/1: 264d832bc605beaf5168c080bfed567c + content/2: 580af53aa9812f2ec29a632e145669a5 + 445b7d324d865a5796fd42e5a37e584e: + meta/title: 61ff643dc79ca2d6f8e5f138f8892bf8 + meta/openapi: 77443e4bbca3e94947607a45397e6bb4 + content/0: c3d96e3528a55b20b8fbcae10af25b02 + content/1: 264d832bc605beaf5168c080bfed567c + content/2: 580af53aa9812f2ec29a632e145669a5 diff --git a/lingo/glossary.csv b/lingo/glossary.csv index b82334b3..7521c78b 100644 --- a/lingo/glossary.csv +++ b/lingo/glossary.csv @@ -30,6 +30,8 @@ en,es,Leaderboard,Clasificación,custom_translation,Gamification feature noun en,es,Leaderboards,Clasificaciones,custom_translation,Gamification feature noun plural en,es,Streak,Racha,custom_translation,Gamification feature noun en,es,Streaks,Rachas,custom_translation,Gamification feature noun plural +en,es,Streak Pause,Pausa de racha,custom_translation,Gamification feature noun +en,es,Streak Pauses,Pausas de racha,custom_translation,Gamification feature noun plural en,es,Achievement,Logro,custom_translation,Gamification feature noun en,es,Achievements,Logros,custom_translation,Gamification feature noun plural en,es,Points,Puntos,custom_translation,Gamification feature noun plural diff --git a/openapi/admin.json b/openapi/admin.json index d2883ca8..293e28c5 100644 --- a/openapi/admin.json +++ b/openapi/admin.json @@ -2,13 +2,13 @@ "openapi": "3.1.0", "info": { "title": "Trophy", - "version": "1.20.1" + "version": "1.21.1" }, "x-fern-global-headers": [ { "header": "X-SDK-VERSION", "name": "sdkVersion", - "x-fern-default": "1.20.1" + "x-fern-default": "1.21.1" } ], "paths": { @@ -1826,7 +1826,7 @@ ] }, "delete": { - "description": "Delete (archive) points systems by ID.", + "description": "Delete points systems by ID.", "operationId": "admin_points_systems_delete", "x-fern-server-name": "admin", "x-fern-sdk-group-name": [ @@ -3862,7 +3862,7 @@ ] }, "delete": { - "description": "Delete (archive) points triggers by ID. Maximum 100 trigger IDs per request.", + "description": "Delete points triggers by ID. Maximum 100 trigger IDs per request.", "operationId": "admin_points_triggers_delete", "x-fern-server-name": "admin", "x-fern-sdk-group-name": [ @@ -4862,6 +4862,300 @@ ] } }, + "/streaks/pauses": { + "servers": [ + { + "url": "https://admin.trophy.so/v1", + "description": "Admin API" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/TenantId" + } + ], + "post": { + "description": "Create streak pauses for multiple users. A pause covers a specific date range and maintains the user's streak length during that range instead of ending the streak. Start dates in the past are rejected.", + "operationId": "admin_streaks_pauses_create", + "x-fern-server-name": "admin", + "x-fern-sdk-group-name": [ + "admin", + "streaks", + "pauses" + ], + "x-fern-sdk-method-name": "create", + "tags": [ + "Admin" + ], + "x-codeSamples": [ + { + "lang": "javascript", + "source": "import { TrophyApiClient } from '@trophyso/node';\n\nconst trophy = new TrophyApiClient({\n apiKey: 'YOUR_API_KEY'\n});\n\nconst response = await trophy.admin.streaks.pauses.create({\n pauses: [\n { userId: 'user-123', start: '2026-08-20', end: '2026-08-27' },\n { userId: 'user-456', start: '2026-09-01', end: '2026-09-07' },\n ]\n});\n" + }, + { + "lang": "python", + "source": "from trophy import TrophyApi\n\nclient = TrophyApi(api_key='YOUR_API_KEY')\n\nresponse = client.admin.streaks.pauses.create({\n \"pauses\": [\n {\"userId\": \"user-123\", \"start\": \"2026-08-20\", \"end\": \"2026-08-27\"},\n {\"userId\": \"user-456\", \"start\": \"2026-09-01\", \"end\": \"2026-09-07\"}\n ]\n})\n" + }, + { + "lang": "go", + "source": "import (\n \"context\"\n\n api \"github.com/trophyso/trophy-go\"\n trophyclient \"github.com/trophyso/trophy-go/client\"\n \"github.com/trophyso/trophy-go/option\"\n)\n\nclient := trophyclient.NewClient(\n option.WithApiKey(\"YOUR_API_KEY\"),\n)\n\nresponse, err := client.Admin.Streaks.Pauses.Create(context.TODO(), nil)\n" + } + ], + "requestBody": { + "description": "Array of pauses to create", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateStreakPausesRequest" + }, + "examples": { + "Create pauses for multiple users": { + "value": { + "pauses": [ + { + "userId": "user-123", + "start": "2026-08-20", + "end": "2026-08-27" + }, + { + "userId": "user-456", + "start": "2026-09-01", + "end": "2026-09-07" + } + ] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful operation (no pauses created)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateStreakPausesResponse" + }, + "examples": { + "Mixed success and errors": { + "value": { + "created": [], + "issues": [ + { + "userId": "non-existent-user", + "severity": "error", + "message": "User does not exist" + } + ] + } + } + } + } + } + }, + "201": { + "description": "Created (at least one pause created)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateStreakPausesResponse" + }, + "examples": { + "Success with no issues": { + "value": { + "created": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "userId": "user-123", + "start": "2026-08-20", + "end": "2026-08-27", + "status": "active" + } + ], + "issues": [] + } + }, + "Mixed success and errors": { + "value": { + "created": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "userId": "user-123", + "start": "2026-08-20", + "end": "2026-08-27", + "status": "active" + } + ], + "issues": [ + { + "userId": "non-existent-user", + "severity": "error", + "message": "User does not exist" + } + ] + } + } + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AdminErrorBody" + } + } + } + }, + "422": { + "description": "Unprocessible Entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AdminErrorBody" + } + } + } + } + }, + "summary": "Create streak pauses for multiple users", + "security": [ + { + "ApiKeyAuth": [] + } + ] + }, + "delete": { + "description": "Delete streak pauses by ID.", + "operationId": "admin_streaks_pauses_delete", + "x-fern-server-name": "admin", + "x-fern-sdk-group-name": [ + "admin", + "streaks", + "pauses" + ], + "x-fern-sdk-method-name": "delete", + "tags": [ + "Admin" + ], + "x-codeSamples": [ + { + "lang": "javascript", + "source": "import { TrophyApiClient } from '@trophyso/node';\n\nconst trophy = new TrophyApiClient({\n apiKey: 'YOUR_API_KEY'\n});\n\nconst response = await trophy.admin.streaks.pauses.delete({\n ids: [\n '550e8400-e29b-41d4-a716-446655440000',\n '550e8400-e29b-41d4-a716-446655440001'\n ]\n});\n" + }, + { + "lang": "python", + "source": "from trophy import TrophyApi\n\nclient = TrophyApi(api_key='YOUR_API_KEY')\n\nresponse = client.admin.streaks.pauses.delete(\n ids=[\n '550e8400-e29b-41d4-a716-446655440000',\n '550e8400-e29b-41d4-a716-446655440001'\n ]\n)\n" + }, + { + "lang": "go", + "source": "import (\n \"context\"\n\n api \"github.com/trophyso/trophy-go\"\n trophyclient \"github.com/trophyso/trophy-go/client\"\n \"github.com/trophyso/trophy-go/option\"\n)\n\nclient := trophyclient.NewClient(\n option.WithApiKey(\"YOUR_API_KEY\"),\n)\n\nresponse, err := client.Admin.Streaks.Pauses.Delete(context.TODO(), nil)\n" + } + ], + "parameters": [ + { + "name": "ids", + "in": "query", + "description": "Streak pause IDs to delete. Repeat the query param or provide a comma-separated list.", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "minItems": 1, + "maxItems": 100 + }, + "style": "form", + "explode": true, + "examples": { + "Multiple query params": { + "value": [ + "550e8400-e29b-41d4-a716-446655440000", + "550e8400-e29b-41d4-a716-446655440001" + ] + } + } + } + ], + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteStreakPausesResponse" + }, + "examples": { + "Success with no issues": { + "value": { + "deleted": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000" + } + ], + "issues": [] + } + }, + "Mixed success and errors": { + "value": { + "deleted": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000" + } + ], + "issues": [ + { + "id": "not-a-uuid", + "severity": "error", + "message": "id must be a valid UUID" + }, + { + "id": "550e8400-e29b-41d4-a716-446655440999", + "severity": "error", + "message": "Streak pause not found by ID" + } + ] + } + } + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AdminErrorBody" + } + } + } + }, + "422": { + "description": "Unprocessible Entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AdminErrorBody" + } + } + } + } + }, + "summary": "Delete streak pauses", + "security": [ + { + "ApiKeyAuth": [] + } + ] + } + }, "/streaks/restore": { "servers": [ { @@ -6058,6 +6352,143 @@ "issues" ] }, + "CreateStreakPausesRequest": { + "title": "CreateStreakPausesRequest", + "type": "object", + "description": "Request body for creating streak pauses.", + "properties": { + "pauses": { + "type": "array", + "items": { + "type": "object", + "properties": { + "userId": { + "type": "string", + "description": "The ID of the user to create a pause for.", + "example": "user-123" + }, + "start": { + "type": "string", + "format": "date", + "description": "The first date the pause covers, in YYYY-MM-DD format. Must not be before today in the user's timezone.", + "example": "2026-08-20" + }, + "end": { + "type": "string", + "format": "date", + "description": "The last date the pause covers, in YYYY-MM-DD format. Must be on or after start.", + "example": "2026-08-27" + } + }, + "required": [ + "userId", + "start", + "end" + ] + }, + "description": "Array of pauses to create. Maximum 100 pauses per request.", + "maxItems": 100, + "minItems": 1 + } + }, + "required": [ + "pauses" + ] + }, + "AdminStreakPause": { + "title": "AdminStreakPause", + "type": "object", + "description": "A streak pause returned from the admin pauses endpoints.", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "The unique ID of the streak pause." + }, + "userId": { + "type": "string", + "description": "The ID of the user the pause belongs to.", + "example": "user-123" + }, + "start": { + "type": "string", + "format": "date", + "description": "The first date the pause covers.", + "example": "2026-08-20" + }, + "end": { + "type": "string", + "format": "date", + "description": "The last date the pause covers.", + "example": "2026-08-27" + }, + "status": { + "type": "string", + "enum": [ + "active", + "archived" + ], + "description": "The status of the pause." + } + }, + "required": [ + "id", + "userId", + "start", + "end", + "status" + ] + }, + "CreateStreakPausesResponse": { + "title": "CreateStreakPausesResponse", + "type": "object", + "description": "Response containing created streak pauses and any issues encountered.", + "properties": { + "created": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AdminStreakPause" + }, + "description": "Array of streak pauses that were created." + }, + "issues": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AdminIssue" + }, + "description": "Array of issues encountered during pause creation." + } + }, + "required": [ + "created", + "issues" + ] + }, + "DeleteStreakPausesResponse": { + "title": "DeleteStreakPausesResponse", + "type": "object", + "description": "Response containing deleted streak pauses and any issues encountered.", + "properties": { + "deleted": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DeletedResource" + }, + "description": "Array of deleted streak pause IDs." + }, + "issues": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AdminIssue" + }, + "description": "Array of issues encountered during pause deletion." + } + }, + "required": [ + "deleted", + "issues" + ] + }, "CreateAttributesRequest": { "title": "CreateAttributesRequest", "type": "array", diff --git a/openapi/application.json b/openapi/application.json index 1fd9cd75..6fe3bdaa 100644 --- a/openapi/application.json +++ b/openapi/application.json @@ -2,13 +2,13 @@ "openapi": "3.1.0", "info": { "title": "Trophy", - "version": "1.20.1" + "version": "1.21.1" }, "x-fern-global-headers": [ { "header": "X-SDK-VERSION", "name": "sdkVersion", - "x-fern-default": "1.20.1" + "x-fern-default": "1.21.1" } ], "paths": { @@ -2010,41 +2010,49 @@ "periodEnd": "2025-04-05", "expires": "2025-04-12", "extended": "2025-04-03T14:30:00Z", + "pauses": [], "streakHistory": [ { "periodStart": "2025-03-30", "periodEnd": "2025-04-05", - "length": 1 + "length": 1, + "usedPause": false }, { "periodStart": "2025-04-06", "periodEnd": "2025-04-12", - "length": 2 + "length": 2, + "usedPause": false }, { "periodStart": "2025-04-13", "periodEnd": "2025-04-19", - "length": 3 + "length": 3, + "usedPause": false }, { "periodStart": "2025-04-20", "periodEnd": "2025-04-26", - "length": 0 + "length": 0, + "usedPause": false }, { "periodStart": "2025-04-27", "periodEnd": "2025-05-03", - "length": 1 + "length": 1, + "usedPause": false }, { "periodStart": "2025-05-04", "periodEnd": "2025-05-10", - "length": 2 + "length": 2, + "usedPause": false }, { "periodStart": "2025-05-11", "periodEnd": "2025-05-17", - "length": 3 + "length": 3, + "usedPause": false } ] } @@ -4620,7 +4628,7 @@ "post": { "summary": "Points changed", "operationId": "webhooks_points_changed", - "description": "Triggered when a user is awarded or loses points. This event is fired a maximum of once per user per points system per minute.", + "description": "Triggered when a user is awarded or loses points. This event is fired a maximum of once per user per points system every fifteen minutes.", "requestBody": { "description": "The webhook event.", "content": { @@ -5035,7 +5043,7 @@ "post": { "summary": "Leaderboard changed", "operationId": "webhooks_leaderboard_changed", - "description": "Triggered when leaderboard rankings change.", + "description": "Triggered when leaderboard rankings change. This event is fired a maximum of once per leaderboard every fifteen minutes.", "requestBody": { "description": "The webhook event.", "content": { @@ -5427,7 +5435,7 @@ "post": { "summary": "Leaderboard rank changed", "operationId": "webhooks_leaderboard_rank_changed", - "description": "Triggered when a user's leaderboard rank changes.", + "description": "Triggered when a user's leaderboard rank changes. This event is fired a maximum of once per user per leaderboard every fifteen minutes.", "requestBody": { "description": "The webhook event.", "content": { @@ -5695,19 +5703,58 @@ "type": "boolean", "description": "Whether the user used a streak freeze during this period. Only present if the organization has enabled streak freezes.", "example": false + }, + "usedPause": { + "type": "boolean", + "description": "Whether the user's streak was paused during this period.", + "example": false } }, "required": [ "periodStart", "periodEnd", - "length" + "length", + "usedPause" + ] + } + }, + "pauses": { + "type": "array", + "description": "Upcoming and currently active streak pauses for the user.", + "items": { + "type": "object", + "description": "An object representing a streak pause.", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "The unique ID of the streak pause." + }, + "start": { + "type": "string", + "format": "date", + "description": "The first date the pause covers.", + "example": "2026-08-20" + }, + "end": { + "type": "string", + "format": "date", + "description": "The last date the pause covers.", + "example": "2026-08-27" + } + }, + "required": [ + "id", + "start", + "end" ] } } }, "required": [ "extended", - "streakHistory" + "streakHistory", + "pauses" ] } ] diff --git a/snippets/streak-response-block.mdx b/snippets/streak-response-block.mdx index 320798ae..eb978c85 100644 --- a/snippets/streak-response-block.mdx +++ b/snippets/streak-response-block.mdx @@ -8,41 +8,55 @@ "periodStart": "2025-03-31", "periodEnd": "2025-04-05", "expires": "2025-04-12", + "pauses": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "start": "2026-08-20", + "end": "2026-08-27" + } + ], "streakHistory": [ { "periodStart": "2025-03-30", "periodEnd": "2025-04-05", - "length": 1 + "length": 1, + "usedPause": false }, { "periodStart": "2025-04-06", "periodEnd": "2025-04-12", - "length": 2 + "length": 2, + "usedPause": false }, { "periodStart": "2025-04-13", "periodEnd": "2025-04-19", - "length": 3 + "length": 3, + "usedPause": false }, { "periodStart": "2025-04-20", "periodEnd": "2025-04-26", - "length": 0 + "length": 0, + "usedPause": false }, { "periodStart": "2025-04-27", "periodEnd": "2025-05-03", - "length": 1 + "length": 1, + "usedPause": false }, { "periodStart": "2025-05-04", "periodEnd": "2025-05-10", - "length": 2 + "length": 2, + "usedPause": false }, { "periodStart": "2025-05-11", "periodEnd": "2025-05-17", - "length": 3 + "length": 3, + "usedPause": false } ] }