@glasstrace/sdk 0.13.5 → 0.14.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.
package/dist/index.d.cts CHANGED
@@ -38,6 +38,7 @@ declare const CaptureConfigSchema: z.ZodObject<{
38
38
  fullConsoleOutput: z.ZodBoolean;
39
39
  importGraph: z.ZodBoolean;
40
40
  consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
+ errorResponseBodies: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
42
  }, z.core.$strip>;
42
43
  type CaptureConfig = z.infer<typeof CaptureConfigSchema>;
43
44
  /** Developer-facing config for registerGlasstrace(). */
@@ -102,6 +103,7 @@ declare const SdkInitResponseSchema: z.ZodObject<{
102
103
  fullConsoleOutput: z.ZodBoolean;
103
104
  importGraph: z.ZodBoolean;
104
105
  consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
106
+ errorResponseBodies: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
105
107
  }, z.core.$strip>;
106
108
  subscriptionStatus: z.ZodString;
107
109
  linkedAccountId: z.ZodOptional<z.ZodString>;
@@ -361,7 +363,7 @@ interface GlasstraceExporterOptions {
361
363
  environment: string | undefined;
362
364
  endpointUrl: string;
363
365
  createDelegate: ((url: string, headers: Record<string, string>) => SpanExporter) | null;
364
- /** @deprecated No-op retained for backward compatibility. Will be removed in a future major. */
366
+ /** When true, logs diagnostic details about enrichment decisions via sdkLog. */
365
367
  verbose?: boolean;
366
368
  }
367
369
  /**
@@ -383,6 +385,7 @@ declare class GlasstraceExporter implements SpanExporter {
383
385
  private readonly environment;
384
386
  private readonly endpointUrl;
385
387
  private readonly createDelegateFn;
388
+ private readonly verbose;
386
389
  private delegate;
387
390
  private delegateKey;
388
391
  private pendingBatches;
@@ -498,6 +501,72 @@ type NextConfig = Record<string, unknown>;
498
501
  */
499
502
  declare function withGlasstraceConfig(nextConfig: NextConfig): NextConfig;
500
503
 
504
+ /**
505
+ * Returns true when the SDK is in ACTIVE or ACTIVE_DEGRADED state.
506
+ */
507
+ declare function isReady(): boolean;
508
+ /**
509
+ * Resolves when the SDK reaches ACTIVE or ACTIVE_DEGRADED.
510
+ * Rejects on PRODUCTION_DISABLED, REGISTRATION_FAILED, or timeout.
511
+ *
512
+ * Checks current state synchronously first — resolves/rejects immediately
513
+ * if the SDK has already reached a terminal or ready state.
514
+ */
515
+ declare function waitForReady(timeoutMs?: number): Promise<void>;
516
+ /**
517
+ * Simplified public state query for external consumers.
518
+ * Hides implementation details like coexistence scenarios.
519
+ */
520
+ declare function getStatus(): {
521
+ ready: boolean;
522
+ mode: "anonymous" | "authenticated" | "claiming" | "disabled";
523
+ tracing: "active" | "degraded" | "not-configured" | "coexistence";
524
+ };
525
+
526
+ /**
527
+ * OTel Coexistence Public API
528
+ *
529
+ * Provides createGlasstraceSpanProcessor() for developers who want to
530
+ * manually integrate Glasstrace with their existing OTel provider
531
+ * (e.g., Sentry's openTelemetrySpanProcessors config option).
532
+ *
533
+ * Also provides nudge messaging that guides developers toward this
534
+ * clean integration path when auto-attach is used.
535
+ *
536
+ * Design: sdk-otel-coexistence.md Sections 3, 5, 6
537
+ */
538
+
539
+ /**
540
+ * Creates a Glasstrace span processor for manual integration with an
541
+ * existing OTel provider.
542
+ *
543
+ * Use this when another tool (e.g., Sentry) owns the OTel provider and
544
+ * you want to add Glasstrace to their processor list:
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * import * as Sentry from "@sentry/nextjs";
549
+ * import { createGlasstraceSpanProcessor } from "@glasstrace/sdk";
550
+ *
551
+ * Sentry.init({
552
+ * dsn: "...",
553
+ * openTelemetrySpanProcessors: [createGlasstraceSpanProcessor()],
554
+ * });
555
+ * ```
556
+ *
557
+ * **Important:** `registerGlasstrace()` is still required even when using
558
+ * this function. The processor handles span transport (enrichment and
559
+ * export). `registerGlasstrace()` handles everything else: init calls,
560
+ * config sync, session management, anonymous key generation, discovery
561
+ * endpoint, and health reporting.
562
+ *
563
+ * @param options - Optional SDK configuration. If omitted, uses the same
564
+ * config as registerGlasstrace() (environment variables).
565
+ * @returns A BatchSpanProcessor wrapping a GlasstraceExporter with the
566
+ * branded Symbol.for('glasstrace.exporter') for coexistence detection.
567
+ */
568
+ declare function createGlasstraceSpanProcessor(options?: GlasstraceOptions): SpanProcessor;
569
+
501
570
  interface SourceMapEntry {
502
571
  filePath: string;
503
572
  content: string;
@@ -658,4 +727,4 @@ declare function extractImports(fileContent: string): string[];
658
727
  */
659
728
  declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
660
729
 
661
- export { type AutoUploadOptions, type BlobUploader, type ClaimState, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, isAnonymousMode, isProductionDisabled, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, withGlasstraceConfig };
730
+ export { type AutoUploadOptions, type BlobUploader, type ClaimState, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, createGlasstraceSpanProcessor, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, getStatus, isAnonymousMode, isProductionDisabled, isReady, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, waitForReady, withGlasstraceConfig };
package/dist/index.d.ts CHANGED
@@ -38,6 +38,7 @@ declare const CaptureConfigSchema: z.ZodObject<{
38
38
  fullConsoleOutput: z.ZodBoolean;
39
39
  importGraph: z.ZodBoolean;
40
40
  consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
+ errorResponseBodies: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
42
  }, z.core.$strip>;
42
43
  type CaptureConfig = z.infer<typeof CaptureConfigSchema>;
43
44
  /** Developer-facing config for registerGlasstrace(). */
@@ -102,6 +103,7 @@ declare const SdkInitResponseSchema: z.ZodObject<{
102
103
  fullConsoleOutput: z.ZodBoolean;
103
104
  importGraph: z.ZodBoolean;
104
105
  consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
106
+ errorResponseBodies: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
105
107
  }, z.core.$strip>;
106
108
  subscriptionStatus: z.ZodString;
107
109
  linkedAccountId: z.ZodOptional<z.ZodString>;
@@ -361,7 +363,7 @@ interface GlasstraceExporterOptions {
361
363
  environment: string | undefined;
362
364
  endpointUrl: string;
363
365
  createDelegate: ((url: string, headers: Record<string, string>) => SpanExporter) | null;
364
- /** @deprecated No-op retained for backward compatibility. Will be removed in a future major. */
366
+ /** When true, logs diagnostic details about enrichment decisions via sdkLog. */
365
367
  verbose?: boolean;
366
368
  }
367
369
  /**
@@ -383,6 +385,7 @@ declare class GlasstraceExporter implements SpanExporter {
383
385
  private readonly environment;
384
386
  private readonly endpointUrl;
385
387
  private readonly createDelegateFn;
388
+ private readonly verbose;
386
389
  private delegate;
387
390
  private delegateKey;
388
391
  private pendingBatches;
@@ -498,6 +501,72 @@ type NextConfig = Record<string, unknown>;
498
501
  */
499
502
  declare function withGlasstraceConfig(nextConfig: NextConfig): NextConfig;
500
503
 
504
+ /**
505
+ * Returns true when the SDK is in ACTIVE or ACTIVE_DEGRADED state.
506
+ */
507
+ declare function isReady(): boolean;
508
+ /**
509
+ * Resolves when the SDK reaches ACTIVE or ACTIVE_DEGRADED.
510
+ * Rejects on PRODUCTION_DISABLED, REGISTRATION_FAILED, or timeout.
511
+ *
512
+ * Checks current state synchronously first — resolves/rejects immediately
513
+ * if the SDK has already reached a terminal or ready state.
514
+ */
515
+ declare function waitForReady(timeoutMs?: number): Promise<void>;
516
+ /**
517
+ * Simplified public state query for external consumers.
518
+ * Hides implementation details like coexistence scenarios.
519
+ */
520
+ declare function getStatus(): {
521
+ ready: boolean;
522
+ mode: "anonymous" | "authenticated" | "claiming" | "disabled";
523
+ tracing: "active" | "degraded" | "not-configured" | "coexistence";
524
+ };
525
+
526
+ /**
527
+ * OTel Coexistence Public API
528
+ *
529
+ * Provides createGlasstraceSpanProcessor() for developers who want to
530
+ * manually integrate Glasstrace with their existing OTel provider
531
+ * (e.g., Sentry's openTelemetrySpanProcessors config option).
532
+ *
533
+ * Also provides nudge messaging that guides developers toward this
534
+ * clean integration path when auto-attach is used.
535
+ *
536
+ * Design: sdk-otel-coexistence.md Sections 3, 5, 6
537
+ */
538
+
539
+ /**
540
+ * Creates a Glasstrace span processor for manual integration with an
541
+ * existing OTel provider.
542
+ *
543
+ * Use this when another tool (e.g., Sentry) owns the OTel provider and
544
+ * you want to add Glasstrace to their processor list:
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * import * as Sentry from "@sentry/nextjs";
549
+ * import { createGlasstraceSpanProcessor } from "@glasstrace/sdk";
550
+ *
551
+ * Sentry.init({
552
+ * dsn: "...",
553
+ * openTelemetrySpanProcessors: [createGlasstraceSpanProcessor()],
554
+ * });
555
+ * ```
556
+ *
557
+ * **Important:** `registerGlasstrace()` is still required even when using
558
+ * this function. The processor handles span transport (enrichment and
559
+ * export). `registerGlasstrace()` handles everything else: init calls,
560
+ * config sync, session management, anonymous key generation, discovery
561
+ * endpoint, and health reporting.
562
+ *
563
+ * @param options - Optional SDK configuration. If omitted, uses the same
564
+ * config as registerGlasstrace() (environment variables).
565
+ * @returns A BatchSpanProcessor wrapping a GlasstraceExporter with the
566
+ * branded Symbol.for('glasstrace.exporter') for coexistence detection.
567
+ */
568
+ declare function createGlasstraceSpanProcessor(options?: GlasstraceOptions): SpanProcessor;
569
+
501
570
  interface SourceMapEntry {
502
571
  filePath: string;
503
572
  content: string;
@@ -658,4 +727,4 @@ declare function extractImports(fileContent: string): string[];
658
727
  */
659
728
  declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
660
729
 
661
- export { type AutoUploadOptions, type BlobUploader, type ClaimState, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, isAnonymousMode, isProductionDisabled, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, withGlasstraceConfig };
730
+ export { type AutoUploadOptions, type BlobUploader, type ClaimState, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, createGlasstraceSpanProcessor, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, getStatus, isAnonymousMode, isProductionDisabled, isReady, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, waitForReady, withGlasstraceConfig };