@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.d.cts CHANGED
@@ -278,14 +278,27 @@ declare function getOrCreateAnonKey(projectRoot?: string): Promise<AnonApiKey>;
278
278
  */
279
279
  declare function loadCachedConfig(projectRoot?: string): SdkInitResponse | null;
280
280
  /**
281
- * Persists the init response to `.glasstrace/config`.
282
- * Silently skipped when `node:fs` is unavailable (non-Node environments).
283
- * On I/O failure, logs a warning and continues.
281
+ * Persists the init response to `.glasstrace/config` using atomic
282
+ * write-temp + rename semantics. Silently skipped when `node:fs` is
283
+ * unavailable (non-Node environments). On I/O failure, logs a warning.
284
+ *
285
+ * Atomicity: the payload is written to `.glasstrace/config.tmp` and then
286
+ * renamed into place. `rename` is atomic on POSIX filesystems, so readers
287
+ * either see the previous valid config or the new valid config — never a
288
+ * truncated or partially-written file (DISC-1247 Scenario 5). If the
289
+ * rename fails, the temp file is cleaned up on a best-effort basis.
284
290
  */
285
291
  declare function saveCachedConfig(response: SdkInitResponse, projectRoot?: string): Promise<void>;
286
292
  /**
287
293
  * Sends a POST request to `/v1/sdk/init`.
288
294
  * Validates the response against `SdkInitResponseSchema`.
295
+ *
296
+ * Uses `node:https` via {@link httpsPostJson} rather than the global
297
+ * `fetch` because Next.js 16 patches `fetch` for caching/revalidation
298
+ * and can cause the init request to silently hang (DISC-493 Issue 3).
299
+ * Retries transport-level failures (DNS, TCP, TLS) twice with 500ms +
300
+ * 1500ms backoff, capped at a 20-second total deadline. Server responses
301
+ * (HTTP 4xx/5xx) are never retried and are surfaced immediately.
289
302
  */
290
303
  declare function sendInitRequest(config: ResolvedConfig, anonKey: AnonApiKey | null, sdkVersion: string, importGraph?: ImportGraphPayload, healthReport?: SdkHealthReport, diagnostics?: Array<{
291
304
  code: SdkDiagnosticCode;
@@ -514,6 +527,31 @@ type NextConfig = object;
514
527
  * The build NEVER fails because of Glasstrace — all errors are caught
515
528
  * and logged as warnings.
516
529
  *
530
+ * ## What the wrapper configures for you
531
+ *
532
+ * - `experimental.serverSourceMaps: true` — enables server-side source maps
533
+ * so Glasstrace can resolve stack traces back to your source.
534
+ * - `serverExternalPackages: ["@glasstrace/sdk"]` — tells Next to load the
535
+ * SDK via Node's `require()` at runtime instead of bundling it through
536
+ * webpack or Turbopack on the RSC / Route Handler paths. This is the same
537
+ * pattern Prisma, `@vercel/otel`, Sentry, `sharp`, and `bcrypt` ship with.
538
+ * - A webpack `externals` entry that marks every Node.js built-in import
539
+ * (both `node:*` and bare forms like `zlib` or `stream`) as a runtime
540
+ * `commonjs` require. `serverExternalPackages` does not apply to the
541
+ * instrumentation path under `next dev --webpack`
542
+ * (vercel/next.js#58003, #28774), so any bundled SDK chunk that imports
543
+ * `node:child_process` or the bare `zlib` specifier used by
544
+ * `@opentelemetry/otlp-exporter-base` would otherwise crash with
545
+ * `UnhandledSchemeError` or `Can't resolve 'zlib'`. This entry is the
546
+ * actual DISC-1257 fix for the dev-webpack path. Turbopack is
547
+ * unaffected — it ignores `config.webpack` and resolves Node built-ins
548
+ * natively.
549
+ * - An empty `turbopack: {}` when none is set, so Next 16 does not reject
550
+ * the config for setting `webpack` without a companion `turbopack` key
551
+ * (DISC-1256).
552
+ * - A `webpack` hook that collects and uploads `.map` files on client-side
553
+ * production builds.
554
+ *
517
555
  * ## Turbopack
518
556
  *
519
557
  * Next.js 16 made Turbopack the default bundler for `next build`, and Next
@@ -564,10 +602,13 @@ declare function getStatus(): {
564
602
  * manually integrate Glasstrace with their existing OTel provider
565
603
  * (e.g., Sentry's openTelemetrySpanProcessors config option).
566
604
  *
567
- * Also provides nudge messaging that guides developers toward this
568
- * clean integration path when auto-attach is used.
605
+ * Also provides the auto-attach path (tryAutoAttachGlasstraceProcessor)
606
+ * that configureOtel() uses when it detects a pre-registered provider
607
+ * at runtime (Next.js 16 production, Sentry, Datadog, New Relic). Both
608
+ * entry points reuse the same span-processor factory so the manual and
609
+ * automatic paths stay in lockstep.
569
610
  *
570
- * Design: sdk-otel-coexistence.md Sections 3, 5, 6
611
+ * Design: sdk-otel-coexistence.md Sections 3, 4, 5, 6
571
612
  */
572
613
 
573
614
  /**
package/dist/index.d.ts CHANGED
@@ -278,14 +278,27 @@ declare function getOrCreateAnonKey(projectRoot?: string): Promise<AnonApiKey>;
278
278
  */
279
279
  declare function loadCachedConfig(projectRoot?: string): SdkInitResponse | null;
280
280
  /**
281
- * Persists the init response to `.glasstrace/config`.
282
- * Silently skipped when `node:fs` is unavailable (non-Node environments).
283
- * On I/O failure, logs a warning and continues.
281
+ * Persists the init response to `.glasstrace/config` using atomic
282
+ * write-temp + rename semantics. Silently skipped when `node:fs` is
283
+ * unavailable (non-Node environments). On I/O failure, logs a warning.
284
+ *
285
+ * Atomicity: the payload is written to `.glasstrace/config.tmp` and then
286
+ * renamed into place. `rename` is atomic on POSIX filesystems, so readers
287
+ * either see the previous valid config or the new valid config — never a
288
+ * truncated or partially-written file (DISC-1247 Scenario 5). If the
289
+ * rename fails, the temp file is cleaned up on a best-effort basis.
284
290
  */
285
291
  declare function saveCachedConfig(response: SdkInitResponse, projectRoot?: string): Promise<void>;
286
292
  /**
287
293
  * Sends a POST request to `/v1/sdk/init`.
288
294
  * Validates the response against `SdkInitResponseSchema`.
295
+ *
296
+ * Uses `node:https` via {@link httpsPostJson} rather than the global
297
+ * `fetch` because Next.js 16 patches `fetch` for caching/revalidation
298
+ * and can cause the init request to silently hang (DISC-493 Issue 3).
299
+ * Retries transport-level failures (DNS, TCP, TLS) twice with 500ms +
300
+ * 1500ms backoff, capped at a 20-second total deadline. Server responses
301
+ * (HTTP 4xx/5xx) are never retried and are surfaced immediately.
289
302
  */
290
303
  declare function sendInitRequest(config: ResolvedConfig, anonKey: AnonApiKey | null, sdkVersion: string, importGraph?: ImportGraphPayload, healthReport?: SdkHealthReport, diagnostics?: Array<{
291
304
  code: SdkDiagnosticCode;
@@ -514,6 +527,31 @@ type NextConfig = object;
514
527
  * The build NEVER fails because of Glasstrace — all errors are caught
515
528
  * and logged as warnings.
516
529
  *
530
+ * ## What the wrapper configures for you
531
+ *
532
+ * - `experimental.serverSourceMaps: true` — enables server-side source maps
533
+ * so Glasstrace can resolve stack traces back to your source.
534
+ * - `serverExternalPackages: ["@glasstrace/sdk"]` — tells Next to load the
535
+ * SDK via Node's `require()` at runtime instead of bundling it through
536
+ * webpack or Turbopack on the RSC / Route Handler paths. This is the same
537
+ * pattern Prisma, `@vercel/otel`, Sentry, `sharp`, and `bcrypt` ship with.
538
+ * - A webpack `externals` entry that marks every Node.js built-in import
539
+ * (both `node:*` and bare forms like `zlib` or `stream`) as a runtime
540
+ * `commonjs` require. `serverExternalPackages` does not apply to the
541
+ * instrumentation path under `next dev --webpack`
542
+ * (vercel/next.js#58003, #28774), so any bundled SDK chunk that imports
543
+ * `node:child_process` or the bare `zlib` specifier used by
544
+ * `@opentelemetry/otlp-exporter-base` would otherwise crash with
545
+ * `UnhandledSchemeError` or `Can't resolve 'zlib'`. This entry is the
546
+ * actual DISC-1257 fix for the dev-webpack path. Turbopack is
547
+ * unaffected — it ignores `config.webpack` and resolves Node built-ins
548
+ * natively.
549
+ * - An empty `turbopack: {}` when none is set, so Next 16 does not reject
550
+ * the config for setting `webpack` without a companion `turbopack` key
551
+ * (DISC-1256).
552
+ * - A `webpack` hook that collects and uploads `.map` files on client-side
553
+ * production builds.
554
+ *
517
555
  * ## Turbopack
518
556
  *
519
557
  * Next.js 16 made Turbopack the default bundler for `next build`, and Next
@@ -564,10 +602,13 @@ declare function getStatus(): {
564
602
  * manually integrate Glasstrace with their existing OTel provider
565
603
  * (e.g., Sentry's openTelemetrySpanProcessors config option).
566
604
  *
567
- * Also provides nudge messaging that guides developers toward this
568
- * clean integration path when auto-attach is used.
605
+ * Also provides the auto-attach path (tryAutoAttachGlasstraceProcessor)
606
+ * that configureOtel() uses when it detects a pre-registered provider
607
+ * at runtime (Next.js 16 production, Sentry, Datadog, New Relic). Both
608
+ * entry points reuse the same span-processor factory so the manual and
609
+ * automatic paths stay in lockstep.
569
610
  *
570
- * Design: sdk-otel-coexistence.md Sections 3, 5, 6
611
+ * Design: sdk-otel-coexistence.md Sections 3, 4, 5, 6
571
612
  */
572
613
 
573
614
  /**