@teploy/observe-sentry-shim 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Observe project
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,138 @@
1
- # Temporary Holding Version
1
+ # @teploy/observe-sentry-shim
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Drop-in replacement for `@sentry/node` that ships events to a self-hosted
4
+ [Observe](https://github.com/useteploy/teploy-observe) deployment instead of
5
+ Sentry. Zero runtime dependencies — the shim builds JSON envelopes and POSTs
6
+ them directly to Observe's ingest endpoints.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install @teploy/observe-sentry-shim
12
+ ```
13
+
14
+ <!-- not-yet-published: delete this block once @teploy/observe-sentry-shim is on npm -->
15
+ > **Not yet published to npm.** Until it is, `npm install @teploy/observe-sentry-shim` fails
16
+ > with a 404, and a package of that name that appears on npm before this note
17
+ > is removed is not from this project. Build it from this repository instead:
18
+ >
19
+ > ```sh
20
+ > git clone https://github.com/useteploy/teploy-observe
21
+ > cd teploy-observe/sdk/sentry-shim
22
+ > npm ci && npm run build && npm pack
23
+ > # then, in your project:
24
+ > npm install /path/to/teploy-observe/sdk/sentry-shim/teploy-observe-sentry-shim-0.1.0.tgz
25
+ > ```
26
+ <!-- /not-yet-published -->
27
+
28
+ ## Use
29
+
30
+ Swap your import. Existing call sites keep working.
31
+
32
+ ```diff
33
+ - import * as Sentry from "@sentry/node";
34
+ + import * as Sentry from "@teploy/observe-sentry-shim";
35
+
36
+ Sentry.init({
37
+ - dsn: "https://abc@sentry.io/1234",
38
+ + dsn: "https://observe.example.com/__observe__/default",
39
+ release: "v1.4.2",
40
+ environment: "production",
41
+ });
42
+
43
+ Sentry.captureException(err);
44
+ Sentry.setUser({ id: "u_42", email: "alice@example.com" });
45
+ Sentry.captureMessage("cache miss", "warning");
46
+ ```
47
+
48
+ DSN parsing accepts both shapes:
49
+
50
+ - Observe-style: `https://<host>/__observe__/<site_id>`
51
+ - Classic Sentry: `https://<key>@<host>/<project>` — origin becomes the
52
+ endpoint, the trailing path segment becomes the site id.
53
+
54
+ You can skip the DSN entirely and pass `endpoint` + `siteId` directly.
55
+
56
+ ## Supported Sentry APIs
57
+
58
+ | Sentry API | Routed to |
59
+ |-----------------------------------------------|------------------------------------|
60
+ | `init(options)` | configures the shim |
61
+ | `captureException(err, hint?)` | `POST /api/v1/errors` |
62
+ | `captureMessage(msg, level?)` | `POST /api/v1/logs` |
63
+ | `setUser(user)` / `setUser(null)` | scope user |
64
+ | `setTag(k, v)` / `setTags(map)` | scope tags |
65
+ | `setContext(key, ctx)` | scope contexts |
66
+ | `setExtra(k, v)` / `setExtras(map)` | scope extras |
67
+ | `setFingerprint(parts)` | overrides issue grouping |
68
+ | `setLevel(level)` | scope level |
69
+ | `addBreadcrumb(crumb)` | scope breadcrumbs (max 100) |
70
+ | `withScope(fn)` | forks scope, restores on return |
71
+ | `configureScope(fn)` | mutates active scope |
72
+ | `startTransaction({ name, op })` | returns a `Span` stub |
73
+ | `startSpan({ name, op }, fn)` | callback-style span helper |
74
+ | `flush(timeout?)` / `close(timeout?)` | await in-flight sends, bounded by `timeout` (default 2 s) |
75
+ | `getCurrentHub()` / `getCurrentScope()` | minimal Hub/Scope stubs |
76
+ | `withRequestScope(fn)` | O11: per-request scope isolation (see below) |
77
+ | `getStats()` | O11: delivery/loss counters |
78
+
79
+ ## Request-local scope (concurrent-request safety)
80
+
81
+ The module-level scope is shared by default (like Sentry's global scope).
82
+ In a concurrent server that means `setUser` in one request leaks into every
83
+ other request's captures. Wrap each request with `withRequestScope` —
84
+ backed by `node:async_hooks` `AsyncLocalStorage`:
85
+
86
+ ```ts
87
+ import * as Sentry from "@teploy/observe-sentry-shim";
88
+
89
+ // Express (any framework — wrap whatever starts a request's async work):
90
+ app.use((req, res, next) => Sentry.withRequestScope(() => next()));
91
+ ```
92
+
93
+ Inside a request scope, `setUser`/`setTag`/`withScope`/captures see a fork
94
+ of the global scope; concurrent requests cannot observe each other's
95
+ mutations. Full contract: `docs/sdk/COMPATIBILITY.md#node-request-local-scope`.
96
+
97
+ ## Honest no-ops and visible losses (O11)
98
+
99
+ Intentional no-ops warn ONCE per class (console.warn with a pointer to
100
+ `docs/sdk/COMPATIBILITY.md`) instead of failing silently; warnings are
101
+ suppressed in `debug` dry-run mode.
102
+
103
+ The shim never throws out of `capture*` calls (Sentry compat), but losses
104
+ are visible: every failed send (network error, non-2xx) is counted in
105
+ `getStats()` and reported through `init({ onError })`. Each capture is one
106
+ attempt — no retry, no queue (see the compatibility table); use the
107
+ first-party SDKs when you need bounded queues and retry.
108
+
109
+ `flush(timeout)` awaits in-flight sends bounded by `timeout`; sends still
110
+ unconfirmed when it gives up are snapshotted into
111
+ `getStats().unconfirmedAtFlush` and reported — the honest upper bound.
112
+ Call `await flush()` before process exit on your signal paths.
113
+
114
+ ## Intentional no-ops
115
+
116
+ Sentry features without a 1-to-1 Observe equivalent are accepted (for compat)
117
+ but do nothing:
118
+
119
+ - `tracesSampleRate`, `profilesSampleRate` — Observe accepts every span;
120
+ sampling lives at the OTLP exporter or ingest rate-limit layer.
121
+ - `integrations: [...]` — Sentry's integration array is silently ignored.
122
+ Use Observe's official SDKs (`@teploy/observe-browser`, `teploy-observe` for Python,
123
+ the Go SDK) for framework hooks.
124
+ - `autoSessionTracking` / `startSession` / `endSession` — Observe derives
125
+ release health from the `release` tag and event volume server-side.
126
+ - `Span.finish()` is fired but transactions are emitted as logs, not as
127
+ Sentry-style envelopes. Wire OTLP via `@opentelemetry/exporter-trace-otlp-http`
128
+ pointed at `/api/v1/v1/traces` for proper distributed tracing.
129
+ - `Sentry.Replay` — Observe ships its own `observe-replay.js` (rrweb-free).
130
+
131
+ ## License
132
+
133
+ MIT
134
+
135
+ Error envelopes use a 192 KiB aggregate serialized budget, leaving headroom below
136
+ Observe's 256 KiB prepared-record limit. The budget includes Go JSON escaping. Oldest breadcrumbs are removed first
137
+ until the envelope fits. If the remaining error itself exceeds the budget,
138
+ no request is sent and `getStats().lost.payload_oversize` records the loss.
@@ -0,0 +1,261 @@
1
+ /**
2
+ * @teploy/observe-sentry-shim - drop-in replacement for `@sentry/node`, backed by
3
+ * Observe's ingest API.
4
+ *
5
+ * Replace your import:
6
+ *
7
+ * // before:
8
+ * // import * as Sentry from "@sentry/node";
9
+ * import * as Sentry from "@teploy/observe-sentry-shim";
10
+ *
11
+ * Sentry.init({
12
+ * dsn: "https://observe.example.com/__observe__/default",
13
+ * // or:
14
+ * // endpoint: "https://observe.example.com",
15
+ * // siteId: "default",
16
+ * release: "v1.4.2",
17
+ * environment: "production",
18
+ * });
19
+ *
20
+ * Sentry.captureException(new Error("boom"));
21
+ * Sentry.captureMessage("cache miss", "warning");
22
+ *
23
+ * The shim has zero runtime dependencies. It builds JSON envelopes and POSTs
24
+ * them to the same ingest endpoints used by the official Observe SDKs:
25
+ *
26
+ * `Sentry.captureException` -> POST /api/v1/errors
27
+ * `Sentry.captureMessage` -> POST /api/v1/logs
28
+ *
29
+ * Tracing (`startTransaction`/`startSpan`) is wired to OTLP-compatible
30
+ * traces submission at `POST /api/v1/v1/traces` only when a real OTLP
31
+ * exporter is configured by the host application; otherwise it returns a
32
+ * lightweight scope-bound stub so existing call sites do not break.
33
+ */
34
+ export type SeverityLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
35
+ export interface User {
36
+ id?: string | number;
37
+ email?: string;
38
+ username?: string;
39
+ ip_address?: string;
40
+ [key: string]: unknown;
41
+ }
42
+ export interface Breadcrumb {
43
+ type?: string;
44
+ category?: string;
45
+ message?: string;
46
+ data?: Record<string, unknown>;
47
+ level?: SeverityLevel;
48
+ timestamp?: number;
49
+ }
50
+ export interface InitOptions {
51
+ /** Sentry-style DSN. Either `dsn` or `endpoint` is required. */
52
+ dsn?: string;
53
+ /** Direct endpoint, e.g. `https://observe.example.com`. */
54
+ endpoint?: string;
55
+ /** Site identifier. Defaults to `"default"` (or DSN-extracted value). */
56
+ siteId?: string;
57
+ /** API key sent as the `X-API-Key` header. Required in practice: Observe
58
+ * ingest rejects keyless requests with 401. */
59
+ apiKey?: string;
60
+ /** Release tag attached to every event. */
61
+ release?: string;
62
+ /** Environment tag attached to every event. */
63
+ environment?: string;
64
+ /** Maximum breadcrumbs retained per scope. Default: 100. */
65
+ maxBreadcrumbs?: number;
66
+ /** If true, skip outgoing network calls and all no-op diagnostics
67
+ * (useful for tests). */
68
+ debug?: boolean;
69
+ /** Custom fetch implementation. Defaults to global `fetch`. */
70
+ fetch?: typeof fetch;
71
+ /** Skip auto-collection of stack frames if you need a smaller payload. Default: true. */
72
+ attachStacktrace?: boolean;
73
+ /** O11: called with every delivery failure or counted loss (the shim
74
+ * never throws out of capture* calls — this is the drop signal). */
75
+ onError?: (err: Error) => void;
76
+ tracesSampleRate?: number;
77
+ profilesSampleRate?: number;
78
+ integrations?: unknown[];
79
+ beforeSend?: (event: ErrorEnvelope) => ErrorEnvelope | null | Promise<ErrorEnvelope | null>;
80
+ /** Sentry release-health flag. No-op (Observe tracks releases via the tag). */
81
+ autoSessionTracking?: boolean;
82
+ }
83
+ export interface StackFrame {
84
+ filename: string;
85
+ function: string;
86
+ lineno: number;
87
+ colno: number;
88
+ in_app?: boolean;
89
+ }
90
+ export interface ErrorEnvelope {
91
+ site_id: string;
92
+ /** Producer-stable error identity (server-side dedupe key, O01 §5.6).
93
+ * Minted per capture BEFORE beforeSend so a mutated-or-retried envelope
94
+ * keeps the id it was first assigned. */
95
+ event_id?: string;
96
+ error_type: string;
97
+ error_value: string;
98
+ level: SeverityLevel;
99
+ release?: string;
100
+ environment?: string;
101
+ stack_trace?: StackFrame[];
102
+ breadcrumbs?: Breadcrumb[];
103
+ contexts?: Record<string, unknown>;
104
+ extra?: Record<string, unknown>;
105
+ fingerprint?: string[];
106
+ url?: string;
107
+ mechanism?: string;
108
+ handled?: boolean;
109
+ /** Identifier set via setUser({id}). Server hashes with site session_salt. */
110
+ distinct_id?: string;
111
+ }
112
+ export interface LogEnvelope {
113
+ site_id: string;
114
+ level: "debug" | "info" | "warn" | "error" | "fatal";
115
+ message: string;
116
+ service_name?: string;
117
+ attributes?: Record<string, unknown>;
118
+ /** Identifier set via setUser({id}). Server hashes with site session_salt. */
119
+ distinct_id?: string;
120
+ }
121
+ interface ResolvedConfig {
122
+ endpoint: string;
123
+ siteId: string;
124
+ apiKey?: string;
125
+ release?: string;
126
+ environment?: string;
127
+ maxBreadcrumbs: number;
128
+ debug: boolean;
129
+ attachStacktrace: boolean;
130
+ fetchImpl: typeof fetch;
131
+ beforeSend?: InitOptions["beforeSend"];
132
+ onError?: (err: Error) => void;
133
+ }
134
+ declare class Scope {
135
+ user: User | null;
136
+ tags: Record<string, string>;
137
+ extras: Record<string, unknown>;
138
+ contexts: Record<string, unknown>;
139
+ fingerprint: string[] | null;
140
+ level: SeverityLevel | null;
141
+ breadcrumbs: Breadcrumb[];
142
+ clone(): Scope;
143
+ apply(env: ErrorEnvelope): void;
144
+ }
145
+ /**
146
+ * Run `fn` (and everything it awaits) against a FORKED scope so
147
+ * per-request state (setUser, tags, extras, breadcrumbs) cannot leak
148
+ * across concurrent requests. Use as request middleware:
149
+ *
150
+ * ```ts
151
+ * app.use((req, res, next) => Sentry.withRequestScope(() => next()));
152
+ * ```
153
+ *
154
+ * The fork snapshots the GLOBAL scope at entry; mutations inside apply
155
+ * only to this async context.
156
+ */
157
+ export declare function withRequestScope<T>(fn: () => T): T;
158
+ export interface ShimStats {
159
+ /** Envelopes the server accepted (2xx). */
160
+ delivered: number;
161
+ /** Lost envelopes by reason: send_failed (network), http_<status>,
162
+ * non_2xx (unknown status), serialize_failed. No retry exists — each
163
+ * capture is one attempt (see the compatibility table). */
164
+ lost: Record<string, number>;
165
+ /** Envelopes still unconfirmed when flush(timeout) gave up — the honest
166
+ * upper bound; some may still deliver after process exit. */
167
+ unconfirmedAtFlush: number;
168
+ /** Sends currently in flight. */
169
+ inFlight: number;
170
+ }
171
+ /** O11 diagnostics: delivery and loss counters since the last init(). */
172
+ export declare function getStats(): ShimStats;
173
+ /** Initialize the shim. Idempotent - calling again replaces the active config. */
174
+ export declare function init(options: InitOptions): void;
175
+ /** Returns the active configuration (mostly for tests). */
176
+ export declare function getClient(): ResolvedConfig | null;
177
+ /** Sentry: capture an exception. Returns a synthetic event id. */
178
+ export declare function captureException(err: unknown, hint?: {
179
+ mechanism?: string;
180
+ level?: SeverityLevel;
181
+ }): string;
182
+ /** Sentry: capture a message. Routed to /api/v1/logs as a structured log. */
183
+ export declare function captureMessage(message: string, level?: SeverityLevel): string;
184
+ /** Sentry: associate user with subsequent events. Pass `null` to clear. */
185
+ export declare function setUser(user: User | null): void;
186
+ /** Sentry: tag the active scope. */
187
+ export declare function setTag(key: string, value: string | number | boolean): void;
188
+ /** Sentry: set multiple tags. */
189
+ export declare function setTags(tags: Record<string, string | number | boolean>): void;
190
+ /** Sentry: set a structured context block on the active scope. */
191
+ export declare function setContext(key: string, ctx: Record<string, unknown> | null): void;
192
+ /** Sentry: add an extra value (free-form) to the active scope. */
193
+ export declare function setExtra(key: string, value: unknown): void;
194
+ /** Sentry: set multiple extras. */
195
+ export declare function setExtras(extras: Record<string, unknown>): void;
196
+ /** Sentry: override the grouping fingerprint. */
197
+ export declare function setFingerprint(parts: string[]): void;
198
+ /** Sentry: set the level for the next event. */
199
+ export declare function setLevel(level: SeverityLevel): void;
200
+ /** Sentry: append a breadcrumb. Trimmed to `maxBreadcrumbs` per scope. */
201
+ export declare function addBreadcrumb(crumb: Breadcrumb): void;
202
+ /** Sentry: run `fn` against a forked scope. Mutations don't leak out. */
203
+ export declare function withScope<T>(fn: (scope: Scope) => T): T;
204
+ /** Sentry: clear the active root scope. */
205
+ export declare function configureScope(fn: (scope: Scope) => void): void;
206
+ /** Sentry: noop on the shim (sessions are inferred from event metadata). */
207
+ export declare function startSession(): void;
208
+ /** Sentry: endSession noop on the shim. */
209
+ export declare function endSession(): void;
210
+ /** Sentry: lightweight transaction stub. Returns a span-like object. */
211
+ export declare function startTransaction(ctx: {
212
+ name: string;
213
+ op?: string;
214
+ }): Span;
215
+ /** Sentry v8+: callback-style span helper. */
216
+ export declare function startSpan<T>(ctx: {
217
+ name: string;
218
+ op?: string;
219
+ }, fn: (span: Span) => T): T;
220
+ /**
221
+ * Span shim. Records timings locally; finished spans are sent as a single log
222
+ * entry so they show up in `/logs` with their duration. A future revision can
223
+ * route these to OTLP at `/api/v1/v1/traces`.
224
+ */
225
+ export declare class Span {
226
+ readonly name: string;
227
+ readonly op?: string;
228
+ readonly startTimestamp: number;
229
+ endTimestamp: number | null;
230
+ data: Record<string, unknown>;
231
+ status: "ok" | "error" | "unknown";
232
+ constructor(name: string, op?: string);
233
+ setData(key: string, value: unknown): void;
234
+ setStatus(status: "ok" | "error" | "unknown"): this;
235
+ setTag(key: string, value: string | number | boolean): this;
236
+ startChild(ctx: {
237
+ op?: string;
238
+ description?: string;
239
+ }): Span;
240
+ finish(): void;
241
+ }
242
+ export declare function flush(timeout?: number): Promise<boolean>;
243
+ /** Sentry compat: close the client (awaits the entire capture pipeline). */
244
+ export declare function close(timeout?: number): Promise<boolean>;
245
+ /** Sentry compat: getCurrentHub() shim returning a minimal Hub-like object. */
246
+ export declare function getCurrentHub(): Hub;
247
+ /** Sentry compat: getCurrentScope() returns the active scope. */
248
+ export declare function getCurrentScope(): Scope;
249
+ interface Hub {
250
+ captureException: typeof captureException;
251
+ captureMessage: typeof captureMessage;
252
+ setUser: typeof setUser;
253
+ setTag: typeof setTag;
254
+ setExtra: typeof setExtra;
255
+ withScope: typeof withScope;
256
+ configureScope: typeof configureScope;
257
+ addBreadcrumb: typeof addBreadcrumb;
258
+ getClient: typeof getClient;
259
+ }
260
+ export { Scope };
261
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,OAAO,GACP,SAAS,GACT,KAAK,GACL,MAAM,GACN,OAAO,CAAC;AAEZ,MAAM,WAAW,IAAI;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,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G,IAAI;IAKnD,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;IAK3D,UAAU,CAAC,GAAG,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAI5D,MAAM,IAAI,IAAI;CAiBf;AAwBD,wBAAsB,KAAK,CAAC,OAAO,GAAE,MAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAEpE;AAED,4EAA4E;AAC5E,wBAAsB,KAAK,CAAC,OAAO,GAAE,MAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAOpE;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,IAAI,GAAG,CAEnC;AAED,iEAAiE;AACjE,wBAAgB,eAAe,IAAI,KAAK,CAEvC;AAED,UAAU,GAAG;IACX,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,SAAS,EAAE,OAAO,SAAS,CAAC;CAC7B;AAyBD,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,636 @@
1
+ /**
2
+ * @teploy/observe-sentry-shim - drop-in replacement for `@sentry/node`, backed by
3
+ * Observe's ingest API.
4
+ *
5
+ * Replace your import:
6
+ *
7
+ * // before:
8
+ * // import * as Sentry from "@sentry/node";
9
+ * import * as Sentry from "@teploy/observe-sentry-shim";
10
+ *
11
+ * Sentry.init({
12
+ * dsn: "https://observe.example.com/__observe__/default",
13
+ * // or:
14
+ * // endpoint: "https://observe.example.com",
15
+ * // siteId: "default",
16
+ * release: "v1.4.2",
17
+ * environment: "production",
18
+ * });
19
+ *
20
+ * Sentry.captureException(new Error("boom"));
21
+ * Sentry.captureMessage("cache miss", "warning");
22
+ *
23
+ * The shim has zero runtime dependencies. It builds JSON envelopes and POSTs
24
+ * them to the same ingest endpoints used by the official Observe SDKs:
25
+ *
26
+ * `Sentry.captureException` -> POST /api/v1/errors
27
+ * `Sentry.captureMessage` -> POST /api/v1/logs
28
+ *
29
+ * Tracing (`startTransaction`/`startSpan`) is wired to OTLP-compatible
30
+ * traces submission at `POST /api/v1/v1/traces` only when a real OTLP
31
+ * exporter is configured by the host application; otherwise it returns a
32
+ * lightweight scope-bound stub so existing call sites do not break.
33
+ */
34
+ import { AsyncLocalStorage } from "node:async_hooks";
35
+ class Scope {
36
+ user = null;
37
+ tags = {};
38
+ extras = {};
39
+ contexts = {};
40
+ fingerprint = null;
41
+ level = null;
42
+ breadcrumbs = [];
43
+ clone() {
44
+ const s = new Scope();
45
+ s.user = this.user ? { ...this.user } : null;
46
+ s.tags = { ...this.tags };
47
+ s.extras = { ...this.extras };
48
+ s.contexts = { ...this.contexts };
49
+ s.fingerprint = this.fingerprint ? [...this.fingerprint] : null;
50
+ s.level = this.level;
51
+ s.breadcrumbs = [...this.breadcrumbs];
52
+ return s;
53
+ }
54
+ apply(env) {
55
+ if (this.level)
56
+ env.level = this.level;
57
+ if (this.user) {
58
+ env.contexts = { ...(env.contexts ?? {}), user: this.user };
59
+ // Map Sentry-style setUser({id}) to Observe's identify() contract.
60
+ // The server hashes the value with the per-site session_salt before
61
+ // storage, so the raw id never persists by default.
62
+ if (this.user.id !== undefined && this.user.id !== null) {
63
+ env.distinct_id = String(this.user.id);
64
+ }
65
+ }
66
+ if (Object.keys(this.tags).length > 0) {
67
+ env.contexts = { ...(env.contexts ?? {}), tags: this.tags };
68
+ }
69
+ if (Object.keys(this.extras).length > 0) {
70
+ env.extra = { ...(env.extra ?? {}), ...this.extras };
71
+ }
72
+ if (Object.keys(this.contexts).length > 0) {
73
+ env.contexts = { ...(env.contexts ?? {}), ...this.contexts };
74
+ }
75
+ if (this.fingerprint)
76
+ env.fingerprint = this.fingerprint;
77
+ if (this.breadcrumbs.length > 0)
78
+ env.breadcrumbs = [...this.breadcrumbs];
79
+ }
80
+ }
81
+ let config = null;
82
+ let rootScope = new Scope();
83
+ let scopeStack = [];
84
+ // O11 request-local scope (spec: "a Node SDK/shim needs request-local
85
+ // scope rather than sharing user context across concurrent requests").
86
+ // withRequestScope forks the active scope into an AsyncLocalStorage
87
+ // context; concurrent requests mutate isolated forks. Without it, setUser
88
+ // in one request leaked into every other request's captures.
89
+ const requestScope = new AsyncLocalStorage();
90
+ function activeScope() {
91
+ const scoped = requestScope.getStore();
92
+ if (scoped)
93
+ return scoped;
94
+ return scopeStack.length > 0 ? scopeStack[scopeStack.length - 1] : rootScope;
95
+ }
96
+ /**
97
+ * Run `fn` (and everything it awaits) against a FORKED scope so
98
+ * per-request state (setUser, tags, extras, breadcrumbs) cannot leak
99
+ * across concurrent requests. Use as request middleware:
100
+ *
101
+ * ```ts
102
+ * app.use((req, res, next) => Sentry.withRequestScope(() => next()));
103
+ * ```
104
+ *
105
+ * The fork snapshots the GLOBAL scope at entry; mutations inside apply
106
+ * only to this async context.
107
+ */
108
+ export function withRequestScope(fn) {
109
+ const fork = activeScope().clone();
110
+ return requestScope.run(fork, fn);
111
+ }
112
+ // ── O11 honest no-ops ────────────────────────────────────────────────────
113
+ // Accepted-for-compat APIs that do nothing warn ONCE per class (reset by
114
+ // init) with a pointer to the compatibility table, replacing silent
115
+ // no-ops. Suppressed entirely in debug/dry-run mode.
116
+ const warnedNoOps = new Set();
117
+ function warnOnce(noOpClass, message) {
118
+ if (!config || config.debug)
119
+ return;
120
+ if (warnedNoOps.has(noOpClass))
121
+ return;
122
+ warnedNoOps.add(noOpClass);
123
+ try {
124
+ console.warn(`[observe-sentry-shim] ${message} — intentional no-op; see docs/sdk/COMPATIBILITY.md#sentry-intentional-no-ops`);
125
+ }
126
+ catch {
127
+ /* a broken console must not break the SDK */
128
+ }
129
+ }
130
+ let stats = { delivered: 0, lost: {}, unconfirmedAtFlush: 0, inFlight: 0 };
131
+ let inFlightSends = new Set();
132
+ function currentOwner() { return config ? { config, stats, sends: inFlightSends } : null; }
133
+ function track(owner, work) {
134
+ owner.stats.inFlight++;
135
+ owner.sends.add(work);
136
+ return work.finally(() => { owner.sends.delete(work); owner.stats.inFlight--; });
137
+ }
138
+ function countLoss(reason, detail, owner = currentOwner()) {
139
+ if (!owner)
140
+ return;
141
+ owner.stats.lost[reason] = (owner.stats.lost[reason] ?? 0) + 1;
142
+ if (owner.config.debug)
143
+ return;
144
+ const err = new Error(`observe-sentry-shim: lost 1 envelope (${reason})${detail ? ` — ${detail}` : ""}`);
145
+ try {
146
+ owner.config.onError?.(err);
147
+ }
148
+ catch {
149
+ /* an onError hook that throws must not break the SDK */
150
+ }
151
+ }
152
+ /** O11 diagnostics: delivery and loss counters since the last init(). */
153
+ export function getStats() {
154
+ return { ...stats, lost: { ...stats.lost } };
155
+ }
156
+ function parseDsn(dsn) {
157
+ let url;
158
+ try {
159
+ url = new URL(dsn);
160
+ }
161
+ catch {
162
+ return null;
163
+ }
164
+ // Observe-style DSN: https://observe.example.com/__observe__/default
165
+ const marker = url.pathname.indexOf("/__observe__/");
166
+ if (marker >= 0) {
167
+ const tail = url.pathname.slice(marker + "/__observe__/".length);
168
+ const siteId = tail.replace(/\/.*$/, "") || "default";
169
+ const endpoint = url.origin + url.pathname.slice(0, marker);
170
+ return { endpoint, siteId };
171
+ }
172
+ // Sentry-style: https://<publicKey>@<host>/<projectId>
173
+ const parts = url.pathname.split("/").filter(Boolean);
174
+ return {
175
+ endpoint: url.origin,
176
+ siteId: parts[parts.length - 1] || "default",
177
+ };
178
+ }
179
+ /** Initialize the shim. Idempotent - calling again replaces the active config. */
180
+ export function init(options) {
181
+ let endpoint = options.endpoint;
182
+ let siteId = options.siteId;
183
+ if (!endpoint && options.dsn) {
184
+ const parsed = parseDsn(options.dsn);
185
+ if (parsed) {
186
+ endpoint = parsed.endpoint;
187
+ siteId ??= parsed.siteId;
188
+ }
189
+ }
190
+ if (!endpoint) {
191
+ throw new Error("@teploy/observe-sentry-shim: dsn or endpoint is required");
192
+ }
193
+ const fetchImpl = options.fetch ?? globalThis.fetch;
194
+ if (!fetchImpl) {
195
+ throw new Error("@teploy/observe-sentry-shim: no fetch implementation available");
196
+ }
197
+ config = {
198
+ endpoint: endpoint.replace(/\/+$/, ""),
199
+ // A key is bound to one site and a different site_id is refused with a 403,
200
+ // so with a key send none and let the key decide.
201
+ siteId: siteId ?? (options.apiKey ? "" : "default"),
202
+ apiKey: options.apiKey,
203
+ release: options.release,
204
+ environment: options.environment,
205
+ maxBreadcrumbs: options.maxBreadcrumbs ?? 100,
206
+ debug: options.debug ?? false,
207
+ attachStacktrace: options.attachStacktrace ?? true,
208
+ fetchImpl,
209
+ beforeSend: options.beforeSend,
210
+ onError: options.onError,
211
+ };
212
+ rootScope = new Scope();
213
+ scopeStack = [];
214
+ warnedNoOps.clear();
215
+ stats = { delivered: 0, lost: {}, unconfirmedAtFlush: 0, inFlight: 0 };
216
+ inFlightSends = new Set();
217
+ // O11: accepted-but-ignored Sentry options tell the truth once, with a
218
+ // pointer to the compatibility table.
219
+ if (options.tracesSampleRate !== undefined) {
220
+ warnOnce("tracesSampleRate", "tracesSampleRate is not a sampling knob here; spans are always recorded when created");
221
+ }
222
+ if (options.profilesSampleRate !== undefined) {
223
+ warnOnce("profilesSampleRate", "profilesSampleRate is ignored; the shim ships no profiler");
224
+ }
225
+ if (options.integrations !== undefined) {
226
+ warnOnce("integrations", "integrations is accepted for import compatibility and ignored");
227
+ }
228
+ if (options.autoSessionTracking !== undefined) {
229
+ warnOnce("autoSessionTracking", "autoSessionTracking is a no-op; release health is computed server-side from release tags");
230
+ }
231
+ }
232
+ /** Returns the active configuration (mostly for tests). */
233
+ export function getClient() {
234
+ return config;
235
+ }
236
+ // Go's prepared-record encoder escapes these characters even when JS does not.
237
+ function preparedErrorBytes(raw) {
238
+ return Buffer.byteLength(raw.replace(/[<>&\u2028\u2029]/g, () => "\\u0000"), "utf8");
239
+ }
240
+ async function postJSON(path, body, owner = currentOwner(), tracked = true) {
241
+ if (!owner || owner.config.debug)
242
+ return;
243
+ const cfg = owner.config;
244
+ const headers = { "Content-Type": "application/json" };
245
+ if (cfg.apiKey)
246
+ headers["X-API-Key"] = cfg.apiKey;
247
+ const send = (async () => {
248
+ try {
249
+ let raw = JSON.stringify(body);
250
+ if (path === "/api/v1/errors") {
251
+ // Leave headroom below the server's 256 KiB prepared-record cap.
252
+ // Keep the newest breadcrumbs; never retry an oversized payload.
253
+ const payload = JSON.parse(raw);
254
+ if (preparedErrorBytes(raw) > 192 * 1024 && Array.isArray(payload.breadcrumbs)) {
255
+ const crumbs = payload.breadcrumbs;
256
+ payload.breadcrumbs = [];
257
+ let used = preparedErrorBytes(JSON.stringify(payload));
258
+ let start = crumbs.length;
259
+ for (let i = crumbs.length - 1; i >= 0; i--) {
260
+ const cost = preparedErrorBytes(JSON.stringify(crumbs[i])) + 1;
261
+ if (used + cost > 192 * 1024)
262
+ break;
263
+ used += cost;
264
+ start = i;
265
+ }
266
+ payload.breadcrumbs = crumbs.slice(start);
267
+ raw = JSON.stringify(payload);
268
+ }
269
+ if (preparedErrorBytes(raw) > 192 * 1024) {
270
+ countLoss("payload_oversize", "error exceeds aggregate byte budget", owner);
271
+ return;
272
+ }
273
+ }
274
+ const res = await cfg.fetchImpl(cfg.endpoint + path, {
275
+ method: "POST", headers, body: raw, redirect: "error",
276
+ });
277
+ if (!res.ok) {
278
+ countLoss(`http_${res.status}`, `POST ${path} returned ${res.status}`, owner);
279
+ return;
280
+ }
281
+ owner.stats.delivered++;
282
+ }
283
+ catch (err) {
284
+ countLoss("send_failed", err instanceof Error ? err.message : String(err), owner);
285
+ }
286
+ })();
287
+ await (tracked ? track(owner, send) : send);
288
+ }
289
+ function parseStack(stack) {
290
+ if (!stack)
291
+ return undefined;
292
+ const frames = [];
293
+ for (const line of stack.split("\n").slice(0, 50)) {
294
+ // V8 / Node format: " at fn (file:line:col)" or " at file:line:col"
295
+ const m = line.match(/at (?:(.+?) )?\(?([^()]+?):(\d+):(\d+)\)?\s*$/);
296
+ if (!m)
297
+ continue;
298
+ const filename = sanitizeFilename(m[2]);
299
+ frames.push({
300
+ function: m[1] || "<anonymous>",
301
+ filename,
302
+ lineno: parseInt(m[3], 10),
303
+ colno: parseInt(m[4], 10),
304
+ in_app: !/node_modules|node:internal/.test(filename),
305
+ });
306
+ }
307
+ return frames.length > 0 ? frames : undefined;
308
+ }
309
+ // Strip "file://" + percent-encoding from frame filenames so they survive
310
+ // Observe's URL-shaped storage and grouping logic (frames with raw file:// URIs
311
+ // trigger an upstream insertion bug where new issues never reach the listing).
312
+ function sanitizeFilename(raw) {
313
+ let s = raw;
314
+ if (s.startsWith("file://"))
315
+ s = s.slice("file://".length);
316
+ try {
317
+ s = decodeURI(s);
318
+ }
319
+ catch {
320
+ // ignore - keep raw
321
+ }
322
+ return s;
323
+ }
324
+ function buildErrorEnvelope(err, scope, hint) {
325
+ const cfg = config;
326
+ const e = err instanceof Error
327
+ ? err
328
+ : new Error(typeof err === "string" ? err : safeStringify(err));
329
+ const env = {
330
+ site_id: cfg.siteId,
331
+ event_id: randomId(),
332
+ error_type: e.name || "Error",
333
+ error_value: e.message || String(err),
334
+ level: hint?.level ?? "error",
335
+ release: cfg.release,
336
+ environment: cfg.environment,
337
+ stack_trace: cfg.attachStacktrace ? parseStack(e.stack) : undefined,
338
+ mechanism: hint?.mechanism,
339
+ handled: hint?.mechanism === undefined,
340
+ };
341
+ scope.apply(env);
342
+ return env;
343
+ }
344
+ function safeStringify(v) {
345
+ try {
346
+ return JSON.stringify(v);
347
+ }
348
+ catch {
349
+ return String(v);
350
+ }
351
+ }
352
+ /** Sentry: capture an exception. Returns a synthetic event id. */
353
+ export function captureException(err, hint) {
354
+ if (!config)
355
+ return "";
356
+ const owner = currentOwner();
357
+ const env = buildErrorEnvelope(err, activeScope(), hint);
358
+ void track(owner, (async () => {
359
+ let payload = env;
360
+ if (owner.config.beforeSend) {
361
+ try {
362
+ payload = (await owner.config.beforeSend(env)) ?? null;
363
+ }
364
+ catch {
365
+ payload = env;
366
+ }
367
+ }
368
+ if (payload)
369
+ await postJSON("/api/v1/errors", payload, owner, false);
370
+ })());
371
+ // The returned id IS the envelope's event_id (previously a synthetic id
372
+ // the server never saw).
373
+ return env.event_id ?? "";
374
+ }
375
+ /** Sentry: capture a message. Routed to /api/v1/logs as a structured log. */
376
+ export function captureMessage(message, level = "info") {
377
+ if (!config)
378
+ return "";
379
+ const scope = activeScope();
380
+ const log = {
381
+ site_id: config.siteId,
382
+ level: mapLevelToLog(level),
383
+ message,
384
+ attributes: {
385
+ ...(scope.user ? { user: scope.user } : {}),
386
+ ...(Object.keys(scope.tags).length ? { tags: scope.tags } : {}),
387
+ ...(Object.keys(scope.extras).length ? { extra: scope.extras } : {}),
388
+ ...(config.release ? { release: config.release } : {}),
389
+ ...(config.environment ? { environment: config.environment } : {}),
390
+ },
391
+ };
392
+ if (scope.user && scope.user.id !== undefined && scope.user.id !== null) {
393
+ log.distinct_id = String(scope.user.id);
394
+ }
395
+ const id = randomId();
396
+ void postJSON("/api/v1/logs", log);
397
+ return id;
398
+ }
399
+ function mapLevelToLog(level) {
400
+ switch (level) {
401
+ case "fatal":
402
+ return "fatal";
403
+ case "error":
404
+ return "error";
405
+ case "warning":
406
+ return "warn";
407
+ case "debug":
408
+ return "debug";
409
+ case "log":
410
+ case "info":
411
+ default:
412
+ return "info";
413
+ }
414
+ }
415
+ /** Sentry: associate user with subsequent events. Pass `null` to clear. */
416
+ export function setUser(user) {
417
+ activeScope().user = user;
418
+ }
419
+ /** Sentry: tag the active scope. */
420
+ export function setTag(key, value) {
421
+ activeScope().tags[key] = String(value);
422
+ }
423
+ /** Sentry: set multiple tags. */
424
+ export function setTags(tags) {
425
+ for (const [k, v] of Object.entries(tags))
426
+ setTag(k, v);
427
+ }
428
+ /** Sentry: set a structured context block on the active scope. */
429
+ export function setContext(key, ctx) {
430
+ if (ctx === null) {
431
+ delete activeScope().contexts[key];
432
+ }
433
+ else {
434
+ activeScope().contexts[key] = ctx;
435
+ }
436
+ }
437
+ /** Sentry: add an extra value (free-form) to the active scope. */
438
+ export function setExtra(key, value) {
439
+ activeScope().extras[key] = value;
440
+ }
441
+ /** Sentry: set multiple extras. */
442
+ export function setExtras(extras) {
443
+ Object.assign(activeScope().extras, extras);
444
+ }
445
+ /** Sentry: override the grouping fingerprint. */
446
+ export function setFingerprint(parts) {
447
+ activeScope().fingerprint = [...parts];
448
+ }
449
+ /** Sentry: set the level for the next event. */
450
+ export function setLevel(level) {
451
+ activeScope().level = level;
452
+ }
453
+ /** Sentry: append a breadcrumb. Trimmed to `maxBreadcrumbs` per scope. */
454
+ export function addBreadcrumb(crumb) {
455
+ if (!config)
456
+ return;
457
+ const scope = activeScope();
458
+ scope.breadcrumbs.push({
459
+ ...crumb,
460
+ timestamp: crumb.timestamp !== undefined && Number.isFinite(crumb.timestamp)
461
+ ? Math.round(crumb.timestamp * 1000) : Date.now(),
462
+ });
463
+ if (scope.breadcrumbs.length > config.maxBreadcrumbs) {
464
+ scope.breadcrumbs.splice(0, scope.breadcrumbs.length - config.maxBreadcrumbs);
465
+ }
466
+ }
467
+ /** Sentry: run `fn` against a forked scope. Mutations don't leak out. */
468
+ export function withScope(fn) {
469
+ const fork = activeScope().clone();
470
+ if (requestScope.getStore())
471
+ return requestScope.run(fork, () => fn(fork));
472
+ scopeStack.push(fork);
473
+ try {
474
+ return fn(fork);
475
+ }
476
+ finally {
477
+ scopeStack.pop();
478
+ }
479
+ }
480
+ /** Sentry: clear the active root scope. */
481
+ export function configureScope(fn) {
482
+ fn(activeScope());
483
+ }
484
+ /** Sentry: noop on the shim (sessions are inferred from event metadata). */
485
+ export function startSession() {
486
+ // Release health is computed server-side from `release` + event volume;
487
+ // the shim has nothing to track on the client.
488
+ warnOnce("startSession", "startSession() is a no-op; sessions are inferred server-side");
489
+ }
490
+ /** Sentry: endSession noop on the shim. */
491
+ export function endSession() {
492
+ warnOnce("endSession", "endSession() is a no-op; sessions are inferred server-side");
493
+ }
494
+ /** Sentry: lightweight transaction stub. Returns a span-like object. */
495
+ export function startTransaction(ctx) {
496
+ return new Span(ctx.name, ctx.op);
497
+ }
498
+ /** Sentry v8+: callback-style span helper. */
499
+ export function startSpan(ctx, fn) {
500
+ const span = new Span(ctx.name, ctx.op);
501
+ try {
502
+ return fn(span);
503
+ }
504
+ finally {
505
+ span.finish();
506
+ }
507
+ }
508
+ /**
509
+ * Span shim. Records timings locally; finished spans are sent as a single log
510
+ * entry so they show up in `/logs` with their duration. A future revision can
511
+ * route these to OTLP at `/api/v1/v1/traces`.
512
+ */
513
+ export class Span {
514
+ name;
515
+ op;
516
+ startTimestamp;
517
+ endTimestamp = null;
518
+ data = {};
519
+ status = "unknown";
520
+ constructor(name, op) {
521
+ this.name = name;
522
+ this.op = op;
523
+ this.startTimestamp = Date.now();
524
+ }
525
+ setData(key, value) {
526
+ this.data[key] = value;
527
+ }
528
+ setStatus(status) {
529
+ this.status = status;
530
+ return this;
531
+ }
532
+ setTag(key, value) {
533
+ this.data[`tag.${key}`] = String(value);
534
+ return this;
535
+ }
536
+ startChild(ctx) {
537
+ return new Span(ctx.description ?? this.name, ctx.op);
538
+ }
539
+ finish() {
540
+ if (this.endTimestamp !== null)
541
+ return;
542
+ this.endTimestamp = Date.now();
543
+ if (!config)
544
+ return;
545
+ const log = {
546
+ site_id: config.siteId,
547
+ level: this.status === "error" ? "error" : "info",
548
+ message: `span: ${this.name}`,
549
+ attributes: {
550
+ op: this.op,
551
+ duration_ms: this.endTimestamp - this.startTimestamp,
552
+ status: this.status,
553
+ ...this.data,
554
+ },
555
+ };
556
+ void postJSON("/api/v1/logs", log);
557
+ }
558
+ }
559
+ /**
560
+ * Sentry compat: await in-flight sends, bounded by `timeout` (default
561
+ * 2 s). O11 semantics: sends still unconfirmed when the timeout hits are
562
+ * snapshotted into getStats().unconfirmedAtFlush and reported through
563
+ * onError — the honest upper bound, because Node process exit may still
564
+ * complete some of them. Returns false when anything was unconfirmed.
565
+ */
566
+ async function flushOwner(owner, timeout) {
567
+ if (!owner)
568
+ return true;
569
+ let timer;
570
+ try {
571
+ const result = await Promise.race([
572
+ Promise.all([...owner.sends]).then(() => true),
573
+ new Promise((resolve) => { timer = setTimeout(() => resolve(false), Math.max(0, timeout)); }),
574
+ ]);
575
+ owner.stats.unconfirmedAtFlush = owner.sends.size;
576
+ if (!result && owner.sends.size) {
577
+ try {
578
+ owner.config.onError?.(new Error(`observe-sentry-shim: flush gave up with ${owner.sends.size} send(s) unconfirmed`));
579
+ }
580
+ catch { }
581
+ }
582
+ return result && Object.keys(owner.stats.lost).length === 0;
583
+ }
584
+ finally {
585
+ if (timer !== undefined)
586
+ clearTimeout(timer);
587
+ }
588
+ }
589
+ export async function flush(timeout = 2000) {
590
+ return flushOwner(currentOwner(), timeout);
591
+ }
592
+ /** Sentry compat: close the client (awaits the entire capture pipeline). */
593
+ export async function close(timeout = 2000) {
594
+ const owner = currentOwner();
595
+ // Stop new admissions; admitted work retains its immutable destination.
596
+ config = null;
597
+ const result = await flushOwner(owner, timeout);
598
+ if (!config) {
599
+ rootScope = new Scope();
600
+ scopeStack = [];
601
+ }
602
+ return result;
603
+ }
604
+ /** Sentry compat: getCurrentHub() shim returning a minimal Hub-like object. */
605
+ export function getCurrentHub() {
606
+ return defaultHub;
607
+ }
608
+ /** Sentry compat: getCurrentScope() returns the active scope. */
609
+ export function getCurrentScope() {
610
+ return activeScope();
611
+ }
612
+ const defaultHub = {
613
+ captureException,
614
+ captureMessage,
615
+ setUser,
616
+ setTag,
617
+ setExtra,
618
+ withScope,
619
+ configureScope,
620
+ addBreadcrumb,
621
+ getClient,
622
+ };
623
+ function randomId() {
624
+ // 32 hex chars, matching Sentry's event_id shape.
625
+ const bytes = new Uint8Array(16);
626
+ if (typeof globalThis.crypto?.getRandomValues === "function") {
627
+ globalThis.crypto.getRandomValues(bytes);
628
+ }
629
+ else {
630
+ for (let i = 0; i < bytes.length; i++)
631
+ bytes[i] = Math.floor(Math.random() * 256);
632
+ }
633
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
634
+ }
635
+ export { Scope };
636
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAqHrD,MAAM,KAAK;IACT,IAAI,GAAgB,IAAI,CAAC;IACzB,IAAI,GAA2B,EAAE,CAAC;IAClC,MAAM,GAA4B,EAAE,CAAC;IACrC,QAAQ,GAA4B,EAAE,CAAC;IACvC,WAAW,GAAoB,IAAI,CAAC;IACpC,KAAK,GAAyB,IAAI,CAAC;IACnC,WAAW,GAAiB,EAAE,CAAC;IAE/B,KAAK;QACH,MAAM,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC;QACtB,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7C,CAAC,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9B,CAAC,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CA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,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@teploy/observe-sentry-shim",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Drop-in @sentry/node replacement that ships events to a self-hosted Observe deployment.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "typecheck": "tsc --noEmit",
22
+ "test": "tsc --noEmit && node --test --import tsx tests/*.test.ts",
23
+ "test:integration": "node --test --import tsx tests/integration.test.ts"
24
+ },
25
+ "keywords": [
26
+ "sentry",
27
+ "shim",
28
+ "observability",
29
+ "errors",
30
+ "self-hosted",
31
+ "observe"
32
+ ],
33
+ "author": "Observe",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/useteploy/teploy-observe",
38
+ "directory": "sdk/sentry-shim"
39
+ },
40
+ "homepage": "https://github.com/useteploy/teploy-observe",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.20.4",
49
+ "tsx": "^4.19.2",
50
+ "typescript": "^5.4.5"
51
+ },
52
+ "sideEffects": false
53
+ }