@sypnia/telemetry 0.0.0-stage → 0.2.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,27 @@
1
+ // ../next/src/config.ts
2
+ var CONFIG_ENV = "SYPNIA_CONFIG";
3
+ function readConfig() {
4
+ try {
5
+ const raw = typeof process !== "undefined" ? process.env.SYPNIA_CONFIG : void 0;
6
+ if (!raw) return null;
7
+ const parsed = JSON.parse(raw);
8
+ return typeof parsed.project === "string" && parsed.project ? parsed : null;
9
+ } catch {
10
+ return null;
11
+ }
12
+ }
13
+ function serializePatterns(patterns) {
14
+ return patterns?.map((pattern) => typeof pattern === "string" ? pattern : { re: pattern.source, flags: pattern.flags });
15
+ }
16
+ function deserializePatterns(patterns) {
17
+ return patterns?.flatMap((pattern) => {
18
+ if (typeof pattern === "string") return [pattern];
19
+ try {
20
+ return [new RegExp(pattern.re, pattern.flags)];
21
+ } catch {
22
+ return [];
23
+ }
24
+ });
25
+ }
26
+
27
+ export { CONFIG_ENV, deserializePatterns, readConfig, serializePatterns };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * What `withSypnia` resolves at build and hands to both sides of the app:
3
+ * one JSON string in Next's `env`, which Next inlines wherever
4
+ * `process.env.SYPNIA_CONFIG` is written, in the browser and on the server.
5
+ * The ingest key is public: it is meant to reach the browser bundle.
6
+ */
7
+ /** A RegExp as it can cross JSON. */
8
+ interface SerializedPattern {
9
+ re: string;
10
+ flags: string;
11
+ }
12
+ type SerializedPatternList = Array<string | SerializedPattern>;
13
+ /** The Node SDK options of `server` that survive JSON: functions cannot cross from the build to the server. */
14
+ interface SerializedServerOptions {
15
+ ignoreRoutes?: SerializedPatternList;
16
+ allowRoutes?: SerializedPatternList;
17
+ captureDbErrors?: boolean;
18
+ capture?: {
19
+ outgoing?: boolean;
20
+ db?: boolean;
21
+ consoleErrors?: boolean;
22
+ uncaught?: boolean;
23
+ };
24
+ propagate?: boolean;
25
+ slowRequestMs?: number;
26
+ flushBudgetMs?: number;
27
+ enabled?: boolean;
28
+ }
29
+ interface SypniaNextConfig {
30
+ project: string;
31
+ endpoint: string;
32
+ service: string;
33
+ environment: string;
34
+ release: string | null;
35
+ debug: boolean;
36
+ /** Next's build folder, where `routes-manifest.json` names the routes. */
37
+ distDir: string;
38
+ /** `basePath` of the app: routes are named without it. */
39
+ basePath: string;
40
+ /** The app's routes as Next.js names them (`/orders/[id]`): the browser names pages and calls with them. */
41
+ routes?: string[];
42
+ server: SerializedServerOptions;
43
+ }
44
+
45
+ export type { SypniaNextConfig as S };
@@ -0,0 +1,334 @@
1
+ /** An attribute value as OTLP carries it: a whole number travels as `intValue`, any other as `doubleValue`. */
2
+ type AttributeValue = string | number | boolean;
3
+ type Attributes = Record<string, AttributeValue>;
4
+
5
+ /** A list entry of `ignoreRoutes`: a string covers the path and everything under it. Declared here so the published types need no private package. */
6
+ type Pattern = string | RegExp;
7
+ /** A finished span as `beforeSend` sees it. */
8
+ interface SpanForReview {
9
+ name: string;
10
+ kind: 'server' | 'client' | 'internal';
11
+ attributes: Attributes;
12
+ status: {
13
+ code: 'unset' | 'ok' | 'error';
14
+ message: string;
15
+ };
16
+ }
17
+ /** What `init` takes (docs: sdks/node#initoptions). */
18
+ interface NodeOptions {
19
+ /** The ingest key, `spk_…`. `SYPNIA_PROJECT_KEY` by default. */
20
+ project?: string;
21
+ /** Where to send. `SYPNIA_ENDPOINT`, else `https://telemetry.ingest.sypnia.com`. */
22
+ endpoint?: string;
23
+ /** Up to 80 characters. `SYPNIA_SERVICE`, else `server`. */
24
+ service?: string;
25
+ /** 1 to 40 characters. `SYPNIA_ENVIRONMENT`, else `production`. */
26
+ environment?: string;
27
+ /** Up to 40 characters. `SYPNIA_RELEASE`, else none. */
28
+ release?: string;
29
+ enabled?: boolean;
30
+ debug?: boolean;
31
+ /** Incoming paths that are not traced, on top of `OPTIONS` and static files. */
32
+ ignoreRoutes?: Pattern[];
33
+ /** When set, only incoming paths that match are traced (`ignoreRoutes` still applies to them). */
34
+ allowRoutes?: Pattern[];
35
+ /**
36
+ * The code and the full message of a failed database call: a `pg` error, or
37
+ * the body of a PostgREST answer of 400 or above, as the database wrote it,
38
+ * values included. On by default; `false` keeps the status (and a `pg`
39
+ * error's SQLSTATE) only. Successful answers are never read.
40
+ */
41
+ captureDbErrors?: boolean;
42
+ /** Your own way to turn a path into a route. */
43
+ routeFor?: (pathname: string) => string;
44
+ /**
45
+ * The `pg` module itself (`import pg from 'pg'`), for a bundled app (an
46
+ * esbuild-bundled Lambda) where `pg` is not in `node_modules` for the SDK to
47
+ * find. Without it the SDK looks for `pg` from the working directory.
48
+ */
49
+ pg?: object;
50
+ capture?: {
51
+ outgoing?: boolean;
52
+ db?: boolean;
53
+ consoleErrors?: boolean;
54
+ uncaught?: boolean;
55
+ };
56
+ /** Adds `traceparent` to outgoing calls. */
57
+ propagate?: boolean;
58
+ /** When a request still running is exported as partial. `0` turns it off. */
59
+ slowRequestMs?: number;
60
+ /** The longest wait for a send at the end of a serverless invocation. */
61
+ flushBudgetMs?: number;
62
+ /** Called with each finished span; return it, changed or not, or `null` to drop it. */
63
+ beforeSend?: (span: SpanForReview) => SpanForReview | null;
64
+ }
65
+
66
+ /**
67
+ * The functions an app calls (docs: sdks/node#the-functions-you-call). Every
68
+ * one is wrapped: a failure inside the SDK never reaches the app.
69
+ */
70
+
71
+ /** Set by `@sypnia/otel` when its span processor is registered: one tracer per process. */
72
+ declare const BRIDGE_MARKER: unique symbol;
73
+ /** Starts the SDK. Once: a second call does nothing. */
74
+ declare function init(options?: NodeOptions): void;
75
+ interface Who {
76
+ /** Optional on the server: a job often knows the account (a club, a team) and no person. */
77
+ person?: {
78
+ id: string | number;
79
+ name?: string;
80
+ email?: string;
81
+ };
82
+ account?: {
83
+ id: string | number;
84
+ name?: string;
85
+ };
86
+ }
87
+ /** Says who the current request or job belongs to. Only the ids leave the server. */
88
+ declare function identify(who: Who | null): void;
89
+ /** Reports an error your code caught (`sypnia.error.source` `manual`). */
90
+ declare function reportError(error: unknown): void;
91
+ /** Records your own step as an internal span around `fn`. Returns what `fn` returns. */
92
+ declare function span<T>(name: string, fn: () => T, attrs?: Record<string, string | number | boolean>): T;
93
+ /** Sends what is waiting; resolves when it is sent or after `timeoutMs`. */
94
+ declare function flush(timeoutMs?: number): Promise<void>;
95
+ /** Sends what is waiting, then stops the SDK. */
96
+ declare function shutdown(timeoutMs?: number): Promise<void>;
97
+ /** What a framework knows about a request that failed, when it reports the error itself. */
98
+ interface FailedRequest {
99
+ method: string;
100
+ path: string;
101
+ headers: Readonly<Record<string, string | string[] | undefined>>;
102
+ }
103
+ /**
104
+ * Framework integration (used by `@sypnia/next`'s `onRequestError`): an error
105
+ * the framework caught while serving `request`. Inside the request's scope it
106
+ * is an `exception` on its server span; otherwise a server span of its own is
107
+ * written for the request, joined to the browser's trace through its
108
+ * `traceparent`, answered 500.
109
+ */
110
+ declare function captureRequestError(error: unknown, request: FailedRequest, extra?: {
111
+ route?: string;
112
+ digest?: string;
113
+ }): void;
114
+
115
+ /**
116
+ * Keeping a function alive after its response, where the platform offers it
117
+ * (docs: sdks/nextjs#on-serverless): Vercel's request context carries
118
+ * `waitUntil`, and so does the one Next.js itself reads, which other hosts
119
+ * (OpenNext on AWS Lambda, for one) fill in. A framework integration can give
120
+ * its own.
121
+ */
122
+ type WaitUntil = (work: Promise<unknown>) => void;
123
+ /** Framework integration: where `waitUntil` comes from on this platform. */
124
+ declare function setWaitUntil(source: (() => WaitUntil | null) | null): void;
125
+
126
+ /**
127
+ * Requests that no Node server announces (docs: sdks/node#serverless-and-other-runtimes):
128
+ * functions from a `Request` to a `Response`, and hosts that call a
129
+ * framework's handler directly, such as OpenNext on AWS Lambda. The request is
130
+ * traced like any other, and its spans are exported after the response, with
131
+ * the platform's `waitUntil` when there is one, else waiting at most
132
+ * `flushBudgetMs` before the response is returned.
133
+ */
134
+
135
+ type FetchHandler<Args extends unknown[]> = (request: Request, ...rest: Args) => Response | Promise<Response>;
136
+ /** A request as a host hands it over: what it asked for, and how to read its headers. */
137
+ interface HostRequest {
138
+ method: string;
139
+ /** The path, or a whole URL: only the path is kept. */
140
+ path: string;
141
+ header(name: string): string | null | undefined;
142
+ }
143
+ interface TraceRequestOptions<T> {
144
+ /** The status of what the handler returned. */
145
+ statusOf(result: T): number;
146
+ /** This invocation's `waitUntil`, when the host gives one; else the platform's, else the budget. */
147
+ waitUntil?: WaitUntil | null;
148
+ }
149
+ /**
150
+ * Framework integration: runs `handle` as one traced request. Inside a
151
+ * request the server instrumentation already traces (a Node server), only the
152
+ * export after it is added. Never changes what `handle` returns or throws.
153
+ */
154
+ declare function traceRequest<T>(request: HostRequest, handle: () => Promise<T>, options: TraceRequestOptions<T>): Promise<T>;
155
+ declare function wrapFetchHandler<Args extends unknown[]>(handler: FetchHandler<Args>): FetchHandler<Args>;
156
+
157
+ /**
158
+ * The trace handed to work that runs elsewhere (docs: sdks/queues-and-functions):
159
+ * W3C `traceparent`, in a queue message's attributes or in a function's
160
+ * payload, from the span that is current when the work is sent. Reading it
161
+ * back accepts every carrier the docs list.
162
+ */
163
+ /** The current span as a `traceparent`, or null outside a traced request or job (or when the SDK is off). */
164
+ declare function currentTraceparent(): string | null;
165
+ /**
166
+ * A copy of `payload` with `traceparent` added, for a function invoked with it
167
+ * (AWS Lambda `Invoke`, a job row, any JSON message). The same object back
168
+ * when there is nothing to add, it already has one, or it is not a plain object.
169
+ */
170
+ declare function injectTraceContext<T>(payload: T): T;
171
+ /** An SQS message attribute, as `SendMessage` takes it. */
172
+ interface SqsMessageAttribute {
173
+ DataType: string;
174
+ StringValue?: string;
175
+ BinaryValue?: Uint8Array;
176
+ [other: string]: unknown;
177
+ }
178
+ /**
179
+ * `MessageAttributes` for an SQS `SendMessage` with `traceparent` added, as a
180
+ * String attribute. The attributes given are copied, never changed; nothing is
181
+ * added when they already have `traceparent` or hold the 10 SQS allows.
182
+ * Returns `undefined` when there was nothing to send at all, so the field can
183
+ * be passed as it is.
184
+ */
185
+ declare function sqsTraceAttributes<A extends Record<string, SqsMessageAttribute>>(attributes?: A): A | Record<string, SqsMessageAttribute> | undefined;
186
+ /**
187
+ * The `traceparent` a carrier holds, or null: a string; an object with a
188
+ * `traceparent` key (a payload, HTTP headers in any case); an SQS message as a
189
+ * Lambda event gives it, or its `messageAttributes` / `MessageAttributes`; an
190
+ * API Gateway event's `headers`.
191
+ */
192
+ declare function traceparentOf(carrier: unknown): string | null;
193
+
194
+ /**
195
+ * Work that does not arrive as an HTTP request (docs: sdks/queues-and-functions):
196
+ * an SQS message, a Lambda invoked directly or on a schedule, any job taken
197
+ * from a queue. Each one is a server span named after the job, whose
198
+ * `http.route` is that name, so the engine stores it as a request of its
199
+ * service: in the sender's trace when it carried a `traceparent`, else in a
200
+ * trace of its own. What it throws is an `exception` with its stack. Its spans
201
+ * are sent before a Lambda returns.
202
+ */
203
+ type JobAttributes = Record<string, string | number | boolean | null | undefined>;
204
+ /** The part of a Lambda context the SDK reads. */
205
+ interface LambdaContextLike {
206
+ awsRequestId?: string;
207
+ functionName?: string;
208
+ getRemainingTimeInMillis?: () => number;
209
+ }
210
+ /**
211
+ * An SQS message as a Lambda event gives it (the fields the SDK reads). No
212
+ * index signatures: `SQSRecord` of `@types/aws-lambda` is made of interfaces,
213
+ * which have none, and must be assignable.
214
+ */
215
+ interface SqsRecordLike {
216
+ messageId: string;
217
+ eventSourceARN?: string;
218
+ attributes?: {
219
+ ApproximateReceiveCount?: string;
220
+ };
221
+ messageAttributes?: Record<string, {
222
+ stringValue?: string;
223
+ }>;
224
+ }
225
+ interface SqsBatchResponse {
226
+ batchItemFailures: {
227
+ itemIdentifier: string;
228
+ }[];
229
+ }
230
+ /**
231
+ * The trace of a job started by someone else: `fn` runs as a server span named
232
+ * `name`, continuing the `traceparent` of `carrier` (see `traceparentOf`), or
233
+ * in a new trace when it has none. For workers that are not Lambda functions;
234
+ * call `flush()` before the process can be frozen or stopped.
235
+ */
236
+ declare function continueTrace<T>(carrier: unknown, name: string, fn: () => T | Promise<T>, attributes?: JobAttributes): Promise<T>;
237
+ interface SqsRecordOptions<R> {
238
+ /** The job's name: the queue's name by default. */
239
+ name?: string | ((record: R) => string);
240
+ /** More attributes for the message's span. */
241
+ attributes?: (record: R) => JobAttributes | undefined;
242
+ /** The Lambda context, for `faas.invocation_id`. */
243
+ context?: LambdaContextLike;
244
+ }
245
+ /**
246
+ * One SQS message as one job, for a handler that loops over the batch itself:
247
+ * `fn` runs as the message's span, in the trace of the request that sent it.
248
+ * Returns what `fn` returns and throws what it throws, after recording it. It
249
+ * does not send: the handler sends before returning (`flush()`).
250
+ */
251
+ declare function traceSqsRecord<R extends SqsRecordLike, T>(record: R, fn: () => T | Promise<T>, options?: SqsRecordOptions<R>): Promise<T>;
252
+ interface SqsHandlerOptions<R> {
253
+ /** The job's name: the queue's name by default. */
254
+ name?: string | ((record: R) => string);
255
+ /** More attributes for the message's span. */
256
+ attributes?: (record: R) => JobAttributes | undefined;
257
+ /**
258
+ * `true` (the default): a message that throws is returned in
259
+ * `batchItemFailures` and the others are kept; the event source mapping must
260
+ * have `ReportBatchItemFailures`. `false`: the first message that throws
261
+ * stops the batch, and the handler throws, so SQS returns the whole batch.
262
+ */
263
+ partialBatch?: boolean;
264
+ /** The longest wait for the send before returning, within the time the function has left. 2,000 ms. */
265
+ flushTimeoutMs?: number;
266
+ }
267
+ /**
268
+ * A Lambda handler for an SQS event from one that handles one message: each
269
+ * message is its own span, in the trace of the request that sent it.
270
+ */
271
+ declare function wrapSqsHandler<R extends SqsRecordLike, C extends LambdaContextLike | undefined = LambdaContextLike>(handle: (record: R, context: C) => unknown, options?: SqsHandlerOptions<R>): (event: {
272
+ Records?: R[];
273
+ }, context: C) => Promise<SqsBatchResponse>;
274
+ interface LambdaHandlerOptions<E> {
275
+ /** The job's name: the function's name by default. Not used for HTTP events, which are named by their route. */
276
+ name?: string | ((event: E) => string);
277
+ /** More attributes for the invocation's span. */
278
+ attributes?: (event: E) => JobAttributes | undefined;
279
+ /** The longest wait for the send before returning, within the time the function has left. 2,000 ms. */
280
+ flushTimeoutMs?: number;
281
+ }
282
+ /**
283
+ * Any async Lambda handler, one span per invocation: an API Gateway or
284
+ * function URL event is traced as the HTTP request it is; a scheduled event
285
+ * starts a trace of its own; anything else (a direct `Invoke`) continues the
286
+ * `traceparent` of its payload. Its spans are sent before it returns.
287
+ */
288
+ declare function wrapLambdaHandler<E, C extends LambdaContextLike | undefined, R>(handler: (event: E, context: C) => R | Promise<R>, options?: LambdaHandlerOptions<E>): (event: E, context: C) => Promise<R>;
289
+
290
+ /**
291
+ * `@sypnia/node`: Sypnia's own light tracer for Node servers. It sends traces
292
+ * as OTLP/HTTP protobuf, without depending on OpenTelemetry (docs: sdks/node).
293
+ */
294
+
295
+ declare const NodeSdk_BRIDGE_MARKER: typeof BRIDGE_MARKER;
296
+ type NodeSdk_FailedRequest = FailedRequest;
297
+ type NodeSdk_HostRequest = HostRequest;
298
+ type NodeSdk_JobAttributes = JobAttributes;
299
+ type NodeSdk_LambdaContextLike = LambdaContextLike;
300
+ type NodeSdk_LambdaHandlerOptions<E> = LambdaHandlerOptions<E>;
301
+ type NodeSdk_NodeOptions = NodeOptions;
302
+ type NodeSdk_Pattern = Pattern;
303
+ type NodeSdk_SpanForReview = SpanForReview;
304
+ type NodeSdk_SqsBatchResponse = SqsBatchResponse;
305
+ type NodeSdk_SqsHandlerOptions<R> = SqsHandlerOptions<R>;
306
+ type NodeSdk_SqsMessageAttribute = SqsMessageAttribute;
307
+ type NodeSdk_SqsRecordLike = SqsRecordLike;
308
+ type NodeSdk_SqsRecordOptions<R> = SqsRecordOptions<R>;
309
+ type NodeSdk_TraceRequestOptions<T> = TraceRequestOptions<T>;
310
+ type NodeSdk_WaitUntil = WaitUntil;
311
+ type NodeSdk_Who = Who;
312
+ declare const NodeSdk_captureRequestError: typeof captureRequestError;
313
+ declare const NodeSdk_continueTrace: typeof continueTrace;
314
+ declare const NodeSdk_currentTraceparent: typeof currentTraceparent;
315
+ declare const NodeSdk_flush: typeof flush;
316
+ declare const NodeSdk_identify: typeof identify;
317
+ declare const NodeSdk_init: typeof init;
318
+ declare const NodeSdk_injectTraceContext: typeof injectTraceContext;
319
+ declare const NodeSdk_reportError: typeof reportError;
320
+ declare const NodeSdk_setWaitUntil: typeof setWaitUntil;
321
+ declare const NodeSdk_shutdown: typeof shutdown;
322
+ declare const NodeSdk_span: typeof span;
323
+ declare const NodeSdk_sqsTraceAttributes: typeof sqsTraceAttributes;
324
+ declare const NodeSdk_traceRequest: typeof traceRequest;
325
+ declare const NodeSdk_traceSqsRecord: typeof traceSqsRecord;
326
+ declare const NodeSdk_traceparentOf: typeof traceparentOf;
327
+ declare const NodeSdk_wrapFetchHandler: typeof wrapFetchHandler;
328
+ declare const NodeSdk_wrapLambdaHandler: typeof wrapLambdaHandler;
329
+ declare const NodeSdk_wrapSqsHandler: typeof wrapSqsHandler;
330
+ declare namespace NodeSdk {
331
+ export { NodeSdk_BRIDGE_MARKER as BRIDGE_MARKER, type NodeSdk_FailedRequest as FailedRequest, type NodeSdk_HostRequest as HostRequest, type NodeSdk_JobAttributes as JobAttributes, type NodeSdk_LambdaContextLike as LambdaContextLike, type NodeSdk_LambdaHandlerOptions as LambdaHandlerOptions, type NodeSdk_NodeOptions as NodeOptions, type NodeSdk_Pattern as Pattern, type NodeSdk_SpanForReview as SpanForReview, type NodeSdk_SqsBatchResponse as SqsBatchResponse, type NodeSdk_SqsHandlerOptions as SqsHandlerOptions, type NodeSdk_SqsMessageAttribute as SqsMessageAttribute, type NodeSdk_SqsRecordLike as SqsRecordLike, type NodeSdk_SqsRecordOptions as SqsRecordOptions, type NodeSdk_TraceRequestOptions as TraceRequestOptions, type NodeSdk_WaitUntil as WaitUntil, type NodeSdk_Who as Who, NodeSdk_captureRequestError as captureRequestError, NodeSdk_continueTrace as continueTrace, NodeSdk_currentTraceparent as currentTraceparent, NodeSdk_flush as flush, NodeSdk_identify as identify, NodeSdk_init as init, NodeSdk_injectTraceContext as injectTraceContext, NodeSdk_reportError as reportError, NodeSdk_setWaitUntil as setWaitUntil, NodeSdk_shutdown as shutdown, NodeSdk_span as span, NodeSdk_sqsTraceAttributes as sqsTraceAttributes, NodeSdk_traceRequest as traceRequest, NodeSdk_traceSqsRecord as traceSqsRecord, NodeSdk_traceparentOf as traceparentOf, NodeSdk_wrapFetchHandler as wrapFetchHandler, NodeSdk_wrapLambdaHandler as wrapLambdaHandler, NodeSdk_wrapSqsHandler as wrapSqsHandler };
332
+ }
333
+
334
+ export { BRIDGE_MARKER as B, type FailedRequest as F, type HostRequest as H, type JobAttributes as J, type LambdaContextLike as L, NodeSdk as N, type Pattern as P, type SpanForReview as S, type TraceRequestOptions as T, type WaitUntil as W, type LambdaHandlerOptions as a, type NodeOptions as b, type SqsBatchResponse as c, type SqsHandlerOptions as d, type SqsMessageAttribute as e, type SqsRecordLike as f, type SqsRecordOptions as g, type Who as h, captureRequestError as i, continueTrace as j, currentTraceparent as k, flush as l, identify as m, init as n, injectTraceContext as o, shutdown as p, span as q, reportError as r, setWaitUntil as s, sqsTraceAttributes as t, traceRequest as u, traceSqsRecord as v, traceparentOf as w, wrapFetchHandler as x, wrapLambdaHandler as y, wrapSqsHandler as z };
@@ -0,0 +1,16 @@
1
+ import { I as InitOptions } from '../api-Dqlofw7I.js';
2
+ export { f as flush, g as getSessionId, i as identify, o as optIn, b as optOut, r as reportError, t as track } from '../api-Dqlofw7I.js';
3
+
4
+ /**
5
+ * `@sypnia/next/client`: the browser side, switched on from
6
+ * `instrumentation-client.ts` (docs: sdks/nextjs#set-it-up). `init()` takes
7
+ * its values from `withSypnia`; App Router navigations come from Next.js
8
+ * itself through `onRouterTransitionStart`.
9
+ */
10
+
11
+ /** Starts the browser SDK with `withSypnia`'s values; any browser option given here wins. */
12
+ declare function init(options?: Partial<InitOptions>): void;
13
+ /** Next.js calls it when an App Router navigation starts. */
14
+ declare function onRouterTransitionStart(url: string, navigationType: 'push' | 'replace' | 'traverse'): void;
15
+
16
+ export { InitOptions, init, onRouterTransitionStart };
@@ -0,0 +1,34 @@
1
+ import { init, notifyNavigation } from '../chunk-WL43YGLQ.js';
2
+ export { flush, getSessionId, identify, optIn, optOut, reportError, track } from '../chunk-WL43YGLQ.js';
3
+ import { readConfig } from '../chunk-WUAOTFVV.js';
4
+ import '../chunk-46P5IZVP.js';
5
+ import { routeNamer } from '../chunk-VWTXZCR4.js';
6
+ import '../chunk-U6USLZJ2.js';
7
+
8
+ // ../next/src/client.ts
9
+ function init2(options = {}) {
10
+ try {
11
+ const config = readConfig();
12
+ init({
13
+ ...config ? {
14
+ endpoint: config.endpoint,
15
+ environment: config.environment,
16
+ ...config.release ? { release: config.release } : {},
17
+ debug: config.debug,
18
+ // The Next.js names of the app's routes, as the server names them.
19
+ ...config.routes?.length ? { routeFor: routeNamer(config.routes, config.basePath) } : {}
20
+ } : {},
21
+ ...options,
22
+ project: options.project ?? config?.project ?? ""
23
+ });
24
+ } catch {
25
+ }
26
+ }
27
+ function onRouterTransitionStart(url, navigationType) {
28
+ try {
29
+ notifyNavigation(url, navigationType === "replace" || navigationType === "traverse" ? navigationType : "push");
30
+ } catch {
31
+ }
32
+ }
33
+
34
+ export { init2 as init, onRouterTransitionStart };
@@ -0,0 +1,65 @@
1
+ import { S as SypniaNextConfig } from '../config-B6ekRTXY.js';
2
+
3
+ /**
4
+ * `withSypnia(nextConfig, options)` for `next.config.ts` (docs: sdks/nextjs#withsypnianextconfig-options):
5
+ * resolves the values once, at build, hands them to both sides of the app
6
+ * through Next's `env`, and uploads the browser source maps after a
7
+ * production build. It needs nothing from Next.js at run time.
8
+ */
9
+
10
+ /** A string pattern covers a path and everything under it. */
11
+ type Pattern = string | RegExp;
12
+ /** The Node SDK options `server` may carry: those that can cross from the build to the server. */
13
+ interface SypniaServerOptions {
14
+ enabled?: boolean;
15
+ ignoreRoutes?: Pattern[];
16
+ allowRoutes?: Pattern[];
17
+ /** `false`: no database error message is kept, only the status (and a `pg` error's SQLSTATE). */
18
+ captureDbErrors?: boolean;
19
+ capture?: {
20
+ outgoing?: boolean;
21
+ db?: boolean;
22
+ consoleErrors?: boolean;
23
+ uncaught?: boolean;
24
+ };
25
+ propagate?: boolean;
26
+ slowRequestMs?: number;
27
+ flushBudgetMs?: number;
28
+ }
29
+ interface SypniaNextOptions {
30
+ project?: string;
31
+ endpoint?: string;
32
+ service?: string;
33
+ environment?: string;
34
+ release?: string;
35
+ debug?: boolean;
36
+ sourceMaps?: boolean;
37
+ apiUrl?: string;
38
+ server?: SypniaServerOptions;
39
+ }
40
+ /** The part of Next's config `withSypnia` reads and writes (structural: no dependency on `next`). */
41
+ interface NextConfigLike {
42
+ env?: Record<string, string | undefined>;
43
+ distDir?: string;
44
+ basePath?: string;
45
+ pageExtensions?: string[];
46
+ productionBrowserSourceMaps?: boolean;
47
+ compiler?: {
48
+ runAfterProductionCompile?: (metadata: {
49
+ projectDir: string;
50
+ distDir: string;
51
+ }) => Promise<void>;
52
+ [key: string]: unknown;
53
+ };
54
+ [key: string]: unknown;
55
+ }
56
+ type ConfigFunction<C> = (phase: string, context: {
57
+ defaultConfig: Record<string, unknown>;
58
+ }) => C | Promise<C>;
59
+ /** The values both sides get, with every documented default. Null when there is no project. */
60
+ declare function resolveNextConfig(options: SypniaNextOptions, nextConfig: NextConfigLike, phase?: string): SypniaNextConfig | null;
61
+ /** Wraps your Next.js config. Accepts the object form and the function form of `next.config`. */
62
+ declare function withSypnia<C extends NextConfigLike>(nextConfig: C, options?: SypniaNextOptions): C & NextConfigLike;
63
+ declare function withSypnia<C extends NextConfigLike>(nextConfig: ConfigFunction<C>, options?: SypniaNextOptions): ConfigFunction<C & NextConfigLike>;
64
+
65
+ export { type NextConfigLike, type Pattern, type SypniaNextOptions, type SypniaServerOptions, resolveNextConfig, withSypnia };