@glasstrace/sdk 0.15.1 → 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 (78) 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-ZNOD6FC7.js → chunk-CTJI2YKA.js} +8 -15
  13. package/dist/{chunk-ZNOD6FC7.js.map → chunk-CTJI2YKA.js.map} +1 -1
  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-A2AZL6MZ.js → chunk-O63DJKIJ.js} +169 -18
  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-ROFOJQWN.js → chunk-XNDHQN4S.js} +7 -11
  28. package/dist/{chunk-ROFOJQWN.js.map → chunk-XNDHQN4S.js.map} +1 -1
  29. package/dist/cli/init.cjs +673 -161
  30. package/dist/cli/init.cjs.map +1 -1
  31. package/dist/cli/init.d.cts +54 -1
  32. package/dist/cli/init.d.ts +54 -1
  33. package/dist/cli/init.js +146 -37
  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 +10 -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 +56 -59
  43. package/dist/cli/uninit.cjs.map +1 -1
  44. package/dist/cli/uninit.js +4 -4
  45. package/dist/cli/validate.cjs +2 -2
  46. package/dist/cli/validate.js +3 -6
  47. package/dist/cli/validate.js.map +1 -1
  48. package/dist/{esm-MDK7CZID.js → esm-KBPHCVB4.js} +3 -3
  49. package/dist/{getMachineId-bsd-4NIRBWME.js → getMachineId-bsd-345PYXFX.js} +4 -7
  50. package/dist/{getMachineId-bsd-4NIRBWME.js.map → getMachineId-bsd-345PYXFX.js.map} +1 -1
  51. package/dist/{getMachineId-darwin-2XNOCCJQ.js → getMachineId-darwin-5L2D25AD.js} +4 -7
  52. package/dist/{getMachineId-darwin-2XNOCCJQ.js.map → getMachineId-darwin-5L2D25AD.js.map} +1 -1
  53. package/dist/{getMachineId-linux-V6YSQEY7.js → getMachineId-linux-KJR4P5HN.js} +3 -6
  54. package/dist/{getMachineId-linux-V6YSQEY7.js.map → getMachineId-linux-KJR4P5HN.js.map} +1 -1
  55. package/dist/{getMachineId-unsupported-4FKBJNVO.js → getMachineId-unsupported-NDNXDYDY.js} +3 -6
  56. package/dist/{getMachineId-unsupported-4FKBJNVO.js.map → getMachineId-unsupported-NDNXDYDY.js.map} +1 -1
  57. package/dist/{getMachineId-win-WLRZBKVG.js → getMachineId-win-T7PJNJXG.js} +4 -7
  58. package/dist/{getMachineId-win-WLRZBKVG.js.map → getMachineId-win-T7PJNJXG.js.map} +1 -1
  59. package/dist/index.cjs +449 -461
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +38 -3
  62. package/dist/index.d.ts +38 -3
  63. package/dist/index.js +195 -701
  64. package/dist/index.js.map +1 -1
  65. package/dist/{monorepo-YILKGQXQ.js → monorepo-N5Z63XP7.js} +4 -4
  66. package/dist/{source-map-uploader-3GWUQDTS.js → source-map-uploader-MUZPI2S5.js} +5 -4
  67. package/dist/source-map-uploader-MUZPI2S5.js.map +1 -0
  68. package/package.json +1 -1
  69. package/dist/chunk-2LDBR3F3.js.map +0 -1
  70. package/dist/chunk-A2AZL6MZ.js.map +0 -1
  71. package/dist/chunk-BGZ7J74D.js.map +0 -1
  72. package/dist/chunk-UPS5BGER.js +0 -182
  73. package/dist/chunk-UPS5BGER.js.map +0 -1
  74. package/dist/chunk-WK7MPK2T.js.map +0 -1
  75. package/dist/chunk-YMEXDDTA.js.map +0 -1
  76. /package/dist/{esm-MDK7CZID.js.map → chunk-NSBPE2FW.js.map} +0 -0
  77. /package/dist/{monorepo-YILKGQXQ.js.map → esm-KBPHCVB4.js.map} +0 -0
  78. /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,395 +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
- const tmpPath = `${configPath}.tmp`;
308
- try {
309
- await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
310
- await modules.fs.chmod(dirPath, 448);
311
- const cached = {
312
- response,
313
- cachedAt: Date.now()
314
- };
315
- await modules.fs.writeFile(tmpPath, JSON.stringify(cached), {
316
- encoding: "utf-8",
317
- mode: 384
318
- });
319
- try {
320
- await modules.fs.chmod(tmpPath, 384);
321
- await modules.fs.rename(tmpPath, configPath);
322
- } catch (renameErr) {
323
- try {
324
- await modules.fs.unlink(tmpPath);
325
- } catch {
326
- }
327
- throw renameErr;
328
- }
329
- await modules.fs.chmod(configPath, 384);
330
- } catch (err) {
331
- console.warn(
332
- `[glasstrace] Failed to cache config to ${configPath}: ${err instanceof Error ? err.message : String(err)}`
333
- );
334
- }
335
- }
336
- async function sendInitRequest(config, anonKey, sdkVersion, importGraph, healthReport, diagnostics, signal) {
337
- const effectiveKey = config.apiKey || anonKey;
338
- if (!effectiveKey) {
339
- throw new Error("No API key available for init request");
340
- }
341
- const payload = {
342
- sdkVersion
343
- };
344
- if (config.apiKey && anonKey) {
345
- payload.anonKey = anonKey;
346
- }
347
- if (config.environment) {
348
- payload.environment = config.environment;
349
- }
350
- if (importGraph) {
351
- payload.importGraph = importGraph;
352
- }
353
- if (healthReport) {
354
- payload.healthReport = healthReport;
355
- }
356
- if (diagnostics) {
357
- payload.diagnostics = diagnostics;
358
- }
359
- const url = `${config.endpoint}/v1/sdk/init`;
360
- const response = await fetch(url, {
361
- method: "POST",
362
- headers: {
363
- "Content-Type": "application/json",
364
- Authorization: `Bearer ${effectiveKey}`
365
- },
366
- body: JSON.stringify(payload),
367
- signal
368
- });
369
- if (!response.ok) {
370
- try {
371
- await response.text();
372
- } catch {
373
- }
374
- const error = new Error(`Init request failed with status ${response.status}`);
375
- error.status = response.status;
376
- throw error;
377
- }
378
- const body = await response.json();
379
- return SdkInitResponseSchema.parse(body);
380
- }
381
- async function writeClaimedKey(newApiKey, projectRoot) {
382
- const modules = await loadFsPathAsync();
383
- if (modules) {
384
- const root = projectRoot ?? process.cwd();
385
- const envLocalPath = modules.path.join(root, ".env.local");
386
- let envLocalWritten = false;
387
- try {
388
- let content;
389
- try {
390
- content = await modules.fs.readFile(envLocalPath, "utf-8");
391
- if (/^GLASSTRACE_API_KEY=.*/m.test(content)) {
392
- content = content.replace(
393
- /^GLASSTRACE_API_KEY=.*$/gm,
394
- `GLASSTRACE_API_KEY=${newApiKey}`
395
- );
396
- } else {
397
- if (content.length > 0 && !content.endsWith("\n")) {
398
- content += "\n";
399
- }
400
- content += `GLASSTRACE_API_KEY=${newApiKey}
401
- `;
402
- }
403
- } catch (readErr) {
404
- const code = readErr instanceof Error ? readErr.code : void 0;
405
- if (code !== "ENOENT") {
406
- throw readErr;
407
- }
408
- content = `GLASSTRACE_API_KEY=${newApiKey}
409
- `;
410
- }
411
- await modules.fs.writeFile(envLocalPath, content, { encoding: "utf-8", mode: 384 });
412
- await modules.fs.chmod(envLocalPath, 384);
413
- envLocalWritten = true;
414
- } catch {
415
- }
416
- if (envLocalWritten) {
417
- try {
418
- process.stderr.write(
419
- "[glasstrace] Account claimed! API key written to .env.local. Restart your dev server to use it.\n"
420
- );
421
- } catch {
422
- }
423
- return;
424
- }
425
- let claimedKeyWritten = false;
426
- try {
427
- const dirPath = modules.path.join(root, GLASSTRACE_DIR);
428
- await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
429
- await modules.fs.chmod(dirPath, 448);
430
- const claimedKeyPath = modules.path.join(dirPath, "claimed-key");
431
- await modules.fs.writeFile(claimedKeyPath, newApiKey, {
432
- encoding: "utf-8",
433
- mode: 384
434
- });
435
- await modules.fs.chmod(claimedKeyPath, 384);
436
- claimedKeyWritten = true;
437
- } catch {
438
- }
439
- if (claimedKeyWritten) {
440
- try {
441
- process.stderr.write(
442
- "[glasstrace] Account claimed! API key written to .glasstrace/claimed-key. Copy it to your .env.local file.\n"
443
- );
444
- } catch {
445
- }
446
- return;
447
- }
448
- }
449
- try {
450
- process.stderr.write(
451
- "[glasstrace] Account claimed but could not write key to disk. Visit your dashboard settings to rotate and retrieve a new API key.\n"
452
- );
453
- } catch {
454
- }
455
- }
456
- async function performInit(config, anonKey, sdkVersion, healthReport) {
457
- lastInitSucceeded = false;
458
- if (rateLimitBackoff) {
459
- rateLimitBackoff = false;
460
- return null;
461
- }
462
- try {
463
- const effectiveKey = config.apiKey || anonKey;
464
- if (!effectiveKey) {
465
- console.warn("[glasstrace] No API key available for init request.");
466
- return null;
467
- }
468
- const controller = new AbortController();
469
- const timeoutId = setTimeout(() => controller.abort(), INIT_TIMEOUT_MS);
470
- try {
471
- const result = await sendInitRequest(
472
- config,
473
- anonKey,
474
- sdkVersion,
475
- void 0,
476
- healthReport ?? void 0,
477
- void 0,
478
- controller.signal
479
- );
480
- clearTimeout(timeoutId);
481
- currentConfig = result;
482
- recordConfigSync(Date.now());
483
- if (healthReport) {
484
- acknowledgeHealthReport(healthReport);
485
- }
486
- lastInitSucceeded = true;
487
- await saveCachedConfig(result);
488
- if (result.claimResult) {
489
- try {
490
- await writeClaimedKey(result.claimResult.newApiKey);
491
- } catch {
492
- }
493
- return { claimResult: result.claimResult };
494
- }
495
- return null;
496
- } catch (err) {
497
- clearTimeout(timeoutId);
498
- recordInitFailure();
499
- if (err instanceof DOMException && err.name === "AbortError") {
500
- console.warn("[glasstrace] ingestion_unreachable: Init request timed out.");
501
- return null;
502
- }
503
- const status = err.status;
504
- if (status === 401) {
505
- console.warn(
506
- "[glasstrace] ingestion_auth_failed: Check your GLASSTRACE_API_KEY."
507
- );
508
- return null;
509
- }
510
- if (status === 429) {
511
- console.warn("[glasstrace] ingestion_rate_limited: Backing off.");
512
- rateLimitBackoff = true;
513
- return null;
514
- }
515
- if (typeof status === "number" && status >= 400) {
516
- console.warn(
517
- `[glasstrace] Init request failed with status ${status}. Using cached config.`
518
- );
519
- return null;
520
- }
521
- if (err instanceof Error && err.name === "ZodError") {
522
- console.warn(
523
- "[glasstrace] Init response failed validation (schema version mismatch?). Using cached config."
524
- );
525
- return null;
526
- }
527
- console.warn(
528
- `[glasstrace] ingestion_unreachable: ${err instanceof Error ? err.message : String(err)}`
529
- );
530
- return null;
531
- }
532
- } catch (err) {
533
- console.warn(
534
- `[glasstrace] Unexpected init error: ${err instanceof Error ? err.message : String(err)}`
535
- );
536
- }
537
- return null;
538
- }
539
- function getActiveConfig() {
540
- if (currentConfig) {
541
- return currentConfig.config;
542
- }
543
- if (!configCacheChecked) {
544
- configCacheChecked = true;
545
- const cached = loadCachedConfig();
546
- if (cached) {
547
- currentConfig = cached;
548
- return cached.config;
549
- }
550
- }
551
- return { ...DEFAULT_CAPTURE_CONFIG };
552
- }
553
- function getLinkedAccountId() {
554
- return currentConfig?.linkedAccountId;
555
- }
556
- function getClaimResult() {
557
- return currentConfig?.claimResult;
558
- }
559
- function _setCurrentConfig(config) {
560
- currentConfig = config;
561
- }
562
- function consumeRateLimitFlag() {
563
- if (rateLimitBackoff) {
564
- rateLimitBackoff = false;
565
- return true;
566
- }
567
- return false;
568
- }
569
- function didLastInitSucceed() {
570
- return lastInitSucceeded;
571
- }
572
-
573
191
  // src/span-processor.ts
574
- init_esm_shims();
575
192
  var GlasstraceSpanProcessor = class {
576
193
  wrappedProcessor;
577
194
  /* eslint-disable @typescript-eslint/no-unused-vars -- backward compat signature */
@@ -593,7 +210,6 @@ var GlasstraceSpanProcessor = class {
593
210
  };
594
211
 
595
212
  // src/enriching-exporter.ts
596
- init_esm_shims();
597
213
  var ATTR = GLASSTRACE_ATTRIBUTE_NAMES;
598
214
  var API_KEY_PENDING = "pending";
599
215
  var MAX_PENDING_SPANS = 1024;
@@ -972,7 +588,6 @@ function deriveErrorCategory(errorType) {
972
588
  }
973
589
 
974
590
  // src/discovery-endpoint.ts
975
- init_esm_shims();
976
591
  function isAllowedOrigin(origin) {
977
592
  if (origin === null) return true;
978
593
  if (origin.startsWith("chrome-extension://")) return true;
@@ -1061,29 +676,7 @@ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
1061
676
  };
1062
677
  }
1063
678
 
1064
- // src/register.ts
1065
- init_esm_shims();
1066
-
1067
- // src/otel-config.ts
1068
- init_esm_shims();
1069
-
1070
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js
1071
- init_esm_shims();
1072
-
1073
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js
1074
- init_esm_shims();
1075
-
1076
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js
1077
- init_esm_shims();
1078
-
1079
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js
1080
- init_esm_shims();
1081
-
1082
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
1083
- init_esm_shims();
1084
-
1085
679
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
1086
- init_esm_shims();
1087
680
  var OTLPExporterBase = class {
1088
681
  _delegate;
1089
682
  constructor(delegate) {
@@ -1106,7 +699,6 @@ var OTLPExporterBase = class {
1106
699
  };
1107
700
 
1108
701
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js
1109
- init_esm_shims();
1110
702
  var OTLPExporterError = class extends Error {
1111
703
  code;
1112
704
  name = "OTLPExporterError";
@@ -1119,7 +711,6 @@ var OTLPExporterError = class extends Error {
1119
711
  };
1120
712
 
1121
713
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js
1122
- init_esm_shims();
1123
714
  function validateTimeoutMillis(timeoutMillis) {
1124
715
  if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {
1125
716
  return timeoutMillis;
@@ -1148,7 +739,6 @@ function getSharedConfigurationDefaults() {
1148
739
  }
1149
740
 
1150
741
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js
1151
- init_esm_shims();
1152
742
  var BoundedQueueExportPromiseHandler = class {
1153
743
  _concurrencyLimit;
1154
744
  _sendingPromises = [];
@@ -1180,14 +770,7 @@ function createBoundedQueueExportPromiseHandler(options) {
1180
770
  return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
1181
771
  }
1182
772
 
1183
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js
1184
- init_esm_shims();
1185
-
1186
- // ../../node_modules/@opentelemetry/core/build/esm/index.js
1187
- init_esm_shims();
1188
-
1189
773
  // ../../node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
1190
- init_esm_shims();
1191
774
  var SUPPRESS_TRACING_KEY = createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
1192
775
  function suppressTracing(context2) {
1193
776
  return context2.setValue(SUPPRESS_TRACING_KEY, true);
@@ -1197,13 +780,11 @@ function isTracingSuppressed(context2) {
1197
780
  }
1198
781
 
1199
782
  // ../../node_modules/@opentelemetry/core/build/esm/baggage/constants.js
1200
- init_esm_shims();
1201
783
  var BAGGAGE_KEY_PAIR_SEPARATOR = "=";
1202
784
  var BAGGAGE_PROPERTIES_SEPARATOR = ";";
1203
785
  var BAGGAGE_ITEMS_SEPARATOR = ",";
1204
786
 
1205
787
  // ../../node_modules/@opentelemetry/core/build/esm/baggage/utils.js
1206
- init_esm_shims();
1207
788
  function parsePairKeyValue(entry) {
1208
789
  if (!entry)
1209
790
  return;
@@ -1245,7 +826,6 @@ function parseKeyPairsIntoRecord(value) {
1245
826
  }
1246
827
 
1247
828
  // ../../node_modules/@opentelemetry/core/build/esm/common/attributes.js
1248
- init_esm_shims();
1249
829
  function sanitizeAttributes(attributes) {
1250
830
  const out = {};
1251
831
  if (typeof attributes !== "object" || attributes == null) {
@@ -1314,11 +894,7 @@ function isValidPrimitiveAttributeValueType(valType) {
1314
894
  return false;
1315
895
  }
1316
896
 
1317
- // ../../node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
1318
- init_esm_shims();
1319
-
1320
897
  // ../../node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
1321
- init_esm_shims();
1322
898
  function loggingErrorHandler() {
1323
899
  return (ex) => {
1324
900
  diag.error(stringifyException(ex));
@@ -1357,17 +933,7 @@ function globalErrorHandler(ex) {
1357
933
  }
1358
934
  }
1359
935
 
1360
- // ../../node_modules/@opentelemetry/core/build/esm/common/time.js
1361
- init_esm_shims();
1362
-
1363
- // ../../node_modules/@opentelemetry/core/build/esm/platform/index.js
1364
- init_esm_shims();
1365
-
1366
- // ../../node_modules/@opentelemetry/core/build/esm/platform/node/index.js
1367
- init_esm_shims();
1368
-
1369
936
  // ../../node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
1370
- init_esm_shims();
1371
937
  import { inspect } from "util";
1372
938
  function getNumberFromEnv(key) {
1373
939
  const raw = process.env[key];
@@ -1389,15 +955,10 @@ function getStringFromEnv(key) {
1389
955
  return raw;
1390
956
  }
1391
957
 
1392
- // ../../node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
1393
- init_esm_shims();
1394
-
1395
958
  // ../../node_modules/@opentelemetry/core/build/esm/version.js
1396
- init_esm_shims();
1397
959
  var VERSION = "2.6.1";
1398
960
 
1399
961
  // ../../node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
1400
- init_esm_shims();
1401
962
  var ATTR_EXCEPTION_MESSAGE = "exception.message";
1402
963
  var ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
1403
964
  var ATTR_EXCEPTION_TYPE = "exception.type";
@@ -1408,7 +969,6 @@ var ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
1408
969
  var ATTR_TELEMETRY_SDK_VERSION = "telemetry.sdk.version";
1409
970
 
1410
971
  // ../../node_modules/@opentelemetry/core/build/esm/semconv.js
1411
- init_esm_shims();
1412
972
  var ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
1413
973
 
1414
974
  // ../../node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
@@ -1466,18 +1026,13 @@ function addHrTimes(time1, time2) {
1466
1026
  }
1467
1027
 
1468
1028
  // ../../node_modules/@opentelemetry/core/build/esm/ExportResult.js
1469
- init_esm_shims();
1470
1029
  var ExportResultCode;
1471
1030
  (function(ExportResultCode2) {
1472
1031
  ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
1473
1032
  ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
1474
1033
  })(ExportResultCode || (ExportResultCode = {}));
1475
1034
 
1476
- // ../../node_modules/@opentelemetry/core/build/esm/utils/merge.js
1477
- init_esm_shims();
1478
-
1479
1035
  // ../../node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js
1480
- init_esm_shims();
1481
1036
  var objectTag = "[object Object]";
1482
1037
  var nullTag = "[object Null]";
1483
1038
  var undefinedTag = "[object Undefined]";
@@ -1637,11 +1192,7 @@ function shouldMerge(one, two) {
1637
1192
  return true;
1638
1193
  }
1639
1194
 
1640
- // ../../node_modules/@opentelemetry/core/build/esm/utils/callback.js
1641
- init_esm_shims();
1642
-
1643
1195
  // ../../node_modules/@opentelemetry/core/build/esm/utils/promise.js
1644
- init_esm_shims();
1645
1196
  var Deferred = class {
1646
1197
  _promise;
1647
1198
  _resolve;
@@ -1693,7 +1244,6 @@ var BindOnceFuture = class {
1693
1244
  };
1694
1245
 
1695
1246
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js
1696
- init_esm_shims();
1697
1247
  function isPartialSuccessResponse(response) {
1698
1248
  return Object.prototype.hasOwnProperty.call(response, "partialSuccess");
1699
1249
  }
@@ -1791,11 +1341,7 @@ function createOtlpExportDelegate(components, settings) {
1791
1341
  return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
1792
1342
  }
1793
1343
 
1794
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
1795
- init_esm_shims();
1796
-
1797
1344
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
1798
- init_esm_shims();
1799
1345
  function createResource(resource, encoder) {
1800
1346
  const result = {
1801
1347
  attributes: toAttributes(resource.attributes, encoder),
@@ -1856,7 +1402,6 @@ function toAnyValue(value, encoder) {
1856
1402
  }
1857
1403
 
1858
1404
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
1859
- init_esm_shims();
1860
1405
  function hrTimeToNanos(hrTime2) {
1861
1406
  const NANOSECONDS = BigInt(1e9);
1862
1407
  return BigInt(Math.trunc(hrTime2[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime2[1]));
@@ -1885,14 +1430,7 @@ var JSON_ENCODER = {
1885
1430
  }
1886
1431
  };
1887
1432
 
1888
- // ../../node_modules/@opentelemetry/resources/build/esm/index.js
1889
- init_esm_shims();
1890
-
1891
- // ../../node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js
1892
- init_esm_shims();
1893
-
1894
1433
  // ../../node_modules/@opentelemetry/resources/build/esm/default-service-name.js
1895
- init_esm_shims();
1896
1434
  var serviceName;
1897
1435
  function defaultServiceName() {
1898
1436
  if (serviceName === void 0) {
@@ -1907,7 +1445,6 @@ function defaultServiceName() {
1907
1445
  }
1908
1446
 
1909
1447
  // ../../node_modules/@opentelemetry/resources/build/esm/utils.js
1910
- init_esm_shims();
1911
1448
  var isPromiseLike = (val) => {
1912
1449
  return val !== null && typeof val === "object" && typeof val.then === "function";
1913
1450
  };
@@ -2035,7 +1572,6 @@ function mergeSchemaUrl(old, updating) {
2035
1572
  }
2036
1573
 
2037
1574
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
2038
- init_esm_shims();
2039
1575
  var SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256;
2040
1576
  var SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512;
2041
1577
  function buildSpanFlagsFrom(traceFlags, isRemote) {
@@ -2148,11 +1684,7 @@ function spanRecordsToResourceSpans(readableSpans, encoder) {
2148
1684
  return out;
2149
1685
  }
2150
1686
 
2151
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js
2152
- init_esm_shims();
2153
-
2154
1687
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js
2155
- init_esm_shims();
2156
1688
  var JsonTraceSerializer = {
2157
1689
  serializeRequest: (arg) => {
2158
1690
  const request = createExportTraceServiceRequest(arg, JSON_ENCODER);
@@ -2168,17 +1700,7 @@ var JsonTraceSerializer = {
2168
1700
  }
2169
1701
  };
2170
1702
 
2171
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js
2172
- init_esm_shims();
2173
-
2174
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-configuration.js
2175
- init_esm_shims();
2176
-
2177
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js
2178
- init_esm_shims();
2179
-
2180
1703
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js
2181
- init_esm_shims();
2182
1704
  function validateAndNormalizeHeaders(partialHeaders) {
2183
1705
  const headers = {};
2184
1706
  Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {
@@ -2260,19 +1782,11 @@ function getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
2260
1782
  };
2261
1783
  }
2262
1784
 
2263
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js
2264
- init_esm_shims();
2265
-
2266
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js
2267
- init_esm_shims();
2268
-
2269
1785
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
2270
- init_esm_shims();
2271
1786
  import * as zlib from "zlib";
2272
1787
  import { Readable } from "stream";
2273
1788
 
2274
1789
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js
2275
- init_esm_shims();
2276
1790
  function isExportHTTPErrorRetryable(statusCode) {
2277
1791
  return statusCode === 429 || statusCode === 502 || statusCode === 503 || statusCode === 504;
2278
1792
  }
@@ -2292,7 +1806,6 @@ function parseRetryAfterToMills(retryAfter) {
2292
1806
  }
2293
1807
 
2294
1808
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js
2295
- init_esm_shims();
2296
1809
  var VERSION2 = "0.214.0";
2297
1810
 
2298
1811
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
@@ -2450,7 +1963,6 @@ function createHttpExporterTransport(parameters) {
2450
1963
  }
2451
1964
 
2452
1965
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js
2453
- init_esm_shims();
2454
1966
  var MAX_ATTEMPTS = 5;
2455
1967
  var INITIAL_BACKOFF = 1e3;
2456
1968
  var MAX_BACKOFF = 5e3;
@@ -2518,7 +2030,6 @@ function createOtlpHttpExportDelegate(options, serializer) {
2518
2030
  }
2519
2031
 
2520
2032
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js
2521
- init_esm_shims();
2522
2033
  function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
2523
2034
  const envTimeout = getNumberFromEnv(timeoutEnvVar);
2524
2035
  if (envTimeout != null) {
@@ -2554,11 +2065,7 @@ function getSharedConfigurationFromEnvironment(signalIdentifier) {
2554
2065
  };
2555
2066
  }
2556
2067
 
2557
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js
2558
- init_esm_shims();
2559
-
2560
2068
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-env-configuration.js
2561
- init_esm_shims();
2562
2069
  import * as fs from "fs";
2563
2070
  import * as path from "path";
2564
2071
  function getStaticHeadersFromEnv(signalIdentifier) {
@@ -2652,7 +2159,6 @@ function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourc
2652
2159
  }
2653
2160
 
2654
2161
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js
2655
- init_esm_shims();
2656
2162
  function convertLegacyHeaders(config) {
2657
2163
  if (typeof config.headers === "function") {
2658
2164
  return config.headers;
@@ -2699,20 +2205,7 @@ var OTLPTraceExporter = class extends OTLPExporterBase {
2699
2205
  }
2700
2206
  };
2701
2207
 
2702
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js
2703
- init_esm_shims();
2704
-
2705
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js
2706
- init_esm_shims();
2707
-
2708
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
2709
- init_esm_shims();
2710
-
2711
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
2712
- init_esm_shims();
2713
-
2714
2208
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js
2715
- init_esm_shims();
2716
2209
  var ExceptionEventName = "exception";
2717
2210
 
2718
2211
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
@@ -3064,17 +2557,7 @@ var SpanImpl = class {
3064
2557
  }
3065
2558
  };
3066
2559
 
3067
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js
3068
- init_esm_shims();
3069
-
3070
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js
3071
- init_esm_shims();
3072
-
3073
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js
3074
- init_esm_shims();
3075
-
3076
2560
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js
3077
- init_esm_shims();
3078
2561
  var SamplingDecision2;
3079
2562
  (function(SamplingDecision3) {
3080
2563
  SamplingDecision3[SamplingDecision3["NOT_RECORD"] = 0] = "NOT_RECORD";
@@ -3095,7 +2578,6 @@ var AlwaysOffSampler = class {
3095
2578
  };
3096
2579
 
3097
2580
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js
3098
- init_esm_shims();
3099
2581
  var AlwaysOnSampler = class {
3100
2582
  shouldSample() {
3101
2583
  return {
@@ -3108,7 +2590,6 @@ var AlwaysOnSampler = class {
3108
2590
  };
3109
2591
 
3110
2592
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js
3111
- init_esm_shims();
3112
2593
  var ParentBasedSampler = class {
3113
2594
  _root;
3114
2595
  _remoteParentSampled;
@@ -3148,7 +2629,6 @@ var ParentBasedSampler = class {
3148
2629
  };
3149
2630
 
3150
2631
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js
3151
- init_esm_shims();
3152
2632
  var TraceIdRatioBasedSampler = class {
3153
2633
  _ratio;
3154
2634
  _upperBound;
@@ -3270,17 +2750,7 @@ function reconfigureLimits(userConfig) {
3270
2750
  return Object.assign({}, userConfig, { spanLimits });
3271
2751
  }
3272
2752
 
3273
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js
3274
- init_esm_shims();
3275
-
3276
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js
3277
- init_esm_shims();
3278
-
3279
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
3280
- init_esm_shims();
3281
-
3282
2753
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
3283
- init_esm_shims();
3284
2754
  var BatchSpanProcessorBase = class {
3285
2755
  _maxExportBatchSize;
3286
2756
  _maxQueueSize;
@@ -3452,7 +2922,6 @@ var BatchSpanProcessor = class extends BatchSpanProcessorBase {
3452
2922
  };
3453
2923
 
3454
2924
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
3455
- init_esm_shims();
3456
2925
  var SPAN_ID_BYTES = 8;
3457
2926
  var TRACE_ID_BYTES = 16;
3458
2927
  var RandomIdGenerator = class {
@@ -3484,11 +2953,7 @@ function getIdGenerator(bytes) {
3484
2953
  };
3485
2954
  }
3486
2955
 
3487
- // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/TracerMetrics.js
3488
- init_esm_shims();
3489
-
3490
2956
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/semconv.js
3491
- init_esm_shims();
3492
2957
  var ATTR_OTEL_SPAN_PARENT_ORIGIN = "otel.span.parent.origin";
3493
2958
  var ATTR_OTEL_SPAN_SAMPLING_RESULT = "otel.span.sampling_result";
3494
2959
  var METRIC_OTEL_SDK_SPAN_LIVE = "otel.sdk.span.live";
@@ -3548,7 +3013,6 @@ function samplingDecisionToString(decision) {
3548
3013
  }
3549
3014
 
3550
3015
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js
3551
- init_esm_shims();
3552
3016
  var VERSION3 = "2.6.1";
3553
3017
 
3554
3018
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
@@ -3670,7 +3134,6 @@ var Tracer = class {
3670
3134
  };
3671
3135
 
3672
3136
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js
3673
- init_esm_shims();
3674
3137
  var MultiSpanProcessor = class {
3675
3138
  _spanProcessors;
3676
3139
  constructor(spanProcessors) {
@@ -3791,8 +3254,7 @@ var BasicTracerProvider = class {
3791
3254
  };
3792
3255
 
3793
3256
  // src/lifecycle.ts
3794
- init_esm_shims();
3795
- import { EventEmitter } from "events";
3257
+ import { EventEmitter } from "node:events";
3796
3258
  var CoreState = {
3797
3259
  IDLE: "IDLE",
3798
3260
  REGISTERING: "REGISTERING",
@@ -4137,7 +3599,7 @@ function registerBeforeExitTrigger() {
4137
3599
  }
4138
3600
 
4139
3601
  // src/coexistence.ts
4140
- init_esm_shims();
3602
+ var GLASSTRACE_EXPORTER_BRAND = /* @__PURE__ */ Symbol.for("glasstrace.exporter");
4141
3603
  function createGlasstraceSpanProcessor(options) {
4142
3604
  const config = resolveConfig(options);
4143
3605
  const exporterUrl = `${config.endpoint}/v1/traces`;
@@ -4148,13 +3610,64 @@ function createGlasstraceSpanProcessor(options) {
4148
3610
  getConfig: () => getActiveConfig(),
4149
3611
  environment: config.environment,
4150
3612
  endpointUrl: exporterUrl,
4151
- 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
4152
3618
  });
4153
3619
  registerExporterForKeyNotification(exporter);
4154
3620
  return new BatchSpanProcessor(exporter, {
4155
3621
  scheduledDelayMillis: 1e3
4156
3622
  });
4157
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
+ }
4158
3671
  function emitNudgeMessage() {
4159
3672
  const isSentry = detectSentry();
4160
3673
  if (isSentry) {
@@ -4223,6 +3736,12 @@ Add Glasstrace to your provider configuration:
4223
3736
  );
4224
3737
  }
4225
3738
  }
3739
+ function hasBrandedProcessor(processors) {
3740
+ return processors.some((p) => {
3741
+ const exporter = p._exporter;
3742
+ return exporter?.[GLASSTRACE_EXPORTER_BRAND] === true;
3743
+ });
3744
+ }
4226
3745
  function detectSentry() {
4227
3746
  try {
4228
3747
  __require.resolve("@sentry/node");
@@ -4264,65 +3783,75 @@ async function tryImport(moduleId) {
4264
3783
  return null;
4265
3784
  }
4266
3785
  }
4267
- function tryInjectProcessor(tracerProvider, glasstraceExporter) {
4268
- try {
4269
- const proxy = tracerProvider;
4270
- const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
4271
- const withAdd = delegate;
4272
- if (typeof withAdd.addSpanProcessor === "function") {
4273
- if (typeof withAdd.getActiveSpanProcessor === "function") {
4274
- const active = withAdd.getActiveSpanProcessor();
4275
- const brand = /* @__PURE__ */ Symbol.for("glasstrace.exporter");
4276
- const processors = active?._spanProcessors;
4277
- if (Array.isArray(processors) && processors.some((p) => {
4278
- const exp = p._exporter;
4279
- return exp?.[brand] === true;
4280
- })) {
4281
- return "already_present";
4282
- }
4283
- }
4284
- const processor2 = new BatchSpanProcessor(glasstraceExporter, {
4285
- scheduledDelayMillis: 1e3
4286
- });
4287
- withAdd.addSpanProcessor(processor2);
4288
- _injectedProcessor = processor2;
4289
- return "v1_public";
4290
- }
4291
- const provider = delegate;
4292
- const multiProcessor = provider._activeSpanProcessor;
4293
- if (!multiProcessor || !Array.isArray(multiProcessor._spanProcessors)) {
4294
- 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);
4295
3793
  }
4296
- const processor = new BatchSpanProcessor(glasstraceExporter, {
4297
- scheduledDelayMillis: 1e3
4298
- });
4299
- multiProcessor._spanProcessors.push(processor);
4300
- _injectedProcessor = processor;
4301
- return "v2_private";
4302
- } catch {
4303
- 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;
4304
3801
  }
3802
+ await runRegistrationPath(config, sessionManager);
4305
3803
  }
4306
- function isGlasstraceProcessorPresent(tracerProvider) {
4307
- try {
4308
- const proxy = tracerProvider;
4309
- const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
4310
- const provider = delegate;
4311
- const processors = provider._activeSpanProcessor?._spanProcessors;
4312
- if (!Array.isArray(processors)) {
4313
- 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.");
4314
3812
  }
4315
- const brand = /* @__PURE__ */ Symbol.for("glasstrace.exporter");
4316
- return processors.some((p) => {
4317
- const exporter = p._exporter;
4318
- return exporter?.[brand] === true;
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
+ );
3824
+ }
3825
+ registerShutdownHook({
3826
+ name: "coexistence-flush",
3827
+ priority: 5,
3828
+ fn: async () => {
3829
+ if (_injectedProcessor) {
3830
+ await _injectedProcessor.forceFlush();
3831
+ }
3832
+ }
4319
3833
  });
4320
- } catch {
4321
- 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);
4322
3852
  }
4323
3853
  }
4324
- async function configureOtel(config, sessionManager) {
4325
- setOtelState(OtelState.CONFIGURING);
3854
+ async function runRegistrationPath(config, sessionManager) {
4326
3855
  const exporterUrl = `${config.endpoint}/v1/traces`;
4327
3856
  const createOtlpExporter = (url, headers) => new OTLPTraceExporter({ url, headers });
4328
3857
  const glasstraceExporter = new GlasstraceExporter({
@@ -4335,71 +3864,6 @@ async function configureOtel(config, sessionManager) {
4335
3864
  verbose: config.verbose
4336
3865
  });
4337
3866
  _activeExporter = glasstraceExporter;
4338
- await new Promise((resolve2) => {
4339
- if (typeof setImmediate === "function") {
4340
- setImmediate(resolve2);
4341
- } else {
4342
- setTimeout(resolve2, 0);
4343
- }
4344
- });
4345
- const existingProvider = trace.getTracerProvider();
4346
- const probeTracer = existingProvider.getTracer("glasstrace-probe");
4347
- const anotherProviderRegistered = probeTracer.constructor.name !== "ProxyTracer";
4348
- if (anotherProviderRegistered) {
4349
- if (isGlasstraceProcessorPresent(existingProvider)) {
4350
- if (config.verbose) {
4351
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 Glasstrace processor already present.");
4352
- }
4353
- _activeExporter = null;
4354
- setOtelState(OtelState.PROCESSOR_PRESENT);
4355
- emitLifecycleEvent("otel:configured", { state: OtelState.PROCESSOR_PRESENT, scenario: "B-clean" });
4356
- return;
4357
- }
4358
- const injectionMethod = tryInjectProcessor(existingProvider, glasstraceExporter);
4359
- if (injectionMethod === "already_present") {
4360
- if (config.verbose) {
4361
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 Glasstrace processor already present (v1 check).");
4362
- }
4363
- _activeExporter = null;
4364
- setOtelState(OtelState.PROCESSOR_PRESENT);
4365
- emitLifecycleEvent("otel:configured", { state: OtelState.PROCESSOR_PRESENT, scenario: "B-clean" });
4366
- return;
4367
- }
4368
- if (injectionMethod) {
4369
- if (config.verbose) {
4370
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 auto-attaching Glasstrace processor.");
4371
- }
4372
- registerShutdownHook({
4373
- name: "coexistence-flush",
4374
- priority: 5,
4375
- fn: async () => {
4376
- if (_injectedProcessor) {
4377
- await _injectedProcessor.forceFlush();
4378
- }
4379
- }
4380
- });
4381
- registerBeforeExitTrigger();
4382
- const scenario = injectionMethod === "v1_public" ? "D1" : "B-auto";
4383
- setOtelState(OtelState.AUTO_ATTACHED);
4384
- emitLifecycleEvent("otel:configured", { state: OtelState.AUTO_ATTACHED, scenario });
4385
- emitLifecycleEvent("otel:injection_succeeded", { method: injectionMethod });
4386
- emitNudgeMessage();
4387
- return;
4388
- }
4389
- if (config.verbose) {
4390
- sdkLog("info", "[glasstrace] Existing provider detected \u2014 could not auto-attach.");
4391
- }
4392
- emitGuidanceMessage();
4393
- _activeExporter = null;
4394
- setOtelState(OtelState.COEXISTENCE_FAILED);
4395
- emitLifecycleEvent("otel:configured", { state: OtelState.COEXISTENCE_FAILED, scenario: "C/F" });
4396
- emitLifecycleEvent("otel:injection_failed", { reason: "provider internals inaccessible" });
4397
- const coreState = getCoreState();
4398
- if (coreState === CoreState.ACTIVE || coreState === CoreState.KEY_RESOLVED) {
4399
- setCoreState(CoreState.ACTIVE_DEGRADED);
4400
- }
4401
- return;
4402
- }
4403
3867
  const vercelOtel = await tryImport("@vercel/otel");
4404
3868
  if (vercelOtel && typeof vercelOtel.registerOTel === "function") {
4405
3869
  const otelConfig = {
@@ -4462,8 +3926,7 @@ async function configureOtel(config, sessionManager) {
4462
3926
  }
4463
3927
 
4464
3928
  // src/context-manager.ts
4465
- init_esm_shims();
4466
- import { AsyncLocalStorage } from "async_hooks";
3929
+ import { AsyncLocalStorage } from "node:async_hooks";
4467
3930
  function installContextManager() {
4468
3931
  try {
4469
3932
  const als = new AsyncLocalStorage();
@@ -4493,7 +3956,6 @@ function installContextManager() {
4493
3956
  }
4494
3957
 
4495
3958
  // src/heartbeat.ts
4496
- init_esm_shims();
4497
3959
  var HEARTBEAT_INTERVAL_MS = 5 * 60 * 1e3;
4498
3960
  var BACKOFF_BASE_MS = HEARTBEAT_INTERVAL_MS;
4499
3961
  var BACKOFF_MAX_MS = 30 * 60 * 1e3;
@@ -4529,8 +3991,8 @@ function checkShutdownMarker(projectRoot) {
4529
3991
  let fsSync = null;
4530
3992
  let pathSync = null;
4531
3993
  try {
4532
- fsSync = __require("fs");
4533
- pathSync = __require("path");
3994
+ fsSync = __require("node:fs");
3995
+ pathSync = __require("node:path");
4534
3996
  } catch {
4535
3997
  return { triggered: false };
4536
3998
  }
@@ -4618,9 +4080,8 @@ function registerHeartbeatShutdownHook(config, anonKey, sdkVersion) {
4618
4080
  }
4619
4081
 
4620
4082
  // src/runtime-state.ts
4621
- init_esm_shims();
4622
- import { writeFileSync, renameSync, mkdirSync } from "fs";
4623
- import { join } from "path";
4083
+ import { writeFileSync, renameSync, mkdirSync } from "node:fs";
4084
+ import { join } from "node:path";
4624
4085
  var _projectRoot = null;
4625
4086
  var _sdkVersion = "unknown";
4626
4087
  var _lastScenario;
@@ -4715,7 +4176,7 @@ function registerGlasstrace(options) {
4715
4176
  setCoreState(CoreState.REGISTERING);
4716
4177
  startRuntimeStateWriter({
4717
4178
  projectRoot: process.cwd(),
4718
- sdkVersion: "0.15.1"
4179
+ sdkVersion: "0.16.0"
4719
4180
  });
4720
4181
  const config = resolveConfig(options);
4721
4182
  if (config.verbose) {
@@ -4880,8 +4341,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4880
4341
  if (config.verbose) {
4881
4342
  console.info("[glasstrace] Background init firing.");
4882
4343
  }
4883
- const healthReport = collectHealthReport("0.15.1");
4884
- const initResult = await performInit(config, anonKeyForInit, "0.15.1", healthReport);
4344
+ const healthReport = collectHealthReport("0.16.0");
4345
+ const initResult = await performInit(config, anonKeyForInit, "0.16.0", healthReport);
4885
4346
  if (generation !== registrationGeneration) return;
4886
4347
  const currentState = getCoreState();
4887
4348
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -4904,7 +4365,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4904
4365
  }
4905
4366
  maybeInstallConsoleCapture();
4906
4367
  if (didLastInitSucceed()) {
4907
- startHeartbeat(config, anonKeyForInit, "0.15.1", generation, (newApiKey, accountId) => {
4368
+ startHeartbeat(config, anonKeyForInit, "0.16.0", generation, (newApiKey, accountId) => {
4908
4369
  setAuthState(AuthState.CLAIMING);
4909
4370
  emitLifecycleEvent("auth:claim_started", { accountId });
4910
4371
  setResolvedApiKey(newApiKey);
@@ -4934,7 +4395,7 @@ function isDiscoveryEnabled(config) {
4934
4395
  }
4935
4396
 
4936
4397
  // src/config-wrapper.ts
4937
- init_esm_shims();
4398
+ import { isBuiltin as isNodeBuiltin } from "node:module";
4938
4399
  function isTurbopackBuild() {
4939
4400
  if (typeof process === "undefined") return false;
4940
4401
  const argv = Array.isArray(process.argv) ? process.argv : [];
@@ -4943,6 +4404,36 @@ function isTurbopackBuild() {
4943
4404
  if (process.env?.TURBOPACK === "1") return true;
4944
4405
  return false;
4945
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
+ }
4946
4437
  function withGlasstraceConfig(nextConfig) {
4947
4438
  if (typeof process === "undefined" || typeof process.versions?.node !== "string") {
4948
4439
  return nextConfig != null ? { ...nextConfig } : {};
@@ -4954,6 +4445,7 @@ function withGlasstraceConfig(nextConfig) {
4954
4445
  ...existingExperimental,
4955
4446
  serverSourceMaps: true
4956
4447
  };
4448
+ ensureServerExternal(bag);
4957
4449
  if (bag.turbopack == null) {
4958
4450
  bag.turbopack = {};
4959
4451
  }
@@ -4968,6 +4460,9 @@ function withGlasstraceConfig(nextConfig) {
4968
4460
  result = existingWebpack(webpackConfig, context2);
4969
4461
  }
4970
4462
  const webpackContext = context2;
4463
+ if (webpackContext.isServer) {
4464
+ appendNodeSchemeExternal(result);
4465
+ }
4971
4466
  if (!webpackContext.isServer && webpackContext.dev === false) {
4972
4467
  const plugins = result.plugins ?? [];
4973
4468
  plugins.push({
@@ -5007,7 +4502,7 @@ async function handleSourceMapUpload(distDir) {
5007
4502
  );
5008
4503
  return;
5009
4504
  }
5010
- 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");
5011
4506
  const files = await discoverSourceMapFiles2(distDir);
5012
4507
  if (files.length === 0) {
5013
4508
  console.info("[glasstrace] No source map files found. Skipping upload.");
@@ -5027,7 +4522,6 @@ async function handleSourceMapUpload(distDir) {
5027
4522
  }
5028
4523
 
5029
4524
  // src/capture-error.ts
5030
- init_esm_shims();
5031
4525
  function captureError(error) {
5032
4526
  try {
5033
4527
  const span = trace.getSpan(context.active());