@glasstrace/sdk 0.13.6 → 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>;
@@ -499,6 +501,72 @@ type NextConfig = Record<string, unknown>;
499
501
  */
500
502
  declare function withGlasstraceConfig(nextConfig: NextConfig): NextConfig;
501
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
+
502
570
  interface SourceMapEntry {
503
571
  filePath: string;
504
572
  content: string;
@@ -659,4 +727,4 @@ declare function extractImports(fileContent: string): string[];
659
727
  */
660
728
  declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
661
729
 
662
- 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>;
@@ -499,6 +501,72 @@ type NextConfig = Record<string, unknown>;
499
501
  */
500
502
  declare function withGlasstraceConfig(nextConfig: NextConfig): NextConfig;
501
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
+
502
570
  interface SourceMapEntry {
503
571
  filePath: string;
504
572
  content: string;
@@ -659,4 +727,4 @@ declare function extractImports(fileContent: string): string[];
659
727
  */
660
728
  declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
661
729
 
662
- 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 };