@glasstrace/sdk 0.14.2 → 0.16.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.
Files changed (84) hide show
  1. package/README.md +84 -1
  2. package/dist/adapters/drizzle.js +2 -5
  3. package/dist/adapters/drizzle.js.map +1 -1
  4. package/dist/{chunk-PD2SKFQQ.js → chunk-55FBXXER.js} +4 -8
  5. package/dist/{chunk-PD2SKFQQ.js.map → chunk-55FBXXER.js.map} +1 -1
  6. package/dist/chunk-5C2TJFLB.js +851 -0
  7. package/dist/chunk-5C2TJFLB.js.map +1 -0
  8. package/dist/{chunk-YMEXDDTA.js → chunk-7JBKXSBU.js} +3 -99
  9. package/dist/chunk-7JBKXSBU.js.map +1 -0
  10. package/dist/{chunk-2LDBR3F3.js → chunk-BANTDXUT.js} +15 -74
  11. package/dist/chunk-BANTDXUT.js.map +1 -0
  12. package/dist/{chunk-WV3NIPWJ.js → chunk-CTJI2YKA.js} +23 -288
  13. package/dist/chunk-CTJI2YKA.js.map +1 -0
  14. package/dist/{chunk-WK7MPK2T.js → chunk-DQ25VOKK.js} +1 -89
  15. package/dist/chunk-DQ25VOKK.js.map +1 -0
  16. package/dist/{chunk-BL3YDC6V.js → chunk-DXRZKKSO.js} +1 -6
  17. package/dist/{chunk-BL3YDC6V.js.map → chunk-DXRZKKSO.js.map} +1 -1
  18. package/dist/{chunk-BGZ7J74D.js → chunk-NSBPE2FW.js} +2 -16
  19. package/dist/chunk-O63DJKIJ.js +460 -0
  20. package/dist/chunk-O63DJKIJ.js.map +1 -0
  21. package/dist/{chunk-ECEN724Y.js → chunk-TM5NKZTO.js} +4 -8
  22. package/dist/{chunk-ECEN724Y.js.map → chunk-TM5NKZTO.js.map} +1 -1
  23. package/dist/chunk-VUZCLMIX.js +57 -0
  24. package/dist/chunk-VUZCLMIX.js.map +1 -0
  25. package/dist/{chunk-OSXIUKD5.js → chunk-WZXVS2EO.js} +1 -6
  26. package/dist/{chunk-OSXIUKD5.js.map → chunk-WZXVS2EO.js.map} +1 -1
  27. package/dist/{chunk-ARAOZCZT.js → chunk-XNDHQN4S.js} +122 -24
  28. package/dist/chunk-XNDHQN4S.js.map +1 -0
  29. package/dist/cli/init.cjs +1110 -255
  30. package/dist/cli/init.cjs.map +1 -1
  31. package/dist/cli/init.d.cts +86 -1
  32. package/dist/cli/init.d.ts +86 -1
  33. package/dist/cli/init.js +277 -66
  34. package/dist/cli/init.js.map +1 -1
  35. package/dist/cli/mcp-add.cjs +16 -16
  36. package/dist/cli/mcp-add.cjs.map +1 -1
  37. package/dist/cli/mcp-add.js +12 -13
  38. package/dist/cli/mcp-add.js.map +1 -1
  39. package/dist/cli/status.cjs +2 -2
  40. package/dist/cli/status.js +4 -7
  41. package/dist/cli/status.js.map +1 -1
  42. package/dist/cli/uninit.cjs +138 -20
  43. package/dist/cli/uninit.cjs.map +1 -1
  44. package/dist/cli/uninit.d.cts +38 -8
  45. package/dist/cli/uninit.d.ts +38 -8
  46. package/dist/cli/uninit.js +8 -5
  47. package/dist/cli/validate.cjs +135 -0
  48. package/dist/cli/validate.cjs.map +1 -0
  49. package/dist/cli/validate.d.cts +60 -0
  50. package/dist/cli/validate.d.ts +60 -0
  51. package/dist/cli/validate.js +100 -0
  52. package/dist/cli/validate.js.map +1 -0
  53. package/dist/{esm-MDK7CZID.js → esm-KBPHCVB4.js} +3 -3
  54. package/dist/{getMachineId-bsd-4NIRBWME.js → getMachineId-bsd-345PYXFX.js} +4 -7
  55. package/dist/{getMachineId-bsd-4NIRBWME.js.map → getMachineId-bsd-345PYXFX.js.map} +1 -1
  56. package/dist/{getMachineId-darwin-2XNOCCJQ.js → getMachineId-darwin-5L2D25AD.js} +4 -7
  57. package/dist/{getMachineId-darwin-2XNOCCJQ.js.map → getMachineId-darwin-5L2D25AD.js.map} +1 -1
  58. package/dist/{getMachineId-linux-V6YSQEY7.js → getMachineId-linux-KJR4P5HN.js} +3 -6
  59. package/dist/{getMachineId-linux-V6YSQEY7.js.map → getMachineId-linux-KJR4P5HN.js.map} +1 -1
  60. package/dist/{getMachineId-unsupported-4FKBJNVO.js → getMachineId-unsupported-NDNXDYDY.js} +3 -6
  61. package/dist/{getMachineId-unsupported-4FKBJNVO.js.map → getMachineId-unsupported-NDNXDYDY.js.map} +1 -1
  62. package/dist/{getMachineId-win-WLRZBKVG.js → getMachineId-win-T7PJNJXG.js} +4 -7
  63. package/dist/{getMachineId-win-WLRZBKVG.js.map → getMachineId-win-T7PJNJXG.js.map} +1 -1
  64. package/dist/index.cjs +519 -494
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +47 -6
  67. package/dist/index.d.ts +47 -6
  68. package/dist/index.js +250 -719
  69. package/dist/index.js.map +1 -1
  70. package/dist/{monorepo-YILKGQXQ.js → monorepo-N5Z63XP7.js} +4 -4
  71. package/dist/{source-map-uploader-3GWUQDTS.js → source-map-uploader-MUZPI2S5.js} +5 -4
  72. package/dist/source-map-uploader-MUZPI2S5.js.map +1 -0
  73. package/package.json +6 -4
  74. package/dist/chunk-2LDBR3F3.js.map +0 -1
  75. package/dist/chunk-ARAOZCZT.js.map +0 -1
  76. package/dist/chunk-BGZ7J74D.js.map +0 -1
  77. package/dist/chunk-UPS5BGER.js +0 -182
  78. package/dist/chunk-UPS5BGER.js.map +0 -1
  79. package/dist/chunk-WK7MPK2T.js.map +0 -1
  80. package/dist/chunk-WV3NIPWJ.js.map +0 -1
  81. package/dist/chunk-YMEXDDTA.js.map +0 -1
  82. /package/dist/{esm-MDK7CZID.js.map → chunk-NSBPE2FW.js.map} +0 -0
  83. /package/dist/{monorepo-YILKGQXQ.js.map → esm-KBPHCVB4.js.map} +0 -0
  84. /package/dist/{source-map-uploader-3GWUQDTS.js.map → monorepo-N5Z63XP7.js.map} +0 -0
package/dist/index.js CHANGED
@@ -4,32 +4,44 @@ import {
4
4
  computeBuildHash,
5
5
  discoverSourceMapFiles,
6
6
  installConsoleCapture,
7
- isAnonymousMode,
8
- isProductionDisabled,
9
7
  maybeShowMcpNudge,
10
- readEnvVars,
11
- resolveConfig,
12
8
  sdkLog,
13
9
  uploadSourceMaps,
14
10
  uploadSourceMapsAuto,
15
11
  uploadSourceMapsPresigned
16
- } from "./chunk-2LDBR3F3.js";
12
+ } from "./chunk-BANTDXUT.js";
17
13
  import {
14
+ _setCurrentConfig,
18
15
  buildImportGraph,
16
+ collectHealthReport,
17
+ consumeRateLimitFlag,
18
+ didLastInitSucceed,
19
19
  discoverTestFiles,
20
- extractImports
21
- } from "./chunk-UPS5BGER.js";
20
+ extractImports,
21
+ getActiveConfig,
22
+ getClaimResult,
23
+ getLinkedAccountId,
24
+ loadCachedConfig,
25
+ performInit,
26
+ recordSpansDropped,
27
+ recordSpansExported,
28
+ saveCachedConfig,
29
+ sendInitRequest
30
+ } from "./chunk-5C2TJFLB.js";
31
+ import {
32
+ isAnonymousMode,
33
+ isProductionDisabled,
34
+ readEnvVars,
35
+ resolveConfig
36
+ } from "./chunk-VUZCLMIX.js";
22
37
  import {
23
38
  getOrCreateAnonKey,
24
39
  readAnonKey
25
- } from "./chunk-ECEN724Y.js";
40
+ } from "./chunk-TM5NKZTO.js";
26
41
  import {
27
- DEFAULT_CAPTURE_CONFIG,
28
42
  GLASSTRACE_ATTRIBUTE_NAMES,
29
- SdkCachedConfigSchema,
30
- SdkInitResponseSchema,
31
43
  SessionIdSchema
32
- } from "./chunk-YMEXDDTA.js";
44
+ } from "./chunk-7JBKXSBU.js";
33
45
  import {
34
46
  DiagLogLevel,
35
47
  INVALID_SPAN_CONTEXT,
@@ -46,17 +58,12 @@ import {
46
58
  isSpanContextValid,
47
59
  isValidTraceId,
48
60
  trace
49
- } from "./chunk-WK7MPK2T.js";
61
+ } from "./chunk-DQ25VOKK.js";
50
62
  import {
51
- __require,
52
- init_esm_shims
53
- } from "./chunk-BGZ7J74D.js";
54
-
55
- // src/index.ts
56
- init_esm_shims();
63
+ __require
64
+ } from "./chunk-NSBPE2FW.js";
57
65
 
58
66
  // src/errors.ts
59
- init_esm_shims();
60
67
  var SdkError = class extends Error {
61
68
  code;
62
69
  constructor(code, message, cause) {
@@ -67,7 +74,6 @@ var SdkError = class extends Error {
67
74
  };
68
75
 
69
76
  // src/session.ts
70
- init_esm_shims();
71
77
  var FOUR_HOURS_MS = 4 * 60 * 60 * 1e3;
72
78
  var hashFn = null;
73
79
  function fnv1aHash(input) {
@@ -82,7 +88,7 @@ function fnv1aHash(input) {
82
88
  function getHashFn() {
83
89
  if (hashFn) return hashFn;
84
90
  try {
85
- const { createHash } = __require("crypto");
91
+ const { createHash } = __require("node:crypto");
86
92
  hashFn = (input) => createHash("sha256").update(input).digest("hex").slice(0, 16);
87
93
  } catch {
88
94
  hashFn = (input) => {
@@ -158,7 +164,6 @@ var SessionManager = class {
158
164
  };
159
165
 
160
166
  // src/fetch-classifier.ts
161
- init_esm_shims();
162
167
  var cachedPort2 = process.env.PORT ?? "3000";
163
168
  function classifyFetchTarget(url) {
164
169
  let parsed;
@@ -183,381 +188,7 @@ function classifyFetchTarget(url) {
183
188
  return "unknown";
184
189
  }
185
190
 
186
- // src/init-client.ts
187
- init_esm_shims();
188
-
189
- // src/health-collector.ts
190
- init_esm_shims();
191
- var tracesExported = 0;
192
- var tracesDropped = 0;
193
- var initFailures = 0;
194
- var lastConfigSyncAt = null;
195
- function recordSpansExported(count) {
196
- if (!Number.isFinite(count) || count < 0 || !Number.isInteger(count)) return;
197
- tracesExported += count;
198
- }
199
- function recordSpansDropped(count) {
200
- if (!Number.isFinite(count) || count < 0 || !Number.isInteger(count)) return;
201
- tracesDropped += count;
202
- }
203
- function recordInitFailure() {
204
- try {
205
- initFailures += 1;
206
- } catch {
207
- }
208
- }
209
- function recordConfigSync(timestamp) {
210
- try {
211
- lastConfigSyncAt = timestamp;
212
- } catch {
213
- }
214
- }
215
- function collectHealthReport(sdkVersion) {
216
- try {
217
- const now = Date.now();
218
- const configAge = lastConfigSyncAt !== null ? Math.max(0, now - lastConfigSyncAt) : 0;
219
- return {
220
- tracesExportedSinceLastInit: tracesExported,
221
- tracesDropped,
222
- initFailures,
223
- configAge: Math.round(configAge),
224
- sdkVersion
225
- };
226
- } catch {
227
- return null;
228
- }
229
- }
230
- function acknowledgeHealthReport(report) {
231
- const exp = Math.max(0, report.tracesExportedSinceLastInit);
232
- const expVal = tracesExported - exp;
233
- tracesExported = Number.isFinite(expVal) ? Math.max(0, expVal) : tracesExported;
234
- const drop = Math.max(0, report.tracesDropped);
235
- const dropVal = tracesDropped - drop;
236
- tracesDropped = Number.isFinite(dropVal) ? Math.max(0, dropVal) : tracesDropped;
237
- const fail = Math.max(0, report.initFailures);
238
- const failVal = initFailures - fail;
239
- initFailures = Number.isFinite(failVal) ? Math.max(0, failVal) : initFailures;
240
- }
241
-
242
- // src/init-client.ts
243
- var GLASSTRACE_DIR = ".glasstrace";
244
- var CONFIG_FILE = "config";
245
- var TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1e3;
246
- var INIT_TIMEOUT_MS = 1e4;
247
- var fsPathAsyncCache;
248
- async function loadFsPathAsync() {
249
- if (fsPathAsyncCache !== void 0) return fsPathAsyncCache;
250
- try {
251
- const [fs2, path2] = await Promise.all([
252
- import("fs/promises"),
253
- import("path")
254
- ]);
255
- fsPathAsyncCache = { fs: fs2, path: path2 };
256
- return fsPathAsyncCache;
257
- } catch {
258
- fsPathAsyncCache = null;
259
- return null;
260
- }
261
- }
262
- function loadFsSyncOrNull() {
263
- try {
264
- const fs2 = __require("fs");
265
- const path2 = __require("path");
266
- return { readFileSync: fs2.readFileSync, join: path2.join };
267
- } catch {
268
- return null;
269
- }
270
- }
271
- var currentConfig = null;
272
- var configCacheChecked = false;
273
- var rateLimitBackoff = false;
274
- var lastInitSucceeded = false;
275
- function loadCachedConfig(projectRoot) {
276
- const modules = loadFsSyncOrNull();
277
- if (!modules) return null;
278
- const root = projectRoot ?? process.cwd();
279
- const configPath = modules.join(root, GLASSTRACE_DIR, CONFIG_FILE);
280
- try {
281
- const content = modules.readFileSync(configPath, "utf-8");
282
- const parsed = JSON.parse(content);
283
- const cached = SdkCachedConfigSchema.parse(parsed);
284
- const age = Date.now() - cached.cachedAt;
285
- if (age > TWENTY_FOUR_HOURS_MS) {
286
- console.warn(
287
- `[glasstrace] Cached config is ${Math.round(age / 36e5)}h old. Will refresh on next init.`
288
- );
289
- }
290
- const result = SdkInitResponseSchema.safeParse(cached.response);
291
- if (result.success) {
292
- recordConfigSync(cached.cachedAt);
293
- return result.data;
294
- }
295
- console.warn("[glasstrace] Cached config failed validation. Using defaults.");
296
- return null;
297
- } catch {
298
- return null;
299
- }
300
- }
301
- async function saveCachedConfig(response, projectRoot) {
302
- const modules = await loadFsPathAsync();
303
- if (!modules) return;
304
- const root = projectRoot ?? process.cwd();
305
- const dirPath = modules.path.join(root, GLASSTRACE_DIR);
306
- const configPath = modules.path.join(dirPath, CONFIG_FILE);
307
- try {
308
- await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
309
- await modules.fs.chmod(dirPath, 448);
310
- const cached = {
311
- response,
312
- cachedAt: Date.now()
313
- };
314
- await modules.fs.writeFile(configPath, JSON.stringify(cached), { encoding: "utf-8", mode: 384 });
315
- await modules.fs.chmod(configPath, 384);
316
- } catch (err) {
317
- console.warn(
318
- `[glasstrace] Failed to cache config to ${configPath}: ${err instanceof Error ? err.message : String(err)}`
319
- );
320
- }
321
- }
322
- async function sendInitRequest(config, anonKey, sdkVersion, importGraph, healthReport, diagnostics, signal) {
323
- const effectiveKey = config.apiKey || anonKey;
324
- if (!effectiveKey) {
325
- throw new Error("No API key available for init request");
326
- }
327
- const payload = {
328
- sdkVersion
329
- };
330
- if (config.apiKey && anonKey) {
331
- payload.anonKey = anonKey;
332
- }
333
- if (config.environment) {
334
- payload.environment = config.environment;
335
- }
336
- if (importGraph) {
337
- payload.importGraph = importGraph;
338
- }
339
- if (healthReport) {
340
- payload.healthReport = healthReport;
341
- }
342
- if (diagnostics) {
343
- payload.diagnostics = diagnostics;
344
- }
345
- const url = `${config.endpoint}/v1/sdk/init`;
346
- const response = await fetch(url, {
347
- method: "POST",
348
- headers: {
349
- "Content-Type": "application/json",
350
- Authorization: `Bearer ${effectiveKey}`
351
- },
352
- body: JSON.stringify(payload),
353
- signal
354
- });
355
- if (!response.ok) {
356
- try {
357
- await response.text();
358
- } catch {
359
- }
360
- const error = new Error(`Init request failed with status ${response.status}`);
361
- error.status = response.status;
362
- throw error;
363
- }
364
- const body = await response.json();
365
- return SdkInitResponseSchema.parse(body);
366
- }
367
- async function writeClaimedKey(newApiKey, projectRoot) {
368
- const modules = await loadFsPathAsync();
369
- if (modules) {
370
- const root = projectRoot ?? process.cwd();
371
- const envLocalPath = modules.path.join(root, ".env.local");
372
- let envLocalWritten = false;
373
- try {
374
- let content;
375
- try {
376
- content = await modules.fs.readFile(envLocalPath, "utf-8");
377
- if (/^GLASSTRACE_API_KEY=.*/m.test(content)) {
378
- content = content.replace(
379
- /^GLASSTRACE_API_KEY=.*$/gm,
380
- `GLASSTRACE_API_KEY=${newApiKey}`
381
- );
382
- } else {
383
- if (content.length > 0 && !content.endsWith("\n")) {
384
- content += "\n";
385
- }
386
- content += `GLASSTRACE_API_KEY=${newApiKey}
387
- `;
388
- }
389
- } catch (readErr) {
390
- const code = readErr instanceof Error ? readErr.code : void 0;
391
- if (code !== "ENOENT") {
392
- throw readErr;
393
- }
394
- content = `GLASSTRACE_API_KEY=${newApiKey}
395
- `;
396
- }
397
- await modules.fs.writeFile(envLocalPath, content, { encoding: "utf-8", mode: 384 });
398
- await modules.fs.chmod(envLocalPath, 384);
399
- envLocalWritten = true;
400
- } catch {
401
- }
402
- if (envLocalWritten) {
403
- try {
404
- process.stderr.write(
405
- "[glasstrace] Account claimed! API key written to .env.local. Restart your dev server to use it.\n"
406
- );
407
- } catch {
408
- }
409
- return;
410
- }
411
- let claimedKeyWritten = false;
412
- try {
413
- const dirPath = modules.path.join(root, GLASSTRACE_DIR);
414
- await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
415
- await modules.fs.chmod(dirPath, 448);
416
- const claimedKeyPath = modules.path.join(dirPath, "claimed-key");
417
- await modules.fs.writeFile(claimedKeyPath, newApiKey, {
418
- encoding: "utf-8",
419
- mode: 384
420
- });
421
- await modules.fs.chmod(claimedKeyPath, 384);
422
- claimedKeyWritten = true;
423
- } catch {
424
- }
425
- if (claimedKeyWritten) {
426
- try {
427
- process.stderr.write(
428
- "[glasstrace] Account claimed! API key written to .glasstrace/claimed-key. Copy it to your .env.local file.\n"
429
- );
430
- } catch {
431
- }
432
- return;
433
- }
434
- }
435
- try {
436
- process.stderr.write(
437
- "[glasstrace] Account claimed but could not write key to disk. Visit your dashboard settings to rotate and retrieve a new API key.\n"
438
- );
439
- } catch {
440
- }
441
- }
442
- async function performInit(config, anonKey, sdkVersion, healthReport) {
443
- lastInitSucceeded = false;
444
- if (rateLimitBackoff) {
445
- rateLimitBackoff = false;
446
- return null;
447
- }
448
- try {
449
- const effectiveKey = config.apiKey || anonKey;
450
- if (!effectiveKey) {
451
- console.warn("[glasstrace] No API key available for init request.");
452
- return null;
453
- }
454
- const controller = new AbortController();
455
- const timeoutId = setTimeout(() => controller.abort(), INIT_TIMEOUT_MS);
456
- try {
457
- const result = await sendInitRequest(
458
- config,
459
- anonKey,
460
- sdkVersion,
461
- void 0,
462
- healthReport ?? void 0,
463
- void 0,
464
- controller.signal
465
- );
466
- clearTimeout(timeoutId);
467
- currentConfig = result;
468
- recordConfigSync(Date.now());
469
- if (healthReport) {
470
- acknowledgeHealthReport(healthReport);
471
- }
472
- lastInitSucceeded = true;
473
- await saveCachedConfig(result);
474
- if (result.claimResult) {
475
- try {
476
- await writeClaimedKey(result.claimResult.newApiKey);
477
- } catch {
478
- }
479
- return { claimResult: result.claimResult };
480
- }
481
- return null;
482
- } catch (err) {
483
- clearTimeout(timeoutId);
484
- recordInitFailure();
485
- if (err instanceof DOMException && err.name === "AbortError") {
486
- console.warn("[glasstrace] ingestion_unreachable: Init request timed out.");
487
- return null;
488
- }
489
- const status = err.status;
490
- if (status === 401) {
491
- console.warn(
492
- "[glasstrace] ingestion_auth_failed: Check your GLASSTRACE_API_KEY."
493
- );
494
- return null;
495
- }
496
- if (status === 429) {
497
- console.warn("[glasstrace] ingestion_rate_limited: Backing off.");
498
- rateLimitBackoff = true;
499
- return null;
500
- }
501
- if (typeof status === "number" && status >= 400) {
502
- console.warn(
503
- `[glasstrace] Init request failed with status ${status}. Using cached config.`
504
- );
505
- return null;
506
- }
507
- if (err instanceof Error && err.name === "ZodError") {
508
- console.warn(
509
- "[glasstrace] Init response failed validation (schema version mismatch?). Using cached config."
510
- );
511
- return null;
512
- }
513
- console.warn(
514
- `[glasstrace] ingestion_unreachable: ${err instanceof Error ? err.message : String(err)}`
515
- );
516
- return null;
517
- }
518
- } catch (err) {
519
- console.warn(
520
- `[glasstrace] Unexpected init error: ${err instanceof Error ? err.message : String(err)}`
521
- );
522
- }
523
- return null;
524
- }
525
- function getActiveConfig() {
526
- if (currentConfig) {
527
- return currentConfig.config;
528
- }
529
- if (!configCacheChecked) {
530
- configCacheChecked = true;
531
- const cached = loadCachedConfig();
532
- if (cached) {
533
- currentConfig = cached;
534
- return cached.config;
535
- }
536
- }
537
- return { ...DEFAULT_CAPTURE_CONFIG };
538
- }
539
- function getLinkedAccountId() {
540
- return currentConfig?.linkedAccountId;
541
- }
542
- function getClaimResult() {
543
- return currentConfig?.claimResult;
544
- }
545
- function _setCurrentConfig(config) {
546
- currentConfig = config;
547
- }
548
- function consumeRateLimitFlag() {
549
- if (rateLimitBackoff) {
550
- rateLimitBackoff = false;
551
- return true;
552
- }
553
- return false;
554
- }
555
- function didLastInitSucceed() {
556
- return lastInitSucceeded;
557
- }
558
-
559
191
  // src/span-processor.ts
560
- init_esm_shims();
561
192
  var GlasstraceSpanProcessor = class {
562
193
  wrappedProcessor;
563
194
  /* eslint-disable @typescript-eslint/no-unused-vars -- backward compat signature */
@@ -579,7 +210,6 @@ var GlasstraceSpanProcessor = class {
579
210
  };
580
211
 
581
212
  // src/enriching-exporter.ts
582
- init_esm_shims();
583
213
  var ATTR = GLASSTRACE_ATTRIBUTE_NAMES;
584
214
  var API_KEY_PENDING = "pending";
585
215
  var MAX_PENDING_SPANS = 1024;
@@ -958,7 +588,6 @@ function deriveErrorCategory(errorType) {
958
588
  }
959
589
 
960
590
  // src/discovery-endpoint.ts
961
- init_esm_shims();
962
591
  function isAllowedOrigin(origin) {
963
592
  if (origin === null) return true;
964
593
  if (origin.startsWith("chrome-extension://")) return true;
@@ -1047,29 +676,7 @@ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
1047
676
  };
1048
677
  }
1049
678
 
1050
- // src/register.ts
1051
- init_esm_shims();
1052
-
1053
- // src/otel-config.ts
1054
- init_esm_shims();
1055
-
1056
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js
1057
- init_esm_shims();
1058
-
1059
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js
1060
- init_esm_shims();
1061
-
1062
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js
1063
- init_esm_shims();
1064
-
1065
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js
1066
- init_esm_shims();
1067
-
1068
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
1069
- init_esm_shims();
1070
-
1071
679
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
1072
- init_esm_shims();
1073
680
  var OTLPExporterBase = class {
1074
681
  _delegate;
1075
682
  constructor(delegate) {
@@ -1092,7 +699,6 @@ var OTLPExporterBase = class {
1092
699
  };
1093
700
 
1094
701
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js
1095
- init_esm_shims();
1096
702
  var OTLPExporterError = class extends Error {
1097
703
  code;
1098
704
  name = "OTLPExporterError";
@@ -1105,7 +711,6 @@ var OTLPExporterError = class extends Error {
1105
711
  };
1106
712
 
1107
713
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js
1108
- init_esm_shims();
1109
714
  function validateTimeoutMillis(timeoutMillis) {
1110
715
  if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {
1111
716
  return timeoutMillis;
@@ -1134,7 +739,6 @@ function getSharedConfigurationDefaults() {
1134
739
  }
1135
740
 
1136
741
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js
1137
- init_esm_shims();
1138
742
  var BoundedQueueExportPromiseHandler = class {
1139
743
  _concurrencyLimit;
1140
744
  _sendingPromises = [];
@@ -1166,14 +770,7 @@ function createBoundedQueueExportPromiseHandler(options) {
1166
770
  return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
1167
771
  }
1168
772
 
1169
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js
1170
- init_esm_shims();
1171
-
1172
- // ../../node_modules/@opentelemetry/core/build/esm/index.js
1173
- init_esm_shims();
1174
-
1175
773
  // ../../node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
1176
- init_esm_shims();
1177
774
  var SUPPRESS_TRACING_KEY = createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
1178
775
  function suppressTracing(context2) {
1179
776
  return context2.setValue(SUPPRESS_TRACING_KEY, true);
@@ -1183,13 +780,11 @@ function isTracingSuppressed(context2) {
1183
780
  }
1184
781
 
1185
782
  // ../../node_modules/@opentelemetry/core/build/esm/baggage/constants.js
1186
- init_esm_shims();
1187
783
  var BAGGAGE_KEY_PAIR_SEPARATOR = "=";
1188
784
  var BAGGAGE_PROPERTIES_SEPARATOR = ";";
1189
785
  var BAGGAGE_ITEMS_SEPARATOR = ",";
1190
786
 
1191
787
  // ../../node_modules/@opentelemetry/core/build/esm/baggage/utils.js
1192
- init_esm_shims();
1193
788
  function parsePairKeyValue(entry) {
1194
789
  if (!entry)
1195
790
  return;
@@ -1231,7 +826,6 @@ function parseKeyPairsIntoRecord(value) {
1231
826
  }
1232
827
 
1233
828
  // ../../node_modules/@opentelemetry/core/build/esm/common/attributes.js
1234
- init_esm_shims();
1235
829
  function sanitizeAttributes(attributes) {
1236
830
  const out = {};
1237
831
  if (typeof attributes !== "object" || attributes == null) {
@@ -1300,11 +894,7 @@ function isValidPrimitiveAttributeValueType(valType) {
1300
894
  return false;
1301
895
  }
1302
896
 
1303
- // ../../node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
1304
- init_esm_shims();
1305
-
1306
897
  // ../../node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
1307
- init_esm_shims();
1308
898
  function loggingErrorHandler() {
1309
899
  return (ex) => {
1310
900
  diag.error(stringifyException(ex));
@@ -1343,17 +933,7 @@ function globalErrorHandler(ex) {
1343
933
  }
1344
934
  }
1345
935
 
1346
- // ../../node_modules/@opentelemetry/core/build/esm/common/time.js
1347
- init_esm_shims();
1348
-
1349
- // ../../node_modules/@opentelemetry/core/build/esm/platform/index.js
1350
- init_esm_shims();
1351
-
1352
- // ../../node_modules/@opentelemetry/core/build/esm/platform/node/index.js
1353
- init_esm_shims();
1354
-
1355
936
  // ../../node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
1356
- init_esm_shims();
1357
937
  import { inspect } from "util";
1358
938
  function getNumberFromEnv(key) {
1359
939
  const raw = process.env[key];
@@ -1375,15 +955,10 @@ function getStringFromEnv(key) {
1375
955
  return raw;
1376
956
  }
1377
957
 
1378
- // ../../node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
1379
- init_esm_shims();
1380
-
1381
958
  // ../../node_modules/@opentelemetry/core/build/esm/version.js
1382
- init_esm_shims();
1383
959
  var VERSION = "2.6.1";
1384
960
 
1385
961
  // ../../node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
1386
- init_esm_shims();
1387
962
  var ATTR_EXCEPTION_MESSAGE = "exception.message";
1388
963
  var ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
1389
964
  var ATTR_EXCEPTION_TYPE = "exception.type";
@@ -1394,7 +969,6 @@ var ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
1394
969
  var ATTR_TELEMETRY_SDK_VERSION = "telemetry.sdk.version";
1395
970
 
1396
971
  // ../../node_modules/@opentelemetry/core/build/esm/semconv.js
1397
- init_esm_shims();
1398
972
  var ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
1399
973
 
1400
974
  // ../../node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
@@ -1452,18 +1026,13 @@ function addHrTimes(time1, time2) {
1452
1026
  }
1453
1027
 
1454
1028
  // ../../node_modules/@opentelemetry/core/build/esm/ExportResult.js
1455
- init_esm_shims();
1456
1029
  var ExportResultCode;
1457
1030
  (function(ExportResultCode2) {
1458
1031
  ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
1459
1032
  ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
1460
1033
  })(ExportResultCode || (ExportResultCode = {}));
1461
1034
 
1462
- // ../../node_modules/@opentelemetry/core/build/esm/utils/merge.js
1463
- init_esm_shims();
1464
-
1465
1035
  // ../../node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js
1466
- init_esm_shims();
1467
1036
  var objectTag = "[object Object]";
1468
1037
  var nullTag = "[object Null]";
1469
1038
  var undefinedTag = "[object Undefined]";
@@ -1623,11 +1192,7 @@ function shouldMerge(one, two) {
1623
1192
  return true;
1624
1193
  }
1625
1194
 
1626
- // ../../node_modules/@opentelemetry/core/build/esm/utils/callback.js
1627
- init_esm_shims();
1628
-
1629
1195
  // ../../node_modules/@opentelemetry/core/build/esm/utils/promise.js
1630
- init_esm_shims();
1631
1196
  var Deferred = class {
1632
1197
  _promise;
1633
1198
  _resolve;
@@ -1679,7 +1244,6 @@ var BindOnceFuture = class {
1679
1244
  };
1680
1245
 
1681
1246
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js
1682
- init_esm_shims();
1683
1247
  function isPartialSuccessResponse(response) {
1684
1248
  return Object.prototype.hasOwnProperty.call(response, "partialSuccess");
1685
1249
  }
@@ -1777,11 +1341,7 @@ function createOtlpExportDelegate(components, settings) {
1777
1341
  return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
1778
1342
  }
1779
1343
 
1780
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
1781
- init_esm_shims();
1782
-
1783
1344
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
1784
- init_esm_shims();
1785
1345
  function createResource(resource, encoder) {
1786
1346
  const result = {
1787
1347
  attributes: toAttributes(resource.attributes, encoder),
@@ -1842,7 +1402,6 @@ function toAnyValue(value, encoder) {
1842
1402
  }
1843
1403
 
1844
1404
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
1845
- init_esm_shims();
1846
1405
  function hrTimeToNanos(hrTime2) {
1847
1406
  const NANOSECONDS = BigInt(1e9);
1848
1407
  return BigInt(Math.trunc(hrTime2[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime2[1]));
@@ -1871,14 +1430,7 @@ var JSON_ENCODER = {
1871
1430
  }
1872
1431
  };
1873
1432
 
1874
- // ../../node_modules/@opentelemetry/resources/build/esm/index.js
1875
- init_esm_shims();
1876
-
1877
- // ../../node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js
1878
- init_esm_shims();
1879
-
1880
1433
  // ../../node_modules/@opentelemetry/resources/build/esm/default-service-name.js
1881
- init_esm_shims();
1882
1434
  var serviceName;
1883
1435
  function defaultServiceName() {
1884
1436
  if (serviceName === void 0) {
@@ -1893,7 +1445,6 @@ function defaultServiceName() {
1893
1445
  }
1894
1446
 
1895
1447
  // ../../node_modules/@opentelemetry/resources/build/esm/utils.js
1896
- init_esm_shims();
1897
1448
  var isPromiseLike = (val) => {
1898
1449
  return val !== null && typeof val === "object" && typeof val.then === "function";
1899
1450
  };
@@ -2021,7 +1572,6 @@ function mergeSchemaUrl(old, updating) {
2021
1572
  }
2022
1573
 
2023
1574
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
2024
- init_esm_shims();
2025
1575
  var SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256;
2026
1576
  var SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512;
2027
1577
  function buildSpanFlagsFrom(traceFlags, isRemote) {
@@ -2134,11 +1684,7 @@ function spanRecordsToResourceSpans(readableSpans, encoder) {
2134
1684
  return out;
2135
1685
  }
2136
1686
 
2137
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js
2138
- init_esm_shims();
2139
-
2140
1687
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js
2141
- init_esm_shims();
2142
1688
  var JsonTraceSerializer = {
2143
1689
  serializeRequest: (arg) => {
2144
1690
  const request = createExportTraceServiceRequest(arg, JSON_ENCODER);
@@ -2154,17 +1700,7 @@ var JsonTraceSerializer = {
2154
1700
  }
2155
1701
  };
2156
1702
 
2157
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js
2158
- init_esm_shims();
2159
-
2160
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-configuration.js
2161
- init_esm_shims();
2162
-
2163
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js
2164
- init_esm_shims();
2165
-
2166
1703
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js
2167
- init_esm_shims();
2168
1704
  function validateAndNormalizeHeaders(partialHeaders) {
2169
1705
  const headers = {};
2170
1706
  Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {
@@ -2246,19 +1782,11 @@ function getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
2246
1782
  };
2247
1783
  }
2248
1784
 
2249
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js
2250
- init_esm_shims();
2251
-
2252
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js
2253
- init_esm_shims();
2254
-
2255
1785
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
2256
- init_esm_shims();
2257
1786
  import * as zlib from "zlib";
2258
1787
  import { Readable } from "stream";
2259
1788
 
2260
1789
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js
2261
- init_esm_shims();
2262
1790
  function isExportHTTPErrorRetryable(statusCode) {
2263
1791
  return statusCode === 429 || statusCode === 502 || statusCode === 503 || statusCode === 504;
2264
1792
  }
@@ -2278,7 +1806,6 @@ function parseRetryAfterToMills(retryAfter) {
2278
1806
  }
2279
1807
 
2280
1808
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js
2281
- init_esm_shims();
2282
1809
  var VERSION2 = "0.214.0";
2283
1810
 
2284
1811
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
@@ -2436,7 +1963,6 @@ function createHttpExporterTransport(parameters) {
2436
1963
  }
2437
1964
 
2438
1965
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js
2439
- init_esm_shims();
2440
1966
  var MAX_ATTEMPTS = 5;
2441
1967
  var INITIAL_BACKOFF = 1e3;
2442
1968
  var MAX_BACKOFF = 5e3;
@@ -2504,7 +2030,6 @@ function createOtlpHttpExportDelegate(options, serializer) {
2504
2030
  }
2505
2031
 
2506
2032
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js
2507
- init_esm_shims();
2508
2033
  function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
2509
2034
  const envTimeout = getNumberFromEnv(timeoutEnvVar);
2510
2035
  if (envTimeout != null) {
@@ -2540,11 +2065,7 @@ function getSharedConfigurationFromEnvironment(signalIdentifier) {
2540
2065
  };
2541
2066
  }
2542
2067
 
2543
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js
2544
- init_esm_shims();
2545
-
2546
2068
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-env-configuration.js
2547
- init_esm_shims();
2548
2069
  import * as fs from "fs";
2549
2070
  import * as path from "path";
2550
2071
  function getStaticHeadersFromEnv(signalIdentifier) {
@@ -2638,7 +2159,6 @@ function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourc
2638
2159
  }
2639
2160
 
2640
2161
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js
2641
- init_esm_shims();
2642
2162
  function convertLegacyHeaders(config) {
2643
2163
  if (typeof config.headers === "function") {
2644
2164
  return config.headers;
@@ -2685,20 +2205,7 @@ var OTLPTraceExporter = class extends OTLPExporterBase {
2685
2205
  }
2686
2206
  };
2687
2207
 
2688
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js
2689
- init_esm_shims();
2690
-
2691
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js
2692
- init_esm_shims();
2693
-
2694
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
2695
- init_esm_shims();
2696
-
2697
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
2698
- init_esm_shims();
2699
-
2700
2208
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js
2701
- init_esm_shims();
2702
2209
  var ExceptionEventName = "exception";
2703
2210
 
2704
2211
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
@@ -3050,17 +2557,7 @@ var SpanImpl = class {
3050
2557
  }
3051
2558
  };
3052
2559
 
3053
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js
3054
- init_esm_shims();
3055
-
3056
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js
3057
- init_esm_shims();
3058
-
3059
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js
3060
- init_esm_shims();
3061
-
3062
2560
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js
3063
- init_esm_shims();
3064
2561
  var SamplingDecision2;
3065
2562
  (function(SamplingDecision3) {
3066
2563
  SamplingDecision3[SamplingDecision3["NOT_RECORD"] = 0] = "NOT_RECORD";
@@ -3081,7 +2578,6 @@ var AlwaysOffSampler = class {
3081
2578
  };
3082
2579
 
3083
2580
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js
3084
- init_esm_shims();
3085
2581
  var AlwaysOnSampler = class {
3086
2582
  shouldSample() {
3087
2583
  return {
@@ -3094,7 +2590,6 @@ var AlwaysOnSampler = class {
3094
2590
  };
3095
2591
 
3096
2592
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js
3097
- init_esm_shims();
3098
2593
  var ParentBasedSampler = class {
3099
2594
  _root;
3100
2595
  _remoteParentSampled;
@@ -3134,7 +2629,6 @@ var ParentBasedSampler = class {
3134
2629
  };
3135
2630
 
3136
2631
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js
3137
- init_esm_shims();
3138
2632
  var TraceIdRatioBasedSampler = class {
3139
2633
  _ratio;
3140
2634
  _upperBound;
@@ -3256,17 +2750,7 @@ function reconfigureLimits(userConfig) {
3256
2750
  return Object.assign({}, userConfig, { spanLimits });
3257
2751
  }
3258
2752
 
3259
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js
3260
- init_esm_shims();
3261
-
3262
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js
3263
- init_esm_shims();
3264
-
3265
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
3266
- init_esm_shims();
3267
-
3268
2753
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
3269
- init_esm_shims();
3270
2754
  var BatchSpanProcessorBase = class {
3271
2755
  _maxExportBatchSize;
3272
2756
  _maxQueueSize;
@@ -3438,7 +2922,6 @@ var BatchSpanProcessor = class extends BatchSpanProcessorBase {
3438
2922
  };
3439
2923
 
3440
2924
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
3441
- init_esm_shims();
3442
2925
  var SPAN_ID_BYTES = 8;
3443
2926
  var TRACE_ID_BYTES = 16;
3444
2927
  var RandomIdGenerator = class {
@@ -3470,11 +2953,7 @@ function getIdGenerator(bytes) {
3470
2953
  };
3471
2954
  }
3472
2955
 
3473
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/TracerMetrics.js
3474
- init_esm_shims();
3475
-
3476
2956
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/semconv.js
3477
- init_esm_shims();
3478
2957
  var ATTR_OTEL_SPAN_PARENT_ORIGIN = "otel.span.parent.origin";
3479
2958
  var ATTR_OTEL_SPAN_SAMPLING_RESULT = "otel.span.sampling_result";
3480
2959
  var METRIC_OTEL_SDK_SPAN_LIVE = "otel.sdk.span.live";
@@ -3534,7 +3013,6 @@ function samplingDecisionToString(decision) {
3534
3013
  }
3535
3014
 
3536
3015
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js
3537
- init_esm_shims();
3538
3016
  var VERSION3 = "2.6.1";
3539
3017
 
3540
3018
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
@@ -3656,7 +3134,6 @@ var Tracer = class {
3656
3134
  };
3657
3135
 
3658
3136
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js
3659
- init_esm_shims();
3660
3137
  var MultiSpanProcessor = class {
3661
3138
  _spanProcessors;
3662
3139
  constructor(spanProcessors) {
@@ -3777,8 +3254,7 @@ var BasicTracerProvider = class {
3777
3254
  };
3778
3255
 
3779
3256
  // src/lifecycle.ts
3780
- init_esm_shims();
3781
- import { EventEmitter } from "events";
3257
+ import { EventEmitter } from "node:events";
3782
3258
  var CoreState = {
3783
3259
  IDLE: "IDLE",
3784
3260
  REGISTERING: "REGISTERING",
@@ -4123,7 +3599,7 @@ function registerBeforeExitTrigger() {
4123
3599
  }
4124
3600
 
4125
3601
  // src/coexistence.ts
4126
- init_esm_shims();
3602
+ var GLASSTRACE_EXPORTER_BRAND = /* @__PURE__ */ Symbol.for("glasstrace.exporter");
4127
3603
  function createGlasstraceSpanProcessor(options) {
4128
3604
  const config = resolveConfig(options);
4129
3605
  const exporterUrl = `${config.endpoint}/v1/traces`;
@@ -4134,13 +3610,64 @@ function createGlasstraceSpanProcessor(options) {
4134
3610
  getConfig: () => getActiveConfig(),
4135
3611
  environment: config.environment,
4136
3612
  endpointUrl: exporterUrl,
4137
- createDelegate: createOtlpExporter
3613
+ createDelegate: createOtlpExporter,
3614
+ // Propagate verbose so exporter-level enrichment and export logs
3615
+ // stay observable whether the processor is built automatically by
3616
+ // the coexistence path or wired manually by the developer.
3617
+ verbose: config.verbose
4138
3618
  });
4139
3619
  registerExporterForKeyNotification(exporter);
4140
3620
  return new BatchSpanProcessor(exporter, {
4141
3621
  scheduledDelayMillis: 1e3
4142
3622
  });
4143
3623
  }
3624
+ function isGlasstraceProcessorPresent(tracerProvider) {
3625
+ try {
3626
+ const proxy = tracerProvider;
3627
+ const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
3628
+ const v2 = delegate;
3629
+ const v2Processors = v2._activeSpanProcessor?._spanProcessors;
3630
+ if (Array.isArray(v2Processors) && hasBrandedProcessor(v2Processors)) {
3631
+ return true;
3632
+ }
3633
+ const v1 = delegate;
3634
+ if (typeof v1.getActiveSpanProcessor === "function") {
3635
+ const active = v1.getActiveSpanProcessor();
3636
+ const processors = active?._spanProcessors;
3637
+ if (Array.isArray(processors) && hasBrandedProcessor(processors)) {
3638
+ return true;
3639
+ }
3640
+ }
3641
+ return false;
3642
+ } catch {
3643
+ return false;
3644
+ }
3645
+ }
3646
+ function tryAutoAttachGlasstraceProcessor(tracerProvider, options) {
3647
+ try {
3648
+ if (isGlasstraceProcessorPresent(tracerProvider)) {
3649
+ return "already_present";
3650
+ }
3651
+ const proxy = tracerProvider;
3652
+ const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
3653
+ const withAdd = delegate;
3654
+ if (typeof withAdd.addSpanProcessor === "function") {
3655
+ const processor2 = createGlasstraceSpanProcessor(options);
3656
+ withAdd.addSpanProcessor(processor2);
3657
+ return { method: "v1_public", processor: processor2 };
3658
+ }
3659
+ const v2 = delegate;
3660
+ const multiProcessor = v2._activeSpanProcessor;
3661
+ if (!multiProcessor || !Array.isArray(multiProcessor._spanProcessors)) {
3662
+ return null;
3663
+ }
3664
+ const processor = createGlasstraceSpanProcessor(options);
3665
+ multiProcessor._spanProcessors.push(processor);
3666
+ return { method: "v2_private", processor };
3667
+ } catch {
3668
+ return null;
3669
+ }
3670
+ }
4144
3671
  function emitNudgeMessage() {
4145
3672
  const isSentry = detectSentry();
4146
3673
  if (isSentry) {
@@ -4209,6 +3736,12 @@ Add Glasstrace to your provider configuration:
4209
3736
  );
4210
3737
  }
4211
3738
  }
3739
+ function hasBrandedProcessor(processors) {
3740
+ return processors.some((p) => {
3741
+ const exporter = p._exporter;
3742
+ return exporter?.[GLASSTRACE_EXPORTER_BRAND] === true;
3743
+ });
3744
+ }
4212
3745
  function detectSentry() {
4213
3746
  try {
4214
3747
  __require.resolve("@sentry/node");
@@ -4250,65 +3783,75 @@ async function tryImport(moduleId) {
4250
3783
  return null;
4251
3784
  }
4252
3785
  }
4253
- function tryInjectProcessor(tracerProvider, glasstraceExporter) {
4254
- try {
4255
- const proxy = tracerProvider;
4256
- const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
4257
- const withAdd = delegate;
4258
- if (typeof withAdd.addSpanProcessor === "function") {
4259
- if (typeof withAdd.getActiveSpanProcessor === "function") {
4260
- const active = withAdd.getActiveSpanProcessor();
4261
- const brand = /* @__PURE__ */ Symbol.for("glasstrace.exporter");
4262
- const processors = active?._spanProcessors;
4263
- if (Array.isArray(processors) && processors.some((p) => {
4264
- const exp = p._exporter;
4265
- return exp?.[brand] === true;
4266
- })) {
4267
- return "already_present";
4268
- }
4269
- }
4270
- const processor2 = new BatchSpanProcessor(glasstraceExporter, {
4271
- scheduledDelayMillis: 1e3
4272
- });
4273
- withAdd.addSpanProcessor(processor2);
4274
- _injectedProcessor = processor2;
4275
- return "v1_public";
4276
- }
4277
- const provider = delegate;
4278
- const multiProcessor = provider._activeSpanProcessor;
4279
- if (!multiProcessor || !Array.isArray(multiProcessor._spanProcessors)) {
4280
- return null;
3786
+ async function configureOtel(config, sessionManager) {
3787
+ setOtelState(OtelState.CONFIGURING);
3788
+ await new Promise((resolve2) => {
3789
+ if (typeof setImmediate === "function") {
3790
+ setImmediate(resolve2);
3791
+ } else {
3792
+ setTimeout(resolve2, 0);
4281
3793
  }
4282
- const processor = new BatchSpanProcessor(glasstraceExporter, {
4283
- scheduledDelayMillis: 1e3
4284
- });
4285
- multiProcessor._spanProcessors.push(processor);
4286
- _injectedProcessor = processor;
4287
- return "v2_private";
4288
- } catch {
4289
- return null;
3794
+ });
3795
+ const existingProvider = trace.getTracerProvider();
3796
+ const probeTracer = existingProvider.getTracer("glasstrace-probe");
3797
+ const anotherProviderRegistered = probeTracer.constructor.name !== "ProxyTracer";
3798
+ if (anotherProviderRegistered) {
3799
+ await runCoexistencePath(existingProvider, config);
3800
+ return;
4290
3801
  }
3802
+ await runRegistrationPath(config, sessionManager);
4291
3803
  }
4292
- function isGlasstraceProcessorPresent(tracerProvider) {
4293
- try {
4294
- const proxy = tracerProvider;
4295
- const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
4296
- const provider = delegate;
4297
- const processors = provider._activeSpanProcessor?._spanProcessors;
4298
- if (!Array.isArray(processors)) {
4299
- return false;
3804
+ async function runCoexistencePath(existingProvider, config) {
3805
+ const result = tryAutoAttachGlasstraceProcessor(existingProvider, {
3806
+ endpoint: config.endpoint,
3807
+ verbose: config.verbose
3808
+ });
3809
+ if (result === "already_present") {
3810
+ if (config.verbose) {
3811
+ sdkLog("info", "[glasstrace] Existing provider detected \u2014 Glasstrace processor already present.");
3812
+ }
3813
+ setOtelState(OtelState.PROCESSOR_PRESENT);
3814
+ emitLifecycleEvent("otel:configured", { state: OtelState.PROCESSOR_PRESENT, scenario: "B-clean" });
3815
+ return;
3816
+ }
3817
+ if (result !== null) {
3818
+ _injectedProcessor = result.processor;
3819
+ if (config.verbose) {
3820
+ sdkLog(
3821
+ "info",
3822
+ "[glasstrace] Existing provider detected \u2014 auto-attached Glasstrace span processor."
3823
+ );
4300
3824
  }
4301
- const brand = /* @__PURE__ */ Symbol.for("glasstrace.exporter");
4302
- return processors.some((p) => {
4303
- const exporter = p._exporter;
4304
- return exporter?.[brand] === true;
3825
+ registerShutdownHook({
3826
+ name: "coexistence-flush",
3827
+ priority: 5,
3828
+ fn: async () => {
3829
+ if (_injectedProcessor) {
3830
+ await _injectedProcessor.forceFlush();
3831
+ }
3832
+ }
4305
3833
  });
4306
- } catch {
4307
- return false;
3834
+ registerBeforeExitTrigger();
3835
+ const scenario = result.method === "v1_public" ? "D1" : "B-auto";
3836
+ setOtelState(OtelState.AUTO_ATTACHED);
3837
+ emitLifecycleEvent("otel:configured", { state: OtelState.AUTO_ATTACHED, scenario });
3838
+ emitLifecycleEvent("otel:injection_succeeded", { method: result.method });
3839
+ emitNudgeMessage();
3840
+ return;
3841
+ }
3842
+ if (config.verbose) {
3843
+ sdkLog("info", "[glasstrace] Existing provider detected \u2014 could not auto-attach.");
3844
+ }
3845
+ emitGuidanceMessage();
3846
+ setOtelState(OtelState.COEXISTENCE_FAILED);
3847
+ emitLifecycleEvent("otel:configured", { state: OtelState.COEXISTENCE_FAILED, scenario: "C/F" });
3848
+ emitLifecycleEvent("otel:injection_failed", { reason: "provider internals inaccessible" });
3849
+ const coreState = getCoreState();
3850
+ if (coreState === CoreState.ACTIVE || coreState === CoreState.KEY_RESOLVED) {
3851
+ setCoreState(CoreState.ACTIVE_DEGRADED);
4308
3852
  }
4309
3853
  }
4310
- async function configureOtel(config, sessionManager) {
4311
- setOtelState(OtelState.CONFIGURING);
3854
+ async function runRegistrationPath(config, sessionManager) {
4312
3855
  const exporterUrl = `${config.endpoint}/v1/traces`;
4313
3856
  const createOtlpExporter = (url, headers) => new OTLPTraceExporter({ url, headers });
4314
3857
  const glasstraceExporter = new GlasstraceExporter({
@@ -4321,71 +3864,6 @@ async function configureOtel(config, sessionManager) {
4321
3864
  verbose: config.verbose
4322
3865
  });
4323
3866
  _activeExporter = glasstraceExporter;
4324
- await new Promise((resolve2) => {
4325
- if (typeof setImmediate === "function") {
4326
- setImmediate(resolve2);
4327
- } else {
4328
- setTimeout(resolve2, 0);
4329
- }
4330
- });
4331
- const existingProvider = trace.getTracerProvider();
4332
- const probeTracer = existingProvider.getTracer("glasstrace-probe");
4333
- const anotherProviderRegistered = probeTracer.constructor.name !== "ProxyTracer";
4334
- if (anotherProviderRegistered) {
4335
- if (isGlasstraceProcessorPresent(existingProvider)) {
4336
- if (config.verbose) {
4337
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 Glasstrace processor already present.");
4338
- }
4339
- _activeExporter = null;
4340
- setOtelState(OtelState.PROCESSOR_PRESENT);
4341
- emitLifecycleEvent("otel:configured", { state: OtelState.PROCESSOR_PRESENT, scenario: "B-clean" });
4342
- return;
4343
- }
4344
- const injectionMethod = tryInjectProcessor(existingProvider, glasstraceExporter);
4345
- if (injectionMethod === "already_present") {
4346
- if (config.verbose) {
4347
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 Glasstrace processor already present (v1 check).");
4348
- }
4349
- _activeExporter = null;
4350
- setOtelState(OtelState.PROCESSOR_PRESENT);
4351
- emitLifecycleEvent("otel:configured", { state: OtelState.PROCESSOR_PRESENT, scenario: "B-clean" });
4352
- return;
4353
- }
4354
- if (injectionMethod) {
4355
- if (config.verbose) {
4356
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 auto-attaching Glasstrace processor.");
4357
- }
4358
- registerShutdownHook({
4359
- name: "coexistence-flush",
4360
- priority: 5,
4361
- fn: async () => {
4362
- if (_injectedProcessor) {
4363
- await _injectedProcessor.forceFlush();
4364
- }
4365
- }
4366
- });
4367
- registerBeforeExitTrigger();
4368
- const scenario = injectionMethod === "v1_public" ? "D1" : "B-auto";
4369
- setOtelState(OtelState.AUTO_ATTACHED);
4370
- emitLifecycleEvent("otel:configured", { state: OtelState.AUTO_ATTACHED, scenario });
4371
- emitLifecycleEvent("otel:injection_succeeded", { method: injectionMethod });
4372
- emitNudgeMessage();
4373
- return;
4374
- }
4375
- if (config.verbose) {
4376
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 could not auto-attach.");
4377
- }
4378
- emitGuidanceMessage();
4379
- _activeExporter = null;
4380
- setOtelState(OtelState.COEXISTENCE_FAILED);
4381
- emitLifecycleEvent("otel:configured", { state: OtelState.COEXISTENCE_FAILED, scenario: "C/F" });
4382
- emitLifecycleEvent("otel:injection_failed", { reason: "provider internals inaccessible" });
4383
- const coreState = getCoreState();
4384
- if (coreState === CoreState.ACTIVE || coreState === CoreState.KEY_RESOLVED) {
4385
- setCoreState(CoreState.ACTIVE_DEGRADED);
4386
- }
4387
- return;
4388
- }
4389
3867
  const vercelOtel = await tryImport("@vercel/otel");
4390
3868
  if (vercelOtel && typeof vercelOtel.registerOTel === "function") {
4391
3869
  const otelConfig = {
@@ -4430,7 +3908,6 @@ async function configureOtel(config, sessionManager) {
4430
3908
  await provider.shutdown();
4431
3909
  }
4432
3910
  });
4433
- registerSignalHandlers();
4434
3911
  registerBeforeExitTrigger();
4435
3912
  const prismaModule = await tryImport("@prisma/instrumentation");
4436
3913
  if (prismaModule) {
@@ -4449,8 +3926,7 @@ async function configureOtel(config, sessionManager) {
4449
3926
  }
4450
3927
 
4451
3928
  // src/context-manager.ts
4452
- init_esm_shims();
4453
- import { AsyncLocalStorage } from "async_hooks";
3929
+ import { AsyncLocalStorage } from "node:async_hooks";
4454
3930
  function installContextManager() {
4455
3931
  try {
4456
3932
  const als = new AsyncLocalStorage();
@@ -4480,17 +3956,19 @@ function installContextManager() {
4480
3956
  }
4481
3957
 
4482
3958
  // src/heartbeat.ts
4483
- init_esm_shims();
4484
3959
  var HEARTBEAT_INTERVAL_MS = 5 * 60 * 1e3;
4485
3960
  var BACKOFF_BASE_MS = HEARTBEAT_INTERVAL_MS;
4486
3961
  var BACKOFF_MAX_MS = 30 * 60 * 1e3;
4487
3962
  var BACKOFF_JITTER = 0.2;
3963
+ var HEARTBEAT_SHUTDOWN_PRIORITY = 10;
3964
+ var SHUTDOWN_MARKER_RELPATH = ".glasstrace/shutdown-requested";
4488
3965
  var heartbeatTimer = null;
4489
3966
  var heartbeatGeneration = 0;
4490
3967
  var backoffAttempts = 0;
4491
3968
  var backoffUntil = 0;
4492
3969
  var tickInProgress = false;
4493
- var _shutdownHandler = null;
3970
+ var shutdownHookRegistered = false;
3971
+ var shutdownFired = false;
4494
3972
  function startHeartbeat(config, anonKey, sdkVersion, generation, onClaimTransition) {
4495
3973
  if (heartbeatTimer !== null) return;
4496
3974
  heartbeatGeneration = generation;
@@ -4498,7 +3976,7 @@ function startHeartbeat(config, anonKey, sdkVersion, generation, onClaimTransiti
4498
3976
  void heartbeatTick(config, anonKey, sdkVersion, generation, onClaimTransition);
4499
3977
  }, HEARTBEAT_INTERVAL_MS);
4500
3978
  heartbeatTimer.unref();
4501
- registerShutdownHandlers(config, anonKey, sdkVersion);
3979
+ registerHeartbeatShutdownHook(config, anonKey, sdkVersion);
4502
3980
  if (config.verbose) {
4503
3981
  sdkLog("info", "[glasstrace] Heartbeat started (5-minute interval).");
4504
3982
  }
@@ -4508,7 +3986,26 @@ function stopHeartbeat() {
4508
3986
  clearInterval(heartbeatTimer);
4509
3987
  heartbeatTimer = null;
4510
3988
  }
4511
- removeShutdownHandlers();
3989
+ }
3990
+ function checkShutdownMarker(projectRoot) {
3991
+ let fsSync = null;
3992
+ let pathSync = null;
3993
+ try {
3994
+ fsSync = __require("node:fs");
3995
+ pathSync = __require("node:path");
3996
+ } catch {
3997
+ return { triggered: false };
3998
+ }
3999
+ const root = projectRoot ?? (typeof process !== "undefined" ? process.cwd() : ".");
4000
+ const markerPath = pathSync.join(root, SHUTDOWN_MARKER_RELPATH);
4001
+ if (!fsSync.existsSync(markerPath)) return { triggered: false };
4002
+ try {
4003
+ fsSync.unlinkSync(markerPath);
4004
+ } catch {
4005
+ }
4006
+ const shutdown = executeShutdown().catch(() => {
4007
+ });
4008
+ return { triggered: true, shutdown };
4512
4009
  }
4513
4010
  async function heartbeatTick(config, anonKey, sdkVersion, generation, onClaimTransition) {
4514
4011
  if (tickInProgress) return;
@@ -4518,6 +4015,14 @@ async function heartbeatTick(config, anonKey, sdkVersion, generation, onClaimTra
4518
4015
  stopHeartbeat();
4519
4016
  return;
4520
4017
  }
4018
+ const markerResult = checkShutdownMarker();
4019
+ if (markerResult.triggered) {
4020
+ stopHeartbeat();
4021
+ if (markerResult.shutdown) {
4022
+ await markerResult.shutdown;
4023
+ }
4024
+ return;
4025
+ }
4521
4026
  if (Date.now() < backoffUntil) {
4522
4027
  if (config.verbose) {
4523
4028
  sdkLog("info", "[glasstrace] Heartbeat skipped (rate-limit backoff).");
@@ -4552,41 +4057,31 @@ async function heartbeatTick(config, anonKey, sdkVersion, generation, onClaimTra
4552
4057
  tickInProgress = false;
4553
4058
  }
4554
4059
  }
4555
- function registerShutdownHandlers(config, anonKey, sdkVersion) {
4556
- if (typeof process === "undefined" || typeof process.once !== "function") {
4557
- return;
4558
- }
4559
- let shutdownFired = false;
4560
- const handler = (signal) => {
4561
- if (shutdownFired) return;
4562
- shutdownFired = true;
4563
- if (heartbeatTimer !== null) {
4564
- clearInterval(heartbeatTimer);
4565
- heartbeatTimer = null;
4060
+ function registerHeartbeatShutdownHook(config, anonKey, sdkVersion) {
4061
+ if (shutdownHookRegistered) return;
4062
+ shutdownHookRegistered = true;
4063
+ registerShutdownHook({
4064
+ name: "heartbeat-final-report",
4065
+ priority: HEARTBEAT_SHUTDOWN_PRIORITY,
4066
+ fn: async () => {
4067
+ if (shutdownFired) return;
4068
+ shutdownFired = true;
4069
+ if (heartbeatTimer !== null) {
4070
+ clearInterval(heartbeatTimer);
4071
+ heartbeatTimer = null;
4072
+ }
4073
+ try {
4074
+ const healthReport = collectHealthReport(sdkVersion);
4075
+ await performInit(config, anonKey, sdkVersion, healthReport);
4076
+ } catch {
4077
+ }
4566
4078
  }
4567
- const healthReport = collectHealthReport(sdkVersion);
4568
- void performInit(config, anonKey, sdkVersion, healthReport).catch(() => {
4569
- }).finally(() => {
4570
- removeShutdownHandlers();
4571
- process.kill(process.pid, signal);
4572
- });
4573
- };
4574
- _shutdownHandler = handler;
4575
- process.once("SIGTERM", _shutdownHandler);
4576
- process.once("SIGINT", _shutdownHandler);
4577
- }
4578
- function removeShutdownHandlers() {
4579
- if (_shutdownHandler && typeof process !== "undefined") {
4580
- process.removeListener("SIGTERM", _shutdownHandler);
4581
- process.removeListener("SIGINT", _shutdownHandler);
4582
- _shutdownHandler = null;
4583
- }
4079
+ });
4584
4080
  }
4585
4081
 
4586
4082
  // src/runtime-state.ts
4587
- init_esm_shims();
4588
- import { writeFileSync, renameSync, mkdirSync } from "fs";
4589
- import { join } from "path";
4083
+ import { writeFileSync, renameSync, mkdirSync } from "node:fs";
4084
+ import { join } from "node:path";
4590
4085
  var _projectRoot = null;
4591
4086
  var _sdkVersion = "unknown";
4592
4087
  var _lastScenario;
@@ -4681,7 +4176,7 @@ function registerGlasstrace(options) {
4681
4176
  setCoreState(CoreState.REGISTERING);
4682
4177
  startRuntimeStateWriter({
4683
4178
  projectRoot: process.cwd(),
4684
- sdkVersion: "0.14.2"
4179
+ sdkVersion: "0.16.0"
4685
4180
  });
4686
4181
  const config = resolveConfig(options);
4687
4182
  if (config.verbose) {
@@ -4697,6 +4192,11 @@ function registerGlasstrace(options) {
4697
4192
  if (config.verbose) {
4698
4193
  console.info("[glasstrace] Not production-disabled.");
4699
4194
  }
4195
+ const existingProbe = trace.getTracerProvider().getTracer("glasstrace-probe");
4196
+ const anotherProviderRegistered = existingProbe.constructor.name !== "ProxyTracer";
4197
+ if (!anotherProviderRegistered) {
4198
+ registerSignalHandlers();
4199
+ }
4700
4200
  const anonymous = isAnonymousMode(config);
4701
4201
  let effectiveKey = config.apiKey;
4702
4202
  initAuthState(anonymous ? AuthState.ANONYMOUS : AuthState.AUTHENTICATED);
@@ -4727,8 +4227,6 @@ function registerGlasstrace(options) {
4727
4227
  }
4728
4228
  setCoreState(CoreState.KEY_PENDING);
4729
4229
  const currentGeneration = registrationGeneration;
4730
- const existingProbe = trace.getTracerProvider().getTracer("glasstrace-probe");
4731
- const anotherProviderRegistered = existingProbe.constructor.name !== "ProxyTracer";
4732
4230
  if (anotherProviderRegistered) {
4733
4231
  if (config.verbose) {
4734
4232
  console.info("[glasstrace] Another OTel provider detected \u2014 using existing context manager.");
@@ -4843,8 +4341,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4843
4341
  if (config.verbose) {
4844
4342
  console.info("[glasstrace] Background init firing.");
4845
4343
  }
4846
- const healthReport = collectHealthReport("0.14.2");
4847
- const initResult = await performInit(config, anonKeyForInit, "0.14.2", healthReport);
4344
+ const healthReport = collectHealthReport("0.16.0");
4345
+ const initResult = await performInit(config, anonKeyForInit, "0.16.0", healthReport);
4848
4346
  if (generation !== registrationGeneration) return;
4849
4347
  const currentState = getCoreState();
4850
4348
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -4867,7 +4365,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4867
4365
  }
4868
4366
  maybeInstallConsoleCapture();
4869
4367
  if (didLastInitSucceed()) {
4870
- startHeartbeat(config, anonKeyForInit, "0.14.2", generation, (newApiKey, accountId) => {
4368
+ startHeartbeat(config, anonKeyForInit, "0.16.0", generation, (newApiKey, accountId) => {
4871
4369
  setAuthState(AuthState.CLAIMING);
4872
4370
  emitLifecycleEvent("auth:claim_started", { accountId });
4873
4371
  setResolvedApiKey(newApiKey);
@@ -4897,7 +4395,7 @@ function isDiscoveryEnabled(config) {
4897
4395
  }
4898
4396
 
4899
4397
  // src/config-wrapper.ts
4900
- init_esm_shims();
4398
+ import { isBuiltin as isNodeBuiltin } from "node:module";
4901
4399
  function isTurbopackBuild() {
4902
4400
  if (typeof process === "undefined") return false;
4903
4401
  const argv = Array.isArray(process.argv) ? process.argv : [];
@@ -4906,6 +4404,36 @@ function isTurbopackBuild() {
4906
4404
  if (process.env?.TURBOPACK === "1") return true;
4907
4405
  return false;
4908
4406
  }
4407
+ var SDK_PACKAGE_NAME = "@glasstrace/sdk";
4408
+ function appendNodeSchemeExternal(webpackConfig) {
4409
+ const nodeBuiltinExternal = (data, callback) => {
4410
+ const request = data.request;
4411
+ if (typeof request === "string" && isNodeBuiltin(request)) {
4412
+ callback(null, "commonjs " + request);
4413
+ return;
4414
+ }
4415
+ callback(null);
4416
+ };
4417
+ const existing = webpackConfig.externals;
4418
+ if (Array.isArray(existing)) {
4419
+ webpackConfig.externals = [...existing, nodeBuiltinExternal];
4420
+ } else if (existing == null) {
4421
+ webpackConfig.externals = [nodeBuiltinExternal];
4422
+ } else {
4423
+ webpackConfig.externals = [existing, nodeBuiltinExternal];
4424
+ }
4425
+ }
4426
+ function ensureServerExternal(config) {
4427
+ const existingStable = config.serverExternalPackages;
4428
+ const stable = Array.isArray(existingStable) ? (
4429
+ // Clone so we never mutate a caller-owned array in place.
4430
+ existingStable.filter((entry) => typeof entry === "string")
4431
+ ) : [];
4432
+ if (!stable.includes(SDK_PACKAGE_NAME)) {
4433
+ stable.push(SDK_PACKAGE_NAME);
4434
+ }
4435
+ config.serverExternalPackages = stable;
4436
+ }
4909
4437
  function withGlasstraceConfig(nextConfig) {
4910
4438
  if (typeof process === "undefined" || typeof process.versions?.node !== "string") {
4911
4439
  return nextConfig != null ? { ...nextConfig } : {};
@@ -4917,6 +4445,7 @@ function withGlasstraceConfig(nextConfig) {
4917
4445
  ...existingExperimental,
4918
4446
  serverSourceMaps: true
4919
4447
  };
4448
+ ensureServerExternal(bag);
4920
4449
  if (bag.turbopack == null) {
4921
4450
  bag.turbopack = {};
4922
4451
  }
@@ -4931,6 +4460,9 @@ function withGlasstraceConfig(nextConfig) {
4931
4460
  result = existingWebpack(webpackConfig, context2);
4932
4461
  }
4933
4462
  const webpackContext = context2;
4463
+ if (webpackContext.isServer) {
4464
+ appendNodeSchemeExternal(result);
4465
+ }
4934
4466
  if (!webpackContext.isServer && webpackContext.dev === false) {
4935
4467
  const plugins = result.plugins ?? [];
4936
4468
  plugins.push({
@@ -4970,7 +4502,7 @@ async function handleSourceMapUpload(distDir) {
4970
4502
  );
4971
4503
  return;
4972
4504
  }
4973
- const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-3GWUQDTS.js");
4505
+ const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-MUZPI2S5.js");
4974
4506
  const files = await discoverSourceMapFiles2(distDir);
4975
4507
  if (files.length === 0) {
4976
4508
  console.info("[glasstrace] No source map files found. Skipping upload.");
@@ -4990,7 +4522,6 @@ async function handleSourceMapUpload(distDir) {
4990
4522
  }
4991
4523
 
4992
4524
  // src/capture-error.ts
4993
- init_esm_shims();
4994
4525
  function captureError(error) {
4995
4526
  try {
4996
4527
  const span = trace.getSpan(context.active());