praetom 0.1.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/README.md +82 -0
- package/dist/_esm-loader.d.ts +49 -0
- package/dist/_esm-loader.d.ts.map +1 -0
- package/dist/_esm-loader.js +131 -0
- package/dist/_esm-loader.js.map +1 -0
- package/dist/_internal.d.ts +63 -0
- package/dist/_internal.d.ts.map +1 -0
- package/dist/_internal.js +357 -0
- package/dist/_internal.js.map +1 -0
- package/dist/browser.d.ts +90 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +357 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +97 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/commands/discover.d.ts +3 -0
- package/dist/cli/commands/discover.d.ts.map +1 -0
- package/dist/cli/commands/discover.js +15 -0
- package/dist/cli/commands/discover.js.map +1 -0
- package/dist/cli/commands/features.d.ts +5 -0
- package/dist/cli/commands/features.d.ts.map +1 -0
- package/dist/cli/commands/features.js +83 -0
- package/dist/cli/commands/features.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +52 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/login.d.ts +20 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +138 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/logout.d.ts +3 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +15 -0
- package/dist/cli/commands/logout.js.map +1 -0
- package/dist/cli/commands/rotate.d.ts +3 -0
- package/dist/cli/commands/rotate.d.ts.map +1 -0
- package/dist/cli/commands/rotate.js +33 -0
- package/dist/cli/commands/rotate.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +54 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/uninstall.d.ts +3 -0
- package/dist/cli/commands/uninstall.d.ts.map +1 -0
- package/dist/cli/commands/uninstall.js +63 -0
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/commands/usage.d.ts +3 -0
- package/dist/cli/commands/usage.d.ts.map +1 -0
- package/dist/cli/commands/usage.js +19 -0
- package/dist/cli/commands/usage.js.map +1 -0
- package/dist/cli/commands/whoami.d.ts +3 -0
- package/dist/cli/commands/whoami.d.ts.map +1 -0
- package/dist/cli/commands/whoami.js +37 -0
- package/dist/cli/commands/whoami.js.map +1 -0
- package/dist/cli/util/agent-env.d.ts +13 -0
- package/dist/cli/util/agent-env.d.ts.map +1 -0
- package/dist/cli/util/agent-env.js +28 -0
- package/dist/cli/util/agent-env.js.map +1 -0
- package/dist/cli/util/api.d.ts +36 -0
- package/dist/cli/util/api.d.ts.map +1 -0
- package/dist/cli/util/api.js +84 -0
- package/dist/cli/util/api.js.map +1 -0
- package/dist/cli/util/auth-file.d.ts +25 -0
- package/dist/cli/util/auth-file.d.ts.map +1 -0
- package/dist/cli/util/auth-file.js +74 -0
- package/dist/cli/util/auth-file.js.map +1 -0
- package/dist/cli/util/git.d.ts +28 -0
- package/dist/cli/util/git.d.ts.map +1 -0
- package/dist/cli/util/git.js +103 -0
- package/dist/cli/util/git.js.map +1 -0
- package/dist/cli/util/run.d.ts +26 -0
- package/dist/cli/util/run.d.ts.map +1 -0
- package/dist/cli/util/run.js +31 -0
- package/dist/cli/util/run.js.map +1 -0
- package/dist/edge.d.ts +34 -0
- package/dist/edge.d.ts.map +1 -0
- package/dist/edge.js +127 -0
- package/dist/edge.js.map +1 -0
- package/dist/server.d.ts +69 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +193 -0
- package/dist/server.js.map +1 -0
- package/dist/vite/index.d.ts +48 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +138 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/webpack/index.d.ts +64 -0
- package/dist/webpack/index.d.ts.map +1 -0
- package/dist/webpack/index.js +106 -0
- package/dist/webpack/index.js.map +1 -0
- package/dist/webpack/loader.d.ts +27 -0
- package/dist/webpack/loader.d.ts.map +1 -0
- package/dist/webpack/loader.js +54 -0
- package/dist/webpack/loader.js.map +1 -0
- package/dist/webpack/shared.d.ts +25 -0
- package/dist/webpack/shared.d.ts.map +1 -0
- package/dist/webpack/shared.js +63 -0
- package/dist/webpack/shared.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal runtime primitives. NOT part of the public package surface —
|
|
3
|
+
* customers should import from `praetom` or
|
|
4
|
+
* `praetom`, which together expose only `register` and
|
|
5
|
+
* `emit`.
|
|
6
|
+
*
|
|
7
|
+
* Everything else (`feature`, `featureSync`, `continueTrace`, `init`,
|
|
8
|
+
* `flush`, `shutdown`, the buffer, the fetch patch) lives here and is
|
|
9
|
+
* called by `register()` + the autowrap hook + the bundler plugin's
|
|
10
|
+
* generated code. We don't ship a manual-wrap API.
|
|
11
|
+
*/
|
|
12
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
13
|
+
import { randomBytes } from "node:crypto";
|
|
14
|
+
const DEFAULT_ENDPOINT = "https://praetom.com/api/otlp/v1/traces";
|
|
15
|
+
const FLUSH_INTERVAL_MS = 5_000;
|
|
16
|
+
const FLUSH_BATCH_SIZE = 50;
|
|
17
|
+
const g = globalThis;
|
|
18
|
+
if (!g.__praetom) {
|
|
19
|
+
g.__praetom = {
|
|
20
|
+
config: null,
|
|
21
|
+
buffer: [],
|
|
22
|
+
flushTimer: null,
|
|
23
|
+
fetchPatched: false,
|
|
24
|
+
als: new AsyncLocalStorage(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const _state = g.__praetom;
|
|
28
|
+
const als = _state.als;
|
|
29
|
+
export function init(opts) {
|
|
30
|
+
_state.config = {
|
|
31
|
+
token: opts.token,
|
|
32
|
+
endpoint: opts.endpoint ?? DEFAULT_ENDPOINT,
|
|
33
|
+
serviceName: opts.serviceName,
|
|
34
|
+
};
|
|
35
|
+
patchFetch();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Wrap an async function as a feature entry point. Called by the
|
|
39
|
+
* autowrap hook in `server.ts` and the bundler plugin's generated
|
|
40
|
+
* browser-side code — NOT a customer-facing API.
|
|
41
|
+
*/
|
|
42
|
+
export async function feature(slug, fn, attributes) {
|
|
43
|
+
const ctx = {
|
|
44
|
+
traceId: randHex(16),
|
|
45
|
+
spanId: randHex(8),
|
|
46
|
+
slug,
|
|
47
|
+
};
|
|
48
|
+
return runFeature(ctx, null, fn, attributes);
|
|
49
|
+
}
|
|
50
|
+
export function featureSync(slug, fn) {
|
|
51
|
+
const ctx = {
|
|
52
|
+
traceId: randHex(16),
|
|
53
|
+
spanId: randHex(8),
|
|
54
|
+
slug,
|
|
55
|
+
};
|
|
56
|
+
const startMs = Date.now();
|
|
57
|
+
try {
|
|
58
|
+
return als.run(ctx, () => {
|
|
59
|
+
const result = fn();
|
|
60
|
+
record(ctx, null, startMs, false);
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
record(ctx, null, startMs, true);
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Continue a trace from an incoming HTTP request. Called by the
|
|
71
|
+
* autowrap hook when wrapping HTTP handlers — reads `traceparent` and
|
|
72
|
+
* stitches the local span under the upstream span.
|
|
73
|
+
*/
|
|
74
|
+
export async function continueTrace(headers, slug, fn, attributes) {
|
|
75
|
+
const tp = readTraceparent(headers);
|
|
76
|
+
const ctx = tp
|
|
77
|
+
? { traceId: tp.traceId, spanId: randHex(8), slug }
|
|
78
|
+
: { traceId: randHex(16), spanId: randHex(8), slug };
|
|
79
|
+
const parentSpanId = tp?.parentSpanId ?? null;
|
|
80
|
+
return runFeature(ctx, parentSpanId, fn, attributes);
|
|
81
|
+
}
|
|
82
|
+
async function runFeature(ctx, parentSpanId, fn, attributes) {
|
|
83
|
+
const startMs = Date.now();
|
|
84
|
+
return als.run(ctx, async () => {
|
|
85
|
+
try {
|
|
86
|
+
const result = await fn();
|
|
87
|
+
record(ctx, parentSpanId, startMs, false, attributes);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
record(ctx, parentSpanId, startMs, true, attributes);
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export function currentFeatureContext() {
|
|
97
|
+
return als.getStore();
|
|
98
|
+
}
|
|
99
|
+
const HTTP_METHODS = new Set([
|
|
100
|
+
"GET",
|
|
101
|
+
"POST",
|
|
102
|
+
"PUT",
|
|
103
|
+
"PATCH",
|
|
104
|
+
"DELETE",
|
|
105
|
+
"OPTIONS",
|
|
106
|
+
"HEAD",
|
|
107
|
+
]);
|
|
108
|
+
/**
|
|
109
|
+
* Internal wrap-as-entry-point helper. Shared by the CJS Module._load
|
|
110
|
+
* hook, the ESM loader hook, and the bundler plugin's injected code.
|
|
111
|
+
*
|
|
112
|
+
* If `entryName` is an HTTP method (`GET`, `POST`, ...), the wrap reads
|
|
113
|
+
* `traceparent` from the first arg's `headers` to continue an upstream
|
|
114
|
+
* trace. Otherwise it opens a fresh feature span.
|
|
115
|
+
*
|
|
116
|
+
* NOT a public customer API — exported under `__praetom*` only so the
|
|
117
|
+
* bundler-plugin-injected code can call it; customers should never
|
|
118
|
+
* import it directly.
|
|
119
|
+
*/
|
|
120
|
+
export function wrapEntryPoint(slug, entryName, original) {
|
|
121
|
+
const isHttpHandler = HTTP_METHODS.has(entryName);
|
|
122
|
+
const wrapped = function (...args) {
|
|
123
|
+
if (isHttpHandler) {
|
|
124
|
+
const req = args[0];
|
|
125
|
+
const headers = req?.headers;
|
|
126
|
+
if (headers) {
|
|
127
|
+
const attrs = classifyHttpCaller(headers);
|
|
128
|
+
return continueTrace(headers, slug, async () => original.apply(this, args), attrs);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return feature(slug, async () => original.apply(this, args));
|
|
132
|
+
};
|
|
133
|
+
Object.defineProperty(wrapped, "name", { value: entryName });
|
|
134
|
+
return wrapped;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Pulls the request's user-agent and classifies the caller as either
|
|
138
|
+
* "agent" (an AI tool: Claude Code, Cursor, ChatGPT, MCP clients) or
|
|
139
|
+
* "user" (everything else). Stamps the result on the span as
|
|
140
|
+
* `praetom.actor` so the dashboard can split traffic by caller without
|
|
141
|
+
* a second query.
|
|
142
|
+
*/
|
|
143
|
+
function classifyHttpCaller(headers) {
|
|
144
|
+
const ua = readHeader(headers, "user-agent");
|
|
145
|
+
if (!ua)
|
|
146
|
+
return { "praetom.actor": "user" };
|
|
147
|
+
const lc = ua.toLowerCase();
|
|
148
|
+
const isAgent = lc.includes("claude") ||
|
|
149
|
+
lc.includes("cursor") ||
|
|
150
|
+
lc.includes("chatgpt") ||
|
|
151
|
+
lc.includes("openai") ||
|
|
152
|
+
lc.includes("mcp-") ||
|
|
153
|
+
lc.includes("/mcp ") ||
|
|
154
|
+
lc.includes("anthropic-ai");
|
|
155
|
+
return {
|
|
156
|
+
"praetom.actor": isAgent ? "agent" : "user",
|
|
157
|
+
"praetom.user_agent": ua.slice(0, 256),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function readHeader(headers, key) {
|
|
161
|
+
if (typeof headers.get === "function") {
|
|
162
|
+
return (headers.get(key) ??
|
|
163
|
+
headers.get(key.toLowerCase()) ??
|
|
164
|
+
null);
|
|
165
|
+
}
|
|
166
|
+
const rec = headers;
|
|
167
|
+
return rec[key] ?? rec[key.toLowerCase()] ?? null;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Public primitive — fire a point-in-time event tagged with the current
|
|
171
|
+
* feature context if one exists. Use inside business logic to mark
|
|
172
|
+
* latency splits, business events, or error context that the entry-
|
|
173
|
+
* point wrap doesn't capture by itself.
|
|
174
|
+
*
|
|
175
|
+
* Outside a feature context the span still emits, but with no parent —
|
|
176
|
+
* use sparingly for top-level signals.
|
|
177
|
+
*/
|
|
178
|
+
export function emit(eventName, payload) {
|
|
179
|
+
if (!_state.config)
|
|
180
|
+
return;
|
|
181
|
+
const ctx = als.getStore();
|
|
182
|
+
const now = Date.now();
|
|
183
|
+
_state.buffer.push({
|
|
184
|
+
featureSlug: ctx?.slug ?? eventName,
|
|
185
|
+
name: eventName,
|
|
186
|
+
traceId: ctx?.traceId ?? randHex(16),
|
|
187
|
+
spanId: randHex(8),
|
|
188
|
+
parentSpanId: ctx?.spanId ?? null,
|
|
189
|
+
startMs: now,
|
|
190
|
+
endMs: now,
|
|
191
|
+
isError: false,
|
|
192
|
+
attributes: payload ? stringifyAttributes(payload) : undefined,
|
|
193
|
+
});
|
|
194
|
+
scheduleFlush();
|
|
195
|
+
}
|
|
196
|
+
function record(ctx, parentSpanId, startMs, isError, attributes) {
|
|
197
|
+
if (!_state.config)
|
|
198
|
+
return;
|
|
199
|
+
_state.buffer.push({
|
|
200
|
+
featureSlug: ctx.slug,
|
|
201
|
+
name: ctx.slug,
|
|
202
|
+
traceId: ctx.traceId,
|
|
203
|
+
spanId: ctx.spanId,
|
|
204
|
+
parentSpanId,
|
|
205
|
+
startMs,
|
|
206
|
+
endMs: Date.now(),
|
|
207
|
+
isError,
|
|
208
|
+
attributes,
|
|
209
|
+
});
|
|
210
|
+
scheduleFlush();
|
|
211
|
+
}
|
|
212
|
+
function scheduleFlush() {
|
|
213
|
+
if (_state.buffer.length >= FLUSH_BATCH_SIZE) {
|
|
214
|
+
void flushNow();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (!_state.flushTimer) {
|
|
218
|
+
_state.flushTimer = setTimeout(() => {
|
|
219
|
+
_state.flushTimer = null;
|
|
220
|
+
void flushNow();
|
|
221
|
+
}, FLUSH_INTERVAL_MS);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
export async function flush() {
|
|
225
|
+
await flushNow();
|
|
226
|
+
}
|
|
227
|
+
export async function shutdown() {
|
|
228
|
+
if (_state.flushTimer) {
|
|
229
|
+
clearTimeout(_state.flushTimer);
|
|
230
|
+
_state.flushTimer = null;
|
|
231
|
+
}
|
|
232
|
+
await flushNow();
|
|
233
|
+
}
|
|
234
|
+
async function flushNow() {
|
|
235
|
+
if (!_state.config)
|
|
236
|
+
return;
|
|
237
|
+
if (_state.buffer.length === 0)
|
|
238
|
+
return;
|
|
239
|
+
const spans = _state.buffer;
|
|
240
|
+
_state.buffer = [];
|
|
241
|
+
const body = encodeOtlp(spans, _state.config);
|
|
242
|
+
try {
|
|
243
|
+
await fetch(_state.config.endpoint, {
|
|
244
|
+
method: "POST",
|
|
245
|
+
headers: {
|
|
246
|
+
"content-type": "application/json",
|
|
247
|
+
authorization: `Bearer ${_state.config.token}`,
|
|
248
|
+
},
|
|
249
|
+
body: JSON.stringify(body),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// network error — drop. Telemetry must not crash the host.
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function patchFetch() {
|
|
257
|
+
if (_state.fetchPatched)
|
|
258
|
+
return;
|
|
259
|
+
if (typeof globalThis.fetch !== "function")
|
|
260
|
+
return;
|
|
261
|
+
const original = globalThis.fetch.bind(globalThis);
|
|
262
|
+
globalThis.fetch = ((input, init) => {
|
|
263
|
+
const ctx = als.getStore();
|
|
264
|
+
if (!ctx)
|
|
265
|
+
return original(input, init);
|
|
266
|
+
const headers = new Headers(init?.headers ?? {});
|
|
267
|
+
if (!headers.has("traceparent")) {
|
|
268
|
+
headers.set("traceparent", buildTraceparent(ctx.traceId, ctx.spanId));
|
|
269
|
+
}
|
|
270
|
+
return original(input, { ...init, headers });
|
|
271
|
+
});
|
|
272
|
+
_state.fetchPatched = true;
|
|
273
|
+
}
|
|
274
|
+
function buildTraceparent(traceId, spanId) {
|
|
275
|
+
return `00-${traceId}-${spanId}-01`;
|
|
276
|
+
}
|
|
277
|
+
function readTraceparent(source) {
|
|
278
|
+
let raw;
|
|
279
|
+
if (typeof source.get === "function") {
|
|
280
|
+
raw = source.get("traceparent");
|
|
281
|
+
}
|
|
282
|
+
else if (source instanceof Headers) {
|
|
283
|
+
raw = source.get("traceparent");
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
const o = source;
|
|
287
|
+
raw = o.traceparent ?? o.Traceparent ?? o.TRACEPARENT;
|
|
288
|
+
}
|
|
289
|
+
if (!raw)
|
|
290
|
+
return null;
|
|
291
|
+
const parts = raw.trim().split("-");
|
|
292
|
+
if (parts.length !== 4)
|
|
293
|
+
return null;
|
|
294
|
+
const [version, traceId, spanId] = parts;
|
|
295
|
+
if (version !== "00")
|
|
296
|
+
return null;
|
|
297
|
+
if (!/^[0-9a-f]{32}$/i.test(traceId))
|
|
298
|
+
return null;
|
|
299
|
+
if (!/^[0-9a-f]{16}$/i.test(spanId))
|
|
300
|
+
return null;
|
|
301
|
+
return { traceId: traceId.toLowerCase(), parentSpanId: spanId.toLowerCase() };
|
|
302
|
+
}
|
|
303
|
+
function randHex(bytes) {
|
|
304
|
+
return randomBytes(bytes).toString("hex");
|
|
305
|
+
}
|
|
306
|
+
function stringifyAttributes(payload) {
|
|
307
|
+
const out = {};
|
|
308
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
309
|
+
if (v == null)
|
|
310
|
+
continue;
|
|
311
|
+
out[k] = typeof v === "string" ? v : JSON.stringify(v);
|
|
312
|
+
}
|
|
313
|
+
return out;
|
|
314
|
+
}
|
|
315
|
+
function encodeOtlp(spans, config) {
|
|
316
|
+
const resourceAttrs = [];
|
|
317
|
+
if (config.serviceName) {
|
|
318
|
+
resourceAttrs.push({
|
|
319
|
+
key: "service.name",
|
|
320
|
+
value: { stringValue: config.serviceName },
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
resourceSpans: [
|
|
325
|
+
{
|
|
326
|
+
resource: resourceAttrs.length ? { attributes: resourceAttrs } : undefined,
|
|
327
|
+
scopeSpans: [
|
|
328
|
+
{
|
|
329
|
+
scope: { name: "praetom", version: "0.4.0" },
|
|
330
|
+
spans: spans.map((s) => {
|
|
331
|
+
const attrs = [
|
|
332
|
+
{ key: "praetom.feature", value: { stringValue: s.featureSlug } },
|
|
333
|
+
];
|
|
334
|
+
if (s.attributes) {
|
|
335
|
+
for (const [k, v] of Object.entries(s.attributes)) {
|
|
336
|
+
attrs.push({ key: k, value: { stringValue: v } });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
traceId: s.traceId,
|
|
341
|
+
spanId: s.spanId,
|
|
342
|
+
parentSpanId: s.parentSpanId ?? undefined,
|
|
343
|
+
name: s.name,
|
|
344
|
+
kind: 2,
|
|
345
|
+
startTimeUnixNano: `${s.startMs}000000`,
|
|
346
|
+
endTimeUnixNano: `${s.endMs}000000`,
|
|
347
|
+
attributes: attrs,
|
|
348
|
+
status: { code: s.isError ? 2 : 1 },
|
|
349
|
+
};
|
|
350
|
+
}),
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=_internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_internal.js","sourceRoot":"","sources":["../src/_internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAClE,MAA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pD,CAAC;4BACH,CAAC;4BACD,OAAO;gCACL,OAAO,EAAE,CAAC,CAAC,OAAO;gCAClB,MAAM,EAAE,CAAC,CAAC,MAAM;gCAChB,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,SAAS;gCACzC,IAAI,EAAE,CAAC,CAAC,IAAI;gCACZ,IAAI,EAAE,CAAC;gCACP,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAO,QAAQ;gCACvC,eAAe,EAAE,GAAG,CAAC,CAAC,KAAK,QAAQ;gCACnC,UAAU,EAAE,KAAK;gCACjB,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;6BACpC,CAAC;wBACJ,CAAC,CAAC;qBACH;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* praetom — client-side customer API.
|
|
3
|
+
*
|
|
4
|
+
* Two exports, mirroring /server:
|
|
5
|
+
* - register({ ingestId }) — call once at boot (root layout / entry)
|
|
6
|
+
* - emit(eventName, payload?) — point-in-time event from business logic
|
|
7
|
+
*
|
|
8
|
+
* // In a Next.js root layout or _app.tsx:
|
|
9
|
+
* import { register } from "praetom";
|
|
10
|
+
* register({ ingestId: "praetom_..." }); // DSN-style, public OK
|
|
11
|
+
*
|
|
12
|
+
* // Inside a component's interaction handler:
|
|
13
|
+
* import { emit } from "praetom";
|
|
14
|
+
* <button onClick={() => {
|
|
15
|
+
* emit("checkout:button-clicked");
|
|
16
|
+
* submit();
|
|
17
|
+
* }} />
|
|
18
|
+
*
|
|
19
|
+
* Auto-instrumentation: praetom's DB names the components that count
|
|
20
|
+
* as feature entry points. The praetom/vite (and webpack/rollup
|
|
21
|
+
* variants to follow) read the same config at build time and inject the
|
|
22
|
+
* wrap automatically — no source-level feature() calls in customer code.
|
|
23
|
+
*
|
|
24
|
+
* v1 internals:
|
|
25
|
+
* • No native AsyncLocalStorage → module-level "current feature" stack.
|
|
26
|
+
* Safe for single-threaded JS in the common case (one user action =
|
|
27
|
+
* one in-flight feature). Concurrent features in true parallel (e.g.
|
|
28
|
+
* two Promise.all-ed unrelated wraps) may attribute fetches to
|
|
29
|
+
* whichever wrap was entered last; accepted for v1.
|
|
30
|
+
* • Wire shape mirrors the server: OTLP/JSON via beacon on page hide,
|
|
31
|
+
* or via fetch on interval flush. Same trace context propagation via
|
|
32
|
+
* W3C traceparent.
|
|
33
|
+
*/
|
|
34
|
+
interface RegisterOptions {
|
|
35
|
+
ingestId: string;
|
|
36
|
+
/** Override the OTLP endpoint (defaults to praetom.com). */
|
|
37
|
+
endpoint?: string;
|
|
38
|
+
/** Override the runtime config endpoint (defaults to praetom.com). */
|
|
39
|
+
configEndpoint?: string;
|
|
40
|
+
/** Override the repo identifier (defaults to data-praetom-repo on <script>). */
|
|
41
|
+
repo?: string;
|
|
42
|
+
/** Suppress console.warn lines (for tests). */
|
|
43
|
+
silent?: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface FeatureMapEntry {
|
|
46
|
+
slug: string;
|
|
47
|
+
paths: string[];
|
|
48
|
+
entrySymbol?: string;
|
|
49
|
+
side?: string;
|
|
50
|
+
}
|
|
51
|
+
export declare function register(opts: RegisterOptions): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Internal — wrap a callback as a feature entry point. NOT a public
|
|
54
|
+
* export. The bundler plugin (`praetom/vite` and friends)
|
|
55
|
+
* generates code that calls this around the entry symbols praetom's
|
|
56
|
+
* DB names. Customer source code does not contain feature() calls.
|
|
57
|
+
*/
|
|
58
|
+
declare function feature<T>(slug: string, fn: () => Promise<T>): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Fire a point-in-time event tagged with the current feature context
|
|
61
|
+
* if one exists. Use inside component code to mark interactions,
|
|
62
|
+
* business events, or latency-relevant moments that the entry-point
|
|
63
|
+
* wrap doesn't capture.
|
|
64
|
+
*/
|
|
65
|
+
export declare function emit(eventName: string, payload?: Record<string, unknown>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Internal escape hatch for the bundler plugin's generated code. NOT
|
|
68
|
+
* a public export. Exported under an underscored name so the build-
|
|
69
|
+
* tool plugin can import it without polluting the customer-facing
|
|
70
|
+
* surface. May be removed once the plugin codegen stabilizes.
|
|
71
|
+
*/
|
|
72
|
+
export declare const __praetomFeature: typeof feature;
|
|
73
|
+
/**
|
|
74
|
+
* Browser counterpart of the server's `__praetomWrapEntryPoint`. Same
|
|
75
|
+
* shape so the bundler plugin can emit a single `__praetomWrapEntryPoint`
|
|
76
|
+
* call regardless of build layer; browser ignores `entryName` since
|
|
77
|
+
* there's no HTTP request context to continue a trace from.
|
|
78
|
+
*/
|
|
79
|
+
export declare function __praetomWrapEntryPoint<T>(slug: string, _entryName: string, original: (...args: unknown[]) => Promise<T> | T): (...args: unknown[]) => Promise<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Test-only — reset module state between tests.
|
|
82
|
+
*/
|
|
83
|
+
export declare function _resetForTests(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Read the current feature map. Useful for v1.5 bundler-plugin work
|
|
86
|
+
* where the plugin asks the runtime which paths to wrap.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getFeatureMap(): readonly FeatureMapEntry[];
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IAC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