@fetchbrain.com/sdk 0.10.0 → 0.12.0

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.
@@ -0,0 +1,1030 @@
1
+ import { createHmac, createHash } from 'crypto';
2
+ import { promisify } from 'util';
3
+ import { gzip } from 'zlib';
4
+
5
+ // src/analytics/block.ts
6
+ function detectBlockType(statusCode, errorMessage) {
7
+ if (!errorMessage) return void 0;
8
+ const msg = errorMessage?.toLowerCase() || "";
9
+ if (msg.includes("captcha")) return "captcha";
10
+ if (msg.includes("timeout")) return "timeout";
11
+ if (msg.includes("blocked")) return "blocked";
12
+ if (msg.includes("rate limit")) return "429";
13
+ return void 0;
14
+ }
15
+
16
+ // src/analytics/url.ts
17
+ var WORD = /^[A-Za-z]{1,19}$/;
18
+ var TWO_WORDS = /^[A-Za-z]+[-_][A-Za-z]+$/;
19
+ var FILE = /^[A-Za-z]{1,19}\.(?:html?|php|aspx?|jsp|xml|json|txt)$/i;
20
+ function keepSegment(raw) {
21
+ if (raw === "") return true;
22
+ if (raw.includes("%")) return false;
23
+ if (WORD.test(raw) || FILE.test(raw)) return true;
24
+ return raw.length <= 24 && TWO_WORDS.test(raw);
25
+ }
26
+ function generalizeUrlPath(url) {
27
+ try {
28
+ const path = new URL(url).pathname;
29
+ return path.split("/").map((s) => keepSegment(s) ? s : "*").join("/");
30
+ } catch {
31
+ return "/*";
32
+ }
33
+ }
34
+ var MAX_CONTEXT_KEYS = 3;
35
+ var MAX_CONTEXT_VALUE = 64;
36
+ var MAX_CONTEXT_SCAN = 32;
37
+ var MAX_CUSTOM_PROPS = 10;
38
+ var MAX_CUSTOM_STRING = 200;
39
+ var MAX_NAME = 64;
40
+ var KEY_RE = /^[A-Za-z0-9_.-]{1,40}$/;
41
+ var OVERFLOW_KEY = "~other";
42
+ var FIXED_EVENTS = /* @__PURE__ */ new Set([
43
+ "run_started",
44
+ "run_finished",
45
+ "request",
46
+ "enqueued",
47
+ "record_pushed",
48
+ "error",
49
+ "quota_reached"
50
+ ]);
51
+ function isPlainObject(v) {
52
+ return typeof v === "object" && v !== null && !Array.isArray(v);
53
+ }
54
+ function sanitizeContext(raw) {
55
+ if (!isPlainObject(raw)) return void 0;
56
+ try {
57
+ const out = {};
58
+ let n = 0;
59
+ let scanned = 0;
60
+ for (const key of Object.keys(raw)) {
61
+ if (n >= MAX_CONTEXT_KEYS || scanned++ >= MAX_CONTEXT_SCAN) break;
62
+ if (!KEY_RE.test(key)) continue;
63
+ const v = raw[key];
64
+ if (typeof v === "string") out[key] = v.slice(0, MAX_CONTEXT_VALUE);
65
+ else if (typeof v === "number" && Number.isFinite(v)) out[key] = v;
66
+ else continue;
67
+ n++;
68
+ }
69
+ return n > 0 ? out : void 0;
70
+ } catch {
71
+ return void 0;
72
+ }
73
+ }
74
+ var RESERVED_EVENTS = {
75
+ "antibot.challenge": { protection: { type: "string", required: true }, kind: { type: "string" } },
76
+ "antibot.solve": {
77
+ provider: { type: "string", required: true },
78
+ type: { type: "string" },
79
+ ms: { type: "number", required: true },
80
+ cost: { type: "number" },
81
+ ok: { type: "boolean", required: true }
82
+ },
83
+ "antibot.token_end": { reason: { type: "string", required: true }, requests: { type: "number" } }
84
+ };
85
+ function cleanValue(v) {
86
+ if (typeof v === "string") return v.slice(0, MAX_CUSTOM_STRING);
87
+ if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
88
+ if (typeof v === "boolean") return v;
89
+ return void 0;
90
+ }
91
+ function sanitizeCustom(name, props) {
92
+ if (typeof name !== "string" || name.length === 0 || name.length > MAX_NAME) return null;
93
+ if (name.startsWith("~") || FIXED_EVENTS.has(name)) return null;
94
+ try {
95
+ const src = isPlainObject(props) ? props : {};
96
+ const out = {};
97
+ if (name.startsWith("antibot.")) {
98
+ if (!Object.prototype.hasOwnProperty.call(RESERVED_EVENTS, name)) return null;
99
+ const schema = RESERVED_EVENTS[name];
100
+ for (const [key, spec] of Object.entries(schema)) {
101
+ const raw = src[key];
102
+ if (raw === void 0 || raw === null) {
103
+ if (spec.required) return null;
104
+ continue;
105
+ }
106
+ if (typeof raw !== spec.type) return null;
107
+ const v = cleanValue(raw);
108
+ if (v === void 0) return null;
109
+ out[key] = v;
110
+ }
111
+ return { name, props: out };
112
+ }
113
+ let n = 0;
114
+ for (const key of Object.keys(src)) {
115
+ if (n >= MAX_CUSTOM_PROPS) break;
116
+ if (!KEY_RE.test(key)) continue;
117
+ const v = cleanValue(src[key]);
118
+ if (v === void 0) continue;
119
+ out[key] = v;
120
+ n++;
121
+ }
122
+ return { name, props: out };
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ function hashClient(apifyUserId, salt) {
128
+ return createHmac("sha256", salt).update(apifyUserId).digest("hex").slice(0, 16);
129
+ }
130
+ var MAX_MESSAGE = 500;
131
+ var AUTHORITY_RE = /(?<![\w.])[\w.~%+-]+:[^\s"'<>]*@[\w.-]+(?::\d{1,5})?/g;
132
+ var URL_RE = /\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>)]+/gi;
133
+ var KEY_RE2 = /\b(?:apify_api_|sk_live_|sk_test_|gh[pousr]_|xox[baprs]-|fb_[A-Za-z]+_)[A-Za-z0-9_-]{8,}/g;
134
+ var KEYWORD_SECRET_RE = /\b(?:(?:bearer|basic|token|api[-_]?key|authorization|auth|password|passwd|pwd|secret|set-cookie|cookie|sessionid|session)(?![A-Za-z])(?:\s*[:=]|\s)\s*)+\S+/gi;
135
+ var JWT_RE = /\beyJ[\w-]*\.[\w-]+(?:\.[\w-]*)?/g;
136
+ var LONG_SECRET_RE = /(?<![\w+/=-])[A-Za-z0-9_+/-]{20,}={0,2}(?![\w+/=-])/g;
137
+ var UPPER_RE = /[A-Z]/g;
138
+ function isSecretRun(run) {
139
+ if (/[\d+=]/.test(run)) return true;
140
+ if (run.length >= 32) return true;
141
+ const uppers = run.match(UPPER_RE)?.length ?? 0;
142
+ return uppers >= 2 && uppers * 4 > run.length;
143
+ }
144
+ var EMAIL_RE = /[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g;
145
+ var UUID_RE = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
146
+ var IP_RE = /\b\d{1,3}(?:\.\d{1,3}){3}(?::\d{1,5})?(?!\d)/g;
147
+ var IP6_RE = /(?<![\w:])(?:(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){0,5}|::[0-9a-f]{1,4})(?![\w:])/gi;
148
+ var HOST_RE = /(?<![\w@.-])(?:[a-z0-9-]+\.)+([a-z]{2,24})(?::\d{1,5})?(?![\w-])(\/[^\s"'<>)]*)?/gi;
149
+ var FILE_EXT = new Set(
150
+ "ts js mjs cjs json py md lock txt html css yml yaml map tsx jsx log sh toml env".split(" ")
151
+ );
152
+ var STR_RE = /"[^"\n]*"|`[^`\n]*`|(?<![\w])'[^'\n]*'(?![\w])/g;
153
+ var PATH_RE = /(?<![\w<>.])(?:[A-Za-z]:)?(?:[\\/][\w.@~+-]+){2,}[\\/]?/g;
154
+ var REL_PATH_RE = /(?<![\w<>.:/\\-])(?:\.{1,2}[\\/][\w.@~+-]+(?:[\\/][\w.@~+-]+)*|[\w@~+-]+(?:[\\/][\w.@~+-]+){2,}|[\w@~+-]+[\\/][\w@~+-]+\.\w{1,5})/g;
155
+ var NUM_RE = /(?<![A-Za-z_<])\d+(?:\.\d+)?/g;
156
+ function scrubMessage(msg) {
157
+ return String(msg ?? "").slice(0, MAX_MESSAGE * 4).replace(AUTHORITY_RE, "<url>").replace(URL_RE, "<url>").replace(KEY_RE2, "<secret>").replace(JWT_RE, "<secret>").replace(KEYWORD_SECRET_RE, "<secret>").replace(EMAIL_RE, "<email>").replace(UUID_RE, "<uuid>").replace(IP_RE, "<ip>").replace(IP6_RE, "<ip>").replace(HOST_RE, (m, tld, path) => FILE_EXT.has(tld.toLowerCase()) ? m : path ? "<url>" : "<host>").replace(LONG_SECRET_RE, (m) => isSecretRun(m) ? "<secret>" : m).replace(STR_RE, "<str>").replace(PATH_RE, "<path>").replace(REL_PATH_RE, "<path>").replace(NUM_RE, "<n>").slice(0, MAX_MESSAGE);
158
+ }
159
+ var FRAME_RE = /^\s*at\s+(?:(.*?)\s+\()?(.*?):\d+(?::\d+)?\)?\s*$/;
160
+ function topProjectFrame(stack) {
161
+ if (!stack) return void 0;
162
+ for (const line of stack.split("\n")) {
163
+ const m = FRAME_RE.exec(line);
164
+ if (!m) continue;
165
+ const loc = m[2];
166
+ if (loc.includes("node_modules") || loc.startsWith("node:") || loc.startsWith("internal/")) continue;
167
+ const file = loc.split(/[\\/]/).pop() || loc;
168
+ const fn = (m[1] ?? "").replace(/^(?:async|new)\s+/, "").trim();
169
+ return `${file}:${fn || "<anonymous>"}`;
170
+ }
171
+ return void 0;
172
+ }
173
+ function fingerprint(errorClass, scrubbed, frame) {
174
+ return createHash("sha256").update(`${errorClass}
175
+ ${scrubbed}
176
+ ${frame ?? ""}`).digest("hex").slice(0, 16);
177
+ }
178
+
179
+ // src/analytics/aggregates.ts
180
+ var BUCKETS = 32;
181
+ var MAX_MS = 12e4;
182
+ var LOG_R = Math.log(MAX_MS) / (BUCKETS - 1);
183
+ function bucketOf(ms) {
184
+ if (!(ms > 1)) return 0;
185
+ const k = Math.ceil(Math.log(ms) / LOG_R);
186
+ return k >= BUCKETS ? BUCKETS - 1 : k;
187
+ }
188
+ function percentile(h, total, p) {
189
+ if (total === 0) return void 0;
190
+ const rank = Math.ceil(total * p);
191
+ let seen = 0;
192
+ for (let k = 0; k < BUCKETS; k++) {
193
+ seen += h[k];
194
+ if (seen >= rank) return k === 0 ? 1 : Math.round(Math.exp((k - 0.5) * LOG_R));
195
+ }
196
+ return MAX_MS;
197
+ }
198
+ var REPORT_PATTERNS = 50;
199
+ var MAX_LIVE_PATTERNS = 300;
200
+ var MAX_NAMES = 50;
201
+ var MAX_PROPS = 10;
202
+ var MAX_TOP = 20;
203
+ var MAX_LABELS_PER_NAME = 50;
204
+ function newPattern(label) {
205
+ return { label, requests: 0, scraped: 0, blocked: 0, failed: 0, nav: new Uint32Array(BUCKETS), navN: 0 };
206
+ }
207
+ var newCustom = () => ({ count: 0, labels: /* @__PURE__ */ new Map(), props: /* @__PURE__ */ new Map() });
208
+ function toStats(p) {
209
+ const out = {
210
+ label: p.label,
211
+ requests: p.requests,
212
+ scraped: p.scraped,
213
+ blocked: p.blocked,
214
+ failed: p.failed
215
+ };
216
+ const navP95 = percentile(p.nav, p.navN, 0.95);
217
+ if (navP95 !== void 0) out.navP95 = navP95;
218
+ return out;
219
+ }
220
+ var Aggregates = class {
221
+ constructor() {
222
+ this.patterns = /* @__PURE__ */ new Map();
223
+ this.custom_ = /* @__PURE__ */ new Map();
224
+ }
225
+ /** One real request at its final outcome (weight 1). O(1). */
226
+ request(label, urlPattern, outcome, navMs) {
227
+ let p = this.patterns.get(urlPattern);
228
+ if (!p) {
229
+ if (this.patterns.size < MAX_LIVE_PATTERNS) {
230
+ p = newPattern(label);
231
+ this.patterns.set(urlPattern, p);
232
+ } else {
233
+ p = this.overflow ?? (this.overflow = newPattern(""));
234
+ }
235
+ }
236
+ p.requests++;
237
+ if (outcome === "scraped") p.scraped++;
238
+ else if (outcome === "blocked") p.blocked++;
239
+ else if (outcome === "failed") p.failed++;
240
+ if (typeof navMs === "number" && Number.isFinite(navMs)) {
241
+ p.nav[bucketOf(navMs)]++;
242
+ p.navN++;
243
+ }
244
+ }
245
+ /** A developer event (never antibot.*, never sampled). Props are already sanitized. */
246
+ custom(name, label, props, weight = 1) {
247
+ if (name.startsWith("antibot.")) return;
248
+ const w = typeof weight === "number" && Number.isFinite(weight) && weight > 0 ? weight : 1;
249
+ let c = this.custom_.get(name);
250
+ if (!c) {
251
+ if (this.custom_.size < MAX_NAMES) {
252
+ c = newCustom();
253
+ this.custom_.set(name, c);
254
+ } else {
255
+ c = this.otherName ?? (this.otherName = newCustom());
256
+ }
257
+ }
258
+ c.count += w;
259
+ const lk = c.labels.has(label) || c.labels.size < MAX_LABELS_PER_NAME ? label : OVERFLOW_KEY;
260
+ c.labels.set(lk, (c.labels.get(lk) ?? 0) + w);
261
+ for (const key of Object.keys(props)) {
262
+ const v = props[key];
263
+ let ps = c.props.get(key);
264
+ if (!ps) {
265
+ if (c.props.size >= MAX_PROPS) continue;
266
+ ps = typeof v === "string" ? { kind: "s", top: /* @__PURE__ */ new Map(), other: 0 } : typeof v === "number" ? { kind: "n", sum: 0, min: Infinity, max: -Infinity } : { kind: "b", true: 0, false: 0 };
267
+ c.props.set(key, ps);
268
+ }
269
+ if (ps.kind === "s" && typeof v === "string") {
270
+ if (ps.top.has(v) || ps.top.size < MAX_TOP) ps.top.set(v, (ps.top.get(v) ?? 0) + w);
271
+ else ps.other += w;
272
+ } else if (ps.kind === "n" && typeof v === "number" && Number.isFinite(v)) {
273
+ ps.sum += v * w;
274
+ if (v < ps.min) ps.min = v;
275
+ if (v > ps.max) ps.max = v;
276
+ } else if (ps.kind === "b" && typeof v === "boolean") {
277
+ if (v) ps.true += w;
278
+ else ps.false += w;
279
+ }
280
+ }
281
+ }
282
+ toReport() {
283
+ const patterns = {};
284
+ const ranked = [...this.patterns.entries()].sort((a, b) => b[1].requests - a[1].requests);
285
+ const keep = ranked.slice(0, REPORT_PATTERNS);
286
+ for (const [k, p] of keep) patterns[k] = toStats(p);
287
+ const rest = ranked.slice(REPORT_PATTERNS).map((e) => e[1]);
288
+ if (this.overflow) rest.push(this.overflow);
289
+ if (rest.length > 0) {
290
+ const o = newPattern("");
291
+ for (const p of rest) {
292
+ o.requests += p.requests;
293
+ o.scraped += p.scraped;
294
+ o.blocked += p.blocked;
295
+ o.failed += p.failed;
296
+ o.navN += p.navN;
297
+ for (let i = 0; i < BUCKETS; i++) o.nav[i] += p.nav[i];
298
+ }
299
+ patterns[OVERFLOW_KEY] = toStats(o);
300
+ }
301
+ const custom = {};
302
+ for (const [n, c] of this.custom_) custom[n] = customReport(c);
303
+ if (this.otherName) custom[OVERFLOW_KEY] = customReport(this.otherName);
304
+ return { patterns, custom };
305
+ }
306
+ };
307
+ function customReport(c) {
308
+ const props = {};
309
+ for (const [k, p] of c.props) {
310
+ if (p.kind === "s") props[k] = p.other > 0 ? { kind: "s", top: Object.fromEntries(p.top), other: p.other } : { kind: "s", top: Object.fromEntries(p.top) };
311
+ else if (p.kind === "n") props[k] = p.min > p.max ? { kind: "n", sum: 0, min: 0, max: 0 } : { ...p };
312
+ else props[k] = { ...p };
313
+ }
314
+ return { count: c.count, labels: Object.fromEntries(c.labels), props };
315
+ }
316
+ var gzipAsync = promisify(gzip);
317
+ var MAX_BATCH_BYTES = 200 * 1024;
318
+ var EVENTS_MARK = "\0fetchbrain-events\0";
319
+ var EVENTS_MARK_JSON = JSON.stringify(EVENTS_MARK);
320
+ var eventsPlaceholder = { toJSON: () => EVENTS_MARK };
321
+ var MAX_SEQ = 1e12;
322
+ function startSeqFromEnv(env = process.env, now = Date.now()) {
323
+ try {
324
+ const raw = env.APIFY_STARTED_AT || env.ACTOR_STARTED_AT;
325
+ if (!raw) return 0;
326
+ const startedAt = Date.parse(raw);
327
+ if (!Number.isFinite(startedAt)) return 0;
328
+ const seq = Math.max(0, Math.floor((now - startedAt) / 1e3)) * 1e3;
329
+ return Number.isSafeInteger(seq) && seq < MAX_SEQ ? seq : 0;
330
+ } catch {
331
+ return 0;
332
+ }
333
+ }
334
+ var MAX_PAUSE_MS = 24 * 60 * 60 * 1e3;
335
+ var BACKOFF_BASE_MS = 5e3;
336
+ var BACKOFF_MAX_MS = 6e4;
337
+ var AnalyticsQueue = class {
338
+ constructor(send, opts = {}) {
339
+ this.send = send;
340
+ this.dropped = 0;
341
+ this.sampleRate = 1;
342
+ /** The last batch was cut by size: keep sending instead of waiting for a full batch. */
343
+ this.cut = false;
344
+ // Absolute indexes: the oldest event is `startIdx`, the next write is `endIdx`.
345
+ this.startIdx = 0;
346
+ this.endIdx = 0;
347
+ this.generation = 0;
348
+ this.failures = 0;
349
+ this.notBefore = 0;
350
+ // backoff gate
351
+ this.pausedUntil = 0;
352
+ /** Extras that did not fit the previous batch (pathological label counts); at most maxBatch. */
353
+ this.carry = [];
354
+ const startSeq = opts.startSeq;
355
+ this.nextSeq = typeof startSeq === "number" && Number.isSafeInteger(startSeq) && startSeq >= 0 && startSeq < MAX_SEQ ? startSeq : 0;
356
+ this.maxBatch = opts.maxBatch ?? 250;
357
+ this.flushMs = opts.flushMs ?? 3e4;
358
+ this.capacity = opts.capacity ?? 1e4;
359
+ this.finalFlushTimeoutMs = opts.finalFlushTimeoutMs ?? 1800;
360
+ this.maxBatchAttempts = opts.maxBatchAttempts ?? 5;
361
+ this.maxBatchAgeMs = opts.maxBatchAgeMs ?? 6e5;
362
+ this.maxBatchBytes = opts.maxBatchBytes ?? MAX_BATCH_BYTES;
363
+ this.compress = opts.compress ?? ((j) => gzipAsync(j));
364
+ this.wrap = opts.wrap ?? ((events) => events);
365
+ this.ring = new Array(this.capacity);
366
+ }
367
+ /** Events currently buffered. */
368
+ get size() {
369
+ return this.endIdx - this.startIdx;
370
+ }
371
+ /** Hold every send until `until` (epoch ms), clamped to ≤24 h ahead, like a server pause. NaN is ignored. */
372
+ pause(until) {
373
+ if (typeof until !== "number" || Number.isNaN(until)) return;
374
+ this.pausedUntil = Math.max(this.pausedUntil, Math.min(until, Date.now() + MAX_PAUSE_MS));
375
+ }
376
+ setBeforeFlush(fn) {
377
+ this.beforeFlush = fn;
378
+ }
379
+ push(e) {
380
+ if (this.endIdx - this.startIdx >= this.capacity) {
381
+ this.ring[this.startIdx % this.capacity] = void 0;
382
+ this.startIdx++;
383
+ this.dropped++;
384
+ }
385
+ this.ring[this.endIdx % this.capacity] = e;
386
+ this.endIdx++;
387
+ if (this.endIdx - this.startIdx >= this.maxBatch && this.canKick()) this.kick();
388
+ }
389
+ start() {
390
+ if (this.timer) clearInterval(this.timer);
391
+ this.timer = setInterval(() => this.kick(), this.flushMs);
392
+ this.timer.unref();
393
+ }
394
+ async stop() {
395
+ if (this.timer) clearInterval(this.timer);
396
+ this.timer = void 0;
397
+ if (this.retryTimer) clearTimeout(this.retryTimer);
398
+ this.retryTimer = void 0;
399
+ let deadline;
400
+ const timeout = new Promise((resolve) => {
401
+ deadline = setTimeout(resolve, this.finalFlushTimeoutMs);
402
+ deadline.unref();
403
+ });
404
+ try {
405
+ await Promise.race([this.drain(), timeout]);
406
+ } catch {
407
+ } finally {
408
+ if (deadline) clearTimeout(deadline);
409
+ if (this.inflight) {
410
+ this.generation++;
411
+ this.abort?.abort();
412
+ if (this.current && !this.pending) this.pending = this.current;
413
+ this.current = void 0;
414
+ this.inflight = void 0;
415
+ }
416
+ }
417
+ }
418
+ /** Synchronous gate so a gated push() allocates nothing. */
419
+ canKick() {
420
+ if (this.inflight || !this.timer) return false;
421
+ const now = Date.now();
422
+ return now >= this.notBefore && now >= this.pausedUntil;
423
+ }
424
+ kick() {
425
+ void this.flush(false).catch(() => {
426
+ });
427
+ }
428
+ async drain() {
429
+ const gen = this.generation;
430
+ if (this.inflight) await this.inflight.catch(() => false);
431
+ if (gen !== this.generation) return;
432
+ await this.flush(true);
433
+ }
434
+ /** Send batches until the ring has less than a full batch (or, when final, is empty). */
435
+ async flush(final) {
436
+ if (this.inflight) return;
437
+ const gen = this.generation;
438
+ const run = (async () => {
439
+ let ok2 = true;
440
+ for (; ; ) {
441
+ if (gen !== this.generation) return false;
442
+ const now = Date.now();
443
+ if (now < this.pausedUntil) return ok2;
444
+ if (!final && now < this.notBefore) return ok2;
445
+ ok2 = await this.sendOne(gen);
446
+ if (!ok2 || gen !== this.generation) return false;
447
+ const left = this.size;
448
+ if (left === 0 && this.carry.length === 0) return true;
449
+ if (!final && left < this.maxBatch && this.carry.length === 0 && !this.cut) return true;
450
+ }
451
+ })();
452
+ this.inflight = run;
453
+ let ok = false;
454
+ try {
455
+ ok = await run;
456
+ } catch {
457
+ ok = false;
458
+ }
459
+ if (gen !== this.generation) return;
460
+ this.inflight = void 0;
461
+ if (!ok) this.scheduleRetry();
462
+ }
463
+ scheduleRetry() {
464
+ if (this.retryTimer) clearTimeout(this.retryTimer);
465
+ if (!this.timer) return;
466
+ const wait = Math.max(0, this.notBefore - Date.now(), this.pausedUntil - Date.now());
467
+ this.retryTimer = setTimeout(() => this.kick(), wait);
468
+ this.retryTimer.unref();
469
+ }
470
+ /** Build and send one batch. True on success or when there was nothing to send. */
471
+ async sendOne(gen) {
472
+ let job = this.pending;
473
+ if (!job) {
474
+ let extras = [];
475
+ try {
476
+ extras = this.beforeFlush?.() ?? [];
477
+ } catch {
478
+ extras = [];
479
+ }
480
+ if (this.carry.length > 0) {
481
+ extras = this.carry.concat(extras);
482
+ this.carry = [];
483
+ }
484
+ if (extras.length > this.maxBatch) {
485
+ this.setCarry(extras.slice(this.maxBatch));
486
+ extras = extras.slice(0, this.maxBatch);
487
+ }
488
+ const n = Math.min(this.size, this.maxBatch - extras.length);
489
+ if (n === 0 && extras.length === 0) return true;
490
+ const b0 = this.startIdx;
491
+ const batch = [];
492
+ for (let i = 0; i < n; i++) batch.push(this.ring[(b0 + i) % this.capacity]);
493
+ for (const e of extras) batch.push(e);
494
+ const seq = this.nextSeq++;
495
+ let built;
496
+ try {
497
+ built = this.serialize(batch, seq);
498
+ } catch {
499
+ this.consume(b0, n);
500
+ return true;
501
+ }
502
+ this.cut = built.k < batch.length;
503
+ if (built.k < n) {
504
+ this.setCarry(extras.concat(this.carry));
505
+ job = { seq, batch: batch.slice(0, built.k), b0, n: built.k, attempts: 0, firstAt: Date.now(), json: built.json };
506
+ } else {
507
+ if (built.k < batch.length) this.setCarry(extras.slice(built.k - n).concat(this.carry));
508
+ job = { seq, batch: batch.slice(0, built.k), b0, n, attempts: 0, firstAt: Date.now(), json: built.json };
509
+ }
510
+ }
511
+ this.current = job;
512
+ const ac = new AbortController();
513
+ this.abort = ac;
514
+ let gz;
515
+ try {
516
+ if (!job.gz) {
517
+ job.gz = await this.compress(job.json ?? JSON.stringify(this.wrap(job.batch, job.seq)));
518
+ job.json = void 0;
519
+ }
520
+ gz = job.gz;
521
+ } catch {
522
+ if (gen !== this.generation) return false;
523
+ this.current = void 0;
524
+ this.pending = void 0;
525
+ this.consume(job.b0, job.n);
526
+ return true;
527
+ }
528
+ if (gen !== this.generation) return false;
529
+ let result = null;
530
+ try {
531
+ result = await this.send(gz, ac.signal);
532
+ } catch {
533
+ result = null;
534
+ }
535
+ if (gen !== this.generation) return false;
536
+ this.current = void 0;
537
+ if (result === null) {
538
+ job.attempts++;
539
+ this.failures++;
540
+ const delay = Math.min(BACKOFF_BASE_MS * 2 ** (this.failures - 1), BACKOFF_MAX_MS);
541
+ this.notBefore = Date.now() + delay;
542
+ if (job.attempts >= this.maxBatchAttempts || Date.now() - job.firstAt >= this.maxBatchAgeMs) {
543
+ this.dropped += job.batch.length;
544
+ this.pending = void 0;
545
+ this.consume(job.b0, job.n);
546
+ } else {
547
+ this.pending = job;
548
+ }
549
+ return false;
550
+ }
551
+ if (result.retry) {
552
+ if (typeof result.pauseUntil === "number") this.pause(result.pauseUntil);
553
+ if (Date.now() - job.firstAt >= this.maxBatchAgeMs) {
554
+ this.dropped += job.batch.length;
555
+ this.pending = void 0;
556
+ this.consume(job.b0, job.n);
557
+ } else {
558
+ this.pending = job;
559
+ }
560
+ return false;
561
+ }
562
+ this.failures = 0;
563
+ this.notBefore = 0;
564
+ if (typeof result.pauseUntil === "number") this.pause(result.pauseUntil);
565
+ if (result.drop) {
566
+ this.dropped += job.batch.length;
567
+ this.pending = void 0;
568
+ this.consume(job.b0, job.n);
569
+ return true;
570
+ }
571
+ if (typeof result.sampleRate === "number") this.sampleRate = result.sampleRate;
572
+ this.pending = void 0;
573
+ this.consume(job.b0, job.n);
574
+ return true;
575
+ }
576
+ /**
577
+ * The payload for the longest prefix of `batch` that fits maxBatchBytes (at least one event, so a
578
+ * lone oversized event can't stall the queue; the API refuses it and it is dropped). Each event is
579
+ * serialized once. Throws only if an event can't be serialized.
580
+ */
581
+ serialize(batch, seq) {
582
+ const envelope = JSON.stringify(this.wrap(eventsPlaceholder, seq));
583
+ const at = envelope.indexOf(EVENTS_MARK_JSON);
584
+ if (at < 0) return { json: JSON.stringify(this.wrap(batch, seq)), k: batch.length };
585
+ let bytes = Buffer.byteLength(envelope) - Buffer.byteLength(EVENTS_MARK_JSON) + 2;
586
+ const parts = [];
587
+ for (const e of batch) {
588
+ const part = JSON.stringify(e);
589
+ const b = Buffer.byteLength(part) + (parts.length > 0 ? 1 : 0);
590
+ if (parts.length > 0 && bytes + b > this.maxBatchBytes) break;
591
+ parts.push(part);
592
+ bytes += b;
593
+ }
594
+ const json = envelope.slice(0, at) + "[" + parts.join(",") + "]" + envelope.slice(at + EVENTS_MARK_JSON.length);
595
+ return { json, k: parts.length };
596
+ }
597
+ /** Extras waiting for a later batch, bounded to one batch (the oldest beyond it drop, counted). */
598
+ setCarry(events) {
599
+ const over = events.length - this.maxBatch;
600
+ if (over > 0) {
601
+ this.dropped += over;
602
+ events = events.slice(over);
603
+ }
604
+ this.carry = events;
605
+ }
606
+ consume(b0, n) {
607
+ const newStart = Math.max(this.startIdx, b0 + n);
608
+ for (let i = this.startIdx; i < newStart; i++) this.ring[i % this.capacity] = void 0;
609
+ this.startIdx = newStart;
610
+ }
611
+ };
612
+
613
+ // src/analytics/collector.ts
614
+ var SDK_VERSION = "0.12.0" ;
615
+ var BLOCKED_STATUS = /* @__PURE__ */ new Set([403, 429, 503]);
616
+ var BLOCKED_MESSAGE_TYPES = /* @__PURE__ */ new Set(["captcha", "blocked", "429"]);
617
+ var MAX_LABELS = 50;
618
+ var MAX_STATUS_CODES = 20;
619
+ var MAX_CHILD_LABELS = 50;
620
+ var SAMPLE_THRESHOLD = 200;
621
+ var SLOTS = 10;
622
+ var SLOT_MS = 1e3;
623
+ var ROUTINE = /* @__PURE__ */ new Set(["scraped", "recalled", "skipped"]);
624
+ var MAX_FINGERPRINTS = 1e3;
625
+ var MAX_RAW_KEYS = 2e3;
626
+ var RAW_KEY_CHARS = 300;
627
+ var OVERFLOW_FINGERPRINT = "overflow";
628
+ var MAX_REJECTED_NAMES_LOGGED = 100;
629
+ function errorClassOf(err) {
630
+ try {
631
+ if (err instanceof Error) {
632
+ const n = err.constructor?.name || err.name;
633
+ return typeof n === "string" && /^[\w$.]{1,64}$/.test(n) ? n : "Error";
634
+ }
635
+ return err === null ? "null" : typeof err;
636
+ } catch {
637
+ return "Error";
638
+ }
639
+ }
640
+ function rawMessageOf(err) {
641
+ try {
642
+ if (err instanceof Error) return typeof err.message === "string" ? err.message : String(err.message);
643
+ if (typeof err === "string") return err;
644
+ return String(err);
645
+ } catch {
646
+ return "";
647
+ }
648
+ }
649
+ function stackOf(err) {
650
+ try {
651
+ const s = err?.stack;
652
+ return typeof s === "string" ? s : void 0;
653
+ } catch {
654
+ return void 0;
655
+ }
656
+ }
657
+ var hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
658
+ function newLabelState() {
659
+ return {
660
+ stats: {
661
+ requests: 0,
662
+ scraped: 0,
663
+ recalled: 0,
664
+ skipped: 0,
665
+ bypassed: 0,
666
+ failed: 0,
667
+ blocked: 0,
668
+ blockedAttempts: 0,
669
+ retries: 0,
670
+ records: 0,
671
+ bytes: 0,
672
+ // Keyed by developer labels: no prototype, so "__proto__" is an ordinary key.
673
+ enqueued: /* @__PURE__ */ Object.create(null),
674
+ alreadyQueued: /* @__PURE__ */ Object.create(null),
675
+ status: {}
676
+ },
677
+ pendingRecords: 0,
678
+ nav: new Uint32Array(BUCKETS),
679
+ navN: 0,
680
+ handler: new Uint32Array(BUCKETS),
681
+ handlerN: 0
682
+ };
683
+ }
684
+ function domainOf(url) {
685
+ try {
686
+ return new URL(url).hostname;
687
+ } catch {
688
+ return "";
689
+ }
690
+ }
691
+ var isNum = (v) => typeof v === "number" && Number.isFinite(v);
692
+ var RESERVED_PROPS = /* @__PURE__ */ new Set([
693
+ "client",
694
+ "scraper",
695
+ "runId",
696
+ "seq",
697
+ "ts",
698
+ "label",
699
+ "crawlerType",
700
+ "sdkVersion",
701
+ "platform",
702
+ "weight",
703
+ "context"
704
+ ]);
705
+ var Collector = class {
706
+ constructor(queue, base, opts = {}) {
707
+ this.queue = queue;
708
+ this.base = base;
709
+ this.seq = 0;
710
+ this.labels = /* @__PURE__ */ new Map();
711
+ this.aggregates = new Aggregates();
712
+ // Rate window state.
713
+ this.slots = new Uint32Array(SLOTS);
714
+ this.slotAbs = -1;
715
+ // absolute index (time / SLOT_MS) of the newest slot
716
+ this.windowSum = 0;
717
+ // Error grouping.
718
+ this.groups = /* @__PURE__ */ new Map();
719
+ this.rawKeys = /* @__PURE__ */ new Map();
720
+ // class+message+frame -> fingerprint
721
+ this.rejectedNames = /* @__PURE__ */ new Set();
722
+ const start = opts.startSeq;
723
+ if (typeof start === "number" && Number.isSafeInteger(start) && start > 0) this.seq = start;
724
+ this.now = opts.now ?? Date.now;
725
+ this.random = opts.random ?? Math.random;
726
+ this.debug = opts.debug ?? (() => {
727
+ });
728
+ queue.setBeforeFlush(() => this.drainRecords());
729
+ }
730
+ /** Validated `context` keys from the developer's callback result (≤3 keys, values ≤64 chars). */
731
+ sanitizeContext(raw) {
732
+ return sanitizeContext(raw);
733
+ }
734
+ /** Salted buyer hash; exposed here so enhance.ts never imports events.ts statically. */
735
+ static hashClient(apifyUserId, salt) {
736
+ return hashClient(apifyUserId, salt);
737
+ }
738
+ label(label) {
739
+ let s = this.labels.get(label);
740
+ if (s) return s;
741
+ const key = this.labels.size < MAX_LABELS ? label : OVERFLOW_KEY;
742
+ s = this.labels.get(key);
743
+ if (!s) {
744
+ s = newLabelState();
745
+ this.labels.set(key, s);
746
+ }
747
+ return s;
748
+ }
749
+ /** Base props, applied last so no caller field can overwrite them. */
750
+ props(label) {
751
+ return { ...this.base, seq: this.seq++, ts: Date.now(), label };
752
+ }
753
+ /**
754
+ * Block type of a failed attempt, or undefined when it was not blocked. Blocked =
755
+ * status 403/429/503 or a captcha/blocked/rate-limit message; 404, 500, timeouts
756
+ * and plain handler errors are failures, not blocks.
757
+ */
758
+ blockType(statusCode, message) {
759
+ if (statusCode !== void 0 && BLOCKED_STATUS.has(statusCode)) return String(statusCode);
760
+ const byMsg = message ? detectBlockType(void 0, message) : void 0;
761
+ return byMsg !== void 0 && BLOCKED_MESSAGE_TYPES.has(byMsg) ? byMsg : void 0;
762
+ }
763
+ request(p) {
764
+ const s = this.label(p.label);
765
+ const st = s.stats;
766
+ st.requests++;
767
+ st[p.outcome]++;
768
+ st.retries += p.retries;
769
+ const blockedAttempts = p.blockedAttempts ?? 0;
770
+ st.blockedAttempts += blockedAttempts;
771
+ if (isNum(p.bytes)) st.bytes += p.bytes;
772
+ if (isNum(p.navMs)) {
773
+ s.nav[bucketOf(p.navMs)]++;
774
+ s.navN++;
775
+ }
776
+ if (isNum(p.handlerMs)) {
777
+ s.handler[bucketOf(p.handlerMs)]++;
778
+ s.handlerN++;
779
+ }
780
+ if (isNum(p.statusCode)) {
781
+ const code = String(p.statusCode);
782
+ if (code in st.status || Object.keys(st.status).length < MAX_STATUS_CODES) {
783
+ st.status[code] = (st.status[code] ?? 0) + 1;
784
+ } else {
785
+ st.status.other = (st.status.other ?? 0) + 1;
786
+ }
787
+ }
788
+ const urlPattern = generalizeUrlPath(p.url);
789
+ this.aggregates.request(p.label, urlPattern, p.outcome, isNum(p.navMs) ? p.navMs : void 0);
790
+ const keep = this.sampleRequest(p.outcome);
791
+ if (keep === 0) return;
792
+ let context;
793
+ if (typeof p.context === "function") {
794
+ try {
795
+ context = p.context();
796
+ } catch {
797
+ context = void 0;
798
+ }
799
+ } else {
800
+ context = p.context;
801
+ }
802
+ const event = {
803
+ name: "request",
804
+ props: {
805
+ outcome: p.outcome,
806
+ retries: p.retries,
807
+ statusCode: p.statusCode,
808
+ domain: domainOf(p.url),
809
+ urlPattern,
810
+ navMs: p.navMs,
811
+ handlerMs: p.handlerMs,
812
+ recallMs: p.recallMs,
813
+ bytes: p.bytes,
814
+ blockType: p.blockType,
815
+ blockedAttempts,
816
+ context,
817
+ // Absent weight = 1 (every non-sampled event).
818
+ weight: keep === 1 ? void 0 : keep,
819
+ ...this.props(p.label)
820
+ }
821
+ };
822
+ this.queue.push(event);
823
+ }
824
+ /** Requests/s over the last 10 s; counts this request. O(1) amortized. */
825
+ tickRate() {
826
+ const t = this.now();
827
+ const abs = Math.floor(t / SLOT_MS);
828
+ if (this.slotAbs < 0) this.slotAbs = abs;
829
+ if (abs > this.slotAbs) {
830
+ const gap = Math.min(abs - this.slotAbs, SLOTS);
831
+ for (let i = 1; i <= gap; i++) {
832
+ const k = (this.slotAbs + i) % SLOTS;
833
+ this.windowSum -= this.slots[k];
834
+ this.slots[k] = 0;
835
+ }
836
+ this.slotAbs = abs;
837
+ }
838
+ this.slots[this.slotAbs % SLOTS]++;
839
+ this.windowSum++;
840
+ return this.windowSum / (SLOTS * SLOT_MS / 1e3);
841
+ }
842
+ /**
843
+ * 0 = drop, 1 = keep with weight 1, otherwise keep with this weight (1/p).
844
+ * Only routine scraped/recalled/skipped events are sampled, and only above
845
+ * 200 requests/s or when the server asked for a lower sampleRate.
846
+ */
847
+ sampleRequest(outcome) {
848
+ const rate = this.tickRate();
849
+ if (!ROUTINE.has(outcome)) return 1;
850
+ const sr = this.queue.sampleRate;
851
+ const serverRate = typeof sr === "number" && sr > 0 && sr <= 1 ? sr : 1;
852
+ const p = Math.min(1, SAMPLE_THRESHOLD / rate) * serverRate;
853
+ if (!(p > 0) || p >= 1) return 1;
854
+ return this.random() < p ? 1 / p : 0;
855
+ }
856
+ /** Records pushed (dataset items). Summed per label; sent as one record_pushed per label per batch. */
857
+ records(label, count) {
858
+ if (!isNum(count) || count <= 0) return;
859
+ const s = this.label(label);
860
+ s.stats.records += count;
861
+ s.pendingRecords += count;
862
+ }
863
+ drainRecords() {
864
+ const out = [];
865
+ for (const [label, s] of this.labels) {
866
+ if (s.pendingRecords <= 0) continue;
867
+ out.push({ name: "record_pushed", props: { count: s.pendingRecords, ...this.props(label) } });
868
+ s.pendingRecords = 0;
869
+ }
870
+ return out;
871
+ }
872
+ /** Children one handler call enqueued under one child label (count = newly added). */
873
+ enqueued(parentLabel, childLabel, count, alreadyQueued = 0) {
874
+ const added = isNum(count) && count > 0 ? count : 0;
875
+ const already = isNum(alreadyQueued) && alreadyQueued > 0 ? alreadyQueued : 0;
876
+ if (added + already === 0) return;
877
+ const st = this.label(parentLabel).stats;
878
+ const child = hasOwn(st.enqueued, childLabel) || hasOwn(st.alreadyQueued, childLabel) || Object.keys(st.enqueued).length < MAX_CHILD_LABELS ? childLabel : OVERFLOW_KEY;
879
+ st.enqueued[child] = (hasOwn(st.enqueued, child) ? st.enqueued[child] : 0) + added;
880
+ st.alreadyQueued[child] = (hasOwn(st.alreadyQueued, child) ? st.alreadyQueued[child] : 0) + already;
881
+ this.queue.push({
882
+ name: "enqueued",
883
+ props: { childLabel: child, count: added, alreadyQueued: already, ...this.props(parentLabel) }
884
+ });
885
+ }
886
+ /**
887
+ * A request's final failure. Grouped by fingerprint (class + scrubbed message +
888
+ * top project frame); the message is scrubbed once per new raw message and the
889
+ * result cached. Each event carries the cumulative per-run count for its
890
+ * fingerprint (the server sets it, never adds).
891
+ *
892
+ * Bounds: at most 1,000 fingerprints per run. Past that, a new fingerprint is
893
+ * counted under the single fingerprint "overflow" (class "Overflow", empty
894
+ * message). The raw-message cache holds ≤2,000 truncated keys; past that, new
895
+ * raw messages are scrubbed without caching.
896
+ */
897
+ error(label, err, context) {
898
+ const errorClass = errorClassOf(err);
899
+ const raw = rawMessageOf(err);
900
+ let frame;
901
+ try {
902
+ frame = topProjectFrame(stackOf(err));
903
+ } catch {
904
+ frame = void 0;
905
+ }
906
+ const rawKey = `${errorClass}
907
+ ${frame ?? ""}
908
+ ${raw.slice(0, RAW_KEY_CHARS)}`;
909
+ let fp = this.rawKeys.get(rawKey);
910
+ let message = "";
911
+ if (fp === void 0) {
912
+ try {
913
+ message = scrubMessage(raw);
914
+ } catch {
915
+ message = "";
916
+ }
917
+ fp = fingerprint(errorClass, message, frame);
918
+ if (this.rawKeys.size < MAX_RAW_KEYS) this.rawKeys.set(rawKey, fp);
919
+ }
920
+ let g = this.groups.get(fp);
921
+ if (!g) {
922
+ if (this.groups.size < MAX_FINGERPRINTS) {
923
+ g = { fingerprint: fp, errorClass, message, frame, count: 0 };
924
+ this.groups.set(fp, g);
925
+ } else {
926
+ g = this.groups.get(OVERFLOW_FINGERPRINT);
927
+ if (!g) {
928
+ g = { fingerprint: OVERFLOW_FINGERPRINT, errorClass: "Overflow", message: "", count: 0 };
929
+ this.groups.set(OVERFLOW_FINGERPRINT, g);
930
+ }
931
+ }
932
+ }
933
+ g.count++;
934
+ this.queue.push({
935
+ name: "error",
936
+ props: {
937
+ fingerprint: g.fingerprint,
938
+ errorClass: g.errorClass,
939
+ message: g.message,
940
+ frame: g.frame,
941
+ count: g.count,
942
+ context,
943
+ ...this.props(label)
944
+ }
945
+ });
946
+ }
947
+ runStarted(p) {
948
+ this.queue.push({
949
+ name: "run_started",
950
+ props: {
951
+ memoryMb: isNum(p.memoryMb) ? p.memoryMb : void 0,
952
+ maxConcurrency: isNum(p.maxConcurrency) ? p.maxConcurrency : void 0,
953
+ ...this.props("")
954
+ }
955
+ });
956
+ }
957
+ /** The account hit a monthly limit. The caller emits it at most once per run per cap. */
958
+ quotaReached(cap) {
959
+ this.queue.push({ name: "quota_reached", props: { cap, ...this.props("") } });
960
+ }
961
+ /** Exact run totals from the in-memory counters (failed = failed + blocked final outcomes). */
962
+ runFinished(p) {
963
+ let requests = 0;
964
+ let records = 0;
965
+ let failed = 0;
966
+ for (const s of this.labels.values()) {
967
+ requests += s.stats.requests;
968
+ records += s.stats.records;
969
+ failed += s.stats.failed + s.stats.blocked;
970
+ }
971
+ this.queue.push({
972
+ name: "run_finished",
973
+ props: { requests, records, failed, durationMs: isNum(p.durationMs) ? p.durationMs : 0, ...this.props("") }
974
+ });
975
+ }
976
+ /**
977
+ * A developer event. Never sampled. Invalid names/props are dropped; each rejected
978
+ * name (reserved, fixed, or invalid) logs one debug line per run.
979
+ */
980
+ capture(name, props, label = "", context) {
981
+ const clean = sanitizeCustom(name, props);
982
+ if (!clean) {
983
+ if (typeof name === "string" && name.length > 0) {
984
+ const key = name.slice(0, 64);
985
+ if (!this.rejectedNames.has(key) && this.rejectedNames.size < MAX_REJECTED_NAMES_LOGGED) {
986
+ this.rejectedNames.add(key);
987
+ this.debug(`Analytics: event "${key}" rejected (reserved or invalid name, or invalid props)`);
988
+ }
989
+ }
990
+ return;
991
+ }
992
+ const custom = {};
993
+ for (const k of Object.keys(clean.props)) if (!RESERVED_PROPS.has(k)) custom[k] = clean.props[k];
994
+ if (!clean.name.startsWith("antibot.")) this.aggregates.custom(clean.name, label, custom);
995
+ this.queue.push({
996
+ name: clean.name,
997
+ custom: true,
998
+ // Base keys are reserved: a custom prop with those names is dropped, never overrides them.
999
+ props: { ...custom, weight: void 0, context, ...this.props(label) }
1000
+ });
1001
+ }
1002
+ /** Exact per-run URL-pattern and custom-event aggregates for the run report. */
1003
+ aggregateReport() {
1004
+ return this.aggregates.toReport();
1005
+ }
1006
+ /** Exact counters per label (copies), with percentiles from the histograms. */
1007
+ labelStats() {
1008
+ const out = {};
1009
+ for (const [label, s] of this.labels) {
1010
+ const st = {
1011
+ ...s.stats,
1012
+ enqueued: { ...s.stats.enqueued },
1013
+ alreadyQueued: { ...s.stats.alreadyQueued },
1014
+ status: { ...s.stats.status }
1015
+ };
1016
+ const navP50 = percentile(s.nav, s.navN, 0.5);
1017
+ const navP95 = percentile(s.nav, s.navN, 0.95);
1018
+ const handlerP95 = percentile(s.handler, s.handlerN, 0.95);
1019
+ if (navP50 !== void 0) st.navP50 = navP50;
1020
+ if (navP95 !== void 0) st.navP95 = navP95;
1021
+ if (handlerP95 !== void 0) st.handlerP95 = handlerP95;
1022
+ out[label] = st;
1023
+ }
1024
+ return out;
1025
+ }
1026
+ };
1027
+
1028
+ export { AnalyticsQueue, Collector, SDK_VERSION, startSeqFromEnv };
1029
+ //# sourceMappingURL=collector-3OZRBCM4.mjs.map
1030
+ //# sourceMappingURL=collector-3OZRBCM4.mjs.map