@glasstrace/sdk 1.3.4 → 1.3.5

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/README.md CHANGED
@@ -165,6 +165,12 @@ The nudge never fires in production (detected via `NODE_ENV` or
165
165
 
166
166
  ## Production deployment under Next 16
167
167
 
168
+ As of `@glasstrace/sdk@1.3.5`, auto-attach detection now classifies the
169
+ SDK's own bundled proxy correctly under bundler minification (DISC-1556
170
+ — verified against the `clean-next-sdk130` validation fixture). The
171
+ manual integration documented below remains supported for users who
172
+ prefer explicit configuration.
173
+
168
174
  Next 16 (`next build && next start`) registers an OpenTelemetry
169
175
  TracerProvider before user code runs. When `registerGlasstrace()` then
170
176
  detects that provider, the SDK attempts to attach its span processor to
@@ -3671,6 +3671,27 @@ var OTLPTraceExporter = class extends OTLPExporterBase {
3671
3671
  }
3672
3672
  };
3673
3673
 
3674
+ // src/proxy-detection.ts
3675
+ function isProxyTracerProvider(value) {
3676
+ if (value === null || value === void 0 || typeof value !== "object") {
3677
+ return false;
3678
+ }
3679
+ return "getTracer" in value && typeof value.getTracer === "function" && "getDelegate" in value && typeof value.getDelegate === "function" && "setDelegate" in value && typeof value.setDelegate === "function" && "getDelegateTracer" in value && typeof value.getDelegateTracer === "function";
3680
+ }
3681
+ function isProxyTracer(value, ownerProvider) {
3682
+ if (value === null || value === void 0 || typeof value !== "object") {
3683
+ return false;
3684
+ }
3685
+ const structurallyShaped = "_getTracer" in value && typeof value._getTracer === "function" && "startSpan" in value && typeof value.startSpan === "function" && "startActiveSpan" in value && typeof value.startActiveSpan === "function";
3686
+ if (!structurallyShaped) {
3687
+ return false;
3688
+ }
3689
+ if (!Object.hasOwn(value, "_provider")) {
3690
+ return false;
3691
+ }
3692
+ return value._provider === ownerProvider;
3693
+ }
3694
+
3674
3695
  // src/otel-config.ts
3675
3696
  var resolvedApiKey = API_KEY_PENDING;
3676
3697
  var activeExporter = null;
@@ -3709,7 +3730,7 @@ async function configureOtel(config, sessionManager) {
3709
3730
  });
3710
3731
  const existingProvider = trace.getTracerProvider();
3711
3732
  const probeTracer = existingProvider.getTracer("glasstrace-probe");
3712
- const anotherProviderRegistered = probeTracer.constructor.name !== "ProxyTracer";
3733
+ const anotherProviderRegistered = !isProxyTracerProvider(existingProvider) || !isProxyTracer(probeTracer, existingProvider);
3713
3734
  if (anotherProviderRegistered) {
3714
3735
  setCoexistenceState("coexisting");
3715
3736
  await runCoexistencePath(existingProvider, config);
@@ -4269,7 +4290,7 @@ function registerGlasstrace(options) {
4269
4290
  setCoreState(CoreState.REGISTERING);
4270
4291
  startRuntimeStateWriter({
4271
4292
  projectRoot: process.cwd(),
4272
- sdkVersion: "1.3.4"
4293
+ sdkVersion: "1.3.5"
4273
4294
  });
4274
4295
  const config = resolveConfig(options);
4275
4296
  if (config.verbose) {
@@ -4285,8 +4306,9 @@ function registerGlasstrace(options) {
4285
4306
  if (config.verbose) {
4286
4307
  console.info("[glasstrace] Not production-disabled.");
4287
4308
  }
4288
- const existingProbe = trace.getTracerProvider().getTracer("glasstrace-probe");
4289
- const anotherProviderRegistered = existingProbe.constructor.name !== "ProxyTracer";
4309
+ const existingTracerProvider = trace.getTracerProvider();
4310
+ const existingProbe = existingTracerProvider.getTracer("glasstrace-probe");
4311
+ const anotherProviderRegistered = !isProxyTracerProvider(existingTracerProvider) || !isProxyTracer(existingProbe, existingTracerProvider);
4290
4312
  if (anotherProviderRegistered) {
4291
4313
  setCoexistenceState("coexisting");
4292
4314
  }
@@ -4435,8 +4457,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4435
4457
  if (config.verbose) {
4436
4458
  console.info("[glasstrace] Background init firing.");
4437
4459
  }
4438
- const healthReport = collectHealthReport("1.3.4");
4439
- const initResult = await performInit(config, anonKeyForInit, "1.3.4", healthReport);
4460
+ const healthReport = collectHealthReport("1.3.5");
4461
+ const initResult = await performInit(config, anonKeyForInit, "1.3.5", healthReport);
4440
4462
  if (generation !== registrationGeneration) return;
4441
4463
  const currentState = getCoreState();
4442
4464
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -4459,7 +4481,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4459
4481
  }
4460
4482
  maybeInstallConsoleCapture();
4461
4483
  if (didLastInitSucceed()) {
4462
- startHeartbeat(config, anonKeyForInit, "1.3.4", generation, (newApiKey, accountId) => {
4484
+ startHeartbeat(config, anonKeyForInit, "1.3.5", generation, (newApiKey, accountId) => {
4463
4485
  setAuthState(AuthState.CLAIMING);
4464
4486
  emitLifecycleEvent("auth:claim_started", { accountId });
4465
4487
  setResolvedApiKey(newApiKey);
@@ -4859,4 +4881,4 @@ export {
4859
4881
  withGlasstraceConfig,
4860
4882
  captureError
4861
4883
  };
4862
- //# sourceMappingURL=chunk-XFNK4YEW.js.map
4884
+ //# sourceMappingURL=chunk-EK6MYHR2.js.map