@rustrak/client 0.18.1 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +325 -123
  2. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  3. package/dist/client.cjs +86 -0
  4. package/dist/client.cjs.map +1 -0
  5. package/dist/client.d.cts +18 -0
  6. package/dist/client.d.cts.map +1 -0
  7. package/dist/client.d.mts +18 -0
  8. package/dist/client.d.mts.map +1 -0
  9. package/dist/client.mjs +86 -0
  10. package/dist/client.mjs.map +1 -0
  11. package/dist/config.d.cts +10 -0
  12. package/dist/config.d.cts.map +1 -0
  13. package/dist/config.d.mts +10 -0
  14. package/dist/config.d.mts.map +1 -0
  15. package/dist/errors.cjs +52 -0
  16. package/dist/errors.cjs.map +1 -0
  17. package/dist/errors.d.cts +77 -0
  18. package/dist/errors.d.cts.map +1 -0
  19. package/dist/errors.d.mts +77 -0
  20. package/dist/errors.d.mts.map +1 -0
  21. package/dist/errors.mjs +48 -0
  22. package/dist/errors.mjs.map +1 -0
  23. package/dist/generated/client/client.gen.cjs +174 -0
  24. package/dist/generated/client/client.gen.cjs.map +1 -0
  25. package/dist/generated/client/client.gen.mjs +174 -0
  26. package/dist/generated/client/client.gen.mjs.map +1 -0
  27. package/dist/generated/client/types.gen.d.cts +71 -0
  28. package/dist/generated/client/types.gen.d.cts.map +1 -0
  29. package/dist/generated/client/types.gen.d.mts +71 -0
  30. package/dist/generated/client/types.gen.d.mts.map +1 -0
  31. package/dist/generated/client/utils.gen.cjs +184 -0
  32. package/dist/generated/client/utils.gen.cjs.map +1 -0
  33. package/dist/generated/client/utils.gen.d.cts +21 -0
  34. package/dist/generated/client/utils.gen.d.cts.map +1 -0
  35. package/dist/generated/client/utils.gen.d.mts +21 -0
  36. package/dist/generated/client/utils.gen.d.mts.map +1 -0
  37. package/dist/generated/client/utils.gen.mjs +177 -0
  38. package/dist/generated/client/utils.gen.mjs.map +1 -0
  39. package/dist/generated/client.gen.cjs +7 -0
  40. package/dist/generated/client.gen.cjs.map +1 -0
  41. package/dist/generated/client.gen.mjs +8 -0
  42. package/dist/generated/client.gen.mjs.map +1 -0
  43. package/dist/generated/core/auth.gen.cjs +12 -0
  44. package/dist/generated/core/auth.gen.cjs.map +1 -0
  45. package/dist/generated/core/auth.gen.d.cts +11 -0
  46. package/dist/generated/core/auth.gen.d.cts.map +1 -0
  47. package/dist/generated/core/auth.gen.d.mts +11 -0
  48. package/dist/generated/core/auth.gen.d.mts.map +1 -0
  49. package/dist/generated/core/auth.gen.mjs +12 -0
  50. package/dist/generated/core/auth.gen.mjs.map +1 -0
  51. package/dist/generated/core/bodySerializer.gen.cjs +21 -0
  52. package/dist/generated/core/bodySerializer.gen.cjs.map +1 -0
  53. package/dist/generated/core/bodySerializer.gen.d.cts +15 -0
  54. package/dist/generated/core/bodySerializer.gen.d.cts.map +1 -0
  55. package/dist/generated/core/bodySerializer.gen.d.mts +15 -0
  56. package/dist/generated/core/bodySerializer.gen.d.mts.map +1 -0
  57. package/dist/generated/core/bodySerializer.gen.mjs +20 -0
  58. package/dist/generated/core/bodySerializer.gen.mjs.map +1 -0
  59. package/dist/generated/core/pathSerializer.gen.cjs +87 -0
  60. package/dist/generated/core/pathSerializer.gen.cjs.map +1 -0
  61. package/dist/generated/core/pathSerializer.gen.d.cts +9 -0
  62. package/dist/generated/core/pathSerializer.gen.d.cts.map +1 -0
  63. package/dist/generated/core/pathSerializer.gen.d.mts +9 -0
  64. package/dist/generated/core/pathSerializer.gen.d.mts.map +1 -0
  65. package/dist/generated/core/pathSerializer.gen.mjs +82 -0
  66. package/dist/generated/core/pathSerializer.gen.mjs.map +1 -0
  67. package/dist/generated/core/serverSentEvents.gen.cjs +96 -0
  68. package/dist/generated/core/serverSentEvents.gen.cjs.map +1 -0
  69. package/dist/generated/core/serverSentEvents.gen.d.cts +25 -0
  70. package/dist/generated/core/serverSentEvents.gen.d.cts.map +1 -0
  71. package/dist/generated/core/serverSentEvents.gen.d.mts +25 -0
  72. package/dist/generated/core/serverSentEvents.gen.d.mts.map +1 -0
  73. package/dist/generated/core/serverSentEvents.gen.mjs +96 -0
  74. package/dist/generated/core/serverSentEvents.gen.mjs.map +1 -0
  75. package/dist/generated/core/types.gen.d.cts +27 -0
  76. package/dist/generated/core/types.gen.d.cts.map +1 -0
  77. package/dist/generated/core/types.gen.d.mts +27 -0
  78. package/dist/generated/core/types.gen.d.mts.map +1 -0
  79. package/dist/generated/core/utils.gen.cjs +81 -0
  80. package/dist/generated/core/utils.gen.cjs.map +1 -0
  81. package/dist/generated/core/utils.gen.mjs +78 -0
  82. package/dist/generated/core/utils.gen.mjs.map +1 -0
  83. package/dist/generated/sdk.gen.cjs +3334 -0
  84. package/dist/generated/sdk.gen.cjs.map +1 -0
  85. package/dist/generated/sdk.gen.d.cts +288 -0
  86. package/dist/generated/sdk.gen.d.cts.map +1 -0
  87. package/dist/generated/sdk.gen.d.mts +288 -0
  88. package/dist/generated/sdk.gen.d.mts.map +1 -0
  89. package/dist/generated/sdk.gen.mjs +3305 -0
  90. package/dist/generated/sdk.gen.mjs.map +1 -0
  91. package/dist/generated/types.gen.d.cts +3915 -0
  92. package/dist/generated/types.gen.d.cts.map +1 -0
  93. package/dist/generated/types.gen.d.mts +3915 -0
  94. package/dist/generated/types.gen.d.mts.map +1 -0
  95. package/dist/generated/zod.gen.cjs +3273 -0
  96. package/dist/generated/zod.gen.cjs.map +1 -0
  97. package/dist/generated/zod.gen.mjs +2789 -0
  98. package/dist/generated/zod.gen.mjs.map +1 -0
  99. package/dist/index.cjs +15 -3248
  100. package/dist/index.d.cts +6 -2037
  101. package/dist/index.d.mts +6 -0
  102. package/dist/index.mjs +4 -0
  103. package/dist/result.cjs +59 -0
  104. package/dist/result.cjs.map +1 -0
  105. package/dist/result.d.cts +15 -0
  106. package/dist/result.d.cts.map +1 -0
  107. package/dist/result.d.mts +15 -0
  108. package/dist/result.d.mts.map +1 -0
  109. package/dist/result.mjs +55 -0
  110. package/dist/result.mjs.map +1 -0
  111. package/dist/utils/http.cjs +339 -0
  112. package/dist/utils/http.cjs.map +1 -0
  113. package/dist/utils/http.mjs +336 -0
  114. package/dist/utils/http.mjs.map +1 -0
  115. package/package.json +17 -12
  116. package/dist/index.cjs.map +0 -1
  117. package/dist/index.d.ts +0 -2037
  118. package/dist/index.js +0 -3232
  119. package/dist/index.js.map +0 -1
package/dist/index.js DELETED
@@ -1,3232 +0,0 @@
1
- import { z } from 'zod';
2
- import ky, { isHTTPError } from 'ky';
3
-
4
- // src/resources/agents.ts
5
- var paginatedResponseSchema = (itemSchema) => z.object({
6
- items: z.array(itemSchema),
7
- next_cursor: z.string().optional(),
8
- has_more: z.boolean()
9
- });
10
- var offsetPaginatedResponseSchema = (itemSchema) => z.object({
11
- items: z.array(itemSchema),
12
- total_count: z.number().int(),
13
- page: z.number().int(),
14
- per_page: z.number().int(),
15
- total_pages: z.number().int()
16
- });
17
- z.enum(["asc", "desc"]);
18
- z.enum([
19
- "digest_order",
20
- "last_seen",
21
- "event_count"
22
- ]);
23
- var issueFilterSchema = z.enum(["open", "resolved", "muted", "all"]);
24
- var dateTimeSchema = z.string().datetime();
25
- var uuidSchema = z.string().uuid();
26
- var eventIdSchema = z.string().regex(
27
- /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
28
- "Invalid event id"
29
- );
30
- z.object({
31
- error: z.string(),
32
- message: z.string().optional()
33
- });
34
-
35
- // src/schemas/agent.ts
36
- var agentTimeseriesPointSchema = z.object({
37
- bucket: dateTimeSchema,
38
- value: z.number()
39
- });
40
- var agentDurationPointSchema = z.object({
41
- bucket: dateTimeSchema,
42
- avg_ms: z.number(),
43
- p95_ms: z.number()
44
- });
45
- var genAiBreakdownRowSchema = z.object({
46
- label: z.string(),
47
- value: z.number()
48
- });
49
- var agentTraceSummarySchema = z.object({
50
- trace_id: z.string(),
51
- /** Every distinct agent that ran in this trace, earliest first. */
52
- agent_names: z.array(z.string()),
53
- duration_ms: z.number().nullable(),
54
- total_tokens: z.number(),
55
- tool_call_count: z.number().int(),
56
- /** `ai_client` spans: how many times a model was actually called. */
57
- llm_call_count: z.number().int(),
58
- /** AI spans in this trace whose status is set and not `ok`. */
59
- error_count: z.number().int(),
60
- started_at: dateTimeSchema
61
- });
62
- var agentSummarySchema = z.object({
63
- agent_runs: z.number().int(),
64
- llm_calls: z.number().int(),
65
- tool_calls: z.number().int(),
66
- error_count: z.number().int(),
67
- total_tokens: z.number(),
68
- avg_duration_ms: z.number(),
69
- p95_duration_ms: z.number()
70
- });
71
- var agentModelRowSchema = z.object({
72
- model: z.string(),
73
- requests: z.number().int(),
74
- errors: z.number().int(),
75
- avg_ms: z.number(),
76
- p95_ms: z.number(),
77
- input_tokens: z.number(),
78
- cached_input_tokens: z.number(),
79
- output_tokens: z.number(),
80
- reasoning_output_tokens: z.number(),
81
- total_tokens: z.number()
82
- });
83
- var agentToolRowSchema = z.object({
84
- tool: z.string(),
85
- calls: z.number().int(),
86
- errors: z.number().int(),
87
- avg_ms: z.number(),
88
- p95_ms: z.number()
89
- });
90
- var providerTypeSchema = z.enum([
91
- "webhook",
92
- "email",
93
- "slack",
94
- "custom_webhook"
95
- ]);
96
- var alertTypeSchema = z.enum(["new_issue", "regression", "unmute"]);
97
- var alertStatusSchema = z.enum([
98
- "pending",
99
- "sent",
100
- "failed",
101
- "skipped"
102
- ]);
103
- var alertIntegrationSchema = z.object({
104
- id: z.number().int(),
105
- name: z.string(),
106
- provider_type: providerTypeSchema,
107
- credentials: z.record(z.string(), z.unknown()),
108
- is_enabled: z.boolean(),
109
- failure_count: z.number().int(),
110
- last_failure_at: dateTimeSchema.nullable(),
111
- last_failure_message: z.string().nullable(),
112
- last_success_at: dateTimeSchema.nullable(),
113
- created_at: dateTimeSchema,
114
- updated_at: dateTimeSchema
115
- });
116
- var createAlertIntegrationSchema = z.object({
117
- name: z.string().min(1),
118
- provider_type: providerTypeSchema,
119
- credentials: z.record(z.string(), z.unknown()),
120
- is_enabled: z.boolean().optional()
121
- });
122
- var updateAlertIntegrationSchema = z.object({
123
- name: z.string().min(1).optional(),
124
- credentials: z.record(z.string(), z.unknown()).optional(),
125
- is_enabled: z.boolean().optional()
126
- });
127
- var alertRuleChannelInputSchema = z.object({
128
- integration_id: z.number().int(),
129
- routing_override: z.record(z.string(), z.unknown()).default({})
130
- });
131
- var alertRuleConditionsSchema = z.object({
132
- /** The quietest level that still fires. The server takes `null` as absent. */
133
- min_level: z.enum(["debug", "info", "warning", "error", "fatal"]).nullish(),
134
- /** When non-empty, the only environments that fire. */
135
- environments: z.array(z.string()).optional(),
136
- /** A new issue fires when it reaches this many events, not on its first. */
137
- min_events: z.number().int().min(1).nullish()
138
- });
139
- var alertRuleSchema = z.object({
140
- id: z.number().int(),
141
- project_id: z.number().int(),
142
- name: z.string(),
143
- alert_type: alertTypeSchema,
144
- is_enabled: z.boolean(),
145
- // A rule stored before the filters existed may hold any object. The server
146
- // evaluates one it cannot read as no filters; one bad row must not fail the
147
- // whole list either.
148
- conditions: alertRuleConditionsSchema.catch({}),
149
- cooldown_minutes: z.number().int(),
150
- last_triggered_at: dateTimeSchema.nullable(),
151
- created_at: dateTimeSchema,
152
- updated_at: dateTimeSchema,
153
- channels: z.array(alertRuleChannelInputSchema).default([]),
154
- integration_ids: z.array(z.number().int())
155
- });
156
- var createAlertRuleSchema = z.object({
157
- name: z.string().min(1),
158
- alert_type: alertTypeSchema,
159
- channels: z.array(alertRuleChannelInputSchema).default([]),
160
- is_enabled: z.boolean().optional(),
161
- conditions: alertRuleConditionsSchema.optional(),
162
- cooldown_minutes: z.number().int().min(0).optional()
163
- });
164
- var updateAlertRuleSchema = z.object({
165
- name: z.string().min(1).optional(),
166
- is_enabled: z.boolean().optional(),
167
- conditions: alertRuleConditionsSchema.optional(),
168
- cooldown_minutes: z.number().int().min(0).optional(),
169
- channels: z.array(alertRuleChannelInputSchema).optional()
170
- });
171
- var alertHistorySchema = z.object({
172
- id: z.number().int(),
173
- alert_rule_id: z.number().int().nullable(),
174
- integration_id: z.number().int().nullable(),
175
- issue_id: z.string().uuid().nullable(),
176
- project_id: z.number().int().nullable(),
177
- alert_type: z.string(),
178
- channel_type: z.string(),
179
- channel_name: z.string(),
180
- status: alertStatusSchema,
181
- attempt_count: z.number().int(),
182
- next_retry_at: dateTimeSchema.nullable(),
183
- error_message: z.string().nullable(),
184
- http_status_code: z.number().int().nullable(),
185
- idempotency_key: z.string(),
186
- created_at: dateTimeSchema,
187
- sent_at: dateTimeSchema.nullable()
188
- });
189
- var testChannelResponseSchema = z.object({
190
- success: z.boolean(),
191
- message: z.string(),
192
- /**
193
- * What the endpoint answered, when it answered anything.
194
- *
195
- * Delivery is judged by the HTTP status and the body is not interpreted, so
196
- * the body is handed back instead: a group bot that refuses a message still
197
- * answers 200 and explains itself here.
198
- */
199
- response_body: z.string().nullish()
200
- });
201
- var previewTemplateResponseSchema = z.object({
202
- ok: z.boolean(),
203
- rendered: z.string().nullish(),
204
- error: z.string().nullish()
205
- });
206
- var testIntegrationBodySchema = z.object({
207
- routing_override: z.record(z.string(), z.unknown()).optional()
208
- });
209
- var eventSchema = z.object({
210
- id: uuidSchema,
211
- event_id: eventIdSchema,
212
- issue_id: uuidSchema.nullable(),
213
- title: z.string(),
214
- timestamp: dateTimeSchema,
215
- level: z.string(),
216
- platform: z.string(),
217
- release: z.string(),
218
- environment: z.string(),
219
- event_type: z.string()
220
- });
221
- var eventDetailSchema = z.object({
222
- id: uuidSchema,
223
- event_id: eventIdSchema,
224
- issue_id: uuidSchema.nullable(),
225
- title: z.string(),
226
- timestamp: dateTimeSchema,
227
- ingested_at: dateTimeSchema,
228
- level: z.string(),
229
- platform: z.string(),
230
- release: z.string(),
231
- environment: z.string(),
232
- server_name: z.string(),
233
- sdk_name: z.string(),
234
- sdk_version: z.string(),
235
- event_type: z.string(),
236
- data: z.record(z.string(), z.any())
237
- // Full Sentry event JSON
238
- });
239
- var gitHubAppSchema = z.object({
240
- app_id: z.number().int(),
241
- slug: z.string(),
242
- html_url: z.string(),
243
- owner_login: z.string(),
244
- install_url: z.string(),
245
- last_webhook_at: dateTimeSchema.nullable(),
246
- created_at: dateTimeSchema
247
- });
248
- var gitHubInstallationSchema = z.object({
249
- id: z.number().int(),
250
- account_login: z.string(),
251
- account_type: z.string(),
252
- suspended: z.boolean(),
253
- created_at: dateTimeSchema
254
- });
255
- var gitHubStatusSchema = z.object({
256
- app: gitHubAppSchema.nullable(),
257
- installations: z.array(gitHubInstallationSchema),
258
- webhook_url: z.string()
259
- });
260
- var gitHubManifestSchema = z.object({
261
- action_url: z.string(),
262
- manifest: z.string()
263
- });
264
- var gitHubRepositorySchema = z.object({
265
- installation_id: z.number().int(),
266
- full_name: z.string(),
267
- default_branch: z.string(),
268
- private: z.boolean(),
269
- html_url: z.string()
270
- });
271
- var codeMappingSchema = z.object({
272
- stack_root: z.string(),
273
- source_root: z.string()
274
- });
275
- var projectRepositorySchema = z.object({
276
- project_id: z.number().int(),
277
- installation_id: z.number().int(),
278
- repo_full_name: z.string(),
279
- default_branch: z.string(),
280
- html_url: z.string(),
281
- code_mappings: z.array(codeMappingSchema),
282
- /** Open a GitHub issue for new issues that pass `auto_create_conditions`. */
283
- auto_create_issues: z.boolean(),
284
- auto_create_conditions: alertRuleConditionsSchema,
285
- codeowners_rules: z.number().int().nullable(),
286
- codeowners_synced_at: dateTimeSchema.nullable()
287
- });
288
- var updateProjectRepositorySchema = z.object({
289
- installation_id: z.number().int(),
290
- repo_full_name: z.string().min(1),
291
- code_mappings: z.array(codeMappingSchema).optional(),
292
- auto_create_issues: z.boolean().optional(),
293
- auto_create_conditions: alertRuleConditionsSchema.optional()
294
- });
295
- var issueLinkSchema = z.object({
296
- id: z.number().int(),
297
- issue_id: z.string(),
298
- repo_full_name: z.string(),
299
- number: z.number().int(),
300
- title: z.string(),
301
- url: z.string(),
302
- state: z.string(),
303
- created_at: dateTimeSchema
304
- });
305
- var repoCommitSchema = z.object({
306
- repo_full_name: z.string(),
307
- sha: z.string(),
308
- message: z.string(),
309
- author_name: z.string(),
310
- author_login: z.string().nullable(),
311
- url: z.string(),
312
- committed_at: dateTimeSchema
313
- });
314
- var issueGitHubSchema = z.object({
315
- links: z.array(issueLinkSchema),
316
- suspect_commits: z.array(repoCommitSchema),
317
- owners: z.array(z.string())
318
- });
319
- var gitHubLoginSchema = z.object({
320
- login: z.string().nullable()
321
- });
322
- var globalRoleSchema = z.enum(["admin", "member"]);
323
- var teamMemberSchema = z.object({
324
- id: z.number().int(),
325
- email: z.string().email(),
326
- role: globalRoleSchema,
327
- is_active: z.boolean(),
328
- /** True for the first-registered account, which cannot be demoted or deleted. */
329
- is_primary: z.boolean().optional(),
330
- created_at: dateTimeSchema,
331
- last_login: dateTimeSchema.nullable().optional()
332
- });
333
- var updateUserRoleSchema = z.object({
334
- role: globalRoleSchema
335
- });
336
-
337
- // src/schemas/invitation.ts
338
- var invitationStatusSchema = z.string();
339
- var invitationSchema = z.object({
340
- token: z.string(),
341
- email: z.string().email(),
342
- role: globalRoleSchema,
343
- status: invitationStatusSchema,
344
- expires_at: dateTimeSchema,
345
- created_at: dateTimeSchema
346
- });
347
- var invitationInfoSchema = z.object({
348
- email: z.string().email(),
349
- role: globalRoleSchema,
350
- status: invitationStatusSchema,
351
- expires_at: dateTimeSchema
352
- });
353
- var createInvitationSchema = z.object({
354
- email: z.string().email(),
355
- role: globalRoleSchema
356
- });
357
- var acceptInvitationSchema = z.object({
358
- token: z.string().min(1),
359
- password: z.string().min(1)
360
- });
361
- var issueStatusSchema = z.enum(["unresolved", "resolved", "ignored"]);
362
- var issuePrioritySchema = z.enum(["low", "medium", "high"]);
363
- var issueSchema = z.object({
364
- id: uuidSchema,
365
- project_id: z.number().int(),
366
- short_id: z.string(),
367
- title: z.string(),
368
- value: z.string(),
369
- culprit: z.string(),
370
- logger: z.string(),
371
- first_seen: dateTimeSchema,
372
- last_seen: dateTimeSchema,
373
- event_count: z.number().int(),
374
- level: z.string().nullable(),
375
- platform: z.string().nullable(),
376
- // Status model (#165)
377
- status: issueStatusSchema,
378
- substatus: z.string().nullable(),
379
- priority: issuePrioritySchema.nullable(),
380
- assigned_to: z.number().int().nullable(),
381
- assignee_type: z.string().nullable(),
382
- issue_type: z.string(),
383
- issue_category: z.string(),
384
- first_release: z.string(),
385
- last_release: z.string(),
386
- status_details: z.record(z.string(), z.unknown()),
387
- // Aggregate enrichment — only the single-issue GET populates this; the list
388
- // and PATCH endpoints return the lean response, so default to 0 when absent.
389
- user_report_count: z.number().int().optional().default(0),
390
- // Per-user fields — only present when the request carries a user session.
391
- is_bookmarked: z.boolean().optional(),
392
- is_subscribed: z.boolean().optional(),
393
- has_seen: z.boolean().optional(),
394
- // Bulk list stats — only the list endpoint populates these (computed once
395
- // per page); the single-issue GET and PATCH responses omit them.
396
- user_count: z.number().int().optional(),
397
- trend: z.array(z.number().int()).optional(),
398
- // Deprecated, derived from `status`; kept for backward compatibility.
399
- is_resolved: z.boolean(),
400
- is_muted: z.boolean()
401
- });
402
- var updateIssueStateSchema = z.object({
403
- status: z.union([issueStatusSchema, z.literal("resolvedInNextRelease")]).optional(),
404
- substatus: z.string().optional(),
405
- priority: issuePrioritySchema.optional(),
406
- assigned_to: z.number().int().nullable().optional(),
407
- assignee_type: z.string().nullable().optional(),
408
- is_resolved: z.boolean().optional(),
409
- is_muted: z.boolean().optional()
410
- });
411
- var issueHashSchema = z.object({
412
- id: z.number().int(),
413
- project_id: z.number().int(),
414
- issue_id: uuidSchema,
415
- grouping_key: z.string(),
416
- grouping_key_hash: z.string(),
417
- created_at: dateTimeSchema
418
- });
419
- var tagValueCountSchema = z.object({
420
- value: z.string(),
421
- count: z.number().int()
422
- });
423
- var issueTagValueSchema = z.object({
424
- key: z.string(),
425
- name: z.string(),
426
- value: z.string(),
427
- count: z.number().int(),
428
- first_seen: dateTimeSchema,
429
- last_seen: dateTimeSchema
430
- });
431
- var tagSummarySchema = z.object({
432
- key: z.string(),
433
- total_values: z.number().int(),
434
- top_values: z.array(tagValueCountSchema)
435
- });
436
- var issueAggregatesSchema = z.object({
437
- user_count: z.number().int(),
438
- tags: z.array(tagSummarySchema)
439
- });
440
- z.enum(["24h", "30d"]);
441
- var issueStatsSchema = z.object({
442
- data: z.array(z.tuple([z.number(), z.number()]))
443
- });
444
- var activityEntrySchema = z.object({
445
- id: uuidSchema,
446
- issue_id: uuidSchema,
447
- user_id: z.number().int().nullable(),
448
- type: z.string(),
449
- data: z.string(),
450
- created_at: dateTimeSchema
451
- });
452
- var userReportSchema = z.object({
453
- id: uuidSchema,
454
- project_id: z.number().int(),
455
- issue_id: uuidSchema.nullable(),
456
- event_id: uuidSchema.nullable(),
457
- name: z.string(),
458
- // Server stores '' for anonymous reports (column DEFAULT '' / unwrap_or_default),
459
- // matching real Sentry's own save_userreport(report.get("email", "")) — accept it.
460
- email: z.union([z.email(), z.literal("")]),
461
- comments: z.string(),
462
- created_at: dateTimeSchema
463
- });
464
- var createCommentSchema = z.object({
465
- text: z.string()
466
- });
467
- var createUserReportSchema = z.object({
468
- name: z.string().optional(),
469
- email: z.email().optional(),
470
- comments: z.string().optional(),
471
- event_id: uuidSchema.optional()
472
- });
473
- var bulkUpdateIssuesSchema = z.object({
474
- ids: z.array(uuidSchema),
475
- status: z.union([issueStatusSchema, z.literal("resolvedInNextRelease")]).optional(),
476
- priority: issuePrioritySchema.optional()
477
- });
478
- var bulkDeleteIssuesSchema = z.union([
479
- z.strictObject({ ids: z.array(uuidSchema) }),
480
- z.strictObject({ filter: issueFilterSchema })
481
- ]);
482
- var logSchema = z.object({
483
- id: uuidSchema,
484
- trace_id: z.string().nullable(),
485
- span_id: z.string().nullable(),
486
- level: z.string(),
487
- /** OTel severity number (1=trace … 21=fatal). Null for unknown levels. */
488
- severity_number: z.number().int().nullable(),
489
- body: z.string(),
490
- attributes: z.record(z.string(), z.any()),
491
- timestamp: dateTimeSchema,
492
- ingested_at: dateTimeSchema
493
- });
494
- var projectRoleSchema = z.enum(["viewer", "editor", "admin"]);
495
- var projectMemberSchema = z.object({
496
- user_id: z.number().int(),
497
- email: z.string().email(),
498
- role: projectRoleSchema,
499
- created_at: dateTimeSchema
500
- });
501
- var upsertProjectMemberSchema = z.object({
502
- user_id: z.number().int(),
503
- role: projectRoleSchema
504
- });
505
- var intervalUnitSchema = z.enum([
506
- "minute",
507
- "hour",
508
- "day",
509
- "week",
510
- "month",
511
- "year"
512
- ]);
513
- var scheduleSchema = z.discriminatedUnion("type", [
514
- z.object({ type: z.literal("crontab"), value: z.string() }),
515
- z.object({
516
- type: z.literal("interval"),
517
- value: z.number().int().min(1),
518
- unit: intervalUnitSchema
519
- })
520
- ]);
521
- var previewScheduleSchema = z.object({
522
- schedule: scheduleSchema,
523
- /** IANA zone the schedule is read in. Defaults to UTC. */
524
- timezone: z.string().optional()
525
- });
526
- var schedulePreviewSchema = z.object({
527
- next_runs: z.array(dateTimeSchema)
528
- });
529
-
530
- // src/schemas/monitor.ts
531
- var monitorConfigSchema = z.object({
532
- schedule: scheduleSchema,
533
- checkin_margin: z.number().int(),
534
- max_runtime: z.number().int(),
535
- timezone: z.string(),
536
- failure_issue_threshold: z.number().int(),
537
- recovery_threshold: z.number().int()
538
- });
539
- var monitorConfigInputSchema = z.object({
540
- schedule: scheduleSchema.optional(),
541
- checkin_margin: z.number().int().min(1).optional(),
542
- max_runtime: z.number().int().min(1).optional(),
543
- timezone: z.string().optional(),
544
- failure_issue_threshold: z.number().int().min(1).max(720).optional(),
545
- recovery_threshold: z.number().int().min(1).max(720).optional()
546
- });
547
- var checkInStatusSchema = z.enum([
548
- "ok",
549
- "error",
550
- "in_progress",
551
- "missed",
552
- "timeout",
553
- "unknown"
554
- ]);
555
- var monitorEnvironmentStatusSchema = z.enum(["active", "ok", "error"]);
556
- var checkInSchema = z.object({
557
- id: uuidSchema,
558
- environment: z.string(),
559
- status: checkInStatusSchema,
560
- duration_ms: z.number().int().nullable(),
561
- date_added: dateTimeSchema,
562
- date_updated: dateTimeSchema,
563
- expected_time: dateTimeSchema.nullable()
564
- });
565
- var monitorEnvironmentSchema = z.object({
566
- id: uuidSchema,
567
- environment: z.string(),
568
- status: monitorEnvironmentStatusSchema,
569
- next_checkin: dateTimeSchema.nullable(),
570
- next_checkin_latest: dateTimeSchema.nullable(),
571
- last_checkin: dateTimeSchema.nullable(),
572
- /** Newest first. */
573
- recent_checkins: z.array(checkInSchema)
574
- });
575
- var monitorSchema = z.object({
576
- id: uuidSchema,
577
- slug: z.string(),
578
- name: z.string(),
579
- config: monitorConfigSchema,
580
- is_muted: z.boolean(),
581
- created_at: dateTimeSchema,
582
- environments: z.array(monitorEnvironmentSchema)
583
- });
584
- var createMonitorSchema = z.object({
585
- name: z.string().trim().min(1).max(128),
586
- /** Derived from `name` when left out. */
587
- slug: z.string().min(1).max(50).optional(),
588
- config: monitorConfigInputSchema
589
- });
590
- var updateMonitorSchema = z.object({
591
- name: z.string().trim().min(1).max(128).optional(),
592
- config: monitorConfigInputSchema.optional(),
593
- is_muted: z.boolean().optional()
594
- });
595
- var metricDeltaSchema = z.object({
596
- current: z.number().int(),
597
- /**
598
- * The same window immediately before this one. Null only for all-time
599
- * requests, where a `0` would render as a misleading "+100%".
600
- */
601
- previous: z.number().int().nullable()
602
- });
603
- var projectListStatsSchema = z.object({
604
- /**
605
- * Distinct issues active in each bucket, oldest first. A shape, not a
606
- * total: an issue firing all day appears in every bucket it touched.
607
- */
608
- trend: z.array(z.number().int()),
609
- events: metricDeltaSchema,
610
- /** Issues first seen in the window. Drives the "getting worse" signal. */
611
- new_issues: metricDeltaSchema,
612
- /** Unresolved issues right now, independent of the window. */
613
- open_issues: z.number().int(),
614
- /** The subset of `open_issues` at `fatal` level. */
615
- fatal_issues: z.number().int()
616
- });
617
- var projectSchema = z.object({
618
- id: z.number().int(),
619
- name: z.string(),
620
- slug: z.string(),
621
- sentry_key: uuidSchema,
622
- dsn: z.string(),
623
- stored_event_count: z.number().int(),
624
- digested_event_count: z.number().int(),
625
- /** Accepted events the quota dropped instead of storing. */
626
- rate_limited_event_count: z.number().int(),
627
- /**
628
- * The project's own limits, or null where it follows the server's. They can
629
- * only tighten `MAX_EVENTS_PER_PROJECT_*`, never raise it.
630
- */
631
- rate_limit_per_minute: z.number().int().nullable(),
632
- rate_limit_per_hour: z.number().int().nullable(),
633
- created_at: dateTimeSchema,
634
- updated_at: dateTimeSchema,
635
- platform: z.string().nullable(),
636
- stats: projectListStatsSchema.optional()
637
- });
638
- var createProjectSchema = z.object({
639
- name: z.string().min(1),
640
- /**
641
- * Slugified server-side. Supplying it means the user chose it, so a taken
642
- * slug is a 409. Omitting it derives one from the name and silently
643
- * de-duplicates, since nobody chose that value.
644
- */
645
- slug: z.string().min(1).optional(),
646
- /**
647
- * Validated server-side against SELECTABLE_PLATFORMS. Omitting it leaves the
648
- * project eligible for platform auto-detection from its first event.
649
- */
650
- platform: z.string().min(1).optional()
651
- });
652
- var updateProjectSchema = z.object({
653
- name: z.string().min(1).optional(),
654
- platform: z.string().min(1).optional(),
655
- /**
656
- * Slugified server-side. Unlike on create, a taken slug is a 409 rather than
657
- * being silently de-duplicated.
658
- */
659
- slug: z.string().min(1).optional(),
660
- /** A number sets the project's own limit; null removes it. */
661
- rate_limit_per_minute: z.number().int().min(1).nullable().optional(),
662
- rate_limit_per_hour: z.number().int().min(1).nullable().optional()
663
- });
664
- var rateLimitsSchema = z.object({
665
- project_per_minute: z.number().int(),
666
- project_per_hour: z.number().int()
667
- });
668
- var releaseHealthRowSchema = z.object({
669
- release: z.string(),
670
- environment: z.string(),
671
- total: z.number().int(),
672
- errored: z.number().int(),
673
- crashed: z.number().int(),
674
- abnormal: z.number().int(),
675
- healthy: z.number().int(),
676
- crash_free_sessions_rate: z.number().nullable(),
677
- crash_free_users_rate: z.number().nullable()
678
- });
679
- var sessionSummarySchema = z.object({
680
- total: z.number().int(),
681
- errored: z.number().int(),
682
- crashed: z.number().int(),
683
- abnormal: z.number().int(),
684
- crash_free_sessions_rate: z.number().nullable(),
685
- crash_free_users_rate: z.number().nullable(),
686
- active_releases: z.number().int()
687
- });
688
- var sessionTimeseriesPointSchema = z.object({
689
- bucket: dateTimeSchema,
690
- total: z.number().int(),
691
- crashed: z.number().int(),
692
- crash_free_sessions_rate: z.number().nullable()
693
- });
694
- var sessionTimeseriesSchema = z.array(sessionTimeseriesPointSchema);
695
- var chunkUploadCapabilitySchema = z.object({
696
- url: z.string(),
697
- chunkSize: z.number().int(),
698
- chunksPerRequest: z.number().int(),
699
- maxRequestSize: z.number().int(),
700
- hashAlgorithm: z.string(),
701
- accept: z.array(z.string()),
702
- concurrency: z.number().int().optional()
703
- });
704
- var assembleInputSchema = z.object({
705
- checksum: z.string().min(1),
706
- chunks: z.array(z.string().min(1)),
707
- projects: z.array(z.string().min(1)).min(1)
708
- });
709
- var assembleResponseSchema = z.object({
710
- state: z.string(),
711
- missingChunks: z.array(z.string()),
712
- detail: z.string().optional()
713
- });
714
- var sourceMapFileSchema = z.object({
715
- debugId: z.string(),
716
- fileType: z.string(),
717
- size: z.number().int(),
718
- timesUsed: z.number().int(),
719
- dateUploaded: z.string()
720
- });
721
- var listSourceMapsResponseSchema = z.object({
722
- data: z.array(sourceMapFileSchema)
723
- });
724
- var eventTimeseriesPointSchema = z.object({
725
- bucket: dateTimeSchema,
726
- total: z.number().int(),
727
- fatal: z.number().int(),
728
- error: z.number().int(),
729
- warning: z.number().int(),
730
- info: z.number().int()
731
- });
732
- var eventTimeseriesSchema = z.array(eventTimeseriesPointSchema);
733
- var metricDeltaSchema2 = z.object({
734
- current: z.number().int(),
735
- previous: z.number().int().nullable()
736
- });
737
- var projectStatsSummarySchema = z.object({
738
- /** Resolved window in hours, or `null` for all time. */
739
- period_hours: z.number().int().nullable(),
740
- events: metricDeltaSchema2,
741
- new_issues: metricDeltaSchema2,
742
- /** Currently unresolved issues, independent of the window. */
743
- open_issues: z.number().int()
744
- });
745
- var sourceMapStorageSchema = z.object({
746
- chunk_bytes: z.number(),
747
- source_file_bytes: z.number(),
748
- total_bytes: z.number(),
749
- file_count: z.number()
750
- });
751
- var storageSummarySchema = z.object({
752
- total_db_size_bytes: z.number(),
753
- events_count: z.number(),
754
- transactions_count: z.number(),
755
- spans_count: z.number(),
756
- logs_count: z.number(),
757
- source_maps: sourceMapStorageSchema
758
- });
759
- var projectStorageSchema = z.object({
760
- project_id: z.number(),
761
- project_name: z.string(),
762
- events_count: z.number(),
763
- transactions_count: z.number(),
764
- spans_count: z.number(),
765
- logs_count: z.number(),
766
- source_maps_count: z.number(),
767
- /** `events_bytes + transactions_bytes + logs_bytes`. */
768
- estimated_bytes: z.number(),
769
- events_bytes: z.number(),
770
- /** Transactions with their spans. */
771
- transactions_bytes: z.number(),
772
- logs_bytes: z.number()
773
- });
774
- var cleanupCountsSchema = z.object({
775
- events: z.number(),
776
- transactions: z.number(),
777
- spans: z.number(),
778
- logs: z.number(),
779
- issues_removed: z.number(),
780
- /** Unused source maps deleted; only a retention cleanup removes them. */
781
- source_maps: z.number().default(0)
782
- });
783
- var cleanupStatusSchema = z.object({
784
- state: z.enum(["idle", "running", "completed", "failed"]),
785
- removed: cleanupCountsSchema,
786
- started_at: z.string().nullable(),
787
- finished_at: z.string().nullable(),
788
- error: z.string().nullable()
789
- });
790
- var sourceMapGcResultSchema = z.object({
791
- files_removed: z.number(),
792
- bytes_freed: z.number()
793
- });
794
- var kindAgeSchema = z.object({
795
- counts: z.array(z.number()),
796
- oldest: dateTimeSchema.nullable()
797
- });
798
- var storageAgeSchema = z.object({
799
- bucket_days: z.array(z.number()),
800
- projects: z.array(
801
- z.object({
802
- project_id: z.number(),
803
- events: kindAgeSchema,
804
- transactions: kindAgeSchema,
805
- logs: kindAgeSchema
806
- })
807
- )
808
- });
809
- var retentionDaysSchema = z.number().int().min(1).max(36500).nullable();
810
- var retentionWindowsSchema = z.object({
811
- events_days: retentionDaysSchema,
812
- /** Transactions with their spans. */
813
- transactions_days: retentionDaysSchema,
814
- logs_days: retentionDaysSchema
815
- });
816
- var projectRetentionSchema = retentionWindowsSchema.extend({
817
- project_id: z.number().int()
818
- });
819
- var retentionSettingsSchema = z.object({
820
- defaults: retentionWindowsSchema,
821
- overrides: z.array(projectRetentionSchema),
822
- frequency: z.enum(["daily", "weekly"]),
823
- /** Hour of the day, UTC. */
824
- hour: z.number().int().min(0).max(23),
825
- /** Day of a weekly cleanup, 0 = Sunday. */
826
- weekday: z.number().int().min(0).max(6)
827
- });
828
- var retentionRunSchema = z.object({
829
- started_at: dateTimeSchema,
830
- finished_at: dateTimeSchema.nullable(),
831
- status: z.enum(["running", "ok", "error"]),
832
- removed: cleanupCountsSchema.nullable(),
833
- error: z.string().nullable()
834
- });
835
- var retentionSchema = z.object({
836
- settings: retentionSettingsSchema,
837
- /** Null while everything is kept forever, and for up to a minute after the settings change. */
838
- next_run_at: dateTimeSchema.nullable(),
839
- last_run: retentionRunSchema.nullable()
840
- });
841
- var cleanupOptionsSchema = z.object({
842
- older_than_days: z.number().int().min(1),
843
- project_id: z.number().int().optional(),
844
- include_events: z.boolean().optional(),
845
- include_transactions: z.boolean().optional(),
846
- include_logs: z.boolean().optional()
847
- });
848
- var authTokenSchema = z.object({
849
- id: z.number().int(),
850
- token_prefix: z.string(),
851
- description: z.string().nullable(),
852
- created_at: dateTimeSchema,
853
- last_used_at: dateTimeSchema.nullable()
854
- });
855
- var authTokenCreatedSchema = z.object({
856
- id: z.number().int(),
857
- token: z.string(),
858
- description: z.string().nullable(),
859
- created_at: dateTimeSchema
860
- });
861
- var createAuthTokenSchema = z.object({
862
- description: z.string().optional()
863
- });
864
- var transactionSchema = z.object({
865
- id: uuidSchema,
866
- event_id: eventIdSchema,
867
- transaction_name: z.string(),
868
- timestamp: dateTimeSchema,
869
- start_timestamp: dateTimeSchema.nullable(),
870
- duration_ms: z.number().nullable(),
871
- platform: z.string(),
872
- environment: z.string(),
873
- release: z.string(),
874
- ingested_at: dateTimeSchema
875
- });
876
- var transactionDetailSchema = z.object({
877
- id: uuidSchema,
878
- event_id: eventIdSchema,
879
- transaction_name: z.string(),
880
- timestamp: dateTimeSchema,
881
- start_timestamp: dateTimeSchema.nullable(),
882
- duration_ms: z.number().nullable(),
883
- platform: z.string(),
884
- environment: z.string(),
885
- release: z.string(),
886
- ingested_at: dateTimeSchema,
887
- data: z.record(z.string(), z.any())
888
- // Full Sentry transaction payload
889
- });
890
- var spanSchema = z.object({
891
- id: uuidSchema,
892
- /** Parent transaction, if this span was extracted from one. `null` for a standalone span. */
893
- transaction_id: uuidSchema.nullable(),
894
- span_id: z.string().nullable(),
895
- trace_id: z.string().nullable(),
896
- parent_span_id: z.string().nullable(),
897
- op: z.string().nullable(),
898
- description: z.string().nullable(),
899
- status: z.string().nullable(),
900
- start_timestamp: dateTimeSchema.nullable(),
901
- timestamp: dateTimeSchema.nullable(),
902
- duration_ms: z.number().nullable(),
903
- exclusive_time_ms: z.number().nullable(),
904
- is_segment: z.boolean(),
905
- segment_id: z.string().nullable(),
906
- /** Reported by the span itself, or stamped from its parent transaction. Null only for rows ingested before that stamping existed. */
907
- platform: z.string().nullable(),
908
- release: z.string().nullable(),
909
- environment: z.string().nullable(),
910
- /** gen_ai.* denormalized fields — all null unless recognized as an AI span. */
911
- gen_ai_operation_type: z.string().nullable(),
912
- gen_ai_agent_name: z.string().nullable(),
913
- gen_ai_request_model: z.string().nullable(),
914
- gen_ai_response_model: z.string().nullable(),
915
- gen_ai_tool_name: z.string().nullable(),
916
- gen_ai_conversation_id: z.string().nullable(),
917
- gen_ai_usage_input_tokens: z.number().nullable(),
918
- gen_ai_usage_output_tokens: z.number().nullable(),
919
- gen_ai_usage_total_tokens: z.number().nullable()
920
- });
921
- var spanDetailSchema = spanSchema.extend({
922
- attributes: z.record(z.string(), z.any()),
923
- /** Always absent for a Spans Protocol v2 span: v2 has no tags concept. */
924
- tags: z.record(z.string(), z.any()).nullish()
925
- });
926
- var transactionStatsSchema = z.object({
927
- transaction_name: z.string(),
928
- op: z.string().nullable(),
929
- count: z.number().int(),
930
- p50_ms: z.number(),
931
- p95_ms: z.number(),
932
- p99_ms: z.number(),
933
- failure_rate: z.number()
934
- });
935
- var userSchema = z.object({
936
- id: z.number().int().positive(),
937
- email: z.string().email(),
938
- role: globalRoleSchema,
939
- is_admin: z.boolean(),
940
- /**
941
- * The dashboard language this user chose.
942
- *
943
- * `null` means they never chose one, which a consumer should treat as
944
- * "infer it" rather than as English. Optional as well as nullable so a
945
- * client stays compatible with a server predating the column.
946
- */
947
- language: z.string().nullable().optional(),
948
- /** The IANA timezone this user chose, `null` when they never chose one. */
949
- timezone: z.string().nullable().optional()
950
- });
951
- var updatePreferencesRequestSchema = z.object({
952
- language: z.string().nullable().optional(),
953
- timezone: z.string().nullable().optional()
954
- });
955
- var authResponseSchema = z.object({
956
- user: userSchema
957
- });
958
- z.object({
959
- user: userSchema,
960
- cookies: z.array(z.string())
961
- });
962
- var loginRequestSchema = z.object({
963
- email: z.string().email(),
964
- password: z.string().min(1)
965
- });
966
- var registerRequestSchema = z.object({
967
- email: z.string().email(),
968
- password: z.string().min(1)
969
- });
970
- var ssoConfigSchema = z.object({
971
- enabled: z.boolean(),
972
- provider_name: z.string().nullable()
973
- });
974
- var ssoStartSchema = z.object({
975
- authorization_url: z.string().url()
976
- });
977
- var ssoLinkSchema = z.object({
978
- email: z.string(),
979
- provider_name: z.string()
980
- });
981
- var confirmSsoLinkRequestSchema = z.object({
982
- password: z.string().min(1)
983
- });
984
- var changePasswordRequestSchema = z.object({
985
- current_password: z.string().min(1),
986
- new_password: z.string().min(1)
987
- });
988
-
989
- // src/errors.ts
990
- var FIELD_ERROR_CODES = [
991
- "required",
992
- "invalid",
993
- "already_exists",
994
- "too_short",
995
- "too_long",
996
- "custom"
997
- ];
998
- var SERVER_ERROR_MESSAGE = "The server failed to handle the request.";
999
- var NETWORK_ERROR_MESSAGE = "The request could not reach the server.";
1000
- var TIMEOUT_ERROR_MESSAGE = "The request timed out.";
1001
- function isRetryable(error) {
1002
- return error.kind === "network" || error.kind === "server_error" || error.kind === "rate_limited";
1003
- }
1004
-
1005
- // src/result.ts
1006
- function Ok(data) {
1007
- return { success: true, data };
1008
- }
1009
- function Err(error) {
1010
- return { success: false, error };
1011
- }
1012
- function unwrap(result) {
1013
- if (result.success) {
1014
- return result.data;
1015
- }
1016
- throw new Error(
1017
- `unwrap() called on a failed Result: ${describe(result.error)}`
1018
- );
1019
- }
1020
- function unwrapOr(result, fallback) {
1021
- return result.success ? result.data : fallback;
1022
- }
1023
- function mapResult(result, fn) {
1024
- return result.success ? Ok(fn(result.data)) : result;
1025
- }
1026
- function describe(error) {
1027
- if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
1028
- return error.message;
1029
- }
1030
- return String(error);
1031
- }
1032
- var RustrakTransportFailure = class extends Error {
1033
- rustrakError;
1034
- constructor(error) {
1035
- super(error.message);
1036
- this.name = "RustrakTransportFailure";
1037
- this.rustrakError = error;
1038
- }
1039
- };
1040
- function isTransportFailure(value) {
1041
- return value instanceof RustrakTransportFailure;
1042
- }
1043
- function readErrorMessage(error, status) {
1044
- const fallback = `HTTP ${status} error`;
1045
- const body = error.data;
1046
- if (body && typeof body === "object") {
1047
- const nested = typeof body.error === "object" ? body.error?.message : body.error;
1048
- return nested || body.message || fallback;
1049
- }
1050
- return fallback;
1051
- }
1052
- var KNOWN_FIELD_ERROR_CODES = new Set(FIELD_ERROR_CODES);
1053
- function isFieldErrorCode(value) {
1054
- return typeof value === "string" && KNOWN_FIELD_ERROR_CODES.has(value);
1055
- }
1056
- var warnedFieldErrorCodes = /* @__PURE__ */ new Set();
1057
- function warnUnknownFieldErrorCode(code, field) {
1058
- if (warnedFieldErrorCodes.has(code)) return;
1059
- warnedFieldErrorCodes.add(code);
1060
- console.warn(
1061
- `[@rustrak/client] Dropped a field error with an unrecognised code "${code}" (field "${field}"). This client build does not know that code, so the affected inputs degrade to a form-level error. The server is most likely newer than @rustrak/client; upgrade the client to match the server version.`
1062
- );
1063
- }
1064
- function readIncidentId(error) {
1065
- const body = error.data;
1066
- const raw = body && typeof body === "object" ? body.error?.incident_id : void 0;
1067
- return typeof raw === "string" && raw.length > 0 ? raw : void 0;
1068
- }
1069
- function readFieldErrors(error) {
1070
- const body = error.data;
1071
- const raw = body && typeof body === "object" ? body.error?.fields : void 0;
1072
- if (!Array.isArray(raw)) {
1073
- return void 0;
1074
- }
1075
- const fields = [];
1076
- for (const entry of raw) {
1077
- if (typeof entry !== "object" || entry === null) continue;
1078
- const { field, code, message } = entry;
1079
- if (typeof field !== "string") continue;
1080
- if (!isFieldErrorCode(code)) {
1081
- if (typeof code === "string") warnUnknownFieldErrorCode(code, field);
1082
- continue;
1083
- }
1084
- fields.push(
1085
- code === "custom" && typeof message === "string" ? { field, code, message } : { field, code }
1086
- );
1087
- }
1088
- return fields.length > 0 ? fields : void 0;
1089
- }
1090
- function readRetryAfter(response) {
1091
- const header = response.headers.get("Retry-After")?.trim();
1092
- if (!header) {
1093
- return void 0;
1094
- }
1095
- if (/^\d+$/.test(header)) {
1096
- return Number.parseInt(header, 10);
1097
- }
1098
- if (/^[+-]\d+$/.test(header)) {
1099
- return void 0;
1100
- }
1101
- const date = Date.parse(header);
1102
- if (Number.isNaN(date)) {
1103
- return void 0;
1104
- }
1105
- return Math.max(0, Math.ceil((date - Date.now()) / 1e3));
1106
- }
1107
- function annotate(base, fields) {
1108
- return fields === void 0 ? base : { ...base, fields };
1109
- }
1110
- function transformHttpError(error) {
1111
- const { response } = error;
1112
- const status = response.status;
1113
- if (status >= 500) {
1114
- const base = {
1115
- kind: "server_error",
1116
- status,
1117
- message: SERVER_ERROR_MESSAGE
1118
- };
1119
- const incidentId = readIncidentId(error);
1120
- return incidentId === void 0 ? base : { ...base, incidentId };
1121
- }
1122
- const message = readErrorMessage(error, status);
1123
- const fields = readFieldErrors(error);
1124
- switch (status) {
1125
- case 400:
1126
- return annotate({ kind: "validation", status, message }, fields);
1127
- case 401:
1128
- return annotate({ kind: "unauthenticated", status, message }, fields);
1129
- case 403:
1130
- return annotate({ kind: "forbidden", status, message }, fields);
1131
- case 404:
1132
- return annotate({ kind: "not_found", status, message }, fields);
1133
- case 409:
1134
- return annotate({ kind: "conflict", status, message }, fields);
1135
- case 410:
1136
- return annotate({ kind: "gone", status, message }, fields);
1137
- case 413:
1138
- return annotate({ kind: "payload_too_large", status, message }, fields);
1139
- case 429: {
1140
- const retryAfter = readRetryAfter(response);
1141
- return annotate(
1142
- retryAfter === void 0 ? { kind: "rate_limited", status, message } : { kind: "rate_limited", status, message, retryAfter },
1143
- fields
1144
- );
1145
- }
1146
- default:
1147
- return annotate({ kind: "client_error", status, message }, fields);
1148
- }
1149
- }
1150
- function createKyInstance(config) {
1151
- const headers = {
1152
- // `Accept` is set here rather than relied on from ky. The `.json()`
1153
- // shortcut sets it before the request is issued, and `BaseResource` no
1154
- // longer uses that shortcut: it awaits the `Response` and parses the body
1155
- // itself, so without this every one of the 86 methods would send `*/*` and
1156
- // any content-negotiating hop could answer with HTML.
1157
- Accept: "application/json",
1158
- "Content-Type": "application/json",
1159
- ...config.headers
1160
- };
1161
- if (config.token) {
1162
- headers.Authorization = `Bearer ${config.token}`;
1163
- }
1164
- return ky.create({
1165
- prefix: config.baseUrl,
1166
- timeout: config.timeout ?? 3e4,
1167
- credentials: "include",
1168
- retry: {
1169
- limit: config.maxRetries ?? 2,
1170
- statusCodes: [408, 500, 502, 503, 504],
1171
- methods: ["get", "post", "put", "patch", "delete"]
1172
- },
1173
- headers,
1174
- hooks: {
1175
- beforeError: [
1176
- ({ error }) => {
1177
- if (error.name === "TimeoutError") {
1178
- throw new RustrakTransportFailure({
1179
- kind: "network",
1180
- message: TIMEOUT_ERROR_MESSAGE,
1181
- reason: "timeout"
1182
- });
1183
- }
1184
- if (isHTTPError(error)) {
1185
- throw new RustrakTransportFailure(transformHttpError(error));
1186
- }
1187
- throw new RustrakTransportFailure({
1188
- kind: "network",
1189
- message: NETWORK_ERROR_MESSAGE,
1190
- reason: "unreachable"
1191
- });
1192
- }
1193
- ]
1194
- }
1195
- });
1196
- }
1197
-
1198
- // src/resources/base.ts
1199
- var TRANSPORT_TYPE_ERROR = /terminated|aborted|socket|network|closed|reset|fetch failed/i;
1200
- function isProgrammingError(error) {
1201
- if (!(error instanceof Error)) {
1202
- return true;
1203
- }
1204
- if (error instanceof ReferenceError || error instanceof RangeError) {
1205
- return true;
1206
- }
1207
- if (error instanceof TypeError) {
1208
- return error.cause === void 0 && !TRANSPORT_TYPE_ERROR.test(error.message);
1209
- }
1210
- return false;
1211
- }
1212
- function classifyBodyFailure(error) {
1213
- if (error instanceof SyntaxError) {
1214
- return {
1215
- kind: "invalid_response",
1216
- message: "The server returned a body that is not valid JSON."
1217
- };
1218
- }
1219
- if (isProgrammingError(error)) {
1220
- return "rethrow";
1221
- }
1222
- return {
1223
- kind: "network",
1224
- message: NETWORK_ERROR_MESSAGE,
1225
- reason: error instanceof Error && error.name === "TimeoutError" ? "timeout" : "unreachable"
1226
- };
1227
- }
1228
- function discardBody(response) {
1229
- try {
1230
- void response.body?.cancel().catch(() => {
1231
- });
1232
- } catch {
1233
- }
1234
- }
1235
- var BaseResource = class {
1236
- http;
1237
- constructor(http) {
1238
- this.http = http;
1239
- }
1240
- /**
1241
- * Validate an API response against its Zod schema.
1242
- *
1243
- * Failure is `invalid_response`: "our own response schema did not match",
1244
- * never "the user's input was rejected". No Zod issues are attached: they
1245
- * embed the offending response data.
1246
- */
1247
- validate(data, schema) {
1248
- const result = schema.safeParse(data);
1249
- if (!result.success) {
1250
- return Err({
1251
- kind: "invalid_response",
1252
- message: "The server response did not match the expected schema."
1253
- });
1254
- }
1255
- return Ok(result.data);
1256
- }
1257
- /**
1258
- * Validate caller-supplied input before it reaches the network.
1259
- *
1260
- * Failure is `invalid_request` and has no `status`: nothing was sent.
1261
- */
1262
- validateInput(input, schema) {
1263
- const result = schema.safeParse(input);
1264
- if (!result.success) {
1265
- return Err({
1266
- kind: "invalid_request",
1267
- message: "The request input did not match the expected schema."
1268
- });
1269
- }
1270
- return Ok(result.data);
1271
- }
1272
- /**
1273
- * The boundary. Runs `send`, converts a transport failure into an `Err`, and
1274
- * hands the `Response` to `read`.
1275
- *
1276
- * Anything thrown that is not the internal carrier is a programming error and
1277
- * is rethrown.
1278
- */
1279
- async requestResponse(send, read) {
1280
- let response;
1281
- try {
1282
- response = await send();
1283
- } catch (error) {
1284
- if (isTransportFailure(error)) {
1285
- return Err(error.rustrakError);
1286
- }
1287
- throw error;
1288
- }
1289
- return read(response);
1290
- }
1291
- /**
1292
- * Read a JSON body, mapping a failed read onto the right `kind`.
1293
- *
1294
- * Shared with `AuthResource`, which needs the `Set-Cookie` headers off the
1295
- * raw `Response` and so cannot go through {@link BaseResource.request}.
1296
- */
1297
- async readJson(response) {
1298
- try {
1299
- return Ok(await response.json());
1300
- } catch (error) {
1301
- const failure = classifyBodyFailure(error);
1302
- if (failure === "rethrow") {
1303
- throw error;
1304
- }
1305
- return Err(failure);
1306
- }
1307
- }
1308
- /** Send a request and validate its JSON body against `schema`. */
1309
- async request(send, schema) {
1310
- return this.requestResponse(send, async (response) => {
1311
- const body = await this.readJson(response);
1312
- if (!body.success) {
1313
- return body;
1314
- }
1315
- return this.validate(body.data, schema);
1316
- });
1317
- }
1318
- /** Send a request whose response body carries no contract (204, or ignored). */
1319
- async requestVoid(send) {
1320
- return this.requestResponse(send, async (response) => {
1321
- discardBody(response);
1322
- return Ok(void 0);
1323
- });
1324
- }
1325
- };
1326
-
1327
- // src/resources/agents.ts
1328
- function timeseriesSearchParams(options) {
1329
- const searchParams = {};
1330
- if (options?.period_hours) {
1331
- searchParams.period_hours = String(options.period_hours);
1332
- }
1333
- if (options?.interval_hours) {
1334
- searchParams.interval_hours = String(options.interval_hours);
1335
- }
1336
- if (options?.environment) {
1337
- searchParams.environment = options.environment;
1338
- }
1339
- return searchParams;
1340
- }
1341
- function breakdownSearchParams(options) {
1342
- const searchParams = {};
1343
- if (options?.period_hours) {
1344
- searchParams.period_hours = String(options.period_hours);
1345
- }
1346
- if (options?.limit) {
1347
- searchParams.limit = String(options.limit);
1348
- }
1349
- if (options?.environment) {
1350
- searchParams.environment = options.environment;
1351
- }
1352
- return searchParams;
1353
- }
1354
- var AgentsResource = class extends BaseResource {
1355
- /**
1356
- * Time-bucketed count of agent-run spans (`gen_ai.operation.type:agent`).
1357
- */
1358
- async getRuns(projectId, options) {
1359
- return this.request(
1360
- () => this.http.get(`api/projects/${projectId}/agents/runs`, {
1361
- searchParams: timeseriesSearchParams(options)
1362
- }),
1363
- z.array(agentTimeseriesPointSchema)
1364
- );
1365
- }
1366
- /**
1367
- * Time-bucketed avg/p95 duration for `agent`/`ai_client` spans.
1368
- */
1369
- async getDuration(projectId, options) {
1370
- return this.request(
1371
- () => this.http.get(`api/projects/${projectId}/agents/duration`, {
1372
- searchParams: timeseriesSearchParams(options)
1373
- }),
1374
- z.array(agentDurationPointSchema)
1375
- );
1376
- }
1377
- /**
1378
- * Top models by LLM call count (`gen_ai.operation.type:ai_client`).
1379
- */
1380
- async getModelsByCalls(projectId, options) {
1381
- return this.request(
1382
- () => this.http.get(`api/projects/${projectId}/agents/models/calls`, {
1383
- searchParams: breakdownSearchParams(options)
1384
- }),
1385
- z.array(genAiBreakdownRowSchema)
1386
- );
1387
- }
1388
- /**
1389
- * Top models by total tokens used (`gen_ai.operation.type:ai_client`).
1390
- */
1391
- async getModelsByTokens(projectId, options) {
1392
- return this.request(
1393
- () => this.http.get(`api/projects/${projectId}/agents/models/tokens`, {
1394
- searchParams: breakdownSearchParams(options)
1395
- }),
1396
- z.array(genAiBreakdownRowSchema)
1397
- );
1398
- }
1399
- /**
1400
- * Top tools by call count (`gen_ai.operation.type:tool`).
1401
- */
1402
- async getTools(projectId, options) {
1403
- return this.request(
1404
- () => this.http.get(`api/projects/${projectId}/agents/tools`, {
1405
- searchParams: breakdownSearchParams(options)
1406
- }),
1407
- z.array(genAiBreakdownRowSchema)
1408
- );
1409
- }
1410
- /**
1411
- * Paginated per-trace_id aggregate (duration, tokens, tool usage) across
1412
- * all AI spans sharing that trace, regardless of origin.
1413
- */
1414
- async getTraces(projectId, options) {
1415
- const searchParams = {};
1416
- if (options?.page) {
1417
- searchParams.page = String(options.page);
1418
- }
1419
- if (options?.per_page) {
1420
- searchParams.per_page = String(options.per_page);
1421
- }
1422
- if (options?.period_hours) {
1423
- searchParams.period_hours = String(options.period_hours);
1424
- }
1425
- if (options?.environment) {
1426
- searchParams.environment = options.environment;
1427
- }
1428
- return this.request(
1429
- () => this.http.get(`api/projects/${projectId}/agents/traces`, {
1430
- searchParams
1431
- }),
1432
- offsetPaginatedResponseSchema(agentTraceSummarySchema)
1433
- );
1434
- }
1435
- /**
1436
- * Headline totals over the selected window — the numbers the charts show
1437
- * the shape of but cannot state.
1438
- */
1439
- async getSummary(projectId, options) {
1440
- return this.request(
1441
- () => this.http.get(`api/projects/${projectId}/agents/summary`, {
1442
- searchParams: breakdownSearchParams(options)
1443
- }),
1444
- agentSummarySchema
1445
- );
1446
- }
1447
- /**
1448
- * Per-model table: volume, failures, latency and the full token split.
1449
- */
1450
- async getModelsTable(projectId, options) {
1451
- return this.request(
1452
- () => this.http.get(`api/projects/${projectId}/agents/models`, {
1453
- searchParams: breakdownSearchParams(options)
1454
- }),
1455
- z.array(agentModelRowSchema)
1456
- );
1457
- }
1458
- /**
1459
- * Per-tool table: call volume, failures and latency.
1460
- */
1461
- async getToolsTable(projectId, options) {
1462
- return this.request(
1463
- () => this.http.get(`api/projects/${projectId}/agents/tools/stats`, {
1464
- searchParams: breakdownSearchParams(options)
1465
- }),
1466
- z.array(agentToolRowSchema)
1467
- );
1468
- }
1469
- /**
1470
- * Environments present in this project's AI spans — the options the filter
1471
- * offers, read from the data rather than hardcoded.
1472
- */
1473
- async getEnvironments(projectId) {
1474
- return this.request(
1475
- () => this.http.get(`api/projects/${projectId}/agents/environments`),
1476
- z.array(z.string())
1477
- );
1478
- }
1479
- };
1480
- var AlertIntegrationsResource = class extends BaseResource {
1481
- /**
1482
- * List all alert integrations
1483
- */
1484
- async list() {
1485
- return this.request(
1486
- () => this.http.get("api/integrations"),
1487
- z.array(alertIntegrationSchema)
1488
- );
1489
- }
1490
- /**
1491
- * Get a single alert integration by ID
1492
- */
1493
- async get(id) {
1494
- return this.request(
1495
- () => this.http.get(`api/integrations/${id}`),
1496
- alertIntegrationSchema
1497
- );
1498
- }
1499
- /**
1500
- * Create a new alert integration
1501
- */
1502
- async create(input) {
1503
- const validatedInput = this.validateInput(
1504
- input,
1505
- createAlertIntegrationSchema
1506
- );
1507
- if (!validatedInput.success) {
1508
- return validatedInput;
1509
- }
1510
- return this.request(
1511
- () => this.http.post("api/integrations", { json: validatedInput.data }),
1512
- alertIntegrationSchema
1513
- );
1514
- }
1515
- /**
1516
- * Update an existing alert integration
1517
- */
1518
- async update(id, input) {
1519
- const validatedInput = this.validateInput(
1520
- input,
1521
- updateAlertIntegrationSchema
1522
- );
1523
- if (!validatedInput.success) {
1524
- return validatedInput;
1525
- }
1526
- return this.request(
1527
- () => this.http.patch(`api/integrations/${id}`, {
1528
- json: validatedInput.data
1529
- }),
1530
- alertIntegrationSchema
1531
- );
1532
- }
1533
- /**
1534
- * Delete an alert integration
1535
- */
1536
- async delete(id) {
1537
- return this.requestVoid(() => this.http.delete(`api/integrations/${id}`));
1538
- }
1539
- /**
1540
- * Send a test notification to verify integration configuration.
1541
- * For Slack bot_token integrations, routingOverride must include `channel`.
1542
- */
1543
- async test(id, routingOverride) {
1544
- let body;
1545
- if (routingOverride !== void 0) {
1546
- const validatedInput = this.validateInput(
1547
- { routing_override: routingOverride },
1548
- testIntegrationBodySchema
1549
- );
1550
- if (!validatedInput.success) {
1551
- return validatedInput;
1552
- }
1553
- body = validatedInput.data;
1554
- }
1555
- return this.request(
1556
- () => this.http.post(
1557
- `api/integrations/${id}/test`,
1558
- body !== void 0 ? { json: body } : void 0
1559
- ),
1560
- testChannelResponseSchema
1561
- );
1562
- }
1563
- /**
1564
- * Render a Custom Webhook template against a sample payload.
1565
- *
1566
- * Answers with the body that would be sent, or with why it would not
1567
- * render. It goes to the server because the server owns the template
1568
- * engine: a preview computed anywhere else would eventually disagree with
1569
- * what a delivery actually sends.
1570
- */
1571
- async previewTemplate(template) {
1572
- return this.request(
1573
- () => this.http.post("api/integrations/preview-template", {
1574
- json: { template }
1575
- }),
1576
- previewTemplateResponseSchema
1577
- );
1578
- }
1579
- };
1580
- var AlertRulesResource = class extends BaseResource {
1581
- /**
1582
- * List all alert rules for a project
1583
- */
1584
- async list(projectId) {
1585
- return this.request(
1586
- () => this.http.get(`api/projects/${projectId}/alert-rules`),
1587
- z.array(alertRuleSchema)
1588
- );
1589
- }
1590
- /**
1591
- * Get a single alert rule by ID
1592
- */
1593
- async get(projectId, ruleId) {
1594
- return this.request(
1595
- () => this.http.get(`api/projects/${projectId}/alert-rules/${ruleId}`),
1596
- alertRuleSchema
1597
- );
1598
- }
1599
- /**
1600
- * Create a new alert rule for a project
1601
- */
1602
- async create(projectId, input) {
1603
- const validatedInput = this.validateInput(input, createAlertRuleSchema);
1604
- if (!validatedInput.success) {
1605
- return validatedInput;
1606
- }
1607
- return this.request(
1608
- () => this.http.post(`api/projects/${projectId}/alert-rules`, {
1609
- json: validatedInput.data
1610
- }),
1611
- alertRuleSchema
1612
- );
1613
- }
1614
- /**
1615
- * Update an existing alert rule
1616
- */
1617
- async update(projectId, ruleId, input) {
1618
- const validatedInput = this.validateInput(input, updateAlertRuleSchema);
1619
- if (!validatedInput.success) {
1620
- return validatedInput;
1621
- }
1622
- return this.request(
1623
- () => this.http.patch(`api/projects/${projectId}/alert-rules/${ruleId}`, {
1624
- json: validatedInput.data
1625
- }),
1626
- alertRuleSchema
1627
- );
1628
- }
1629
- /**
1630
- * Delete an alert rule
1631
- */
1632
- async delete(projectId, ruleId) {
1633
- return this.requestVoid(
1634
- () => this.http.delete(`api/projects/${projectId}/alert-rules/${ruleId}`)
1635
- );
1636
- }
1637
- /**
1638
- * List alert history for a project
1639
- */
1640
- async listHistory(projectId, options) {
1641
- const searchParams = new URLSearchParams();
1642
- if (options?.limit !== void 0) {
1643
- searchParams.set("limit", options.limit.toString());
1644
- }
1645
- const query = searchParams.toString();
1646
- const url = query ? `api/projects/${projectId}/alert-history?${query}` : `api/projects/${projectId}/alert-history`;
1647
- return this.request(() => this.http.get(url), z.array(alertHistorySchema));
1648
- }
1649
- };
1650
-
1651
- // src/resources/auth.ts
1652
- function readSetCookie(response) {
1653
- if (typeof response.headers.getSetCookie === "function") {
1654
- return response.headers.getSetCookie();
1655
- }
1656
- const folded = response.headers.get("set-cookie");
1657
- return folded === null ? [] : [folded];
1658
- }
1659
- var AuthResource = class extends BaseResource {
1660
- /** Return the public SSO login configuration. */
1661
- async getSsoConfig() {
1662
- return this.request(
1663
- () => this.http.get("auth/sso/config"),
1664
- ssoConfigSchema
1665
- );
1666
- }
1667
- /** Begin SSO and return the provider URL plus the encrypted state cookie. */
1668
- async startSso() {
1669
- return this.requestResponse(
1670
- () => this.http.post("auth/sso/start"),
1671
- async (response) => {
1672
- const cookies = readSetCookie(response);
1673
- const body = await this.readJson(response);
1674
- if (!body.success) return body;
1675
- const data = this.validate(body.data, ssoStartSchema);
1676
- if (!data.success) return data;
1677
- return Ok({
1678
- authorizationUrl: data.data.authorization_url,
1679
- cookies
1680
- });
1681
- }
1682
- );
1683
- }
1684
- /** The account an SSO login is waiting to link, if any. */
1685
- async getSsoLink() {
1686
- return this.request(() => this.http.get("auth/sso/link"), ssoLinkSchema);
1687
- }
1688
- /** Link the pending SSO identity with the account's password and sign in. */
1689
- async confirmSsoLink(password) {
1690
- const validatedInput = this.validateInput(
1691
- { password },
1692
- confirmSsoLinkRequestSchema
1693
- );
1694
- if (!validatedInput.success) {
1695
- return validatedInput;
1696
- }
1697
- return this.requestResponse(
1698
- () => this.http.post("auth/sso/link", { json: validatedInput.data }),
1699
- (response) => this.readLoginResult(response)
1700
- );
1701
- }
1702
- /** Complete an OIDC callback and return the normal Rustrak session cookie. */
1703
- async completeSso(callback) {
1704
- const searchParams = new URLSearchParams();
1705
- if (callback.code) searchParams.set("code", callback.code);
1706
- if (callback.state) searchParams.set("state", callback.state);
1707
- if (callback.error) searchParams.set("error", callback.error);
1708
- return this.requestResponse(
1709
- () => this.http.get("auth/sso/callback", { searchParams }),
1710
- (response) => this.readLoginResult(response)
1711
- );
1712
- }
1713
- /**
1714
- * Register a new user account
1715
- * Creates a new user and automatically logs them in (sets session cookie)
1716
- * @param credentials - Email and password for the new account
1717
- * @returns LoginResult with user information and session cookies
1718
- */
1719
- async register(credentials) {
1720
- const validatedInput = this.validateInput(
1721
- credentials,
1722
- registerRequestSchema
1723
- );
1724
- if (!validatedInput.success) {
1725
- return validatedInput;
1726
- }
1727
- return this.requestResponse(
1728
- () => this.http.post("auth/register", { json: validatedInput.data }),
1729
- (response) => this.readLoginResult(response)
1730
- );
1731
- }
1732
- /**
1733
- * Login with email and password
1734
- * Authenticates the user and sets a session cookie
1735
- * @param credentials - Email and password
1736
- * @returns LoginResult with user information and session cookies
1737
- */
1738
- async login(credentials) {
1739
- const validatedInput = this.validateInput(credentials, loginRequestSchema);
1740
- if (!validatedInput.success) {
1741
- return validatedInput;
1742
- }
1743
- return this.requestResponse(
1744
- () => this.http.post("auth/login", { json: validatedInput.data }),
1745
- (response) => this.readLoginResult(response)
1746
- );
1747
- }
1748
- /**
1749
- * Logout the current user
1750
- * Clears the session cookie
1751
- * @returns Array of Set-Cookie headers (typically clearing cookies)
1752
- */
1753
- async logout() {
1754
- return this.requestResponse(
1755
- () => this.http.post("auth/logout"),
1756
- async (response) => {
1757
- const cookies = readSetCookie(response);
1758
- discardBody(response);
1759
- return Ok(cookies);
1760
- }
1761
- );
1762
- }
1763
- /**
1764
- * Get current authenticated user
1765
- * Requires a valid session cookie
1766
- *
1767
- * No session is `{success: false, kind: 'unauthenticated'}`, not a `null`
1768
- * user: it is the literal reading of the server's 401. Callers must send the
1769
- * visitor to login on `unauthenticated` **only**. Treating `network` or
1770
- * `server_error` the same way turns a flaky connection into a login loop.
1771
- *
1772
- * @returns The current user, or `unauthenticated` when there is no session
1773
- */
1774
- async getCurrentUser() {
1775
- return this.request(() => this.http.get("auth/me"), userSchema);
1776
- }
1777
- /**
1778
- * Stores how this reader wants the dashboard presented to them.
1779
- *
1780
- * A key left out is left alone; a key sent as `null` is cleared. That is why
1781
- * the request type is optional *and* nullable rather than one or the other:
1782
- * "do not touch" and "forget my choice" are different instructions.
1783
- */
1784
- async updatePreferences(preferences) {
1785
- const validatedInput = this.validateInput(
1786
- preferences,
1787
- updatePreferencesRequestSchema
1788
- );
1789
- if (!validatedInput.success) return validatedInput;
1790
- return this.request(
1791
- () => this.http.patch("auth/me", { json: validatedInput.data }),
1792
- userSchema
1793
- );
1794
- }
1795
- /** Replaces the signed-in user's password, given the current one. */
1796
- async changePassword(request) {
1797
- const validatedInput = this.validateInput(
1798
- request,
1799
- changePasswordRequestSchema
1800
- );
1801
- if (!validatedInput.success) return validatedInput;
1802
- return this.requestVoid(
1803
- () => this.http.post("auth/me/password", {
1804
- json: validatedInput.data,
1805
- retry: 0
1806
- })
1807
- );
1808
- }
1809
- /**
1810
- * Get the details of a pending invitation by its token (public endpoint)
1811
- * Used by the accept-invitation page before the user has an account
1812
- * @param token - Invitation token
1813
- * @returns Invitation info (email, role, status, expiry)
1814
- */
1815
- async getInvitation(token) {
1816
- return this.request(
1817
- () => this.http.get(`auth/invitation/${token}`),
1818
- invitationInfoSchema
1819
- );
1820
- }
1821
- /**
1822
- * Accept a pending invitation, creating the user account and logging in
1823
- * @param input - Invitation token and the new account's password
1824
- * @returns LoginResult with user information and session cookies
1825
- */
1826
- async acceptInvitation(input) {
1827
- const validatedInput = this.validateInput(input, acceptInvitationSchema);
1828
- if (!validatedInput.success) {
1829
- return validatedInput;
1830
- }
1831
- return this.requestResponse(
1832
- () => this.http.post("auth/accept-invitation", {
1833
- json: validatedInput.data
1834
- }),
1835
- (response) => this.readLoginResult(response)
1836
- );
1837
- }
1838
- /**
1839
- * The three session-establishing endpoints share a body and need the
1840
- * `Set-Cookie` headers off the raw `Response`, which is why they go through
1841
- * `requestResponse` rather than the plain JSON path.
1842
- */
1843
- async readLoginResult(response) {
1844
- const cookies = readSetCookie(response);
1845
- const body = await this.readJson(response);
1846
- if (!body.success) {
1847
- return body;
1848
- }
1849
- const authResponse = this.validate(body.data, authResponseSchema);
1850
- if (!authResponse.success) {
1851
- return authResponse;
1852
- }
1853
- return Ok({ user: authResponse.data.user, cookies });
1854
- }
1855
- };
1856
-
1857
- // src/resources/events.ts
1858
- var EventsResource = class extends BaseResource {
1859
- /**
1860
- * List events for an issue with pagination
1861
- */
1862
- async list(projectId, issueId, options) {
1863
- const searchParams = {};
1864
- if (options?.order) {
1865
- searchParams.order = options.order;
1866
- }
1867
- if (options?.cursor) {
1868
- searchParams.cursor = options.cursor;
1869
- }
1870
- return this.request(
1871
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/events`, {
1872
- searchParams
1873
- }),
1874
- paginatedResponseSchema(eventSchema)
1875
- );
1876
- }
1877
- /**
1878
- * Get a single event by ID with full details
1879
- */
1880
- async get(projectId, issueId, eventId) {
1881
- return this.request(
1882
- () => this.http.get(
1883
- `api/projects/${projectId}/issues/${issueId}/events/${eventId}`
1884
- ),
1885
- eventDetailSchema
1886
- );
1887
- }
1888
- /** Resolve the client-supplied Sentry event ID, including its owning issue. */
1889
- async getBySentryId(projectId, eventId) {
1890
- return this.request(
1891
- () => this.http.get(
1892
- `api/projects/${projectId}/events/sentry/${encodeURIComponent(eventId)}`
1893
- ),
1894
- eventDetailSchema
1895
- );
1896
- }
1897
- };
1898
-
1899
- // src/resources/github.ts
1900
- var GitHubResource = class extends BaseResource {
1901
- /** The app, its installations and the webhook address (admin only). */
1902
- async status() {
1903
- return this.request(() => this.http.get("api/github"), gitHubStatusSchema);
1904
- }
1905
- /** The form to post to GitHub to create the app, under an org if given. */
1906
- async manifest(organization) {
1907
- return this.request(
1908
- () => this.http.post("api/github/manifest", { json: { organization } }),
1909
- gitHubManifestSchema
1910
- );
1911
- }
1912
- async disconnect() {
1913
- return this.requestVoid(() => this.http.delete("api/github"));
1914
- }
1915
- /** Repositories the installations reach, for a project's settings. */
1916
- async repositories(projectId) {
1917
- return this.request(
1918
- () => this.http.get("api/github/repositories", {
1919
- searchParams: { project_id: projectId }
1920
- }),
1921
- gitHubRepositorySchema.array()
1922
- );
1923
- }
1924
- async projectRepository(projectId) {
1925
- return this.request(
1926
- () => this.http.get(`api/projects/${projectId}/github`),
1927
- projectRepositorySchema.nullable()
1928
- );
1929
- }
1930
- async setProjectRepository(projectId, input) {
1931
- const validated = this.validateInput(input, updateProjectRepositorySchema);
1932
- if (!validated.success) {
1933
- return validated;
1934
- }
1935
- return this.request(
1936
- () => this.http.put(`api/projects/${projectId}/github`, {
1937
- json: validated.data
1938
- }),
1939
- projectRepositorySchema
1940
- );
1941
- }
1942
- async removeProjectRepository(projectId) {
1943
- return this.requestVoid(
1944
- () => this.http.delete(`api/projects/${projectId}/github`)
1945
- );
1946
- }
1947
- /** Copies the repository's CODEOWNERS into Rustrak. */
1948
- async syncCodeowners(projectId) {
1949
- return this.request(
1950
- () => this.http.post(`api/projects/${projectId}/github/codeowners`),
1951
- projectRepositorySchema
1952
- );
1953
- }
1954
- /** Links, suspect commits and owners for one issue. */
1955
- async issue(projectId, issueId) {
1956
- return this.request(
1957
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/github`),
1958
- issueGitHubSchema
1959
- );
1960
- }
1961
- async createIssue(projectId, issueId, input = {}) {
1962
- return this.request(
1963
- () => this.http.post(
1964
- `api/projects/${projectId}/issues/${issueId}/github/issues`,
1965
- { json: input }
1966
- ),
1967
- issueLinkSchema
1968
- );
1969
- }
1970
- /** `reference` is a GitHub URL, `owner/repo#12` or `#12`. */
1971
- async linkIssue(projectId, issueId, reference) {
1972
- return this.request(
1973
- () => this.http.post(
1974
- `api/projects/${projectId}/issues/${issueId}/github/links`,
1975
- { json: { reference } }
1976
- ),
1977
- issueLinkSchema
1978
- );
1979
- }
1980
- async unlinkIssue(projectId, issueId, linkId) {
1981
- return this.requestVoid(
1982
- () => this.http.delete(
1983
- `api/projects/${projectId}/issues/${issueId}/github/links/${linkId}`
1984
- )
1985
- );
1986
- }
1987
- /** The signed-in person's GitHub username, used to sync assignees. */
1988
- async myLogin() {
1989
- return this.request(
1990
- () => this.http.get("api/github/me"),
1991
- gitHubLoginSchema
1992
- );
1993
- }
1994
- async setMyLogin(login) {
1995
- return this.request(
1996
- () => this.http.put("api/github/me", { json: { login } }),
1997
- gitHubLoginSchema
1998
- );
1999
- }
2000
- };
2001
- var serverVersionSchema = z.object({
2002
- version: z.string()
2003
- });
2004
-
2005
- // src/resources/health.ts
2006
- var HealthResource = class extends BaseResource {
2007
- /**
2008
- * The version the server reports for itself.
2009
- *
2010
- * Authenticated: the server answers this one to a session or a Bearer token
2011
- * only, and returns 401 to anonymous callers. `/health` and `/health/ready`
2012
- * stay open for probes; a version number is what tells a stranger which
2013
- * advisories apply to your instance, so it is not probe material.
2014
- */
2015
- async getVersion() {
2016
- return this.request(
2017
- () => this.http.get("health/version"),
2018
- serverVersionSchema
2019
- );
2020
- }
2021
- };
2022
-
2023
- // src/resources/invitations.ts
2024
- var InvitationsResource = class extends BaseResource {
2025
- /**
2026
- * Create a new invitation
2027
- * @param input - Email and global role for the invited user
2028
- */
2029
- async create(input) {
2030
- const validatedInput = this.validateInput(input, createInvitationSchema);
2031
- if (!validatedInput.success) {
2032
- return validatedInput;
2033
- }
2034
- return this.request(
2035
- () => this.http.post("api/invitations", { json: validatedInput.data }),
2036
- invitationSchema
2037
- );
2038
- }
2039
- /**
2040
- * List all invitations
2041
- */
2042
- async list() {
2043
- return this.request(
2044
- () => this.http.get("api/invitations"),
2045
- invitationSchema.array()
2046
- );
2047
- }
2048
- /**
2049
- * Revoke a pending invitation
2050
- * @param token - Invitation token to revoke
2051
- */
2052
- async revoke(token) {
2053
- return this.requestVoid(() => this.http.delete(`api/invitations/${token}`));
2054
- }
2055
- };
2056
- var IssuesResource = class extends BaseResource {
2057
- /**
2058
- * List issues for a project with offset-based pagination
2059
- */
2060
- async list(projectId, options) {
2061
- const searchParams = {};
2062
- if (options?.page !== void 0) {
2063
- searchParams.page = options.page.toString();
2064
- }
2065
- if (options?.per_page !== void 0) {
2066
- searchParams.per_page = options.per_page.toString();
2067
- }
2068
- if (options?.sort) {
2069
- searchParams.sort = options.sort;
2070
- }
2071
- if (options?.order) {
2072
- searchParams.order = options.order;
2073
- }
2074
- if (options?.filter) {
2075
- searchParams.filter = options.filter;
2076
- }
2077
- if (options?.q) {
2078
- searchParams.q = options.q;
2079
- }
2080
- return this.request(
2081
- () => this.http.get(`api/projects/${projectId}/issues`, { searchParams }),
2082
- offsetPaginatedResponseSchema(issueSchema)
2083
- );
2084
- }
2085
- /**
2086
- * Get a single issue by ID
2087
- */
2088
- async get(projectId, issueId) {
2089
- return this.request(
2090
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}`),
2091
- issueSchema
2092
- );
2093
- }
2094
- /**
2095
- * Update issue state (status, substatus, priority, assignment, …)
2096
- */
2097
- async updateState(projectId, issueId, input) {
2098
- const validatedInput = this.validateInput(input, updateIssueStateSchema);
2099
- if (!validatedInput.success) {
2100
- return validatedInput;
2101
- }
2102
- return this.request(
2103
- () => this.http.patch(`api/projects/${projectId}/issues/${issueId}`, {
2104
- json: validatedInput.data
2105
- }),
2106
- issueSchema
2107
- );
2108
- }
2109
- /**
2110
- * Resolve an issue in the next release (suppresses regression until a deploy).
2111
- */
2112
- async resolveInNextRelease(projectId, issueId) {
2113
- return this.updateState(projectId, issueId, {
2114
- status: "resolvedInNextRelease"
2115
- });
2116
- }
2117
- /**
2118
- * Delete an issue
2119
- */
2120
- async delete(projectId, issueId) {
2121
- return this.requestVoid(
2122
- () => this.http.delete(`api/projects/${projectId}/issues/${issueId}`)
2123
- );
2124
- }
2125
- /**
2126
- * Bulk-mutate issues (status and/or priority).
2127
- */
2128
- async bulkUpdate(projectId, input) {
2129
- const validatedInput = this.validateInput(input, bulkUpdateIssuesSchema);
2130
- if (!validatedInput.success) {
2131
- return validatedInput;
2132
- }
2133
- return this.request(
2134
- () => this.http.put(`api/projects/${projectId}/issues`, {
2135
- json: validatedInput.data
2136
- }),
2137
- z.object({ updated: z.number().int() })
2138
- );
2139
- }
2140
- /**
2141
- * Bulk-delete issues.
2142
- */
2143
- async bulkDelete(projectId, input) {
2144
- const validatedInput = this.validateInput(input, bulkDeleteIssuesSchema);
2145
- if (!validatedInput.success) {
2146
- return validatedInput;
2147
- }
2148
- return this.request(
2149
- () => this.http.delete(`api/projects/${projectId}/issues`, {
2150
- json: validatedInput.data
2151
- }),
2152
- z.object({ deleted: z.number().int() })
2153
- );
2154
- }
2155
- /**
2156
- * List the grouping hashes that map to an issue.
2157
- */
2158
- async getHashes(projectId, issueId) {
2159
- return this.request(
2160
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/hashes`),
2161
- z.array(issueHashSchema)
2162
- );
2163
- }
2164
- /**
2165
- * List the distinct values (with counts) for a tag key across the issue.
2166
- * Returns a bare list, one entry per value (Sentry-compatible shape).
2167
- */
2168
- async getTagValues(projectId, issueId, key) {
2169
- return this.request(
2170
- () => this.http.get(
2171
- `api/projects/${projectId}/issues/${issueId}/tags/${encodeURIComponent(key)}`
2172
- ),
2173
- z.array(issueTagValueSchema)
2174
- );
2175
- }
2176
- /**
2177
- * Fetch per-issue aggregates (unique user count + top tags).
2178
- */
2179
- async getAggregates(projectId, issueId) {
2180
- return this.request(
2181
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/aggregates`),
2182
- issueAggregatesSchema
2183
- );
2184
- }
2185
- /**
2186
- * Fetch a zero-filled event-count timeseries (24h or 30d).
2187
- */
2188
- async getStats(projectId, issueId, window = "24h") {
2189
- return this.request(
2190
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/stats`, {
2191
- searchParams: { window }
2192
- }),
2193
- issueStatsSchema
2194
- );
2195
- }
2196
- /**
2197
- * List an issue's activity log (status changes, comments/notes, …).
2198
- */
2199
- async getActivity(projectId, issueId) {
2200
- return this.request(
2201
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/activity`),
2202
- z.array(activityEntrySchema)
2203
- );
2204
- }
2205
- /**
2206
- * Add a comment (note) to an issue.
2207
- */
2208
- async addComment(projectId, issueId, input) {
2209
- const validatedInput = this.validateInput(input, createCommentSchema);
2210
- if (!validatedInput.success) {
2211
- return validatedInput;
2212
- }
2213
- return this.request(
2214
- () => this.http.post(`api/projects/${projectId}/issues/${issueId}/comments`, {
2215
- json: validatedInput.data
2216
- }),
2217
- activityEntrySchema
2218
- );
2219
- }
2220
- /**
2221
- * Set or clear the current user's bookmark on an issue.
2222
- */
2223
- async setBookmark(projectId, issueId, enabled) {
2224
- return this.request(
2225
- () => this.http.put(`api/projects/${projectId}/issues/${issueId}/bookmark`, {
2226
- json: { enabled }
2227
- }),
2228
- z.object({ is_bookmarked: z.boolean() })
2229
- );
2230
- }
2231
- /**
2232
- * Set or clear the current user's subscription to an issue.
2233
- */
2234
- async setSubscription(projectId, issueId, enabled) {
2235
- return this.request(
2236
- () => this.http.put(
2237
- `api/projects/${projectId}/issues/${issueId}/subscription`,
2238
- { json: { enabled } }
2239
- ),
2240
- z.object({ is_subscribed: z.boolean() })
2241
- );
2242
- }
2243
- /**
2244
- * Mark the issue as seen by the current user.
2245
- */
2246
- async markSeen(projectId, issueId) {
2247
- return this.request(
2248
- () => this.http.post(`api/projects/${projectId}/issues/${issueId}/seen`),
2249
- z.object({ has_seen: z.boolean() })
2250
- );
2251
- }
2252
- /**
2253
- * List user feedback reports for an issue.
2254
- */
2255
- async listUserReports(projectId, issueId) {
2256
- return this.request(
2257
- () => this.http.get(
2258
- `api/projects/${projectId}/issues/${issueId}/user-reports`
2259
- ),
2260
- z.array(userReportSchema)
2261
- );
2262
- }
2263
- /**
2264
- * Attach a user feedback report to an issue.
2265
- */
2266
- async createUserReport(projectId, issueId, input) {
2267
- const validatedInput = this.validateInput(input, createUserReportSchema);
2268
- if (!validatedInput.success) {
2269
- return validatedInput;
2270
- }
2271
- return this.request(
2272
- () => this.http.post(
2273
- `api/projects/${projectId}/issues/${issueId}/user-reports`,
2274
- { json: validatedInput.data }
2275
- ),
2276
- userReportSchema
2277
- );
2278
- }
2279
- };
2280
-
2281
- // src/resources/logs.ts
2282
- var LogsResource = class extends BaseResource {
2283
- /**
2284
- * List logs for a project with offset-based pagination (newest first by log
2285
- * timestamp), optionally filtered by level/trace_id.
2286
- */
2287
- async list(projectId, options) {
2288
- const searchParams = {};
2289
- if (options?.page) {
2290
- searchParams.page = String(options.page);
2291
- }
2292
- if (options?.per_page) {
2293
- searchParams.per_page = String(options.per_page);
2294
- }
2295
- if (options?.level) {
2296
- searchParams.level = options.level;
2297
- }
2298
- if (options?.trace_id) {
2299
- searchParams.trace_id = options.trace_id;
2300
- }
2301
- return this.request(
2302
- () => this.http.get(`api/projects/${projectId}/logs`, { searchParams }),
2303
- offsetPaginatedResponseSchema(logSchema)
2304
- );
2305
- }
2306
- };
2307
-
2308
- // src/resources/members.ts
2309
- var MembersResource = class extends BaseResource {
2310
- /**
2311
- * List members of a project
2312
- * @param projectId - ID of the project
2313
- */
2314
- async list(projectId) {
2315
- return this.request(
2316
- () => this.http.get(`api/projects/${projectId}/members`),
2317
- projectMemberSchema.array()
2318
- );
2319
- }
2320
- /**
2321
- * Add or update a project member
2322
- * @param projectId - ID of the project
2323
- * @param input - User ID and per-project role
2324
- */
2325
- async upsert(projectId, input) {
2326
- const validatedInput = this.validateInput(input, upsertProjectMemberSchema);
2327
- if (!validatedInput.success) {
2328
- return validatedInput;
2329
- }
2330
- return this.requestVoid(
2331
- () => this.http.put(`api/projects/${projectId}/members`, {
2332
- json: validatedInput.data
2333
- })
2334
- );
2335
- }
2336
- /**
2337
- * Remove a member from a project
2338
- * @param projectId - ID of the project
2339
- * @param userId - ID of the user to remove
2340
- */
2341
- async remove(projectId, userId) {
2342
- return this.requestVoid(
2343
- () => this.http.delete(`api/projects/${projectId}/members/${userId}`)
2344
- );
2345
- }
2346
- };
2347
- var MonitorsResource = class extends BaseResource {
2348
- /** Every monitor of a project, with its environments and recent check-ins. */
2349
- async list(projectId) {
2350
- return this.request(
2351
- () => this.http.get(`api/projects/${projectId}/monitors`),
2352
- z.array(monitorSchema)
2353
- );
2354
- }
2355
- async get(projectId, slug) {
2356
- return this.request(
2357
- () => this.http.get(
2358
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
2359
- ),
2360
- monitorSchema
2361
- );
2362
- }
2363
- async create(projectId, input) {
2364
- const validated = this.validateInput(input, createMonitorSchema);
2365
- if (!validated.success) {
2366
- return validated;
2367
- }
2368
- return this.request(
2369
- () => this.http.post(`api/projects/${projectId}/monitors`, {
2370
- json: validated.data
2371
- }),
2372
- monitorSchema
2373
- );
2374
- }
2375
- /** Fields left out keep their value, including each field of `config`. */
2376
- async update(projectId, slug, input) {
2377
- const validated = this.validateInput(input, updateMonitorSchema);
2378
- if (!validated.success) {
2379
- return validated;
2380
- }
2381
- return this.request(
2382
- () => this.http.put(
2383
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`,
2384
- { json: validated.data }
2385
- ),
2386
- monitorSchema
2387
- );
2388
- }
2389
- /** Deletes the monitor and its check-ins. Its issues stay. */
2390
- async delete(projectId, slug) {
2391
- return this.requestVoid(
2392
- () => this.http.delete(
2393
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
2394
- )
2395
- );
2396
- }
2397
- /** Check-ins of one monitor, newest first. */
2398
- async listCheckIns(projectId, slug, options) {
2399
- const searchParams = {};
2400
- if (options?.page) {
2401
- searchParams.page = String(options.page);
2402
- }
2403
- if (options?.per_page) {
2404
- searchParams.per_page = String(options.per_page);
2405
- }
2406
- if (options?.environment) {
2407
- searchParams.environment = options.environment;
2408
- }
2409
- return this.request(
2410
- () => this.http.get(
2411
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}/checkins`,
2412
- { searchParams }
2413
- ),
2414
- offsetPaginatedResponseSchema(checkInSchema)
2415
- );
2416
- }
2417
- };
2418
-
2419
- // src/resources/projects.ts
2420
- var ProjectsResource = class extends BaseResource {
2421
- /**
2422
- * List projects with pagination
2423
- */
2424
- async list(options) {
2425
- const searchParams = new URLSearchParams();
2426
- if (options?.page !== void 0) {
2427
- searchParams.set("page", options.page.toString());
2428
- }
2429
- if (options?.per_page !== void 0) {
2430
- searchParams.set("per_page", options.per_page.toString());
2431
- }
2432
- if (options?.order) {
2433
- searchParams.set("order", options.order);
2434
- }
2435
- if (options?.stats_period) {
2436
- searchParams.set("stats_period", options.stats_period);
2437
- }
2438
- const query = searchParams.toString();
2439
- const url = query ? `api/projects?${query}` : "api/projects";
2440
- return this.request(
2441
- () => this.http.get(url),
2442
- offsetPaginatedResponseSchema(projectSchema)
2443
- );
2444
- }
2445
- /**
2446
- * The server's per-project limits, which a project without its own follows
2447
- */
2448
- async rateLimits() {
2449
- return this.request(
2450
- () => this.http.get("api/rate-limits"),
2451
- rateLimitsSchema
2452
- );
2453
- }
2454
- /**
2455
- * Get a single project by ID
2456
- */
2457
- async get(id) {
2458
- return this.request(
2459
- () => this.http.get(`api/projects/${id}`),
2460
- projectSchema
2461
- );
2462
- }
2463
- /**
2464
- * Create a new project
2465
- */
2466
- async create(input) {
2467
- const validatedInput = this.validateInput(input, createProjectSchema);
2468
- if (!validatedInput.success) {
2469
- return validatedInput;
2470
- }
2471
- return this.request(
2472
- () => this.http.post("api/projects", { json: validatedInput.data }),
2473
- projectSchema
2474
- );
2475
- }
2476
- /**
2477
- * Update an existing project
2478
- */
2479
- async update(id, input) {
2480
- const validatedInput = this.validateInput(input, updateProjectSchema);
2481
- if (!validatedInput.success) {
2482
- return validatedInput;
2483
- }
2484
- return this.request(
2485
- () => this.http.patch(`api/projects/${id}`, { json: validatedInput.data }),
2486
- projectSchema
2487
- );
2488
- }
2489
- /**
2490
- * Delete a project
2491
- */
2492
- async delete(id) {
2493
- return this.requestVoid(() => this.http.delete(`api/projects/${id}`));
2494
- }
2495
- };
2496
- var ReleasesResource = class extends BaseResource {
2497
- /**
2498
- * Get issues first seen in a given release, most recently introduced first.
2499
- *
2500
- * @param projectId - Project ID
2501
- * @param release - Release version
2502
- * @param limit - Max issues to return (default: 10, max: 50)
2503
- */
2504
- async newIssues(projectId, release, limit) {
2505
- const searchParams = {};
2506
- if (limit !== void 0) {
2507
- searchParams.limit = limit.toString();
2508
- }
2509
- return this.request(
2510
- () => this.http.get(
2511
- `api/projects/${projectId}/releases/${encodeURIComponent(release)}/new-issues`,
2512
- { searchParams }
2513
- ),
2514
- z.array(issueSchema)
2515
- );
2516
- }
2517
- };
2518
-
2519
- // src/resources/schedules.ts
2520
- var SchedulesResource = class extends BaseResource {
2521
- /** Validates a schedule and lists its next five runs. */
2522
- async preview(input) {
2523
- const validated = this.validateInput(input, previewScheduleSchema);
2524
- if (!validated.success) {
2525
- return validated;
2526
- }
2527
- return this.request(
2528
- () => this.http.post("api/schedules/preview", { json: validated.data }),
2529
- schedulePreviewSchema
2530
- );
2531
- }
2532
- };
2533
-
2534
- // src/resources/sessions.ts
2535
- var SessionsResource = class extends BaseResource {
2536
- /**
2537
- * Get per-release health stats for a project, one offset-based page of
2538
- * (release, environment) rows at a time, ordered by session volume.
2539
- * @param projectId - Project ID
2540
- * @param options - Time window, release scoping and pagination.
2541
- */
2542
- async stats(projectId, options) {
2543
- const searchParams = {};
2544
- if (options?.period) {
2545
- searchParams.period = options.period;
2546
- }
2547
- if (options?.release) {
2548
- searchParams.release = options.release;
2549
- }
2550
- if (options?.page) {
2551
- searchParams.page = String(options.page);
2552
- }
2553
- if (options?.per_page) {
2554
- searchParams.per_page = String(options.per_page);
2555
- }
2556
- return this.request(
2557
- () => this.http.get(`api/projects/${projectId}/sessions/stats`, {
2558
- searchParams
2559
- }),
2560
- offsetPaginatedResponseSchema(releaseHealthRowSchema)
2561
- );
2562
- }
2563
- /**
2564
- * Get project-wide session health, aggregated across all releases and environments.
2565
- * @param projectId - Project ID
2566
- * @param period - Time window (e.g. '24h', '7d'). Defaults to '24h'.
2567
- */
2568
- async summary(projectId, period) {
2569
- const searchParams = {};
2570
- if (period) {
2571
- searchParams.period = period;
2572
- }
2573
- return this.request(
2574
- () => this.http.get(`api/projects/${projectId}/sessions/summary`, {
2575
- searchParams
2576
- }),
2577
- sessionSummarySchema
2578
- );
2579
- }
2580
- /**
2581
- * Get a time-bucketed session trend for a project, aggregated across all
2582
- * releases and environments.
2583
- * @param projectId - Project ID
2584
- * @param period - Time window (e.g. '24h', '7d'). Defaults to '24h'.
2585
- * @param interval - Bucket width in hours (default: 1, max: 24).
2586
- */
2587
- async timeseries(projectId, period, interval) {
2588
- const searchParams = {};
2589
- if (period) {
2590
- searchParams.period = period;
2591
- }
2592
- if (interval !== void 0) {
2593
- searchParams.interval = interval.toString();
2594
- }
2595
- return this.request(
2596
- () => this.http.get(`api/projects/${projectId}/sessions/timeseries`, {
2597
- searchParams
2598
- }),
2599
- sessionTimeseriesSchema
2600
- );
2601
- }
2602
- };
2603
-
2604
- // src/resources/sourcemaps.ts
2605
- var SourceMapsResource = class extends BaseResource {
2606
- /**
2607
- * Get chunk upload capabilities for an organization.
2608
- * Returns the upload URL, chunk size limits, and accepted artifact types.
2609
- */
2610
- async getChunkUploadCapability(orgSlug) {
2611
- return this.request(
2612
- () => this.http.get(`api/0/organizations/${orgSlug}/chunk-upload/`),
2613
- chunkUploadCapabilitySchema
2614
- );
2615
- }
2616
- /**
2617
- * Upload chunks as multipart/form-data, batching by `chunksPerRequest` (default 64).
2618
- * Each part's field name must be the pre-computed SHA-1 hash of its content — the server
2619
- * rejects mismatches with 400. Callers must supply the hash (also needed for assembleBundle).
2620
- */
2621
- async uploadChunks(orgSlug, chunks, chunksPerRequest = 64) {
2622
- if (!Number.isInteger(chunksPerRequest) || chunksPerRequest <= 0) {
2623
- return Err({
2624
- kind: "invalid_request",
2625
- message: "chunksPerRequest must be a positive integer."
2626
- });
2627
- }
2628
- for (let i = 0; i < chunks.length; i += chunksPerRequest) {
2629
- const batch = chunks.slice(i, i + chunksPerRequest);
2630
- const form = new FormData();
2631
- for (const chunk of batch) {
2632
- form.append(chunk.hash, chunk.data);
2633
- }
2634
- const uploaded = await this.requestVoid(
2635
- () => this.http.post(`api/0/organizations/${orgSlug}/chunk-upload/`, {
2636
- body: form
2637
- })
2638
- );
2639
- if (!uploaded.success) {
2640
- return uploaded;
2641
- }
2642
- }
2643
- return Ok(void 0);
2644
- }
2645
- /**
2646
- * Trigger assembly of a previously uploaded artifact bundle.
2647
- *
2648
- * @returns The assembly state. Poll until `state === "ok"` or `state === "error"`.
2649
- * When `state === "not_found"` the `missingChunks` array lists what
2650
- * still needs uploading via `uploadChunks`.
2651
- */
2652
- async assembleBundle(orgSlug, input) {
2653
- const validatedInput = this.validateInput(input, assembleInputSchema);
2654
- if (!validatedInput.success) {
2655
- return validatedInput;
2656
- }
2657
- return this.request(
2658
- () => this.http.post(
2659
- `api/0/organizations/${orgSlug}/artifactbundle/assemble/`,
2660
- { json: validatedInput.data }
2661
- ),
2662
- assembleResponseSchema
2663
- );
2664
- }
2665
- /**
2666
- * List all source map files uploaded for a project.
2667
- */
2668
- async list(orgSlug, projectSlug) {
2669
- return this.request(
2670
- () => this.http.get(
2671
- `api/0/projects/${orgSlug}/${projectSlug}/files/source-maps/`
2672
- ),
2673
- listSourceMapsResponseSchema
2674
- );
2675
- }
2676
- };
2677
-
2678
- // src/resources/spans.ts
2679
- var SpansResource = class extends BaseResource {
2680
- /**
2681
- * List spans for a project with offset-based pagination (newest first),
2682
- * optionally filtered by op/status/trace_id/operation_type.
2683
- */
2684
- async list(projectId, options) {
2685
- const searchParams = {};
2686
- if (options?.page) {
2687
- searchParams.page = String(options.page);
2688
- }
2689
- if (options?.per_page) {
2690
- searchParams.per_page = String(options.per_page);
2691
- }
2692
- if (options?.op) {
2693
- searchParams.op = options.op;
2694
- }
2695
- if (options?.status) {
2696
- searchParams.status = options.status;
2697
- }
2698
- if (options?.trace_id) {
2699
- searchParams.trace_id = options.trace_id;
2700
- }
2701
- if (options?.operation_type) {
2702
- searchParams.operation_type = options.operation_type;
2703
- }
2704
- return this.request(
2705
- () => this.http.get(`api/projects/${projectId}/spans`, { searchParams }),
2706
- offsetPaginatedResponseSchema(spanSchema)
2707
- );
2708
- }
2709
- /**
2710
- * Fetch one span together with its raw attribute bag — the `gen_ai.*`
2711
- * payload (prompts, responses, tool arguments and results) that `list()`
2712
- * omits so a trace's worth of spans stays cheap to load.
2713
- *
2714
- * `spanId` is the row id from a list item's `id`, not the SDK's 16-hex
2715
- * `span_id`.
2716
- */
2717
- async get(projectId, spanId) {
2718
- return this.request(
2719
- () => this.http.get(`api/projects/${projectId}/spans/${spanId}`),
2720
- spanDetailSchema
2721
- );
2722
- }
2723
- };
2724
-
2725
- // src/resources/stats.ts
2726
- var StatsResource = class extends BaseResource {
2727
- /**
2728
- * Get time-bucketed error-event volume for a project, split by severity.
2729
- *
2730
- * Buckets are zero-filled across the window, so a quiet hour comes back as a
2731
- * point with `total: 0` rather than being absent. All-time requests (no
2732
- * `period`) are sparse: there is no lower bound to fill from.
2733
- *
2734
- * @param projectId - Project ID
2735
- * @param period - Time window (e.g. '24h', '7d'). Omit for all time.
2736
- * @param interval - Bucket width in hours (default: 1, max: 24).
2737
- */
2738
- async timeseries(projectId, period, interval) {
2739
- const searchParams = {};
2740
- if (period) {
2741
- searchParams.period = period;
2742
- }
2743
- if (interval !== void 0) {
2744
- searchParams.interval = interval.toString();
2745
- }
2746
- return this.request(
2747
- () => this.http.get(`api/projects/${projectId}/events/stats`, {
2748
- searchParams
2749
- }),
2750
- eventTimeseriesSchema
2751
- );
2752
- }
2753
- /**
2754
- * Get project-wide counters for a window, each paired with the same counter
2755
- * over the window immediately before it.
2756
- *
2757
- * @param projectId - Project ID
2758
- * @param period - Time window (e.g. '24h', '7d'). Omit for all time, which
2759
- * leaves every `previous` null.
2760
- */
2761
- async summary(projectId, period) {
2762
- const searchParams = {};
2763
- if (period) {
2764
- searchParams.period = period;
2765
- }
2766
- return this.request(
2767
- () => this.http.get(`api/projects/${projectId}/stats/summary`, {
2768
- searchParams
2769
- }),
2770
- projectStatsSummarySchema
2771
- );
2772
- }
2773
- };
2774
- var StorageResource = class extends BaseResource {
2775
- /**
2776
- * Get the instance-wide storage summary: row counts per data category, the
2777
- * whole-DB size, and exact source-map weight.
2778
- */
2779
- async getSummary() {
2780
- return this.request(
2781
- () => this.http.get("api/storage/summary"),
2782
- storageSummarySchema
2783
- );
2784
- }
2785
- /**
2786
- * Get the per-project storage breakdown (one row per project, including
2787
- * empty ones).
2788
- */
2789
- async getProjects() {
2790
- return this.request(
2791
- () => this.http.get("api/storage/projects"),
2792
- z.array(projectStorageSchema)
2793
- );
2794
- }
2795
- /**
2796
- * Dry-run: count the rows a cleanup would remove. Mutates nothing — use it to
2797
- * confirm impact before {@link executeCleanup}.
2798
- */
2799
- async previewCleanup(options) {
2800
- const validatedInput = this.validateInput(options, cleanupOptionsSchema);
2801
- if (!validatedInput.success) {
2802
- return validatedInput;
2803
- }
2804
- return this.request(
2805
- () => this.http.post("api/storage/cleanup/preview", {
2806
- json: validatedInput.data
2807
- }),
2808
- cleanupCountsSchema
2809
- );
2810
- }
2811
- /**
2812
- * Start a cleanup: delete data older than `older_than_days` (optionally
2813
- * scoped to one project) and remove the issues it leaves with zero events.
2814
- *
2815
- * Returns as soon as the server has started it, with the `running` status.
2816
- * The deletion runs in the background; follow it with
2817
- * {@link getCleanupStatus}. A second start while one is running fails with
2818
- * a `conflict`.
2819
- */
2820
- async executeCleanup(options) {
2821
- const validatedInput = this.validateInput(options, cleanupOptionsSchema);
2822
- if (!validatedInput.success) {
2823
- return validatedInput;
2824
- }
2825
- return this.request(
2826
- () => this.http.post("api/storage/cleanup", {
2827
- json: validatedInput.data,
2828
- // No retry: if the first attempt started the cleanup and only its
2829
- // response was lost, a retry would be refused as a second run and
2830
- // report a failure for a cleanup that is in fact running.
2831
- retry: 0
2832
- }),
2833
- cleanupStatusSchema
2834
- );
2835
- }
2836
- /**
2837
- * The running cleanup's progress, or the outcome of the last one.
2838
- */
2839
- async getCleanupStatus() {
2840
- return this.request(
2841
- () => this.http.get("api/storage/cleanup/status"),
2842
- cleanupStatusSchema
2843
- );
2844
- }
2845
- /**
2846
- * Dry-run for {@link gcSourceMaps}: count the orphaned source-map files and
2847
- * bytes a GC would reclaim. Mutates nothing.
2848
- */
2849
- async previewGcSourceMaps() {
2850
- return this.request(
2851
- () => this.http.post("api/storage/source-maps/gc/preview"),
2852
- sourceMapGcResultSchema
2853
- );
2854
- }
2855
- /**
2856
- * Garbage-collect orphaned source maps: files no longer referenced by any
2857
- * upload, removed from the DB and unlinked from disk. Safe — never touches
2858
- * referenced files.
2859
- */
2860
- async gcSourceMaps() {
2861
- return this.request(
2862
- () => this.http.post("api/storage/source-maps/gc"),
2863
- sourceMapGcResultSchema
2864
- );
2865
- }
2866
- /**
2867
- * Retention: how long each kind of data is kept, by default and per
2868
- * project, when its cleanup runs next and how the last one went.
2869
- */
2870
- async getRetention() {
2871
- return this.request(
2872
- () => this.http.get("api/storage/retention"),
2873
- retentionSchema
2874
- );
2875
- }
2876
- /** Replaces the retention settings. A new schedule applies within a minute. */
2877
- async updateRetention(settings) {
2878
- const validated = this.validateInput(settings, retentionSettingsSchema);
2879
- if (!validated.success) {
2880
- return validated;
2881
- }
2882
- return this.request(
2883
- () => this.http.put("api/storage/retention", { json: validated.data }),
2884
- retentionSchema
2885
- );
2886
- }
2887
- /**
2888
- * Enforces the saved retention now, without waiting for the schedule, and
2889
- * deletes unused source maps. Returns the started job; follow it with
2890
- * {@link getCleanupStatus}. A `validation` error while everything is kept
2891
- * forever, `conflict` while a cleanup runs.
2892
- */
2893
- async runRetention() {
2894
- return this.request(
2895
- () => this.http.post("api/storage/retention/run", {
2896
- // No retry, as for `executeCleanup`: a lost response after the
2897
- // cleanup started would be retried into a refused second run.
2898
- retry: 0
2899
- }),
2900
- cleanupStatusSchema
2901
- );
2902
- }
2903
- /** How long ago each project's data arrived, per kind, in age buckets. */
2904
- async getAge() {
2905
- return this.request(
2906
- () => this.http.get("api/storage/age"),
2907
- storageAgeSchema
2908
- );
2909
- }
2910
- /**
2911
- * Dry-run: what enforcing these retention settings now would delete, each
2912
- * project against its own windows. Saves and deletes nothing.
2913
- */
2914
- async previewRetention(settings) {
2915
- const validated = this.validateInput(settings, retentionSettingsSchema);
2916
- if (!validated.success) {
2917
- return validated;
2918
- }
2919
- return this.request(
2920
- () => this.http.post("api/storage/retention/preview", {
2921
- json: validated.data
2922
- }),
2923
- cleanupCountsSchema
2924
- );
2925
- }
2926
- };
2927
-
2928
- // src/resources/team.ts
2929
- var TeamResource = class extends BaseResource {
2930
- /**
2931
- * List all team members (users)
2932
- */
2933
- async list() {
2934
- return this.request(
2935
- () => this.http.get("api/team"),
2936
- teamMemberSchema.array()
2937
- );
2938
- }
2939
- /**
2940
- * Change a user's global role
2941
- * @param userId - ID of the user to update
2942
- * @param role - New global role to assign
2943
- */
2944
- async updateRole(userId, role) {
2945
- const body = this.validateInput({ role }, updateUserRoleSchema);
2946
- if (!body.success) {
2947
- return body;
2948
- }
2949
- return this.requestVoid(
2950
- () => this.http.patch(`api/team/${userId}/role`, { json: body.data })
2951
- );
2952
- }
2953
- /**
2954
- * Permanently remove a user from the instance.
2955
- * @param userId - ID of the user to delete
2956
- */
2957
- async remove(userId) {
2958
- return this.requestVoid(() => this.http.delete(`api/team/${userId}`));
2959
- }
2960
- };
2961
-
2962
- // src/resources/tokens.ts
2963
- var TokensResource = class extends BaseResource {
2964
- /**
2965
- * List all auth tokens (masked)
2966
- */
2967
- async list() {
2968
- return this.request(
2969
- () => this.http.get("api/tokens"),
2970
- authTokenSchema.array()
2971
- );
2972
- }
2973
- /**
2974
- * Get a single auth token by ID (full token value).
2975
- *
2976
- * Previously returned a masked version, but the server now returns the
2977
- * complete token for GET /api/tokens/{id}.
2978
- */
2979
- async get(id) {
2980
- return this.request(
2981
- () => this.http.get(`api/tokens/${id}`),
2982
- authTokenCreatedSchema
2983
- );
2984
- }
2985
- /**
2986
- * Create a new auth token
2987
- * Note: The full token is only returned once during creation
2988
- */
2989
- async create(input) {
2990
- const validatedInput = this.validateInput(input, createAuthTokenSchema);
2991
- if (!validatedInput.success) {
2992
- return validatedInput;
2993
- }
2994
- return this.request(
2995
- () => this.http.post("api/tokens", { json: validatedInput.data }),
2996
- authTokenCreatedSchema
2997
- );
2998
- }
2999
- /**
3000
- * Delete an auth token
3001
- */
3002
- async delete(id) {
3003
- return this.requestVoid(() => this.http.delete(`api/tokens/${id}`));
3004
- }
3005
- };
3006
- var TransactionsResource = class extends BaseResource {
3007
- /**
3008
- * List transactions for a project with offset-based pagination (newest first)
3009
- */
3010
- async list(projectId, options) {
3011
- const searchParams = {};
3012
- if (options?.page) {
3013
- searchParams.page = String(options.page);
3014
- }
3015
- if (options?.per_page) {
3016
- searchParams.per_page = String(options.per_page);
3017
- }
3018
- if (options?.name) {
3019
- searchParams.name = options.name;
3020
- }
3021
- if (options?.op) {
3022
- searchParams.op = options.op;
3023
- }
3024
- if (options?.status) {
3025
- searchParams.status = options.status;
3026
- }
3027
- if (options?.environment) {
3028
- searchParams.environment = options.environment;
3029
- }
3030
- if (options?.release) {
3031
- searchParams.release = options.release;
3032
- }
3033
- return this.request(
3034
- () => this.http.get(`api/projects/${projectId}/transactions`, {
3035
- searchParams
3036
- }),
3037
- offsetPaginatedResponseSchema(transactionSchema)
3038
- );
3039
- }
3040
- /**
3041
- * Get the indexed spans extracted from a transaction, in waterfall order.
3042
- */
3043
- async getSpans(projectId, transactionId) {
3044
- return this.request(
3045
- () => this.http.get(
3046
- `api/projects/${projectId}/transactions/${transactionId}/spans`
3047
- ),
3048
- z.array(spanSchema)
3049
- );
3050
- }
3051
- /**
3052
- * Get aggregate performance stats (count, p50/p95/p99 latency, failure rate)
3053
- * grouped by transaction name + op, most frequent first, with offset-based
3054
- * pagination — same shape as the other list endpoints.
3055
- */
3056
- async getStats(projectId, options) {
3057
- const searchParams = {};
3058
- if (options?.page) {
3059
- searchParams.page = String(options.page);
3060
- }
3061
- if (options?.per_page) {
3062
- searchParams.per_page = String(options.per_page);
3063
- }
3064
- return this.request(
3065
- () => this.http.get(`api/projects/${projectId}/transactions/stats`, {
3066
- searchParams
3067
- }),
3068
- offsetPaginatedResponseSchema(transactionStatsSchema)
3069
- );
3070
- }
3071
- /**
3072
- * Get aggregate stats for a single (transaction name, op) group — a direct
3073
- * lookup that works regardless of how many groups the project has. Reports
3074
- * `not_found` when the group has no transactions.
3075
- */
3076
- async getStatForGroup(projectId, name, op) {
3077
- const searchParams = { name };
3078
- if (op) {
3079
- searchParams.op = op;
3080
- }
3081
- return this.request(
3082
- () => this.http.get(`api/projects/${projectId}/transactions/stats/group`, {
3083
- searchParams
3084
- }),
3085
- transactionStatsSchema
3086
- );
3087
- }
3088
- /**
3089
- * Get a single transaction by ID with its full Sentry payload (spans,
3090
- * contexts.trace, measurements, tags) for the performance detail view.
3091
- */
3092
- async get(projectId, transactionId) {
3093
- return this.request(
3094
- () => this.http.get(
3095
- `api/projects/${projectId}/transactions/${transactionId}`
3096
- ),
3097
- transactionDetailSchema
3098
- );
3099
- }
3100
- };
3101
-
3102
- // src/client.ts
3103
- var RustrakClient = class {
3104
- http;
3105
- /**
3106
- * Authentication API resource
3107
- */
3108
- auth;
3109
- /**
3110
- * Projects API resource
3111
- */
3112
- projects;
3113
- /**
3114
- * Issues API resource
3115
- */
3116
- issues;
3117
- /**
3118
- * Events API resource
3119
- */
3120
- events;
3121
- /**
3122
- * Auth Tokens API resource
3123
- */
3124
- tokens;
3125
- /**
3126
- * Alert Integrations API resource (global credential destinations)
3127
- */
3128
- alertIntegrations;
3129
- /**
3130
- * Alert Rules API resource (per-project alert configuration)
3131
- */
3132
- alertRules;
3133
- /**
3134
- * Source Maps API resource (sentry-cli artifact bundle upload protocol)
3135
- */
3136
- sourceMaps;
3137
- /**
3138
- * Team API resource (global user roster and roles)
3139
- */
3140
- team;
3141
- /**
3142
- * Invitations API resource (pending user invitations)
3143
- */
3144
- invitations;
3145
- /**
3146
- * Project Members API resource (per-project membership and roles)
3147
- */
3148
- members;
3149
- /**
3150
- * Sessions API resource (release health)
3151
- */
3152
- sessions;
3153
- /**
3154
- * Releases API resource (data scoped to a specific release)
3155
- */
3156
- releases;
3157
- /**
3158
- * Transactions API resource (performance monitoring)
3159
- */
3160
- transactions;
3161
- /**
3162
- * Logs API resource (standalone logs)
3163
- */
3164
- logs;
3165
- /**
3166
- * Cron monitors API resource (Sentry Crons)
3167
- */
3168
- monitors;
3169
- /**
3170
- * Schedules API resource (previews for crontab/interval schedules)
3171
- */
3172
- schedules;
3173
- /**
3174
- * Spans API resource (standalone + transaction-embedded spans, shared table)
3175
- */
3176
- spans;
3177
- /**
3178
- * AI Agent Monitoring dashboard API resource
3179
- */
3180
- agents;
3181
- /**
3182
- * Stats API resource (project-wide overview aggregates)
3183
- */
3184
- stats;
3185
- /**
3186
- * Storage API resource (usage + retention cleanup, admin only)
3187
- */
3188
- storage;
3189
- /**
3190
- * Health API resource (version info)
3191
- */
3192
- health;
3193
- /**
3194
- * GitHub integration resource
3195
- */
3196
- github;
3197
- /**
3198
- * Create a new Rustrak API client
3199
- *
3200
- * @param config - Client configuration
3201
- */
3202
- constructor(config) {
3203
- this.http = createKyInstance(config);
3204
- this.auth = new AuthResource(this.http);
3205
- this.projects = new ProjectsResource(this.http);
3206
- this.issues = new IssuesResource(this.http);
3207
- this.events = new EventsResource(this.http);
3208
- this.tokens = new TokensResource(this.http);
3209
- this.github = new GitHubResource(this.http);
3210
- this.alertIntegrations = new AlertIntegrationsResource(this.http);
3211
- this.alertRules = new AlertRulesResource(this.http);
3212
- this.sourceMaps = new SourceMapsResource(this.http);
3213
- this.team = new TeamResource(this.http);
3214
- this.invitations = new InvitationsResource(this.http);
3215
- this.members = new MembersResource(this.http);
3216
- this.sessions = new SessionsResource(this.http);
3217
- this.releases = new ReleasesResource(this.http);
3218
- this.transactions = new TransactionsResource(this.http);
3219
- this.logs = new LogsResource(this.http);
3220
- this.monitors = new MonitorsResource(this.http);
3221
- this.schedules = new SchedulesResource(this.http);
3222
- this.spans = new SpansResource(this.http);
3223
- this.agents = new AgentsResource(this.http);
3224
- this.stats = new StatsResource(this.http);
3225
- this.storage = new StorageResource(this.http);
3226
- this.health = new HealthResource(this.http);
3227
- }
3228
- };
3229
-
3230
- export { Err, FIELD_ERROR_CODES, NETWORK_ERROR_MESSAGE, Ok, RustrakClient, SERVER_ERROR_MESSAGE, TIMEOUT_ERROR_MESSAGE, isRetryable, mapResult, unwrap, unwrapOr };
3231
- //# sourceMappingURL=index.js.map
3232
- //# sourceMappingURL=index.js.map