@glasstrace/sdk 0.20.1 → 1.0.1

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 (46) hide show
  1. package/README.md +76 -5
  2. package/dist/chunk-3TU62WD6.js +142 -0
  3. package/dist/chunk-3TU62WD6.js.map +1 -0
  4. package/dist/chunk-67RIOAXV.js +105 -0
  5. package/dist/chunk-67RIOAXV.js.map +1 -0
  6. package/dist/{chunk-IQN6TRMQ.js → chunk-KE7MCPO5.js} +3 -140
  7. package/dist/chunk-KE7MCPO5.js.map +1 -0
  8. package/dist/{chunk-R4DAIPXD.js → chunk-MV3F7HVX.js} +96 -10
  9. package/dist/chunk-MV3F7HVX.js.map +1 -0
  10. package/dist/{chunk-BT2OCXCG.js → chunk-UGJ3X4CT.js} +1 -1
  11. package/dist/chunk-UGJ3X4CT.js.map +1 -0
  12. package/dist/cli/init.cjs +1 -1
  13. package/dist/cli/init.cjs.map +1 -1
  14. package/dist/cli/init.js +2 -2
  15. package/dist/cli/init.js.map +1 -1
  16. package/dist/{edge-entry-Ds2fNOeh.d.ts → edge-entry-CFq085RZ.d.ts} +2 -29
  17. package/dist/{edge-entry-FJFKkeFF.d.cts → edge-entry-DYl05SJ-.d.cts} +2 -29
  18. package/dist/edge-entry.cjs +2 -102
  19. package/dist/edge-entry.cjs.map +1 -1
  20. package/dist/edge-entry.d.cts +2 -2
  21. package/dist/edge-entry.d.ts +2 -2
  22. package/dist/edge-entry.js +3 -5
  23. package/dist/index.cjs +38 -244
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/{index.d-DgeH-pNJ.d.cts → index.d-CYYe3PxB.d.cts} +1 -1
  26. package/dist/{index.d-DgeH-pNJ.d.ts → index.d-CYYe3PxB.d.ts} +1 -1
  27. package/dist/index.d.cts +4 -5
  28. package/dist/index.d.ts +4 -5
  29. package/dist/index.js +4 -29
  30. package/dist/node-entry.cjs +93 -104
  31. package/dist/node-entry.cjs.map +1 -1
  32. package/dist/node-entry.d.cts +2 -2
  33. package/dist/node-entry.d.ts +2 -2
  34. package/dist/node-entry.js +6 -7
  35. package/dist/node-subpath.cjs.map +1 -1
  36. package/dist/node-subpath.d.cts +110 -3
  37. package/dist/node-subpath.d.ts +110 -3
  38. package/dist/node-subpath.js +3 -2
  39. package/dist/{source-map-uploader-YXWO6JLN.js → source-map-uploader-BJIXRLJ6.js} +3 -2
  40. package/package.json +11 -2
  41. package/dist/chunk-BT2OCXCG.js.map +0 -1
  42. package/dist/chunk-IQN6TRMQ.js.map +0 -1
  43. package/dist/chunk-R4DAIPXD.js.map +0 -1
  44. package/dist/chunk-Z2EGETTT.js +0 -204
  45. package/dist/chunk-Z2EGETTT.js.map +0 -1
  46. /package/dist/{source-map-uploader-YXWO6JLN.js.map → source-map-uploader-BJIXRLJ6.js.map} +0 -0
@@ -188,4 +188,4 @@ type SourceMapManifestResponse = z.infer<typeof SourceMapManifestResponseSchema>
188
188
  */
189
189
  declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
190
190
 
191
- export { type AnonApiKey as A, type CaptureConfig as C, type GlasstraceEnvVars as G, type ImportGraphPayload as I, type SdkDiagnosticCode as S, type SessionId as a, type SourceMapUploadResponse as b, type SourceMapManifestResponse as c, type GlasstraceOptions as d, type SdkInitResponse as e, type SdkHealthReport as f, deriveSessionId as g };
191
+ export { type AnonApiKey as A, type CaptureConfig as C, type GlasstraceEnvVars as G, type ImportGraphPayload as I, type SdkInitResponse as S, type GlasstraceOptions as a, type SdkHealthReport as b, type SdkDiagnosticCode as c, deriveSessionId as d, type SessionId as e, type SourceMapUploadResponse as f, type SourceMapManifestResponse as g };
@@ -188,4 +188,4 @@ type SourceMapManifestResponse = z.infer<typeof SourceMapManifestResponseSchema>
188
188
  */
189
189
  declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
190
190
 
191
- export { type AnonApiKey as A, type CaptureConfig as C, type GlasstraceEnvVars as G, type ImportGraphPayload as I, type SdkDiagnosticCode as S, type SessionId as a, type SourceMapUploadResponse as b, type SourceMapManifestResponse as c, type GlasstraceOptions as d, type SdkInitResponse as e, type SdkHealthReport as f, deriveSessionId as g };
191
+ export { type AnonApiKey as A, type CaptureConfig as C, type GlasstraceEnvVars as G, type ImportGraphPayload as I, type SdkInitResponse as S, type GlasstraceOptions as a, type SdkHealthReport as b, type SdkDiagnosticCode as c, deriveSessionId as d, type SessionId as e, type SourceMapUploadResponse as f, type SourceMapManifestResponse as g };
package/dist/index.d.cts CHANGED
@@ -1,8 +1,7 @@
1
- import { S as SessionManager } from './edge-entry-FJFKkeFF.cjs';
2
- export { C as ClaimState, a as CorrelationIdRequest, G as GlasstraceSpanProcessor, b as SdkError, c as captureCorrelationId, d as createDiscoveryHandler, g as getDateString, e as getOrigin } from './edge-entry-FJFKkeFF.cjs';
3
- export { AutoUploadOptions, BlobUploader, PRESIGNED_THRESHOLD_BYTES, SourceMapEntry, SourceMapFileInfo, buildImportGraph, collectSourceMaps, computeBuildHash, discoverSourceMapFiles, discoverTestFiles, extractImports, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned } from './node-subpath.cjs';
4
- import { G as GlasstraceEnvVars, d as GlasstraceOptions, A as AnonApiKey, e as SdkInitResponse, C as CaptureConfig, f as SdkHealthReport, I as ImportGraphPayload, S as SdkDiagnosticCode } from './index.d-DgeH-pNJ.cjs';
5
- export { g as deriveSessionId } from './index.d-DgeH-pNJ.cjs';
1
+ import { a as SessionManager } from './edge-entry-DYl05SJ-.cjs';
2
+ export { C as CorrelationIdRequest, G as GlasstraceSpanProcessor, S as SdkError, c as captureCorrelationId, g as getDateString, b as getOrigin } from './edge-entry-DYl05SJ-.cjs';
3
+ import { G as GlasstraceEnvVars, a as GlasstraceOptions, A as AnonApiKey, S as SdkInitResponse, C as CaptureConfig, b as SdkHealthReport, I as ImportGraphPayload, c as SdkDiagnosticCode } from './index.d-CYYe3PxB.cjs';
4
+ export { d as deriveSessionId } from './index.d-CYYe3PxB.cjs';
6
5
  import { ReadableSpan } from './export/ReadableSpan';
7
6
  import { SpanExporter } from './export/SpanExporter';
8
7
  import { ExportResult } from './ExportResult';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { S as SessionManager } from './edge-entry-Ds2fNOeh.js';
2
- export { C as ClaimState, a as CorrelationIdRequest, G as GlasstraceSpanProcessor, b as SdkError, c as captureCorrelationId, d as createDiscoveryHandler, g as getDateString, e as getOrigin } from './edge-entry-Ds2fNOeh.js';
3
- export { AutoUploadOptions, BlobUploader, PRESIGNED_THRESHOLD_BYTES, SourceMapEntry, SourceMapFileInfo, buildImportGraph, collectSourceMaps, computeBuildHash, discoverSourceMapFiles, discoverTestFiles, extractImports, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned } from './node-subpath.js';
4
- import { G as GlasstraceEnvVars, d as GlasstraceOptions, A as AnonApiKey, e as SdkInitResponse, C as CaptureConfig, f as SdkHealthReport, I as ImportGraphPayload, S as SdkDiagnosticCode } from './index.d-DgeH-pNJ.js';
5
- export { g as deriveSessionId } from './index.d-DgeH-pNJ.js';
1
+ import { a as SessionManager } from './edge-entry-CFq085RZ.js';
2
+ export { C as CorrelationIdRequest, G as GlasstraceSpanProcessor, S as SdkError, c as captureCorrelationId, g as getDateString, b as getOrigin } from './edge-entry-CFq085RZ.js';
3
+ import { G as GlasstraceEnvVars, a as GlasstraceOptions, A as AnonApiKey, S as SdkInitResponse, C as CaptureConfig, b as SdkHealthReport, I as ImportGraphPayload, c as SdkDiagnosticCode } from './index.d-CYYe3PxB.js';
4
+ export { d as deriveSessionId } from './index.d-CYYe3PxB.js';
6
5
  import { ReadableSpan } from './export/ReadableSpan';
7
6
  import { SpanExporter } from './export/SpanExporter';
8
7
  import { ExportResult } from './ExportResult';
package/dist/index.js CHANGED
@@ -12,23 +12,14 @@ import {
12
12
  registerGlasstrace,
13
13
  waitForReady,
14
14
  withGlasstraceConfig
15
- } from "./chunk-R4DAIPXD.js";
15
+ } from "./chunk-MV3F7HVX.js";
16
16
  import {
17
17
  GlasstraceSpanProcessor,
18
18
  SdkError,
19
- captureCorrelationId,
20
- createDiscoveryHandler
21
- } from "./chunk-Z2EGETTT.js";
19
+ captureCorrelationId
20
+ } from "./chunk-67RIOAXV.js";
22
21
  import "./chunk-DQ25VOKK.js";
23
- import {
24
- PRESIGNED_THRESHOLD_BYTES,
25
- collectSourceMaps,
26
- computeBuildHash,
27
- discoverSourceMapFiles,
28
- uploadSourceMaps,
29
- uploadSourceMapsAuto,
30
- uploadSourceMapsPresigned
31
- } from "./chunk-IQN6TRMQ.js";
22
+ import "./chunk-3TU62WD6.js";
32
23
  import {
33
24
  getActiveConfig,
34
25
  getLinkedAccountId,
@@ -37,11 +28,6 @@ import {
37
28
  saveCachedConfig,
38
29
  sendInitRequest
39
30
  } from "./chunk-DO2YPMQ5.js";
40
- import {
41
- buildImportGraph,
42
- discoverTestFiles,
43
- extractImports
44
- } from "./chunk-BT2OCXCG.js";
45
31
  import {
46
32
  isAnonymousMode,
47
33
  isProductionDisabled,
@@ -59,21 +45,13 @@ import "./chunk-NSBPE2FW.js";
59
45
  export {
60
46
  GlasstraceExporter,
61
47
  GlasstraceSpanProcessor,
62
- PRESIGNED_THRESHOLD_BYTES,
63
48
  SdkError,
64
49
  SessionManager,
65
- buildImportGraph,
66
50
  captureCorrelationId,
67
51
  captureError,
68
52
  classifyFetchTarget,
69
- collectSourceMaps,
70
- computeBuildHash,
71
- createDiscoveryHandler,
72
53
  createGlasstraceSpanProcessor,
73
54
  deriveSessionId,
74
- discoverSourceMapFiles,
75
- discoverTestFiles,
76
- extractImports,
77
55
  getActiveConfig,
78
56
  getDateString,
79
57
  getDiscoveryHandler,
@@ -92,9 +70,6 @@ export {
92
70
  resolveConfig,
93
71
  saveCachedConfig,
94
72
  sendInitRequest,
95
- uploadSourceMaps,
96
- uploadSourceMapsAuto,
97
- uploadSourceMapsPresigned,
98
73
  waitForReady,
99
74
  withGlasstraceConfig
100
75
  };
@@ -16884,7 +16884,6 @@ __export(node_entry_exports, {
16884
16884
  classifyFetchTarget: () => classifyFetchTarget,
16885
16885
  collectSourceMaps: () => collectSourceMaps,
16886
16886
  computeBuildHash: () => computeBuildHash,
16887
- createDiscoveryHandler: () => createDiscoveryHandler,
16888
16887
  createGlasstraceSpanProcessor: () => createGlasstraceSpanProcessor,
16889
16888
  deriveSessionId: () => deriveSessionId,
16890
16889
  discoverSourceMapFiles: () => discoverSourceMapFiles,
@@ -17037,104 +17036,6 @@ var GlasstraceSpanProcessor = class {
17037
17036
  }
17038
17037
  };
17039
17038
 
17040
- // src/discovery-endpoint.ts
17041
- var runtimeHandlerDeprecationWarned = false;
17042
- function warnRuntimeHandlerDeprecatedOnce() {
17043
- if (runtimeHandlerDeprecationWarned) return;
17044
- runtimeHandlerDeprecationWarned = true;
17045
- console.warn(
17046
- "[glasstrace] createDiscoveryHandler is deprecated. Run `npx glasstrace init` to generate a static file at public/.well-known/glasstrace.json (or static/.well-known/glasstrace.json on SvelteKit). The runtime handler will be removed in v1.0.0."
17047
- );
17048
- }
17049
- function isAllowedOrigin(origin) {
17050
- if (origin === null) return true;
17051
- if (origin.startsWith("chrome-extension://")) return true;
17052
- if (origin.startsWith("moz-extension://")) return true;
17053
- if (origin.startsWith("safari-web-extension://")) return true;
17054
- return false;
17055
- }
17056
- function buildCorsHeaders(origin) {
17057
- const headers = {
17058
- "Content-Type": "application/json",
17059
- Vary: "Origin"
17060
- };
17061
- if (origin && isAllowedOrigin(origin)) {
17062
- headers["Access-Control-Allow-Origin"] = origin;
17063
- }
17064
- return headers;
17065
- }
17066
- function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
17067
- return async (request) => {
17068
- let url2;
17069
- try {
17070
- url2 = new URL(request.url);
17071
- } catch {
17072
- return null;
17073
- }
17074
- if (url2.pathname !== "/__glasstrace/config") {
17075
- return null;
17076
- }
17077
- warnRuntimeHandlerDeprecatedOnce();
17078
- const origin = request.headers.get("Origin");
17079
- const corsHeaders = buildCorsHeaders(origin);
17080
- if (request.method === "OPTIONS") {
17081
- return new Response(null, {
17082
- status: 204,
17083
- headers: {
17084
- ...corsHeaders,
17085
- "Access-Control-Allow-Methods": "GET, OPTIONS",
17086
- "Access-Control-Allow-Headers": "Content-Type"
17087
- }
17088
- });
17089
- }
17090
- if (request.method !== "GET") {
17091
- return new Response(
17092
- JSON.stringify({ error: "method_not_allowed" }),
17093
- {
17094
- status: 405,
17095
- headers: corsHeaders
17096
- }
17097
- );
17098
- }
17099
- try {
17100
- const anonKey = await getAnonKey();
17101
- if (anonKey === null) {
17102
- return new Response(
17103
- JSON.stringify({ error: "not_ready" }),
17104
- {
17105
- status: 503,
17106
- headers: corsHeaders
17107
- }
17108
- );
17109
- }
17110
- const sessionId = getSessionId();
17111
- const responseBody = { key: anonKey, sessionId };
17112
- const claimState = getClaimState?.();
17113
- if (claimState?.claimed) {
17114
- responseBody.claimed = true;
17115
- if (claimState.accountHint) {
17116
- responseBody.accountHint = claimState.accountHint;
17117
- }
17118
- }
17119
- return new Response(
17120
- JSON.stringify(responseBody),
17121
- {
17122
- status: 200,
17123
- headers: corsHeaders
17124
- }
17125
- );
17126
- } catch {
17127
- return new Response(
17128
- JSON.stringify({ error: "internal_error" }),
17129
- {
17130
- status: 500,
17131
- headers: corsHeaders
17132
- }
17133
- );
17134
- }
17135
- };
17136
- }
17137
-
17138
17039
  // src/correlation-id.ts
17139
17040
  init_esm();
17140
17041
  init_dist();
@@ -18333,6 +18234,95 @@ function deriveErrorCategory(errorType) {
18333
18234
  // src/register.ts
18334
18235
  init_env_detection();
18335
18236
 
18237
+ // src/discovery-endpoint.ts
18238
+ function isAllowedOrigin(origin) {
18239
+ if (origin === null) return true;
18240
+ if (origin.startsWith("chrome-extension://")) return true;
18241
+ if (origin.startsWith("moz-extension://")) return true;
18242
+ if (origin.startsWith("safari-web-extension://")) return true;
18243
+ return false;
18244
+ }
18245
+ function buildCorsHeaders(origin) {
18246
+ const headers = {
18247
+ "Content-Type": "application/json",
18248
+ Vary: "Origin"
18249
+ };
18250
+ if (origin && isAllowedOrigin(origin)) {
18251
+ headers["Access-Control-Allow-Origin"] = origin;
18252
+ }
18253
+ return headers;
18254
+ }
18255
+ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
18256
+ return async (request) => {
18257
+ let url2;
18258
+ try {
18259
+ url2 = new URL(request.url);
18260
+ } catch {
18261
+ return null;
18262
+ }
18263
+ if (url2.pathname !== "/__glasstrace/config") {
18264
+ return null;
18265
+ }
18266
+ const origin = request.headers.get("Origin");
18267
+ const corsHeaders = buildCorsHeaders(origin);
18268
+ if (request.method === "OPTIONS") {
18269
+ return new Response(null, {
18270
+ status: 204,
18271
+ headers: {
18272
+ ...corsHeaders,
18273
+ "Access-Control-Allow-Methods": "GET, OPTIONS",
18274
+ "Access-Control-Allow-Headers": "Content-Type"
18275
+ }
18276
+ });
18277
+ }
18278
+ if (request.method !== "GET") {
18279
+ return new Response(
18280
+ JSON.stringify({ error: "method_not_allowed" }),
18281
+ {
18282
+ status: 405,
18283
+ headers: corsHeaders
18284
+ }
18285
+ );
18286
+ }
18287
+ try {
18288
+ const anonKey = await getAnonKey();
18289
+ if (anonKey === null) {
18290
+ return new Response(
18291
+ JSON.stringify({ error: "not_ready" }),
18292
+ {
18293
+ status: 503,
18294
+ headers: corsHeaders
18295
+ }
18296
+ );
18297
+ }
18298
+ const sessionId = getSessionId();
18299
+ const responseBody = { key: anonKey, sessionId };
18300
+ const claimState = getClaimState?.();
18301
+ if (claimState?.claimed) {
18302
+ responseBody.claimed = true;
18303
+ if (claimState.accountHint) {
18304
+ responseBody.accountHint = claimState.accountHint;
18305
+ }
18306
+ }
18307
+ return new Response(
18308
+ JSON.stringify(responseBody),
18309
+ {
18310
+ status: 200,
18311
+ headers: corsHeaders
18312
+ }
18313
+ );
18314
+ } catch {
18315
+ return new Response(
18316
+ JSON.stringify({ error: "internal_error" }),
18317
+ {
18318
+ status: 500,
18319
+ headers: corsHeaders
18320
+ }
18321
+ );
18322
+ }
18323
+ };
18324
+ }
18325
+
18336
18326
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
18337
18327
  var OTLPExporterBase = class {
18338
18328
  _delegate;
@@ -21907,7 +21897,7 @@ function registerGlasstrace(options) {
21907
21897
  setCoreState(CoreState.REGISTERING);
21908
21898
  startRuntimeStateWriter({
21909
21899
  projectRoot: process.cwd(),
21910
- sdkVersion: "0.20.1"
21900
+ sdkVersion: "1.0.1"
21911
21901
  });
21912
21902
  const config2 = resolveConfig(options);
21913
21903
  if (config2.verbose) {
@@ -22073,8 +22063,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22073
22063
  if (config2.verbose) {
22074
22064
  console.info("[glasstrace] Background init firing.");
22075
22065
  }
22076
- const healthReport = collectHealthReport("0.20.1");
22077
- const initResult = await performInit(config2, anonKeyForInit, "0.20.1", healthReport);
22066
+ const healthReport = collectHealthReport("1.0.1");
22067
+ const initResult = await performInit(config2, anonKeyForInit, "1.0.1", healthReport);
22078
22068
  if (generation !== registrationGeneration) return;
22079
22069
  const currentState = getCoreState();
22080
22070
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22097,7 +22087,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22097
22087
  }
22098
22088
  maybeInstallConsoleCapture();
22099
22089
  if (didLastInitSucceed()) {
22100
- startHeartbeat(config2, anonKeyForInit, "0.20.1", generation, (newApiKey, accountId) => {
22090
+ startHeartbeat(config2, anonKeyForInit, "1.0.1", generation, (newApiKey, accountId) => {
22101
22091
  setAuthState(AuthState.CLAIMING);
22102
22092
  emitLifecycleEvent("auth:claim_started", { accountId });
22103
22093
  setResolvedApiKey(newApiKey);
@@ -22459,7 +22449,6 @@ async function buildImportGraph(projectRoot) {
22459
22449
  classifyFetchTarget,
22460
22450
  collectSourceMaps,
22461
22451
  computeBuildHash,
22462
- createDiscoveryHandler,
22463
22452
  createGlasstraceSpanProcessor,
22464
22453
  deriveSessionId,
22465
22454
  discoverSourceMapFiles,