@rustrak/client 0.3.5 → 0.3.7

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.
package/dist/index.cjs CHANGED
@@ -608,6 +608,42 @@ var sourceMapFileSchema = zod.z.object({
608
608
  var listSourceMapsResponseSchema = zod.z.object({
609
609
  data: zod.z.array(sourceMapFileSchema)
610
610
  });
611
+ var sourceMapStorageSchema = zod.z.object({
612
+ chunk_bytes: zod.z.number(),
613
+ source_file_bytes: zod.z.number(),
614
+ total_bytes: zod.z.number(),
615
+ file_count: zod.z.number()
616
+ });
617
+ var storageSummarySchema = zod.z.object({
618
+ total_db_size_bytes: zod.z.number(),
619
+ events_count: zod.z.number(),
620
+ transactions_count: zod.z.number(),
621
+ spans_count: zod.z.number(),
622
+ source_maps: sourceMapStorageSchema
623
+ });
624
+ var projectStorageSchema = zod.z.object({
625
+ project_id: zod.z.number(),
626
+ project_name: zod.z.string(),
627
+ events_count: zod.z.number(),
628
+ transactions_count: zod.z.number(),
629
+ spans_count: zod.z.number(),
630
+ source_maps_count: zod.z.number(),
631
+ estimated_bytes: zod.z.number()
632
+ });
633
+ var cleanupCountsSchema = zod.z.object({
634
+ events: zod.z.number(),
635
+ transactions: zod.z.number(),
636
+ spans: zod.z.number(),
637
+ issues_removed: zod.z.number()
638
+ });
639
+ var sourceMapGcResultSchema = zod.z.object({
640
+ files_removed: zod.z.number(),
641
+ bytes_freed: zod.z.number()
642
+ });
643
+ var cleanupOptionsSchema = zod.z.object({
644
+ older_than_days: zod.z.number().int().min(1),
645
+ project_id: zod.z.number().int().optional()
646
+ });
611
647
  var authTokenSchema = zod.z.object({
612
648
  id: zod.z.number().int(),
613
649
  token_prefix: zod.z.string(),
@@ -650,6 +686,30 @@ var transactionDetailSchema = zod.z.object({
650
686
  data: zod.z.record(zod.z.string(), zod.z.any())
651
687
  // Full Sentry transaction payload
652
688
  });
689
+ var spanSchema = zod.z.object({
690
+ id: uuidSchema,
691
+ span_id: zod.z.string().nullable(),
692
+ trace_id: zod.z.string().nullable(),
693
+ parent_span_id: zod.z.string().nullable(),
694
+ op: zod.z.string().nullable(),
695
+ description: zod.z.string().nullable(),
696
+ status: zod.z.string().nullable(),
697
+ start_timestamp: dateTimeSchema.nullable(),
698
+ timestamp: dateTimeSchema.nullable(),
699
+ duration_ms: zod.z.number().nullable(),
700
+ exclusive_time_ms: zod.z.number().nullable(),
701
+ is_segment: zod.z.boolean(),
702
+ segment_id: zod.z.string().nullable()
703
+ });
704
+ var transactionStatsSchema = zod.z.object({
705
+ transaction_name: zod.z.string(),
706
+ op: zod.z.string().nullable(),
707
+ count: zod.z.number().int(),
708
+ p50_ms: zod.z.number(),
709
+ p95_ms: zod.z.number(),
710
+ p99_ms: zod.z.number(),
711
+ failure_rate: zod.z.number()
712
+ });
653
713
 
654
714
  // src/resources/events.ts
655
715
  var EventsResource = class extends BaseResource {
@@ -917,6 +977,59 @@ var SourceMapsResource = class extends BaseResource {
917
977
  return this.validate(data, listSourceMapsResponseSchema);
918
978
  }
919
979
  };
980
+ var StorageResource = class extends BaseResource {
981
+ /**
982
+ * Get the instance-wide storage summary: row counts per data category, the
983
+ * whole-DB size, and exact source-map weight.
984
+ */
985
+ async getSummary() {
986
+ const data = await this.http.get("api/storage/summary").json();
987
+ return this.validate(data, storageSummarySchema);
988
+ }
989
+ /**
990
+ * Get the per-project storage breakdown (one row per project, including
991
+ * empty ones).
992
+ */
993
+ async getProjects() {
994
+ const data = await this.http.get("api/storage/projects").json();
995
+ return this.validate(data, zod.z.array(projectStorageSchema));
996
+ }
997
+ /**
998
+ * Dry-run: count the rows a cleanup would remove. Mutates nothing — use it to
999
+ * confirm impact before {@link executeCleanup}.
1000
+ */
1001
+ async previewCleanup(options) {
1002
+ const json = cleanupOptionsSchema.parse(options);
1003
+ const data = await this.http.post("api/storage/cleanup/preview", { json }).json();
1004
+ return this.validate(data, cleanupCountsSchema);
1005
+ }
1006
+ /**
1007
+ * Execute a cleanup: delete data older than `older_than_days` (optionally
1008
+ * scoped to one project) and remove any issue left with zero events.
1009
+ */
1010
+ async executeCleanup(options) {
1011
+ const json = cleanupOptionsSchema.parse(options);
1012
+ const data = await this.http.post("api/storage/cleanup", { json }).json();
1013
+ return this.validate(data, cleanupCountsSchema);
1014
+ }
1015
+ /**
1016
+ * Dry-run for {@link gcSourceMaps}: count the orphaned source-map files and
1017
+ * bytes a GC would reclaim. Mutates nothing.
1018
+ */
1019
+ async previewGcSourceMaps() {
1020
+ const data = await this.http.post("api/storage/source-maps/gc/preview").json();
1021
+ return this.validate(data, sourceMapGcResultSchema);
1022
+ }
1023
+ /**
1024
+ * Garbage-collect orphaned source maps: files no longer referenced by any
1025
+ * upload, removed from the DB and unlinked from disk. Safe — never touches
1026
+ * referenced files.
1027
+ */
1028
+ async gcSourceMaps() {
1029
+ const data = await this.http.post("api/storage/source-maps/gc").json();
1030
+ return this.validate(data, sourceMapGcResultSchema);
1031
+ }
1032
+ };
920
1033
 
921
1034
  // src/resources/team.ts
922
1035
  var TeamResource = class extends BaseResource {
@@ -977,8 +1090,6 @@ var TokensResource = class extends BaseResource {
977
1090
  await this.http.delete(`api/tokens/${id}`);
978
1091
  }
979
1092
  };
980
-
981
- // src/resources/transactions.ts
982
1093
  var TransactionsResource = class extends BaseResource {
983
1094
  /**
984
1095
  * List transactions for a project with offset-based pagination (newest first)
@@ -991,6 +1102,21 @@ var TransactionsResource = class extends BaseResource {
991
1102
  if (options?.per_page) {
992
1103
  searchParams.per_page = String(options.per_page);
993
1104
  }
1105
+ if (options?.name) {
1106
+ searchParams.name = options.name;
1107
+ }
1108
+ if (options?.op) {
1109
+ searchParams.op = options.op;
1110
+ }
1111
+ if (options?.status) {
1112
+ searchParams.status = options.status;
1113
+ }
1114
+ if (options?.environment) {
1115
+ searchParams.environment = options.environment;
1116
+ }
1117
+ if (options?.release) {
1118
+ searchParams.release = options.release;
1119
+ }
994
1120
  const data = await this.http.get(`api/projects/${projectId}/transactions`, {
995
1121
  searchParams
996
1122
  }).json();
@@ -999,6 +1125,47 @@ var TransactionsResource = class extends BaseResource {
999
1125
  offsetPaginatedResponseSchema(transactionSchema)
1000
1126
  );
1001
1127
  }
1128
+ /**
1129
+ * Get the indexed spans extracted from a transaction, in waterfall order.
1130
+ */
1131
+ async getSpans(projectId, transactionId) {
1132
+ const data = await this.http.get(`api/projects/${projectId}/transactions/${transactionId}/spans`).json();
1133
+ return this.validate(data, zod.z.array(spanSchema));
1134
+ }
1135
+ /**
1136
+ * Get aggregate performance stats (count, p50/p95/p99 latency, failure rate)
1137
+ * grouped by transaction name + op, most frequent first, with offset-based
1138
+ * pagination — same shape as the other list endpoints.
1139
+ */
1140
+ async getStats(projectId, options) {
1141
+ const searchParams = {};
1142
+ if (options?.page) {
1143
+ searchParams.page = String(options.page);
1144
+ }
1145
+ if (options?.per_page) {
1146
+ searchParams.per_page = String(options.per_page);
1147
+ }
1148
+ const data = await this.http.get(`api/projects/${projectId}/transactions/stats`, { searchParams }).json();
1149
+ return this.validate(
1150
+ data,
1151
+ offsetPaginatedResponseSchema(transactionStatsSchema)
1152
+ );
1153
+ }
1154
+ /**
1155
+ * Get aggregate stats for a single (transaction name, op) group — a direct
1156
+ * lookup that works regardless of how many groups the project has. Throws
1157
+ * NotFoundError when the group has no transactions.
1158
+ */
1159
+ async getStatForGroup(projectId, name, op) {
1160
+ const searchParams = { name };
1161
+ if (op) {
1162
+ searchParams.op = op;
1163
+ }
1164
+ const data = await this.http.get(`api/projects/${projectId}/transactions/stats/group`, {
1165
+ searchParams
1166
+ }).json();
1167
+ return this.validate(data, transactionStatsSchema);
1168
+ }
1002
1169
  /**
1003
1170
  * Get a single transaction by ID with its full Sentry payload (spans,
1004
1171
  * contexts.trace, measurements, tags) for the performance detail view.
@@ -1127,6 +1294,10 @@ var RustrakClient = class {
1127
1294
  * Transactions API resource (performance monitoring)
1128
1295
  */
1129
1296
  transactions;
1297
+ /**
1298
+ * Storage API resource (usage + retention cleanup, admin only)
1299
+ */
1300
+ storage;
1130
1301
  /**
1131
1302
  * Health API resource (version info)
1132
1303
  */
@@ -1151,6 +1322,7 @@ var RustrakClient = class {
1151
1322
  this.members = new MembersResource(this.http);
1152
1323
  this.sessions = new SessionsResource(this.http);
1153
1324
  this.transactions = new TransactionsResource(this.http);
1325
+ this.storage = new StorageResource(this.http);
1154
1326
  this.health = new HealthResource(this.http);
1155
1327
  }
1156
1328
  };