@glasstrace/sdk 0.18.0 → 0.19.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/{chunk-GSGX76Q5.js → chunk-5N2IR4EO.js} +146 -3
- package/dist/chunk-5N2IR4EO.js.map +1 -0
- package/dist/{chunk-IOPCSX6C.js → chunk-F2TZRBEH.js} +2 -2
- package/dist/{chunk-E33Y7BQH.js → chunk-VN3GZDV6.js} +2 -2
- package/dist/{chunk-J5BW7V2D.js → chunk-YPXW2TN3.js} +2 -2
- package/dist/cli/init.cjs +68 -2
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +4 -4
- package/dist/cli/mcp-add.cjs +66 -0
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +2 -2
- package/dist/index.cjs +148 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -12
- package/dist/index.d.ts +43 -12
- package/dist/index.js +10 -39
- package/dist/index.js.map +1 -1
- package/dist/{source-map-uploader-26QPRSCG.js → source-map-uploader-VPDZWWM2.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-GSGX76Q5.js.map +0 -1
- /package/dist/{chunk-IOPCSX6C.js.map → chunk-F2TZRBEH.js.map} +0 -0
- /package/dist/{chunk-E33Y7BQH.js.map → chunk-VN3GZDV6.js.map} +0 -0
- /package/dist/{chunk-J5BW7V2D.js.map → chunk-YPXW2TN3.js.map} +0 -0
- /package/dist/{source-map-uploader-26QPRSCG.js.map → source-map-uploader-VPDZWWM2.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -140,6 +140,49 @@ declare const SourceMapManifestResponseSchema: z.ZodObject<{
|
|
|
140
140
|
}, z.core.$strip>;
|
|
141
141
|
type SourceMapManifestResponse = z.infer<typeof SourceMapManifestResponseSchema>;
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Session ID derivation — part of the public Glasstrace wire contract.
|
|
145
|
+
*
|
|
146
|
+
* Deriving the session ID is deterministic: given the same inputs,
|
|
147
|
+
* every runtime that implements this module produces the same
|
|
148
|
+
* 16-character hex identifier. That determinism is the contract — it
|
|
149
|
+
* lets independent clients (SDK, browser extension, server tooling)
|
|
150
|
+
* agree on the same session without coordination.
|
|
151
|
+
*
|
|
152
|
+
* This module is pure: it has no module-level state and no
|
|
153
|
+
* runtime-dependent branches. It is safe to import from Node 20+,
|
|
154
|
+
* modern browsers, Vercel Edge, and Cloudflare Workers. The SHA-256
|
|
155
|
+
* implementation is pure JavaScript; no `node:crypto`, no Web Crypto,
|
|
156
|
+
* no bundler-specific shims.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Derives a deterministic session ID from the inputs that define a
|
|
161
|
+
* Glasstrace session. The output is a 16-character lowercase hex
|
|
162
|
+
* string validated through {@link SessionIdSchema}.
|
|
163
|
+
*
|
|
164
|
+
* This function is part of the Glasstrace wire contract: any consumer
|
|
165
|
+
* (SDK, browser extension, server tooling) that calls it with the same
|
|
166
|
+
* arguments receives the same `SessionId`. That property is what lets
|
|
167
|
+
* independent clients agree on a session without coordination.
|
|
168
|
+
*
|
|
169
|
+
* Uses a pure-JavaScript SHA-256 so the output is identical across
|
|
170
|
+
* every runtime this package supports (Node 20+, modern browsers,
|
|
171
|
+
* Vercel Edge, Cloudflare Workers).
|
|
172
|
+
*
|
|
173
|
+
* Security note: the session ID is an **identifier**, not a secret or
|
|
174
|
+
* an authentication token. It is never used for authorization.
|
|
175
|
+
*
|
|
176
|
+
* @param apiKey - The project's API key (or anonymous placeholder).
|
|
177
|
+
* @param origin - The origin string identifying the deployment
|
|
178
|
+
* environment (for example `localhost:3000` or `production`).
|
|
179
|
+
* @param date - UTC date as `YYYY-MM-DD`.
|
|
180
|
+
* @param windowIndex - Zero-based index of the 4-hour activity window
|
|
181
|
+
* within the day.
|
|
182
|
+
* @returns A 16-character hex {@link SessionId}.
|
|
183
|
+
*/
|
|
184
|
+
declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
|
|
185
|
+
|
|
143
186
|
/**
|
|
144
187
|
* Internal SDK error class with a typed diagnostic code.
|
|
145
188
|
* Caught at the boundary and converted to a log message + diagnostic entry.
|
|
@@ -188,18 +231,6 @@ declare function isProductionDisabled(config: ResolvedConfig): boolean;
|
|
|
188
231
|
*/
|
|
189
232
|
declare function isAnonymousMode(config: ResolvedConfig): boolean;
|
|
190
233
|
|
|
191
|
-
/**
|
|
192
|
-
* Derives a deterministic session ID from the given inputs.
|
|
193
|
-
* Uses SHA-256 (truncated to 16 hex chars) when `node:crypto` is available,
|
|
194
|
-
* or a deterministic FNV-1a hash as a fallback in non-Node environments.
|
|
195
|
-
*
|
|
196
|
-
* @param apiKey - The project's API key (or anonymous placeholder).
|
|
197
|
-
* @param origin - The origin string identifying the deployment environment.
|
|
198
|
-
* @param date - UTC date as YYYY-MM-DD.
|
|
199
|
-
* @param windowIndex - Zero-based index of the 4-hour activity window within the day.
|
|
200
|
-
* @returns A 16-character hex SessionId.
|
|
201
|
-
*/
|
|
202
|
-
declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
|
|
203
234
|
/**
|
|
204
235
|
* Returns the origin string for the current process.
|
|
205
236
|
* If GLASSTRACE_ENV is set, returns that value.
|
package/dist/index.d.ts
CHANGED
|
@@ -140,6 +140,49 @@ declare const SourceMapManifestResponseSchema: z.ZodObject<{
|
|
|
140
140
|
}, z.core.$strip>;
|
|
141
141
|
type SourceMapManifestResponse = z.infer<typeof SourceMapManifestResponseSchema>;
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Session ID derivation — part of the public Glasstrace wire contract.
|
|
145
|
+
*
|
|
146
|
+
* Deriving the session ID is deterministic: given the same inputs,
|
|
147
|
+
* every runtime that implements this module produces the same
|
|
148
|
+
* 16-character hex identifier. That determinism is the contract — it
|
|
149
|
+
* lets independent clients (SDK, browser extension, server tooling)
|
|
150
|
+
* agree on the same session without coordination.
|
|
151
|
+
*
|
|
152
|
+
* This module is pure: it has no module-level state and no
|
|
153
|
+
* runtime-dependent branches. It is safe to import from Node 20+,
|
|
154
|
+
* modern browsers, Vercel Edge, and Cloudflare Workers. The SHA-256
|
|
155
|
+
* implementation is pure JavaScript; no `node:crypto`, no Web Crypto,
|
|
156
|
+
* no bundler-specific shims.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Derives a deterministic session ID from the inputs that define a
|
|
161
|
+
* Glasstrace session. The output is a 16-character lowercase hex
|
|
162
|
+
* string validated through {@link SessionIdSchema}.
|
|
163
|
+
*
|
|
164
|
+
* This function is part of the Glasstrace wire contract: any consumer
|
|
165
|
+
* (SDK, browser extension, server tooling) that calls it with the same
|
|
166
|
+
* arguments receives the same `SessionId`. That property is what lets
|
|
167
|
+
* independent clients agree on a session without coordination.
|
|
168
|
+
*
|
|
169
|
+
* Uses a pure-JavaScript SHA-256 so the output is identical across
|
|
170
|
+
* every runtime this package supports (Node 20+, modern browsers,
|
|
171
|
+
* Vercel Edge, Cloudflare Workers).
|
|
172
|
+
*
|
|
173
|
+
* Security note: the session ID is an **identifier**, not a secret or
|
|
174
|
+
* an authentication token. It is never used for authorization.
|
|
175
|
+
*
|
|
176
|
+
* @param apiKey - The project's API key (or anonymous placeholder).
|
|
177
|
+
* @param origin - The origin string identifying the deployment
|
|
178
|
+
* environment (for example `localhost:3000` or `production`).
|
|
179
|
+
* @param date - UTC date as `YYYY-MM-DD`.
|
|
180
|
+
* @param windowIndex - Zero-based index of the 4-hour activity window
|
|
181
|
+
* within the day.
|
|
182
|
+
* @returns A 16-character hex {@link SessionId}.
|
|
183
|
+
*/
|
|
184
|
+
declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
|
|
185
|
+
|
|
143
186
|
/**
|
|
144
187
|
* Internal SDK error class with a typed diagnostic code.
|
|
145
188
|
* Caught at the boundary and converted to a log message + diagnostic entry.
|
|
@@ -188,18 +231,6 @@ declare function isProductionDisabled(config: ResolvedConfig): boolean;
|
|
|
188
231
|
*/
|
|
189
232
|
declare function isAnonymousMode(config: ResolvedConfig): boolean;
|
|
190
233
|
|
|
191
|
-
/**
|
|
192
|
-
* Derives a deterministic session ID from the given inputs.
|
|
193
|
-
* Uses SHA-256 (truncated to 16 hex chars) when `node:crypto` is available,
|
|
194
|
-
* or a deterministic FNV-1a hash as a fallback in non-Node environments.
|
|
195
|
-
*
|
|
196
|
-
* @param apiKey - The project's API key (or anonymous placeholder).
|
|
197
|
-
* @param origin - The origin string identifying the deployment environment.
|
|
198
|
-
* @param date - UTC date as YYYY-MM-DD.
|
|
199
|
-
* @param windowIndex - Zero-based index of the 4-hour activity window within the day.
|
|
200
|
-
* @returns A 16-character hex SessionId.
|
|
201
|
-
*/
|
|
202
|
-
declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
|
|
203
234
|
/**
|
|
204
235
|
* Returns the origin string for the current process.
|
|
205
236
|
* If GLASSTRACE_ENV is set, returns that value.
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
uploadSourceMaps,
|
|
11
11
|
uploadSourceMapsAuto,
|
|
12
12
|
uploadSourceMapsPresigned
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VN3GZDV6.js";
|
|
14
14
|
import {
|
|
15
15
|
_setCurrentConfig,
|
|
16
16
|
buildImportGraph,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
recordSpansExported,
|
|
29
29
|
saveCachedConfig,
|
|
30
30
|
sendInitRequest
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-F2TZRBEH.js";
|
|
32
32
|
import {
|
|
33
33
|
isAnonymousMode,
|
|
34
34
|
isProductionDisabled,
|
|
@@ -38,11 +38,11 @@ import {
|
|
|
38
38
|
import {
|
|
39
39
|
getOrCreateAnonKey,
|
|
40
40
|
readAnonKey
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-YPXW2TN3.js";
|
|
42
42
|
import {
|
|
43
43
|
GLASSTRACE_ATTRIBUTE_NAMES,
|
|
44
|
-
|
|
45
|
-
} from "./chunk-
|
|
44
|
+
deriveSessionId
|
|
45
|
+
} from "./chunk-5N2IR4EO.js";
|
|
46
46
|
import {
|
|
47
47
|
DiagLogLevel,
|
|
48
48
|
INVALID_SPAN_CONTEXT,
|
|
@@ -76,37 +76,8 @@ var SdkError = class extends Error {
|
|
|
76
76
|
|
|
77
77
|
// src/session.ts
|
|
78
78
|
var FOUR_HOURS_MS = 4 * 60 * 60 * 1e3;
|
|
79
|
-
var hashFn = null;
|
|
80
|
-
function fnv1aHash(input) {
|
|
81
|
-
let hash = 2166136261;
|
|
82
|
-
for (let i = 0; i < input.length; i++) {
|
|
83
|
-
hash ^= input.charCodeAt(i);
|
|
84
|
-
hash = Math.imul(hash, 16777619);
|
|
85
|
-
hash >>>= 0;
|
|
86
|
-
}
|
|
87
|
-
return hash.toString(16).padStart(8, "0");
|
|
88
|
-
}
|
|
89
|
-
function getHashFn() {
|
|
90
|
-
if (hashFn) return hashFn;
|
|
91
|
-
try {
|
|
92
|
-
const { createHash } = __require("node:crypto");
|
|
93
|
-
hashFn = (input) => createHash("sha256").update(input).digest("hex").slice(0, 16);
|
|
94
|
-
} catch {
|
|
95
|
-
hashFn = (input) => {
|
|
96
|
-
const h1 = fnv1aHash(input);
|
|
97
|
-
const h2 = fnv1aHash(input + "\0");
|
|
98
|
-
return (h1 + h2).slice(0, 16);
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return hashFn;
|
|
102
|
-
}
|
|
103
79
|
var cachedGlasstraceEnv = process.env.GLASSTRACE_ENV;
|
|
104
80
|
var cachedPort = process.env.PORT ?? "3000";
|
|
105
|
-
function deriveSessionId(apiKey, origin, date, windowIndex) {
|
|
106
|
-
const input = JSON.stringify([apiKey, origin, date, windowIndex]);
|
|
107
|
-
const hash = getHashFn()(input);
|
|
108
|
-
return SessionIdSchema.parse(hash);
|
|
109
|
-
}
|
|
110
81
|
function getOrigin() {
|
|
111
82
|
if (cachedGlasstraceEnv) {
|
|
112
83
|
return cachedGlasstraceEnv;
|
|
@@ -4236,7 +4207,7 @@ function registerGlasstrace(options) {
|
|
|
4236
4207
|
setCoreState(CoreState.REGISTERING);
|
|
4237
4208
|
startRuntimeStateWriter({
|
|
4238
4209
|
projectRoot: process.cwd(),
|
|
4239
|
-
sdkVersion: "0.
|
|
4210
|
+
sdkVersion: "0.19.0"
|
|
4240
4211
|
});
|
|
4241
4212
|
const config = resolveConfig(options);
|
|
4242
4213
|
if (config.verbose) {
|
|
@@ -4402,8 +4373,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
4402
4373
|
if (config.verbose) {
|
|
4403
4374
|
console.info("[glasstrace] Background init firing.");
|
|
4404
4375
|
}
|
|
4405
|
-
const healthReport = collectHealthReport("0.
|
|
4406
|
-
const initResult = await performInit(config, anonKeyForInit, "0.
|
|
4376
|
+
const healthReport = collectHealthReport("0.19.0");
|
|
4377
|
+
const initResult = await performInit(config, anonKeyForInit, "0.19.0", healthReport);
|
|
4407
4378
|
if (generation !== registrationGeneration) return;
|
|
4408
4379
|
const currentState = getCoreState();
|
|
4409
4380
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -4426,7 +4397,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
4426
4397
|
}
|
|
4427
4398
|
maybeInstallConsoleCapture();
|
|
4428
4399
|
if (didLastInitSucceed()) {
|
|
4429
|
-
startHeartbeat(config, anonKeyForInit, "0.
|
|
4400
|
+
startHeartbeat(config, anonKeyForInit, "0.19.0", generation, (newApiKey, accountId) => {
|
|
4430
4401
|
setAuthState(AuthState.CLAIMING);
|
|
4431
4402
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
4432
4403
|
setResolvedApiKey(newApiKey);
|
|
@@ -4563,7 +4534,7 @@ async function handleSourceMapUpload(distDir) {
|
|
|
4563
4534
|
);
|
|
4564
4535
|
return;
|
|
4565
4536
|
}
|
|
4566
|
-
const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-
|
|
4537
|
+
const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-VPDZWWM2.js");
|
|
4567
4538
|
const files = await discoverSourceMapFiles2(distDir);
|
|
4568
4539
|
if (files.length === 0) {
|
|
4569
4540
|
console.info("[glasstrace] No source map files found. Skipping upload.");
|