@rasputin-ai/core 0.5.0-alpha.4 → 0.5.0-alpha.5

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.js CHANGED
@@ -659,7 +659,7 @@ var resolveSourceMaps = async (frames) => {
659
659
 
660
660
  // src/sdk-meta.ts
661
661
  var SDK_NAME = "@rasputin-ai/core";
662
- var SDK_VERSION = "0.5.0-alpha.4";
662
+ var SDK_VERSION = "0.5.0-alpha.5";
663
663
 
664
664
  // src/suppression/identity-needs-message-template.ts
665
665
  var identityNeedsMessageTemplate = (type, code) => {
@@ -1169,6 +1169,76 @@ var createTransport = (options) => {
1169
1169
  return item.summary;
1170
1170
  }
1171
1171
  };
1172
+ const performFlush = async (timeoutMs) => {
1173
+ const controller = new AbortController();
1174
+ const timeout = timeoutMs > 0 ? setTimeout(() => controller.abort(), timeoutMs) : void 0;
1175
+ try {
1176
+ while (queue.size() > 0 || retryBatch) {
1177
+ if (controller.signal.aborted) break;
1178
+ const replaying = retryBatch !== null;
1179
+ const batch = retryBatch?.items ?? queue.drain(batchSize);
1180
+ const idempotencyKey = retryBatch?.idempotencyKey ?? crypto.randomUUID();
1181
+ retryBatch = null;
1182
+ if (batch.length === 0) break;
1183
+ if (replaying) batchReplays++;
1184
+ const events = [];
1185
+ const summaries = [];
1186
+ for (const item of batch) {
1187
+ if (item.kind === "summary") {
1188
+ summaries.push(await prepareSummary(item));
1189
+ continue;
1190
+ }
1191
+ if (options.prepareEvent && item.rawFrames.length > 0) {
1192
+ try {
1193
+ events.push(
1194
+ await options.prepareEvent({
1195
+ event: item.event,
1196
+ rawFrames: item.rawFrames
1197
+ })
1198
+ );
1199
+ } catch {
1200
+ events.push(item.event);
1201
+ }
1202
+ } else {
1203
+ events.push(item.event);
1204
+ }
1205
+ }
1206
+ const result = await sendBatch({
1207
+ ingestUrl: options.ingestUrl,
1208
+ projectApiKey: options.projectApiKey,
1209
+ events,
1210
+ summaries,
1211
+ idempotencyKey,
1212
+ sdkVersion: options.sdkVersion,
1213
+ sdkName: options.sdkName,
1214
+ gzipThresholdBytes,
1215
+ maxRetries,
1216
+ fetch: fetchFn,
1217
+ signal: controller.signal
1218
+ });
1219
+ sendAttempts += result.attempts;
1220
+ sendRetries += result.retries;
1221
+ networkErrors += result.networkErrors;
1222
+ rateLimitedResponses += result.rateLimitedResponses;
1223
+ serverErrorResponses += result.serverErrorResponses;
1224
+ if (result.aborted) flushTimeouts++;
1225
+ if (result.outcome === "ok") batchesSucceeded++;
1226
+ else {
1227
+ lastFailureKind = result.failureKind;
1228
+ lastFailureStatusCode = result.statusCode;
1229
+ if (result.outcome === "dropped") batchesDropped++;
1230
+ else batchesFailed++;
1231
+ }
1232
+ if (result.outcome === "failed") {
1233
+ retryBatch = { items: batch, idempotencyKey };
1234
+ break;
1235
+ }
1236
+ }
1237
+ } finally {
1238
+ if (timeout) clearTimeout(timeout);
1239
+ if (queue.size() === 0 && !retryBatch) stopTimer();
1240
+ }
1241
+ };
1172
1242
  const flush = async (timeoutMs = 1e4) => {
1173
1243
  if (!enabled || closed) {
1174
1244
  queue.clear();
@@ -1180,78 +1250,13 @@ var createTransport = (options) => {
1180
1250
  return flushing;
1181
1251
  }
1182
1252
  flushesStarted++;
1183
- flushing = (async () => {
1184
- const controller = new AbortController();
1185
- const timeout = timeoutMs > 0 ? setTimeout(() => controller.abort(), timeoutMs) : void 0;
1186
- try {
1187
- while (queue.size() > 0 || retryBatch) {
1188
- if (controller.signal.aborted) break;
1189
- const replaying = retryBatch !== null;
1190
- const batch = retryBatch?.items ?? queue.drain(batchSize);
1191
- const idempotencyKey = retryBatch?.idempotencyKey ?? crypto.randomUUID();
1192
- retryBatch = null;
1193
- if (batch.length === 0) break;
1194
- if (replaying) batchReplays++;
1195
- const events = [];
1196
- const summaries = [];
1197
- for (const item of batch) {
1198
- if (item.kind === "summary") {
1199
- summaries.push(await prepareSummary(item));
1200
- continue;
1201
- }
1202
- if (options.prepareEvent && item.rawFrames.length > 0) {
1203
- try {
1204
- events.push(
1205
- await options.prepareEvent({
1206
- event: item.event,
1207
- rawFrames: item.rawFrames
1208
- })
1209
- );
1210
- } catch {
1211
- events.push(item.event);
1212
- }
1213
- } else {
1214
- events.push(item.event);
1215
- }
1216
- }
1217
- const result = await sendBatch({
1218
- ingestUrl: options.ingestUrl,
1219
- projectApiKey: options.projectApiKey,
1220
- events,
1221
- summaries,
1222
- idempotencyKey,
1223
- sdkVersion: options.sdkVersion,
1224
- sdkName: options.sdkName,
1225
- gzipThresholdBytes,
1226
- maxRetries,
1227
- fetch: fetchFn,
1228
- signal: controller.signal
1229
- });
1230
- sendAttempts += result.attempts;
1231
- sendRetries += result.retries;
1232
- networkErrors += result.networkErrors;
1233
- rateLimitedResponses += result.rateLimitedResponses;
1234
- serverErrorResponses += result.serverErrorResponses;
1235
- if (result.aborted) flushTimeouts++;
1236
- if (result.outcome === "ok") batchesSucceeded++;
1237
- else {
1238
- lastFailureKind = result.failureKind;
1239
- lastFailureStatusCode = result.statusCode;
1240
- if (result.outcome === "dropped") batchesDropped++;
1241
- else batchesFailed++;
1242
- }
1243
- if (result.outcome === "failed") {
1244
- retryBatch = { items: batch, idempotencyKey };
1245
- break;
1246
- }
1247
- }
1248
- } finally {
1249
- if (timeout) clearTimeout(timeout);
1250
- if (queue.size() === 0 && !retryBatch) stopTimer();
1251
- flushing = void 0;
1252
- }
1253
- })();
1254
- return flushing;
1253
+ const activeFlush = performFlush(timeoutMs);
1254
+ flushing = activeFlush;
1255
+ try {
1256
+ await activeFlush;
1257
+ } finally {
1258
+ if (flushing === activeFlush) flushing = void 0;
1259
+ }
1255
1260
  };
1256
1261
  const enqueue = (event, priority = "first", rawFrames = []) => {
1257
1262
  if (!enabled || closed) return;
@@ -1,4 +1,4 @@
1
1
  /** Generated by scripts/generate-sdk-meta.ts — do not edit. */
2
2
  export declare const SDK_NAME = "@rasputin-ai/core";
3
- export declare const SDK_VERSION = "0.5.0-alpha.4";
3
+ export declare const SDK_VERSION = "0.5.0-alpha.5";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-transport.d.ts","sourceRoot":"","sources":["../../src/transport/create-transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAe,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAoCxF,eAAO,MAAM,eAAe,GAAI,SAAS,sBAAsB,KAAG,SA4NjE,CAAC"}
1
+ {"version":3,"file":"create-transport.d.ts","sourceRoot":"","sources":["../../src/transport/create-transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAe,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAoCxF,eAAO,MAAM,eAAe,GAAI,SAAS,sBAAsB,KAAG,SAoOjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasputin-ai/core",
3
- "version": "0.5.0-alpha.4",
3
+ "version": "0.5.0-alpha.5",
4
4
  "description": "Core error capture, stack parsing, and ingest transport for Rasputin AI.",
5
5
  "type": "module",
6
6
  "exports": {