@teploy/observe-browser 0.0.0-stage → 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.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Feature-flag evaluation client for @teploy/observe-browser.
3
+ *
4
+ * Wire contract (cmd/observe flagEvaluateHandler, internal/flags):
5
+ *
6
+ * POST {endpoint}/api/v1/flags/evaluate
7
+ * { "site_id", "flag_key", "user_id", "context": { string: string } }
8
+ * -> { "enabled": bool, "variant"?: string, "reason": "evaluated" |
9
+ * "unavailable" | "invalid", "detail"?: string }
10
+ *
11
+ * The route is public (an X-API-Key is accepted but not required) and is
12
+ * rate limited per IP and per site, so this client caches and coalesces.
13
+ *
14
+ * Failure policy: evaluation never rejects. A network error, timeout,
15
+ * non-2xx status, malformed body, or a server answer whose reason is not
16
+ * "evaluated" (the store was unavailable or the flag config is invalid)
17
+ * yields the caller-supplied default with `source: "default"` and the
18
+ * cause in `error`. Such results are never cached, so the next call
19
+ * retries. Without a caller default the fail-safe is `{ enabled: false }`,
20
+ * matching the server's own fail-safe.
21
+ *
22
+ * Exposure safety: this module never records exposures or sends any other
23
+ * telemetry. Evaluating a flag is not the same as the user seeing the
24
+ * variant; exposure is recorded only when the caller asks (see the
25
+ * `exposure` option on index.ts's evaluateFlag, or call track() yourself
26
+ * at the point the variant is actually rendered). Note that the server
27
+ * itself logs each enabled evaluation, which is why identical calls inside
28
+ * the TTL are served from the cache.
29
+ */
30
+ /** What to return when the server cannot give a decision. */
31
+ export interface FlagDefault {
32
+ enabled: boolean;
33
+ variant?: string;
34
+ }
35
+ export interface FlagContext {
36
+ /** Stable user id used for rollout bucketing and variant assignment. */
37
+ userId?: string;
38
+ /** Targeting attributes. Values are sent as strings (the server's
39
+ * context is map[string]string); non-primitive values are skipped. */
40
+ attributes?: Record<string, string | number | boolean>;
41
+ /** Returned when evaluation fails. Default `{ enabled: false }`. */
42
+ default?: FlagDefault;
43
+ /** Per-call cache TTL override in ms. 0 bypasses the cache read. */
44
+ ttlMs?: number;
45
+ /** Per-call timeout override in ms. */
46
+ timeoutMs?: number;
47
+ }
48
+ export interface FlagResult {
49
+ key: string;
50
+ enabled: boolean;
51
+ variant?: string;
52
+ /** Server reason ("evaluated"), or "default" when the default was used. */
53
+ reason: string;
54
+ detail?: string;
55
+ /** Where the value came from. */
56
+ source: "server" | "cache" | "default";
57
+ /** Why the default was used (only when source is "default"). */
58
+ error?: string;
59
+ }
60
+ export interface FlagClientOptions {
61
+ endpoint: string;
62
+ siteId?: string;
63
+ apiKey?: string;
64
+ /** Cache TTL in ms. Default 30000; clamped to [0, 3600000]. 0 disables caching. */
65
+ ttlMs?: number;
66
+ /** Request timeout in ms. Default 3000; clamped to [100, 60000]. */
67
+ timeoutMs?: number;
68
+ /** Max cached decisions. Default 500. */
69
+ maxEntries?: number;
70
+ /** Injectable fetch (tests, polyfills). Defaults to globalThis.fetch. */
71
+ fetch?: typeof fetch;
72
+ }
73
+ export interface FlagClient {
74
+ evaluateFlag(key: string, ctx?: FlagContext): Promise<FlagResult>;
75
+ evaluateFlags(keys: string[], ctx?: FlagContext): Promise<Record<string, FlagResult>>;
76
+ clearCache(): void;
77
+ }
78
+ export declare function createFlagClient(options: FlagClientOptions): FlagClient;
79
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;0EACsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAA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-0,0 +1,185 @@
1
+ /**
2
+ * Feature-flag evaluation client for @teploy/observe-browser.
3
+ *
4
+ * Wire contract (cmd/observe flagEvaluateHandler, internal/flags):
5
+ *
6
+ * POST {endpoint}/api/v1/flags/evaluate
7
+ * { "site_id", "flag_key", "user_id", "context": { string: string } }
8
+ * -> { "enabled": bool, "variant"?: string, "reason": "evaluated" |
9
+ * "unavailable" | "invalid", "detail"?: string }
10
+ *
11
+ * The route is public (an X-API-Key is accepted but not required) and is
12
+ * rate limited per IP and per site, so this client caches and coalesces.
13
+ *
14
+ * Failure policy: evaluation never rejects. A network error, timeout,
15
+ * non-2xx status, malformed body, or a server answer whose reason is not
16
+ * "evaluated" (the store was unavailable or the flag config is invalid)
17
+ * yields the caller-supplied default with `source: "default"` and the
18
+ * cause in `error`. Such results are never cached, so the next call
19
+ * retries. Without a caller default the fail-safe is `{ enabled: false }`,
20
+ * matching the server's own fail-safe.
21
+ *
22
+ * Exposure safety: this module never records exposures or sends any other
23
+ * telemetry. Evaluating a flag is not the same as the user seeing the
24
+ * variant; exposure is recorded only when the caller asks (see the
25
+ * `exposure` option on index.ts's evaluateFlag, or call track() yourself
26
+ * at the point the variant is actually rendered). Note that the server
27
+ * itself logs each enabled evaluation, which is why identical calls inside
28
+ * the TTL are served from the cache.
29
+ */
30
+ const MAX_KEYS_PER_CALL = 50;
31
+ function clamp(v, dflt, min, max) {
32
+ const n = typeof v === "number" && Number.isFinite(v) ? v : dflt;
33
+ return Math.min(max, Math.max(min, n));
34
+ }
35
+ function normalizeAttributes(attrs) {
36
+ const out = {};
37
+ if (!attrs || typeof attrs !== "object")
38
+ return out;
39
+ for (const k of Object.keys(attrs).sort()) {
40
+ const v = attrs[k];
41
+ if (typeof v === "string")
42
+ out[k] = v;
43
+ else if (typeof v === "number" || typeof v === "boolean")
44
+ out[k] = String(v);
45
+ }
46
+ return out;
47
+ }
48
+ function fallback(key, ctx, error) {
49
+ const d = ctx?.default;
50
+ return {
51
+ key,
52
+ enabled: d ? d.enabled === true : false,
53
+ ...(d?.variant ? { variant: d.variant } : {}),
54
+ reason: "default",
55
+ source: "default",
56
+ error,
57
+ };
58
+ }
59
+ export function createFlagClient(options) {
60
+ // With a key the server takes the site from it; see init().
61
+ const siteId = options.siteId ?? (options.apiKey ? "" : "default");
62
+ const ttl = clamp(options.ttlMs, 30000, 0, 3600000);
63
+ const timeout = clamp(options.timeoutMs, 3000, 100, 60000);
64
+ const maxEntries = clamp(options.maxEntries, 500, 1, 10000);
65
+ const url = options.endpoint.replace(/\/+$/, "") + "/api/v1/flags/evaluate";
66
+ const cache = new Map();
67
+ const inflight = new Map();
68
+ function cacheKey(key, userId, attrs) {
69
+ return JSON.stringify([siteId, key, userId, attrs]);
70
+ }
71
+ async function request(key, userId, attrs, ctx, ck, ttlMs, timeoutMs) {
72
+ const doFetch = options.fetch ?? (typeof fetch === "function" ? fetch : undefined);
73
+ if (!doFetch)
74
+ return fallback(key, ctx, "fetch unavailable");
75
+ const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
76
+ let timer;
77
+ // The abort signal cancels the request; the race guarantees the
78
+ // timeout even for a fetch implementation that ignores the signal.
79
+ const timedOut = new Promise((_, reject) => {
80
+ timer = setTimeout(() => {
81
+ controller?.abort();
82
+ reject(new Error(`timeout after ${timeoutMs}ms`));
83
+ }, timeoutMs);
84
+ });
85
+ timedOut.catch(() => { }); // a late rejection after the race is settled is expected
86
+ try {
87
+ const headers = { "Content-Type": "application/json" };
88
+ if (options.apiKey)
89
+ headers["X-API-Key"] = options.apiKey;
90
+ const res = await Promise.race([
91
+ doFetch(url, {
92
+ method: "POST",
93
+ headers,
94
+ body: JSON.stringify({ site_id: siteId, flag_key: key, user_id: userId, context: attrs }),
95
+ credentials: "omit",
96
+ redirect: "error",
97
+ signal: controller?.signal,
98
+ }),
99
+ timedOut,
100
+ ]);
101
+ if (!res.ok)
102
+ return fallback(key, ctx, `status ${res.status}`);
103
+ const body = await Promise.race([res.json(), timedOut]);
104
+ if (!body || typeof body !== "object" || typeof body.enabled !== "boolean") {
105
+ return fallback(key, ctx, "malformed response");
106
+ }
107
+ const reason = typeof body.reason === "string" ? body.reason : "";
108
+ if (reason !== "evaluated") {
109
+ // unavailable / invalid: the server answered its fail-safe, not a decision.
110
+ return fallback(key, ctx, `server reason ${reason || "missing"}`);
111
+ }
112
+ const value = {
113
+ key,
114
+ enabled: body.enabled,
115
+ ...(typeof body.variant === "string" && body.variant ? { variant: body.variant } : {}),
116
+ reason,
117
+ ...(typeof body.detail === "string" && body.detail ? { detail: body.detail } : {}),
118
+ };
119
+ if (ttlMs > 0) {
120
+ cache.delete(ck);
121
+ cache.set(ck, { at: Date.now(), ttl: ttlMs, value });
122
+ while (cache.size > maxEntries) {
123
+ const oldest = cache.keys().next().value;
124
+ if (oldest === undefined)
125
+ break;
126
+ cache.delete(oldest);
127
+ }
128
+ }
129
+ return { ...value, source: "server" };
130
+ }
131
+ catch (err) {
132
+ return fallback(key, ctx, err instanceof Error ? err.message : String(err));
133
+ }
134
+ finally {
135
+ if (timer !== undefined)
136
+ clearTimeout(timer);
137
+ }
138
+ }
139
+ function evaluateFlag(key, ctx) {
140
+ try {
141
+ if (typeof key !== "string" || key === "")
142
+ return Promise.resolve(fallback(String(key), ctx, "flag key required"));
143
+ const userId = typeof ctx?.userId === "string" ? ctx.userId : "";
144
+ const attrs = normalizeAttributes(ctx?.attributes);
145
+ const ttlMs = clamp(ctx?.ttlMs, ttl, 0, 3600000);
146
+ const timeoutMs = clamp(ctx?.timeoutMs, timeout, 100, 60000);
147
+ const ck = cacheKey(key, userId, attrs);
148
+ if (ttlMs > 0) {
149
+ const hit = cache.get(ck);
150
+ if (hit && Date.now() - hit.at < Math.min(hit.ttl, ttlMs))
151
+ return Promise.resolve({ ...hit.value, source: "cache" });
152
+ if (hit)
153
+ cache.delete(ck);
154
+ }
155
+ // Coalesce identical in-flight evaluations into one request. Each
156
+ // caller still gets its own default applied on failure.
157
+ const pending = inflight.get(ck);
158
+ if (pending) {
159
+ return pending.then((r) => (r.source === "default" ? fallback(key, ctx, r.error ?? "failed") : { ...r }));
160
+ }
161
+ const p = request(key, userId, attrs, ctx, ck, ttlMs, timeoutMs).finally(() => {
162
+ if (inflight.get(ck) === p)
163
+ inflight.delete(ck);
164
+ });
165
+ inflight.set(ck, p);
166
+ return p;
167
+ }
168
+ catch (err) {
169
+ return Promise.resolve(fallback(String(key), ctx, err instanceof Error ? err.message : String(err)));
170
+ }
171
+ }
172
+ async function evaluateFlags(keys, ctx) {
173
+ const out = {};
174
+ const unique = Array.from(new Set(Array.isArray(keys) ? keys.filter((k) => typeof k === "string" && k !== "") : []));
175
+ const used = unique.slice(0, MAX_KEYS_PER_CALL);
176
+ const results = await Promise.all(used.map((k) => evaluateFlag(k, ctx)));
177
+ used.forEach((k, i) => { out[k] = results[i]; });
178
+ // Keys beyond the per-call cap are not sent; they resolve to the default.
179
+ for (const k of unique.slice(MAX_KEYS_PER_CALL))
180
+ out[k] = fallback(k, ctx, `more than ${MAX_KEYS_PER_CALL} keys in one call`);
181
+ return out;
182
+ }
183
+ return { evaluateFlag, evaluateFlags, clearCache: () => { cache.clear(); } };
184
+ }
185
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAuDH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,SAAS,KAAK,CAAC,CAAqB,EAAE,IAAY,EAAE,GAAW,EAAE,GAAW;IAC1E,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CA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,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,297 @@
1
+ /**
2
+ * @teploy/observe-browser — Observe's browser SDK.
3
+ *
4
+ * ```ts
5
+ * import { init } from "@teploy/observe-browser";
6
+ *
7
+ * init({
8
+ * endpoint: "https://observe.example.com",
9
+ * siteId: "my-site",
10
+ * // Ingestion requires a site-scoped API key (create one under
11
+ * // Settings > API keys; browser keys are public by design and can only
12
+ * // append telemetry to their own site).
13
+ * apiKey: "pk_site_scoped_ingest_key",
14
+ * });
15
+ * ```
16
+ *
17
+ * For frameworks that can't use script tags (SPA routes, CSP, etc.) this
18
+ * module takes the place of the `<script src="/observe.js">` snippet. It
19
+ * sends the same payloads to the same ingestion endpoints.
20
+ */
21
+ import { type BreadcrumbInput, type BreadcrumbOptions } from "./breadcrumbs.js";
22
+ import { type FlagContext, type FlagResult } from "./flags.js";
23
+ export type { Breadcrumb, BreadcrumbInput, BreadcrumbLevel, BreadcrumbOptions } from "./breadcrumbs.js";
24
+ export type { FlagClient, FlagClientOptions, FlagContext, FlagDefault, FlagResult } from "./flags.js";
25
+ export { createFlagClient } from "./flags.js";
26
+ export interface InitOptions {
27
+ /** Base URL of your Observe deployment, e.g. `https://observe.example.com`. */
28
+ endpoint: string;
29
+ /** The site identifier. Defaults to `"default"`. */
30
+ siteId?: string;
31
+ /** API key for authenticated ingest. Required: the server's ingest
32
+ * routes reject keyless requests (a browser-visible key is public by
33
+ * design — scope it to one site and append-only telemetry). */
34
+ apiKey?: string;
35
+ /** Disable automatic pageview on init (useful for SPAs doing manual routing). */
36
+ disableAutoPageview?: boolean;
37
+ /** Max events buffered before an automatic flush. Default: 50. */
38
+ batchSize?: number;
39
+ /** Flush cadence in ms when the buffer isn't full. Default: 2000. */
40
+ flushIntervalMs?: number;
41
+ /** Application release tag (git SHA, semver, etc.). Stamped on every
42
+ * event and error so the /releases UI can surface crash-free %, error
43
+ * rate, and adoption per release. */
44
+ release?: string;
45
+ /** Environment label stamped on captured errors ("production",
46
+ * "staging", ...). Defaults to "production"; captureException's context
47
+ * can override per-call. */
48
+ environment?: string;
49
+ /** Called when a batch or report cannot be delivered (non-2xx response,
50
+ * network failure, payload rejected as oversized). The SDK never throws
51
+ * into application code, so this is the only drop signal. */
52
+ onError?: (err: Error) => void;
53
+ /** Max automatic retry attempts per batch before it is dropped and
54
+ * reported through onError (audit F32's retry budget). Default: 5. */
55
+ maxRetryAttempts?: number;
56
+ /** Base delay for the retry backoff after a failed send; doubles per
57
+ * attempt up to 60 s (audit F32). Default: 1000 ms. */
58
+ retryBackoffMs?: number;
59
+ /** Visibility hook for the automatic retry policy (audit F32): fires
60
+ * each time a failed batch is scheduled for a retry, before the backoff
61
+ * sleep. Never throws into application code. */
62
+ onRetry?: (info: {
63
+ attempt: number;
64
+ delayMs: number;
65
+ batchSize: number;
66
+ error: Error;
67
+ }) => void;
68
+ /** Per-request deadline for flush sends (TO-034 made the deadline
69
+ * exist; O11 makes it configurable so slow-endpoint behavior is
70
+ * testable and tunable). Default: 10000 ms; clamped to [250, 600000]. */
71
+ requestTimeoutMs?: number;
72
+ /** Breadcrumbs attached to captured errors/messages. `true` installs
73
+ * automatic capture (console, clicks, navigation, fetch, XHR) with
74
+ * defaults; an object tunes it. Off by default: nothing is patched
75
+ * unless you opt in. addBreadcrumb() works either way. */
76
+ breadcrumbs?: boolean | BreadcrumbOptions;
77
+ /** Flag-evaluation tuning for evaluateFlag()/evaluateFlags(). */
78
+ flags?: {
79
+ ttlMs?: number;
80
+ timeoutMs?: number;
81
+ };
82
+ }
83
+ export interface EventPayload {
84
+ site_id: string;
85
+ event_type: string;
86
+ /** Producer-assigned stable identity (F12): generated once when the event
87
+ * is recorded, kept through requeue and retry so the server can dedupe a
88
+ * redelivered batch at flush. */
89
+ event_id?: string;
90
+ /** Page URL as origin+path (F41): query, fragment, and credentials never
91
+ * leave the browser from this SDK. */
92
+ url?: string;
93
+ referrer?: string;
94
+ title?: string;
95
+ /** Hashed user identifier set by identify(). Empty for anonymous events. */
96
+ distinct_id?: string;
97
+ /** Application release tag from init({ release }). Empty if not set. */
98
+ release?: string;
99
+ /** Allowlisted campaign params extracted from the current query string
100
+ * (F41): attribution rides these explicit fields; the server's analytics
101
+ * read them, not the raw query. */
102
+ utm_source?: string;
103
+ utm_medium?: string;
104
+ utm_campaign?: string;
105
+ utm_term?: string;
106
+ utm_content?: string;
107
+ /** Custom event properties. The server only reads properties from here —
108
+ * anything spread at the top level of the payload is not a field it stores. */
109
+ properties?: Record<string, unknown>;
110
+ [key: string]: unknown;
111
+ }
112
+ /** Wire protocol version this SDK speaks (F12/F19 idempotent batches). */
113
+ export declare const PROTOCOL_VERSION = 2;
114
+ export interface ErrorPayload {
115
+ site_id: string;
116
+ /** Producer-stable error identity — the server's dedupe key (O01 §5.6).
117
+ * Minted per capture so a retried submission dedupes server-side. */
118
+ event_id?: string;
119
+ error_type: string;
120
+ error_value: string;
121
+ stack_trace?: Array<{
122
+ filename: string;
123
+ function: string;
124
+ lineno: number;
125
+ colno: number;
126
+ in_app?: boolean;
127
+ }>;
128
+ release_tag?: string;
129
+ environment?: string;
130
+ /** How the error was captured ("onerror", "onunhandledrejection", "manual"). */
131
+ mechanism?: string;
132
+ url?: string;
133
+ breadcrumbs?: unknown[];
134
+ level?: "error" | "warning" | "info";
135
+ /** Active session-replay id, if observe-replay.js is loaded on the page. */
136
+ replay_id?: string;
137
+ /** User identifier set by identify(). Hashed server-side with site salt. */
138
+ distinct_id?: string;
139
+ /** Active trace context, when the error was captured inside a traced
140
+ * operation. Enables exact trace<->error correlation server-side. */
141
+ trace_id?: string;
142
+ span_id?: string;
143
+ /** Extra structured context. captureException's tags ride here under
144
+ * `tags` — the server has no top-level tags field. */
145
+ extra?: Record<string, unknown>;
146
+ }
147
+ export interface LogPayload {
148
+ site_id: string;
149
+ level: "debug" | "info" | "warn" | "error" | "fatal";
150
+ message: string;
151
+ service_name?: string;
152
+ trace_id?: string;
153
+ span_id?: string;
154
+ attributes?: Record<string, unknown>;
155
+ }
156
+ /**
157
+ * O11 diagnostics snapshot. `dropped` counts LOST events by reason; the
158
+ * sum of its values plus `deliveredEvents` plus whatever is still queued
159
+ * (see `queued`) accounts for every event this SDK admitted. `undeliveredAtUnload`
160
+ * is a point-in-time snapshot taken when the page started unloading.
161
+ */
162
+ export interface Stats {
163
+ /** Batches the server acknowledged (accepted >= 0 events). */
164
+ deliveredBatches: number;
165
+ /** Events the server accepted. */
166
+ deliveredEvents: number;
167
+ /** Retry attempts made (a batch may be retried several times). */
168
+ retries: number;
169
+ /** Lost events by reason: admission_unserializable, admission_oversize,
170
+ * queue_full (drop-newest), pack_oversize, retry_exhausted,
171
+ * server_rejected, retention_cap, reinit_drain_failed. */
172
+ dropped: Record<string, number>;
173
+ /** Events reported undelivered at the moment the page began unloading
174
+ * (pagehide/hidden). The keepalive flush may still deliver some; this
175
+ * snapshot is the honest upper bound visible before the page died. */
176
+ undeliveredAtUnload: number;
177
+ /** Events currently waiting in the live buffer + frozen pending requests. */
178
+ queued: number;
179
+ /** This client instance's producer id (correlates with server-side logs). */
180
+ producerId: string;
181
+ }
182
+ /** Initialize the SDK. Re-init disposes the previous client's timer and
183
+ * listeners and drains its queued work under the OLD configuration (audit
184
+ * F31); previously each init() leaked one interval plus three listeners
185
+ * and silently dropped everything the replaced client had buffered.
186
+ * Numeric options are clamped to finite sane ranges (TO-034). */
187
+ export declare function init(options: InitOptions): void;
188
+ /**
189
+ * Record a pageview for the current URL.
190
+ *
191
+ * `pathname` is only carried as a property: the server derives the stored
192
+ * pathname from `url`, so an explicit one is an annotation, not a field.
193
+ *
194
+ * F41: url is origin+path; the allowlisted utm_* campaign params ride as
195
+ * explicit fields. The full query string and fragment never leave the
196
+ * browser.
197
+ */
198
+ export declare function pageview(pathname?: string): void;
199
+ /**
200
+ * Record a custom event. Includes distinct_id when identify() has been called.
201
+ *
202
+ * Custom props are nested under `properties`; the handful of keys the server
203
+ * reads as real fields (url, referrer, title, language, screen, distinct_id,
204
+ * release) stay at the top level. Props beyond the server's 50-property cap
205
+ * are dropped rather than letting the whole event be rejected.
206
+ */
207
+ export declare function track(eventType: string, props?: Record<string, unknown>): void;
208
+ /**
209
+ * Associate subsequent events with a user id (and optional traits).
210
+ *
211
+ * Stores the userId locally and emits a one-shot `$identify` event so the
212
+ * server can record the identification in the events stream. Traits ride
213
+ * as event properties minus any identity-shaped key. Every subsequent
214
+ * track()/captureException() call includes `distinct_id` in the payload —
215
+ * the server hashes it with the per-site `session_salt` before storage,
216
+ * matching the existing session-id privacy pattern.
217
+ */
218
+ export declare function identify(userId: string, traits?: Record<string, unknown>): void;
219
+ /** Clear the current user — call on logout. */
220
+ export declare function reset(): void;
221
+ /**
222
+ * The current client-generated session id, or null before init(). Lets a
223
+ * separately-loaded script (e.g. observe-replay.js, which tracks its own
224
+ * session id via setSessionId()) correlate its events with this session
225
+ * rather than defaulting to an empty session_id.
226
+ */
227
+ export declare function getSessionId(): string | null;
228
+ /** Capture context for error submissions. Every declared option affects
229
+ * the outgoing payload (audit F51: mechanism and tags used to be accepted
230
+ * and silently dropped, and the environment was hard-coded). */
231
+ export interface CaptureContext {
232
+ mechanism?: string;
233
+ release?: string;
234
+ environment?: string;
235
+ tags?: Record<string, string>;
236
+ traceId?: string;
237
+ spanId?: string;
238
+ /** Severity override. captureException defaults to "error". */
239
+ level?: "error" | "warning" | "info";
240
+ }
241
+ /** Record a breadcrumb by hand. Works whether or not automatic capture is
242
+ * enabled; a no-op before init(). Never throws. */
243
+ export declare function addBreadcrumb(crumb: BreadcrumbInput): void;
244
+ /** Drop all buffered breadcrumbs. */
245
+ export declare function clearBreadcrumbs(): void;
246
+ /** Submit a message (no exception object) as an issue event. Sends
247
+ * immediately; never rejects. Level defaults to "info". */
248
+ export declare function captureMessage(message: string, ctx?: CaptureContext): Promise<void>;
249
+ /** Submit an error. Sends immediately — not buffered. Never rejects into
250
+ * application code (AUD-021: the strict transport's rejection is reported
251
+ * through onError instead). */
252
+ export declare function captureException(err: Error, ctx?: CaptureContext): Promise<void>;
253
+ /** Evaluate one feature flag against the server (POST /api/v1/flags/evaluate).
254
+ * Never rejects: on any failure it resolves to ctx.default (or disabled)
255
+ * with `source: "default"`. Results are cached for the TTL and identical
256
+ * in-flight calls are coalesced. `userId` defaults to the identify()d user.
257
+ * Exposure is NOT recorded unless you pass `exposure: true` (records one
258
+ * "flag_exposure" event per flag/user/variant) or call track() yourself
259
+ * where the variant is actually rendered. Resolves to the default before init(). */
260
+ export declare function evaluateFlag(key: string, ctx?: FlagContext & {
261
+ exposure?: boolean;
262
+ }): Promise<FlagResult>;
263
+ /** Evaluate several flags concurrently (duplicate keys collapse; at most 50
264
+ * per call). Same failure and exposure semantics as evaluateFlag. */
265
+ export declare function evaluateFlags(keys: string[], ctx?: FlagContext & {
266
+ exposure?: boolean;
267
+ }): Promise<Record<string, FlagResult>>;
268
+ /** Submit a log entry. Fire-and-forget: failures are reported through
269
+ * onError, never rejected into application code (AUD-021). */
270
+ export declare function log(entry: Omit<LogPayload, "site_id">): Promise<void>;
271
+ /** Force an immediate flush of buffered events. */
272
+ export declare function flush(): Promise<void>;
273
+ /**
274
+ * O11 diagnostics: delivery and loss counters for the active client
275
+ * (null before init()). Every dropped event is counted here by reason AND
276
+ * reported through onError — the SDK never loses events silently.
277
+ * `queued` is live; the rest are monotone counters.
278
+ */
279
+ export declare function getStats(): Stats | null;
280
+ declare const _default: {
281
+ init: typeof init;
282
+ pageview: typeof pageview;
283
+ track: typeof track;
284
+ identify: typeof identify;
285
+ reset: typeof reset;
286
+ captureException: typeof captureException;
287
+ captureMessage: typeof captureMessage;
288
+ addBreadcrumb: typeof addBreadcrumb;
289
+ clearBreadcrumbs: typeof clearBreadcrumbs;
290
+ evaluateFlag: typeof evaluateFlag;
291
+ evaluateFlags: typeof evaluateFlags;
292
+ log: typeof log;
293
+ flush: typeof flush;
294
+ getStats: typeof getStats;
295
+ };
296
+ export default _default;
297
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAmC,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAA2B,MAAM,kBAAkB,CAAC;AAC1I,OAAO,EAAqC,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAElG,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxG,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;mEAE+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;yCAEqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;gCAE4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;iEAE6D;IAC7D,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B;0EACsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;2DACuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;oDAEgD;IAChD,OAAO,CAAC,EAAE,CAAC,IA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