@reproapp/node-sdk 0.0.26 → 0.0.28

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.
@@ -40,6 +40,18 @@ const kickIngestQueueDrain = () => {
40
40
  }
41
41
  };
42
42
  exports.kickIngestQueueDrain = kickIngestQueueDrain;
43
+ const isCriticalIngestEntry = (entry) => (entry.requestCaptureManifest !== undefined ||
44
+ entry.sessionCaptureManifest !== undefined ||
45
+ entry.request !== undefined ||
46
+ entry.db !== undefined ||
47
+ entry.trace !== undefined ||
48
+ entry.email !== undefined);
49
+ const resolveBatchPriority = (entries, options) => {
50
+ if (options.priority === 'high') {
51
+ return 'high';
52
+ }
53
+ return entries.some(isCriticalIngestEntry) ? 'high' : 'normal';
54
+ };
43
55
  const resolveIngestUrl = (config) => {
44
56
  const envBase = typeof process !== 'undefined' ? process?.env?.REPRO_INGEST_BASE : undefined;
45
57
  const ingestBase = String(envBase || config.ingestBase || DEFAULT_INGEST_BASE).replace(/\/+$/, '');
@@ -154,7 +166,7 @@ const drainIngestQueue = async () => {
154
166
  continue;
155
167
  }
156
168
  batch.attempts += 1;
157
- if (batch.attempts >= DEFAULT_QUEUE_MAX_ATTEMPTS) {
169
+ if (batch.attempts >= DEFAULT_QUEUE_MAX_ATTEMPTS && batch.priority !== 'high') {
158
170
  ingestQueue.shift();
159
171
  backoffMs = 0;
160
172
  continue;
@@ -175,7 +187,7 @@ const enqueueIngestEntries = (config, sessionId, entries, options = {}) => {
175
187
  if (!sessionId || !Array.isArray(entries) || entries.length === 0) {
176
188
  return false;
177
189
  }
178
- const priority = options.priority === 'high' ? 'high' : 'normal';
190
+ const priority = resolveBatchPriority(entries, options);
179
191
  const batch = {
180
192
  config: { ...config },
181
193
  sessionId,
@@ -197,13 +209,16 @@ const enqueueIngestEntries = (config, sessionId, entries, options = {}) => {
197
209
  }
198
210
  if (DEFAULT_QUEUE_MAX_ITEMS > 0 && ingestQueue.length > DEFAULT_QUEUE_MAX_ITEMS) {
199
211
  while (ingestQueue.length > DEFAULT_QUEUE_MAX_ITEMS) {
200
- let removeIndex = ingestQueue.length - 1;
212
+ let removeIndex = -1;
201
213
  for (let index = ingestQueue.length - 1; index >= 0; index -= 1) {
202
214
  if (ingestQueue[index]?.priority !== 'high') {
203
215
  removeIndex = index;
204
216
  break;
205
217
  }
206
218
  }
219
+ if (removeIndex === -1) {
220
+ break;
221
+ }
207
222
  ingestQueue.splice(removeIndex, 1);
208
223
  }
209
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reproapp/node-sdk",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "Repro Nest SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "build": "tsc -p tsconfig.json",
13
13
  "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
14
14
  "prepublishOnly": "npm run build",
15
- "test": "npm run build && node test/unawaited.test.js && node test/integration-unawaited.js && node test/request-flush-timing.test.js && node test/request-capture-background.test.js && node test/client-performance-regression.test.js && node test/request-manifest-priority.test.js && node test/runtime-no-double-invoke.test.js && node test/express-trace-http-args.test.js && node test/trace-batch-size.test.js && node test/sdk-background-priority.test.js && node test/ingest-queue-retention.test.js && node test/ingest-timeout.test.js && node -r ./tracer/register test/promise-map.test.js && node test/disable-subtree.test.js && node test/circular-capture.test.js && node test/wrap-plugin-arrow-args.test.js && node test/wrap-plugin-super-call.test.js && node test/function-arg-identity.test.js && node test/privacy-runtime-policy.test.js && node test/runtime-privacy-materialization.test.js && node test/kafka-runtime-privacy-policy.test.js && node test/amqplib-integration.test.js",
15
+ "test": "npm run build && node test/unawaited.test.js && node test/integration-unawaited.js && node test/request-flush-timing.test.js && node test/request-capture-background.test.js && node test/client-performance-regression.test.js && node test/request-manifest-priority.test.js && node test/runtime-no-double-invoke.test.js && node test/express-trace-http-args.test.js && node test/trace-batch-size.test.js && node test/sdk-background-priority.test.js && node test/ingest-queue-retention.test.js && node test/ingest-high-priority-retention.test.js && node test/ingest-critical-retention.test.js && node test/ingest-critical-retry-retention.test.js && node test/ingest-timeout.test.js && node -r ./tracer/register test/promise-map.test.js && node test/disable-subtree.test.js && node test/circular-capture.test.js && node test/wrap-plugin-arrow-args.test.js && node test/wrap-plugin-super-call.test.js && node test/function-arg-identity.test.js && node test/privacy-runtime-policy.test.js && node test/runtime-privacy-materialization.test.js && node test/kafka-runtime-privacy-policy.test.js && node test/amqplib-integration.test.js && node test/mongodb-integration.test.js",
16
16
  "test:containers": "npm run build && node test/runtime-no-double-invoke.testcontainers.test.js && node test/wrap-plugin-super-call.testcontainers.test.js && node test/function-arg-identity.testcontainers.test.js"
17
17
  },
18
18
  "peerDependencies": {