@interfere/next 9.0.2 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -5
- package/dist/config.d.mts +24 -5
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +38 -28
- package/dist/config.mjs.map +1 -1
- package/dist/instrument-client.d.mts +14 -3
- package/dist/instrument-client.d.mts.map +1 -1
- package/dist/instrument-client.mjs +7 -9
- package/dist/instrument-client.mjs.map +1 -1
- package/dist/instrumentation-client.d.mts +1 -0
- package/dist/instrumentation-client.mjs +22 -0
- package/dist/instrumentation-client.mjs.map +1 -0
- package/dist/instrumentation.d.mts +134 -0
- package/dist/instrumentation.d.mts.map +1 -0
- package/dist/instrumentation.edge.d.mts +35 -0
- package/dist/instrumentation.edge.d.mts.map +1 -0
- package/dist/instrumentation.edge.mjs +34 -0
- package/dist/instrumentation.edge.mjs.map +1 -0
- package/dist/instrumentation.mjs +165 -0
- package/dist/instrumentation.mjs.map +1 -0
- package/dist/internal/build/configure-build.d.mts +1 -2
- package/dist/internal/build/configure-build.d.mts.map +1 -1
- package/dist/internal/build/configure-build.mjs +10 -2
- package/dist/internal/build/configure-build.mjs.map +1 -1
- package/dist/internal/build/detect-bundler.d.mts +6 -0
- package/dist/internal/build/detect-bundler.d.mts.map +1 -0
- package/dist/internal/build/detect-bundler.mjs +9 -0
- package/dist/internal/build/detect-bundler.mjs.map +1 -0
- package/dist/internal/build/pipeline.d.mts +14 -1
- package/dist/internal/build/pipeline.d.mts.map +1 -1
- package/dist/internal/build/pipeline.mjs +26 -10
- package/dist/internal/build/pipeline.mjs.map +1 -1
- package/dist/internal/build/release/destinations/index.d.mts +14 -0
- package/dist/internal/build/release/destinations/index.d.mts.map +1 -0
- package/dist/internal/build/release/destinations/index.mjs +13 -0
- package/dist/internal/build/release/destinations/index.mjs.map +1 -0
- package/dist/internal/build/release/destinations/vercel.mjs.map +1 -1
- package/dist/internal/build/release/git.d.mts +13 -0
- package/dist/internal/build/release/git.d.mts.map +1 -1
- package/dist/internal/build/release/git.mjs +13 -2
- package/dist/internal/build/release/git.mjs.map +1 -1
- package/dist/internal/build/release/index.d.mts +2 -1
- package/dist/internal/build/release/index.d.mts.map +1 -1
- package/dist/internal/build/release/index.mjs +4 -5
- package/dist/internal/build/release/index.mjs.map +1 -1
- package/dist/internal/build/release/sources/github.mjs.map +1 -1
- package/dist/internal/build/release/sources/index.d.mts +21 -0
- package/dist/internal/build/release/sources/index.d.mts.map +1 -0
- package/dist/internal/build/release/sources/index.mjs +20 -0
- package/dist/internal/build/release/sources/index.mjs.map +1 -0
- package/dist/internal/build/source-maps/discover-turbopack.d.mts +32 -0
- package/dist/internal/build/source-maps/discover-turbopack.d.mts.map +1 -0
- package/dist/internal/build/source-maps/discover-turbopack.mjs +68 -0
- package/dist/internal/build/source-maps/discover-turbopack.mjs.map +1 -0
- package/dist/internal/build/source-maps/discover-webpack.d.mts +53 -0
- package/dist/internal/build/source-maps/discover-webpack.d.mts.map +1 -0
- package/dist/internal/build/source-maps/discover-webpack.mjs +112 -0
- package/dist/internal/build/source-maps/discover-webpack.mjs.map +1 -0
- package/dist/internal/build/source-maps/discover.d.mts +28 -10
- package/dist/internal/build/source-maps/discover.d.mts.map +1 -1
- package/dist/internal/build/source-maps/discover.mjs +22 -83
- package/dist/internal/build/source-maps/discover.mjs.map +1 -1
- package/dist/internal/build/source-maps/index.d.mts +2 -24
- package/dist/internal/build/source-maps/index.d.mts.map +1 -1
- package/dist/internal/build/source-maps/index.mjs +13 -23
- package/dist/internal/build/source-maps/index.mjs.map +1 -1
- package/dist/internal/build/source-maps/paths.d.mts +28 -0
- package/dist/internal/build/source-maps/paths.d.mts.map +1 -0
- package/dist/internal/build/source-maps/paths.mjs +49 -0
- package/dist/internal/build/source-maps/paths.mjs.map +1 -0
- package/dist/internal/build/source-maps/upload.d.mts +46 -0
- package/dist/internal/build/source-maps/upload.d.mts.map +1 -0
- package/dist/internal/build/source-maps/upload.mjs +134 -0
- package/dist/internal/build/source-maps/upload.mjs.map +1 -0
- package/dist/internal/build/value-injection-loader.mjs.map +1 -1
- package/dist/internal/env.d.mts +11 -2
- package/dist/internal/env.d.mts.map +1 -1
- package/dist/internal/env.mjs +12 -3
- package/dist/internal/env.mjs.map +1 -1
- package/dist/internal/logger.d.mts +9 -1
- package/dist/internal/logger.d.mts.map +1 -1
- package/dist/internal/logger.mjs +10 -2
- package/dist/internal/logger.mjs.map +1 -1
- package/dist/internal/release-slug.d.mts +25 -0
- package/dist/internal/release-slug.d.mts.map +1 -0
- package/dist/internal/release-slug.mjs +32 -0
- package/dist/internal/release-slug.mjs.map +1 -0
- package/dist/internal/route/handle-get.d.mts +14 -1
- package/dist/internal/route/handle-get.d.mts.map +1 -1
- package/dist/internal/route/handle-get.mjs +35 -14
- package/dist/internal/route/handle-get.mjs.map +1 -1
- package/dist/internal/route/handle-post.d.mts +11 -0
- package/dist/internal/route/handle-post.d.mts.map +1 -1
- package/dist/internal/route/handle-post.mjs +11 -50
- package/dist/internal/route/handle-post.mjs.map +1 -1
- package/dist/internal/route/proxy.d.mts +21 -1
- package/dist/internal/route/proxy.d.mts.map +1 -1
- package/dist/internal/route/proxy.mjs +61 -16
- package/dist/internal/route/proxy.mjs.map +1 -1
- package/dist/internal/server/capture.d.mts +2 -2
- package/dist/internal/server/capture.d.mts.map +1 -1
- package/dist/internal/server/capture.mjs +71 -37
- package/dist/internal/server/capture.mjs.map +1 -1
- package/dist/internal/server/console-bridge.d.mts +19 -0
- package/dist/internal/server/console-bridge.d.mts.map +1 -0
- package/dist/internal/server/console-bridge.mjs +112 -0
- package/dist/internal/server/console-bridge.mjs.map +1 -0
- package/dist/internal/server/id-generator.d.mts +38 -0
- package/dist/internal/server/id-generator.d.mts.map +1 -0
- package/dist/internal/server/id-generator.mjs +68 -0
- package/dist/internal/server/id-generator.mjs.map +1 -0
- package/dist/internal/server/instrumentation-options.d.mts +86 -0
- package/dist/internal/server/instrumentation-options.d.mts.map +1 -0
- package/dist/internal/server/instrumentation-options.mjs +1 -0
- package/dist/internal/server/remote-config.mjs +2 -2
- package/dist/internal/server/remote-config.mjs.map +1 -1
- package/dist/internal/server/trace-meta.d.mts +34 -0
- package/dist/internal/server/trace-meta.d.mts.map +1 -0
- package/dist/internal/server/trace-meta.mjs +41 -0
- package/dist/internal/server/trace-meta.mjs.map +1 -0
- package/dist/internal/server/traceparent.d.mts +16 -0
- package/dist/internal/server/traceparent.d.mts.map +1 -0
- package/dist/internal/server/traceparent.mjs +26 -0
- package/dist/internal/server/traceparent.mjs.map +1 -0
- package/dist/internal/server/types.d.mts +1 -7
- package/dist/internal/server/types.d.mts.map +1 -1
- package/dist/internal/setup-warnings.d.mts +17 -0
- package/dist/internal/setup-warnings.d.mts.map +1 -0
- package/dist/internal/setup-warnings.mjs +45 -0
- package/dist/internal/setup-warnings.mjs.map +1 -0
- package/dist/package.mjs +1 -1
- package/dist/provider.d.mts +23 -2
- package/dist/provider.d.mts.map +1 -0
- package/dist/provider.mjs +23 -1
- package/dist/provider.mjs.map +1 -0
- package/dist/route-handler.d.mts +7 -2
- package/dist/route-handler.d.mts.map +1 -1
- package/dist/route-handler.mjs +11 -9
- package/dist/route-handler.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.mjs +2 -2
- package/package.json +73 -20
- package/dist/internal/route/sw-script.d.mts +0 -4
- package/dist/internal/route/sw-script.d.mts.map +0 -1
- package/dist/internal/route/sw-script.mjs +0 -38
- package/dist/internal/route/sw-script.mjs.map +0 -1
- package/dist/internal/server/dedupe.d.mts +0 -5
- package/dist/internal/server/dedupe.d.mts.map +0 -1
- package/dist/internal/server/dedupe.mjs +0 -11
- package/dist/internal/server/dedupe.mjs.map +0 -1
- package/dist/internal/server/envelope.d.mts +0 -14
- package/dist/internal/server/envelope.d.mts.map +0 -1
- package/dist/internal/server/envelope.mjs +0 -59
- package/dist/internal/server/envelope.mjs.map +0 -1
- package/dist/internal/server/normalize-request.d.mts +0 -7
- package/dist/internal/server/normalize-request.d.mts.map +0 -1
- package/dist/internal/server/normalize-request.mjs +0 -50
- package/dist/internal/server/normalize-request.mjs.map +0 -1
- package/dist/internal/server/runtime.d.mts +0 -14
- package/dist/internal/server/runtime.d.mts.map +0 -1
- package/dist/internal/server/runtime.mjs +0 -18
- package/dist/internal/server/runtime.mjs.map +0 -1
- package/dist/internal/server/transport.d.mts +0 -12
- package/dist/internal/server/transport.d.mts.map +0 -1
- package/dist/internal/server/transport.mjs +0 -26
- package/dist/internal/server/transport.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
<a href="https://interfere.com">
|
|
3
3
|
<picture>
|
|
4
4
|
<source media="(prefers-color-scheme: dark)" srcset="https://qyzkf4cgb8ydxtq1.public.blob.vercel-storage.com/v2/header/logo-dark.png">
|
|
5
|
-
<img src="https://qyzkf4cgb8ydxtq1.public.blob.vercel-storage.com/v2/header/logo-light.png" height="64">
|
|
5
|
+
<img src="https://qyzkf4cgb8ydxtq1.public.blob.vercel-storage.com/v2/header/logo-light.png" height="64" alt="Interfere">
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
8
|
<h1 align="center">@interfere/next</h1>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/@interfere/next"><img src="https://img.shields.io/npm/v/@interfere/next.svg" /></a>
|
|
13
|
-
<a href="https://github.com/interfere-inc/interfere/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@interfere/next.svg" /></a>
|
|
14
|
-
<a href="https://www.npmjs.com/package/@interfere/next"><img src="https://img.shields.io/npm/dm/@interfere/next.svg" /></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@interfere/next"><img src="https://img.shields.io/npm/v/@interfere/next.svg" alt="npm version" /></a>
|
|
13
|
+
<a href="https://github.com/interfere-inc/interfere/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@interfere/next.svg" alt="License" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@interfere/next"><img src="https://img.shields.io/npm/dm/@interfere/next.svg" alt="npm downloads" /></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<p align="center">
|
|
@@ -69,7 +69,7 @@ export { onRequestError } from "@interfere/next/server";
|
|
|
69
69
|
|
|
70
70
|
```ts
|
|
71
71
|
// app/api/interfere/[[...path]]/route.ts
|
|
72
|
-
export
|
|
72
|
+
export * from "@interfere/next/route-handler";
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
**4. Add the provider**
|
|
@@ -98,6 +98,34 @@ export default function RootLayout({
|
|
|
98
98
|
| Variable | Required | Description |
|
|
99
99
|
| --- | --- | --- |
|
|
100
100
|
| `INTERFERE_API_KEY` | Yes | Your project API key |
|
|
101
|
+
| `NEXT_PUBLIC_INTERFERE_ROUTE_PREFIX` | No | Override the proxy route prefix (default: `/api/interfere`). Must match the path you mount the route handler at — e.g. set this to `/__telemetry` and mount the handler at `app/__telemetry/[[...path]]/route.ts`. Read by both the server route handler and the client SDK. |
|
|
102
|
+
|
|
103
|
+
## Custom Route Prefix
|
|
104
|
+
|
|
105
|
+
By default the SDK proxies all telemetry through `/api/interfere`. You can move this to any path by setting `NEXT_PUBLIC_INTERFERE_ROUTE_PREFIX` and mounting the route handler at the matching location.
|
|
106
|
+
|
|
107
|
+
**Why change it?** A custom prefix lets you avoid ad-blocker deny-lists that target well-known SDK paths, or align with your own API routing conventions.
|
|
108
|
+
|
|
109
|
+
**1. Set the environment variable**
|
|
110
|
+
|
|
111
|
+
```env
|
|
112
|
+
NEXT_PUBLIC_INTERFERE_ROUTE_PREFIX=/__telemetry
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**2. Mount the route handler at the matching path**
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
// app/__telemetry/[[...path]]/route.ts
|
|
119
|
+
export * from "@interfere/next/route-handler";
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Normalization rules**
|
|
123
|
+
|
|
124
|
+
| Input | Resolved |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `/__telemetry` | `/__telemetry` |
|
|
127
|
+
| `__telemetry/` | `/__telemetry` |
|
|
128
|
+
| *(empty)* or `/` | `/api/interfere` (default) |
|
|
101
129
|
|
|
102
130
|
## Identity Management
|
|
103
131
|
|
package/dist/config.d.mts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReleaseSlug } from "@interfere/types/releases/slug";
|
|
2
2
|
import { NextConfig } from "next";
|
|
3
3
|
|
|
4
4
|
//#region src/config.d.ts
|
|
5
|
-
interface InterfereConfig extends Partial<Pick<Envelope, "buildId" | "releaseId">> {}
|
|
6
5
|
interface NextConfigWithInterfere extends NextConfig {
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Reserved for future SDK config. Setting `buildId` here is rejected
|
|
8
|
+
* loudly — it caused server/client slug drift in 9.x. Override the
|
|
9
|
+
* commit SHA via the `INTERFERE_SOURCE_ID` env var (set on both build
|
|
10
|
+
* and runtime envs) instead.
|
|
11
|
+
*/
|
|
12
|
+
interfere?: {
|
|
13
|
+
readonly buildId?: never;
|
|
14
|
+
};
|
|
8
15
|
}
|
|
9
16
|
interface ResolvedBuildConfig {
|
|
10
17
|
readonly apiKey: string | null;
|
|
11
18
|
readonly apiUrl: string;
|
|
19
|
+
/**
|
|
20
|
+
* Server-internal — the build pipeline still uses this to key R2
|
|
21
|
+
* source-map paths until Phase 7 re-keys them to slug. Never injected
|
|
22
|
+
* into the bundle; never exposed via env.
|
|
23
|
+
*/
|
|
12
24
|
readonly buildId: string | null;
|
|
13
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Deterministically derived from the leading 16 hex of the commit SHA, so
|
|
27
|
+
* the build step and the collector arrive at the same
|
|
28
|
+
* `rel_xxxxxxxxxxxxxxxx` without a round-trip. Stamped into the bundle as
|
|
29
|
+
* `__INTERFERE_RELEASE_SLUG__`. `null` when no commit SHA is available —
|
|
30
|
+
* release-pipeline calls bail in that case.
|
|
31
|
+
*/
|
|
32
|
+
readonly releaseSlug: ReleaseSlug | null;
|
|
14
33
|
}
|
|
15
34
|
declare function withInterfere(nextConfig?: NextConfigWithInterfere): NextConfig;
|
|
16
35
|
interface ProductionCompileContext {
|
|
@@ -18,4 +37,4 @@ interface ProductionCompileContext {
|
|
|
18
37
|
readonly projectDir: string;
|
|
19
38
|
}
|
|
20
39
|
//#endregion
|
|
21
|
-
export {
|
|
40
|
+
export { NextConfigWithInterfere, ProductionCompileContext, ResolvedBuildConfig, withInterfere };
|
package/dist/config.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;UAgBiB,uBAAA,SAAgC,UAAA;;AAAjD;;;;;EAOE,SAAA;IAAA,SAAuB,OAAA;EAAA;AAAA;AAAA,UAGR,mBAAA;EAAA,SACN,MAAA;EAAA,SACA,MAAA;EAcwB;;;;;EAAA,SARxB,OAAA;EAQwB;;AAGnC;;;;;EAHmC,SAAxB,WAAA,EAAa,WAAA;AAAA;AAAA,iBAGR,aAAA,CACd,UAAA,GAAY,uBAAA,GACX,UAAA;AAAA,UAwIc,wBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA;AAAA"}
|
package/dist/config.mjs
CHANGED
|
@@ -1,79 +1,89 @@
|
|
|
1
1
|
import { configureBuild } from "./internal/build/configure-build.mjs";
|
|
2
|
-
import { log } from "./internal/logger.mjs";
|
|
3
|
-
import { runGitCommand } from "./internal/build/release/git.mjs";
|
|
4
2
|
import { readInterfereEnv } from "./internal/env.mjs";
|
|
3
|
+
import { FatalError, log } from "./internal/logger.mjs";
|
|
4
|
+
import { resolveReleaseSlug } from "./internal/release-slug.mjs";
|
|
5
|
+
import { readNextMajorVersion, warnIfServerInstrumentationMissing } from "./internal/setup-warnings.mjs";
|
|
5
6
|
import { omitUndefined } from "@interfere/helpers/omit-undefined";
|
|
6
|
-
import { releaseDestinationIdEnvKeys, releaseSourceIdEnvKeys } from "@interfere/types/integrations";
|
|
7
|
-
import { parseEnvValue, readFirstEnvValue } from "@interfere/types/sdk/env";
|
|
8
7
|
//#region src/config.ts
|
|
8
|
+
const NEXT_INSTRUMENTATION_HOOK_FLAG_LAST_MAJOR = 14;
|
|
9
9
|
function withInterfere(nextConfig = {}) {
|
|
10
10
|
const { interfere, env: userEnv, webpack, turbopack, compiler, productionBrowserSourceMaps, ...rest } = nextConfig;
|
|
11
|
-
|
|
11
|
+
if (interfere && "buildId" in interfere && interfere.buildId !== void 0) return log.fatal("Removed: interfere.buildId", ["`interfere.buildId` was removed in SDK 10. It only worked at build time, so server-side spans drifted from the bundle's slug.", "Override the commit SHA via the `INTERFERE_SOURCE_ID` env var on both build and runtime envs instead."]);
|
|
12
|
+
const projectDir = process.cwd();
|
|
13
|
+
const config = resolveBuildConfig();
|
|
12
14
|
const forceEnable = !!process.env["NEXT_PUBLIC_INTERFERE_FORCE_ENABLE"];
|
|
13
15
|
const build = configureBuild({
|
|
14
16
|
existingWebpack: webpack,
|
|
15
17
|
existingTurbopack: turbopack,
|
|
16
|
-
projectDir
|
|
18
|
+
projectDir,
|
|
17
19
|
values: {
|
|
18
|
-
|
|
19
|
-
__INTERFERE_RELEASE_ID__: config.releaseId,
|
|
20
|
+
__INTERFERE_RELEASE_SLUG__: forceEnable ? "rel_local" : config.releaseSlug,
|
|
20
21
|
...forceEnable && { __INTERFERE_FORCE_ENABLE__: true }
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
24
|
if (config.apiKey !== null && !build.webpack && !build.turbopack) return log.fatal("Missing instrumentation client", ["INTERFERE_API_KEY is set but no instrumentation-client file was found.", "Create an instrumentation-client.ts file in your project root or src/ directory."]);
|
|
25
|
+
if (config.apiKey !== null) warnIfServerInstrumentationMissing(projectDir);
|
|
26
|
+
const nextMajor = readNextMajorVersion(projectDir);
|
|
27
|
+
const needsInstrumentationHookFlag = nextMajor === null || nextMajor <= NEXT_INSTRUMENTATION_HOOK_FLAG_LAST_MAJOR;
|
|
24
28
|
const existingHook = compiler?.runAfterProductionCompile;
|
|
25
29
|
const browserSourceMaps = config.apiKey === null ? productionBrowserSourceMaps : true;
|
|
30
|
+
if (config.apiKey !== null && productionBrowserSourceMaps === false) log.warn("Forcing productionBrowserSourceMaps", ["withInterfere() requires production source maps to symbolicate errors.", "Your `productionBrowserSourceMaps: false` was overridden to `true`."]);
|
|
26
31
|
return {
|
|
27
32
|
...rest,
|
|
28
|
-
env:
|
|
33
|
+
...userEnv ? { env: userEnv } : {},
|
|
29
34
|
compiler: {
|
|
30
35
|
...omitUndefined(compiler ?? {}),
|
|
31
36
|
async runAfterProductionCompile(context) {
|
|
32
37
|
if (existingHook) await existingHook(context);
|
|
33
|
-
|
|
38
|
+
try {
|
|
39
|
+
await runBuildReleasePipeline(context, config);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error instanceof FatalError) throw error;
|
|
42
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
43
|
+
log.warn("Skipping release pipeline", [
|
|
44
|
+
"Interfere encountered an unexpected error.",
|
|
45
|
+
"Build will continue, but this release's data will be ingested, but ignored as evidence when generating insights.",
|
|
46
|
+
`Error: ${message}`
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
34
49
|
}
|
|
35
50
|
},
|
|
36
51
|
...omitUndefined({
|
|
37
52
|
productionBrowserSourceMaps: browserSourceMaps,
|
|
38
53
|
turbopack: build.turbopack,
|
|
39
54
|
webpack: build.webpack
|
|
40
|
-
})
|
|
55
|
+
}),
|
|
56
|
+
...needsInstrumentationHookFlag ? { experimental: {
|
|
57
|
+
...rest.experimental ?? {},
|
|
58
|
+
instrumentationHook: true
|
|
59
|
+
} } : {}
|
|
41
60
|
};
|
|
42
61
|
}
|
|
43
|
-
function resolveBuildConfig(
|
|
62
|
+
function resolveBuildConfig() {
|
|
44
63
|
const { apiKey, apiUrl } = readInterfereEnv();
|
|
45
|
-
const
|
|
46
|
-
const releaseId = parseEnvValue(interfere?.releaseId) ?? readFirstEnvValue(process.env, releaseDestinationIdEnvKeys) ?? buildId;
|
|
64
|
+
const { commitSha, slug } = resolveReleaseSlug();
|
|
47
65
|
return {
|
|
48
66
|
apiKey: apiKey ?? null,
|
|
49
67
|
apiUrl,
|
|
50
|
-
buildId,
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function mergeEnvConfig(userEnv, config) {
|
|
55
|
-
const merged = {};
|
|
56
|
-
if (config.buildId !== null) merged["NEXT_PUBLIC_INTERFERE_BUILD_ID"] = config.buildId;
|
|
57
|
-
if (config.releaseId !== null) merged["NEXT_PUBLIC_INTERFERE_RELEASE_ID"] = config.releaseId;
|
|
58
|
-
return {
|
|
59
|
-
...merged,
|
|
60
|
-
...userEnv
|
|
68
|
+
buildId: commitSha,
|
|
69
|
+
releaseSlug: slug
|
|
61
70
|
};
|
|
62
71
|
}
|
|
63
72
|
async function runBuildReleasePipeline(context, config) {
|
|
64
|
-
const { apiKey, buildId } = config;
|
|
73
|
+
const { apiKey, buildId, releaseSlug } = config;
|
|
65
74
|
if (!apiKey) return log.fatal("API key not set", [
|
|
66
75
|
"withInterfere() requires an API key to upload source maps during production builds.",
|
|
67
76
|
"Set the INTERFERE_API_KEY environment variable, or remove withInterfere() from your Next.js config.",
|
|
68
77
|
"See: https://support.interfere.com/docs/guides/next-js"
|
|
69
78
|
]);
|
|
70
|
-
if (!buildId) return log.fatal("
|
|
79
|
+
if (!(buildId && releaseSlug)) return log.fatal("Commit SHA missing", ["Could not resolve a commit SHA from environment variables or git.", "Set `INTERFERE_SOURCE_ID`, ensure your CI exposes its git SHA env var (e.g. `VERCEL_GIT_COMMIT_SHA`, `GITHUB_SHA`), or run inside a git checkout."]);
|
|
71
80
|
const { runBuildPipeline } = await import("./internal/build/pipeline.mjs");
|
|
72
81
|
try {
|
|
73
82
|
const result = await runBuildPipeline(context, {
|
|
74
83
|
...config,
|
|
75
84
|
apiKey,
|
|
76
|
-
buildId
|
|
85
|
+
buildId,
|
|
86
|
+
releaseSlug
|
|
77
87
|
});
|
|
78
88
|
if (!result.ready) {
|
|
79
89
|
log.warn("Skipping", ["No source maps found"]);
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { omitUndefined } from \"@interfere/helpers/omit-undefined\";\nimport {\n releaseDestinationIdEnvKeys,\n releaseSourceIdEnvKeys,\n} from \"@interfere/types/integrations\";\nimport { parseEnvValue, readFirstEnvValue } from \"@interfere/types/sdk/env\";\nimport type { Envelope } from \"@interfere/types/sdk/envelope\";\n\nimport type { NextConfig } from \"next\";\n\nimport { configureBuild } from \"./internal/build/configure-build.js\";\nimport { runGitCommand } from \"./internal/build/release/git.js\";\nimport { readInterfereEnv } from \"./internal/env.js\";\nimport { log } from \"./internal/logger.js\";\n\nexport interface InterfereConfig\n extends Partial<Pick<Envelope, \"buildId\" | \"releaseId\">> {}\n\nexport interface NextConfigWithInterfere extends NextConfig {\n interfere?: InterfereConfig;\n}\n\nexport interface ResolvedBuildConfig {\n readonly apiKey: string | null;\n readonly apiUrl: string;\n readonly buildId: string | null;\n readonly releaseId: string | null;\n}\n\nexport function withInterfere(\n nextConfig: NextConfigWithInterfere = {}\n): NextConfig {\n const {\n interfere,\n env: userEnv,\n webpack,\n turbopack,\n compiler,\n productionBrowserSourceMaps,\n ...rest\n } = nextConfig;\n\n const config = resolveBuildConfig(interfere);\n const forceEnable = !!process.env[\"NEXT_PUBLIC_INTERFERE_FORCE_ENABLE\"];\n const build = configureBuild({\n existingWebpack: webpack,\n existingTurbopack: turbopack,\n projectDir: process.cwd(),\n values: {\n __INTERFERE_BUILD_ID__: config.buildId,\n __INTERFERE_RELEASE_ID__: config.releaseId,\n ...(forceEnable && { __INTERFERE_FORCE_ENABLE__: true }),\n },\n });\n\n if (config.apiKey !== null && !build.webpack && !build.turbopack) {\n return log.fatal(\"Missing instrumentation client\", [\n \"INTERFERE_API_KEY is set but no instrumentation-client file was found.\",\n \"Create an instrumentation-client.ts file in your project root or src/ directory.\",\n ]);\n }\n\n const existingHook = (compiler as NextCompilerWithProductionHook | undefined)\n ?.runAfterProductionCompile;\n\n const browserSourceMaps =\n config.apiKey === null ? productionBrowserSourceMaps : true;\n\n return {\n ...rest,\n env: mergeEnvConfig(userEnv, config),\n\n compiler: {\n ...omitUndefined(compiler ?? {}),\n async runAfterProductionCompile(context: ProductionCompileContext) {\n if (existingHook) {\n await existingHook(context);\n }\n\n await runBuildReleasePipeline(context, config);\n },\n },\n\n ...omitUndefined({\n productionBrowserSourceMaps: browserSourceMaps,\n turbopack: build.turbopack,\n webpack: build.webpack,\n }),\n };\n}\n\nfunction resolveBuildConfig(interfere?: InterfereConfig): ResolvedBuildConfig {\n const { apiKey, apiUrl } = readInterfereEnv();\n\n const buildId =\n parseEnvValue(interfere?.buildId) ??\n readFirstEnvValue(process.env, releaseSourceIdEnvKeys) ??\n runGitCommand(\"git rev-parse HEAD\");\n\n const releaseId =\n parseEnvValue(interfere?.releaseId) ??\n readFirstEnvValue(process.env, releaseDestinationIdEnvKeys) ??\n buildId;\n\n return { apiKey: apiKey ?? null, apiUrl, buildId, releaseId };\n}\n\nfunction mergeEnvConfig(\n userEnv: NextConfig[\"env\"] | undefined,\n config: ResolvedBuildConfig\n): Record<string, string | undefined> {\n const merged: Record<string, string> = {};\n\n if (config.buildId !== null) {\n merged[\"NEXT_PUBLIC_INTERFERE_BUILD_ID\"] = config.buildId;\n }\n\n if (config.releaseId !== null) {\n merged[\"NEXT_PUBLIC_INTERFERE_RELEASE_ID\"] = config.releaseId;\n }\n\n return { ...merged, ...userEnv };\n}\n\nexport interface ProductionCompileContext {\n readonly distDir: string;\n readonly projectDir: string;\n}\n\ntype NextCompilerWithProductionHook = NonNullable<NextConfig[\"compiler\"]> & {\n runAfterProductionCompile?: (\n context: ProductionCompileContext\n ) => void | Promise<void>;\n};\n\nasync function runBuildReleasePipeline(\n context: ProductionCompileContext,\n config: ResolvedBuildConfig\n): Promise<void> {\n const { apiKey, buildId } = config;\n\n if (!apiKey) {\n return log.fatal(\"API key not set\", [\n \"withInterfere() requires an API key to upload source maps during production builds.\",\n \"Set the INTERFERE_API_KEY environment variable, or remove withInterfere() from your Next.js config.\",\n \"See: https://support.interfere.com/docs/guides/next-js\",\n ]);\n }\n\n if (!buildId) {\n return log.fatal(\"Build ID missing\", [\n \"Could not resolve a build ID from config, environment variables, or git.\",\n \"Set INTERFERE_BUILD_ID, or ensure git is available in your build environment.\",\n ]);\n }\n\n const { runBuildPipeline } = await import(\"./internal/build/pipeline.js\");\n\n try {\n const result = await runBuildPipeline(context, {\n ...config,\n apiKey,\n buildId,\n });\n\n if (!result.ready) {\n log.warn(\"Skipping\", [\"No source maps found\"]);\n return;\n }\n\n log.info(\"Completed\", [\n `https://interfere.com/~/${result.config?.org.slug}/surfaces/${result.config?.surface.slug}`,\n `Release: ${result.release?.destination.slug ?? \"Unknown\"}`,\n `Build: ${result.buildId}`,\n `Artifacts: ${result.fileCount} source maps`,\n ]);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n log.warn(\"Skipping release pipeline\", [\n \"Interfere failed to process this release.\",\n \"Events from this release will be ingested, but ignored as evidence when generating insights.\",\n \"Please check https://status.interfere.com for any outages, or contact support@interfere.com if the problem persists.\",\n `Error: ${message}`,\n ]);\n\n return;\n }\n}\n"],"mappings":";;;;;;;;AA6BA,SAAgB,cACd,aAAsC,EAAE,EAC5B;CACZ,MAAM,EACJ,WACA,KAAK,SACL,SACA,WACA,UACA,6BACA,GAAG,SACD;CAEJ,MAAM,SAAS,mBAAmB,UAAU;CAC5C,MAAM,cAAc,CAAC,CAAC,QAAQ,IAAI;CAClC,MAAM,QAAQ,eAAe;EAC3B,iBAAiB;EACjB,mBAAmB;EACnB,YAAY,QAAQ,KAAK;EACzB,QAAQ;GACN,wBAAwB,OAAO;GAC/B,0BAA0B,OAAO;GACjC,GAAI,eAAe,EAAE,4BAA4B,MAAM;GACxD;EACF,CAAC;AAEF,KAAI,OAAO,WAAW,QAAQ,CAAC,MAAM,WAAW,CAAC,MAAM,UACrD,QAAO,IAAI,MAAM,kCAAkC,CACjD,0EACA,mFACD,CAAC;CAGJ,MAAM,eAAgB,UAClB;CAEJ,MAAM,oBACJ,OAAO,WAAW,OAAO,8BAA8B;AAEzD,QAAO;EACL,GAAG;EACH,KAAK,eAAe,SAAS,OAAO;EAEpC,UAAU;GACR,GAAG,cAAc,YAAY,EAAE,CAAC;GAChC,MAAM,0BAA0B,SAAmC;AACjE,QAAI,aACF,OAAM,aAAa,QAAQ;AAG7B,UAAM,wBAAwB,SAAS,OAAO;;GAEjD;EAED,GAAG,cAAc;GACf,6BAA6B;GAC7B,WAAW,MAAM;GACjB,SAAS,MAAM;GAChB,CAAC;EACH;;AAGH,SAAS,mBAAmB,WAAkD;CAC5E,MAAM,EAAE,QAAQ,WAAW,kBAAkB;CAE7C,MAAM,UACJ,cAAc,WAAW,QAAQ,IACjC,kBAAkB,QAAQ,KAAK,uBAAuB,IACtD,cAAc,qBAAqB;CAErC,MAAM,YACJ,cAAc,WAAW,UAAU,IACnC,kBAAkB,QAAQ,KAAK,4BAA4B,IAC3D;AAEF,QAAO;EAAE,QAAQ,UAAU;EAAM;EAAQ;EAAS;EAAW;;AAG/D,SAAS,eACP,SACA,QACoC;CACpC,MAAM,SAAiC,EAAE;AAEzC,KAAI,OAAO,YAAY,KACrB,QAAO,oCAAoC,OAAO;AAGpD,KAAI,OAAO,cAAc,KACvB,QAAO,sCAAsC,OAAO;AAGtD,QAAO;EAAE,GAAG;EAAQ,GAAG;EAAS;;AAclC,eAAe,wBACb,SACA,QACe;CACf,MAAM,EAAE,QAAQ,YAAY;AAE5B,KAAI,CAAC,OACH,QAAO,IAAI,MAAM,mBAAmB;EAClC;EACA;EACA;EACD,CAAC;AAGJ,KAAI,CAAC,QACH,QAAO,IAAI,MAAM,oBAAoB,CACnC,4EACA,gFACD,CAAC;CAGJ,MAAM,EAAE,qBAAqB,MAAM,OAAO;AAE1C,KAAI;EACF,MAAM,SAAS,MAAM,iBAAiB,SAAS;GAC7C,GAAG;GACH;GACA;GACD,CAAC;AAEF,MAAI,CAAC,OAAO,OAAO;AACjB,OAAI,KAAK,YAAY,CAAC,uBAAuB,CAAC;AAC9C;;AAGF,MAAI,KAAK,aAAa;GACpB,2BAA2B,OAAO,QAAQ,IAAI,KAAK,YAAY,OAAO,QAAQ,QAAQ;GACtF,YAAY,OAAO,SAAS,YAAY,QAAQ;GAChD,UAAU,OAAO;GACjB,cAAc,OAAO,UAAU;GAChC,CAAC;UACK,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAEtE,MAAI,KAAK,6BAA6B;GACpC;GACA;GACA;GACA,UAAU;GACX,CAAC;AAEF"}
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { omitUndefined } from \"@interfere/helpers/omit-undefined\";\nimport type { ReleaseSlug } from \"@interfere/types/releases/slug\";\n\nimport type { NextConfig } from \"next\";\n\nimport { configureBuild } from \"./internal/build/configure-build.js\";\nimport { readInterfereEnv } from \"./internal/env.js\";\nimport { FatalError, log } from \"./internal/logger.js\";\nimport { resolveReleaseSlug } from \"./internal/release-slug.js\";\nimport {\n readNextMajorVersion,\n warnIfServerInstrumentationMissing,\n} from \"./internal/setup-warnings.js\";\n\nconst NEXT_INSTRUMENTATION_HOOK_FLAG_LAST_MAJOR = 14;\n\nexport interface NextConfigWithInterfere extends NextConfig {\n /**\n * Reserved for future SDK config. Setting `buildId` here is rejected\n * loudly — it caused server/client slug drift in 9.x. Override the\n * commit SHA via the `INTERFERE_SOURCE_ID` env var (set on both build\n * and runtime envs) instead.\n */\n interfere?: { readonly buildId?: never };\n}\n\nexport interface ResolvedBuildConfig {\n readonly apiKey: string | null;\n readonly apiUrl: string;\n /**\n * Server-internal — the build pipeline still uses this to key R2\n * source-map paths until Phase 7 re-keys them to slug. Never injected\n * into the bundle; never exposed via env.\n */\n readonly buildId: string | null;\n /**\n * Deterministically derived from the leading 16 hex of the commit SHA, so\n * the build step and the collector arrive at the same\n * `rel_xxxxxxxxxxxxxxxx` without a round-trip. Stamped into the bundle as\n * `__INTERFERE_RELEASE_SLUG__`. `null` when no commit SHA is available —\n * release-pipeline calls bail in that case.\n */\n readonly releaseSlug: ReleaseSlug | null;\n}\n\nexport function withInterfere(\n nextConfig: NextConfigWithInterfere = {}\n): NextConfig {\n const {\n interfere,\n env: userEnv,\n webpack,\n turbopack,\n compiler,\n productionBrowserSourceMaps,\n ...rest\n } = nextConfig;\n\n if (interfere && \"buildId\" in interfere && interfere.buildId !== undefined) {\n return log.fatal(\"Removed: interfere.buildId\", [\n \"`interfere.buildId` was removed in SDK 10. It only worked at build time, so server-side spans drifted from the bundle's slug.\",\n \"Override the commit SHA via the `INTERFERE_SOURCE_ID` env var on both build and runtime envs instead.\",\n ]);\n }\n\n const projectDir = process.cwd();\n const config = resolveBuildConfig();\n const forceEnable = !!process.env[\"NEXT_PUBLIC_INTERFERE_FORCE_ENABLE\"];\n // Force-enable overrides the derived slug with a known sentinel. `next\n // dev` doesn't run the build pipeline, so any commit-derived slug\n // wouldn't be preflight-confirmed at the collector. The sandbox/preview\n // DB seeds `rel_local` as preflight-confirmed (see ENG-1353); prod\n // collectors silently drop force-enabled batches by header (ENG-1356).\n const releaseSlug = forceEnable ? \"rel_local\" : config.releaseSlug;\n const build = configureBuild({\n existingWebpack: webpack,\n existingTurbopack: turbopack,\n projectDir,\n values: {\n __INTERFERE_RELEASE_SLUG__: releaseSlug,\n ...(forceEnable && { __INTERFERE_FORCE_ENABLE__: true }),\n },\n });\n\n if (config.apiKey !== null && !build.webpack && !build.turbopack) {\n return log.fatal(\"Missing instrumentation client\", [\n \"INTERFERE_API_KEY is set but no instrumentation-client file was found.\",\n \"Create an instrumentation-client.ts file in your project root or src/ directory.\",\n ]);\n }\n\n if (config.apiKey !== null) {\n warnIfServerInstrumentationMissing(projectDir);\n }\n\n // `experimental.instrumentationHook` is required to opt in to\n // `instrumentation.ts` on Next 13–14, then becomes default-on (and the\n // flag is removed) in 15+. Default to setting the flag if we can't read\n // the version (monorepo hoist, weird resolve) — cheap on 15+ and avoids\n // silent breakage on 13/14.\n const nextMajor = readNextMajorVersion(projectDir);\n const needsInstrumentationHookFlag =\n nextMajor === null ||\n nextMajor <= NEXT_INSTRUMENTATION_HOOK_FLAG_LAST_MAJOR;\n\n const existingHook = (compiler as NextCompilerWithProductionHook | undefined)\n ?.runAfterProductionCompile;\n\n // Production source maps are required for symbolication. We force them\n // on whenever an API key is present; flip the customer's explicit\n // `false` to `true` and log so the change is visible.\n const browserSourceMaps =\n config.apiKey === null ? productionBrowserSourceMaps : true;\n if (config.apiKey !== null && productionBrowserSourceMaps === false) {\n log.warn(\"Forcing productionBrowserSourceMaps\", [\n \"withInterfere() requires production source maps to symbolicate errors.\",\n \"Your `productionBrowserSourceMaps: false` was overridden to `true`.\",\n ]);\n }\n\n return {\n ...rest,\n ...(userEnv ? { env: userEnv } : {}),\n\n compiler: {\n ...omitUndefined(compiler ?? {}),\n async runAfterProductionCompile(context: ProductionCompileContext) {\n if (existingHook) {\n await existingHook(context);\n }\n\n try {\n await runBuildReleasePipeline(context, config);\n } catch (error) {\n if (error instanceof FatalError) {\n throw error;\n }\n\n const message =\n error instanceof Error ? error.message : String(error);\n\n log.warn(\"Skipping release pipeline\", [\n \"Interfere encountered an unexpected error.\",\n \"Build will continue, but this release's data will be ingested, but ignored as evidence when generating insights.\",\n `Error: ${message}`,\n ]);\n }\n },\n },\n\n ...omitUndefined({\n productionBrowserSourceMaps: browserSourceMaps,\n turbopack: build.turbopack,\n webpack: build.webpack,\n }),\n\n // `instrumentationHook` is a Next 13–14 flag — required to opt into\n // `instrumentation.ts`, removed in 15+ where the hook is default-on. The\n // current Next type defs (peer-dep `^16`) no longer declare it, so we\n // cast through to set it without touching the input config's type.\n ...(needsInstrumentationHookFlag\n ? {\n experimental: {\n ...(rest.experimental ?? {}),\n instrumentationHook: true,\n } as NonNullable<NextConfig[\"experimental\"]>,\n }\n : {}),\n };\n}\n\nfunction resolveBuildConfig(): ResolvedBuildConfig {\n const { apiKey, apiUrl } = readInterfereEnv();\n const { commitSha, slug } = resolveReleaseSlug();\n\n return {\n apiKey: apiKey ?? null,\n apiUrl,\n buildId: commitSha,\n releaseSlug: slug,\n };\n}\n\nexport interface ProductionCompileContext {\n readonly distDir: string;\n readonly projectDir: string;\n}\n\ntype NextCompilerWithProductionHook = NonNullable<NextConfig[\"compiler\"]> & {\n runAfterProductionCompile?: (\n context: ProductionCompileContext\n ) => void | Promise<void>;\n};\n\nasync function runBuildReleasePipeline(\n context: ProductionCompileContext,\n config: ResolvedBuildConfig\n): Promise<void> {\n const { apiKey, buildId, releaseSlug } = config;\n\n if (!apiKey) {\n return log.fatal(\"API key not set\", [\n \"withInterfere() requires an API key to upload source maps during production builds.\",\n \"Set the INTERFERE_API_KEY environment variable, or remove withInterfere() from your Next.js config.\",\n \"See: https://support.interfere.com/docs/guides/next-js\",\n ]);\n }\n\n if (!(buildId && releaseSlug)) {\n return log.fatal(\"Commit SHA missing\", [\n \"Could not resolve a commit SHA from environment variables or git.\",\n \"Set `INTERFERE_SOURCE_ID`, ensure your CI exposes its git SHA env var (e.g. `VERCEL_GIT_COMMIT_SHA`, `GITHUB_SHA`), or run inside a git checkout.\",\n ]);\n }\n\n const { runBuildPipeline } = await import(\"./internal/build/pipeline.js\");\n\n try {\n const result = await runBuildPipeline(context, {\n ...config,\n apiKey,\n buildId,\n releaseSlug,\n });\n\n if (!result.ready) {\n log.warn(\"Skipping\", [\"No source maps found\"]);\n return;\n }\n\n log.info(\"Completed\", [\n `https://interfere.com/~/${result.config?.org.slug}/surfaces/${result.config?.surface.slug}`,\n `Release: ${result.release?.destination.slug ?? \"Unknown\"}`,\n `Build: ${result.buildId}`,\n `Artifacts: ${result.fileCount} source maps`,\n ]);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n log.warn(\"Skipping release pipeline\", [\n \"Interfere failed to process this release.\",\n \"Events from this release will be ingested, but ignored as evidence when generating insights.\",\n \"Please check https://status.interfere.com for any outages, or contact support@interfere.com if the problem persists.\",\n `Error: ${message}`,\n ]);\n\n return;\n }\n}\n"],"mappings":";;;;;;;AAcA,MAAM,4CAA4C;AA+BlD,SAAgB,cACd,aAAsC,EAAE,EAC5B;CACZ,MAAM,EACJ,WACA,KAAK,SACL,SACA,WACA,UACA,6BACA,GAAG,SACD;CAEJ,IAAI,aAAa,aAAa,aAAa,UAAU,YAAY,KAAA,GAC/D,OAAO,IAAI,MAAM,8BAA8B,CAC7C,iIACA,wGACD,CAAC;CAGJ,MAAM,aAAa,QAAQ,KAAK;CAChC,MAAM,SAAS,oBAAoB;CACnC,MAAM,cAAc,CAAC,CAAC,QAAQ,IAAI;CAOlC,MAAM,QAAQ,eAAe;EAC3B,iBAAiB;EACjB,mBAAmB;EACnB;EACA,QAAQ;GACN,4BANgB,cAAc,cAAc,OAAO;GAOnD,GAAI,eAAe,EAAE,4BAA4B,MAAM;GACxD;EACF,CAAC;CAEF,IAAI,OAAO,WAAW,QAAQ,CAAC,MAAM,WAAW,CAAC,MAAM,WACrD,OAAO,IAAI,MAAM,kCAAkC,CACjD,0EACA,mFACD,CAAC;CAGJ,IAAI,OAAO,WAAW,MACpB,mCAAmC,WAAW;CAQhD,MAAM,YAAY,qBAAqB,WAAW;CAClD,MAAM,+BACJ,cAAc,QACd,aAAa;CAEf,MAAM,eAAgB,UAClB;CAKJ,MAAM,oBACJ,OAAO,WAAW,OAAO,8BAA8B;CACzD,IAAI,OAAO,WAAW,QAAQ,gCAAgC,OAC5D,IAAI,KAAK,uCAAuC,CAC9C,0EACA,sEACD,CAAC;CAGJ,OAAO;EACL,GAAG;EACH,GAAI,UAAU,EAAE,KAAK,SAAS,GAAG,EAAE;EAEnC,UAAU;GACR,GAAG,cAAc,YAAY,EAAE,CAAC;GAChC,MAAM,0BAA0B,SAAmC;IACjE,IAAI,cACF,MAAM,aAAa,QAAQ;IAG7B,IAAI;KACF,MAAM,wBAAwB,SAAS,OAAO;aACvC,OAAO;KACd,IAAI,iBAAiB,YACnB,MAAM;KAGR,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;KAExD,IAAI,KAAK,6BAA6B;MACpC;MACA;MACA,UAAU;MACX,CAAC;;;GAGP;EAED,GAAG,cAAc;GACf,6BAA6B;GAC7B,WAAW,MAAM;GACjB,SAAS,MAAM;GAChB,CAAC;EAMF,GAAI,+BACA,EACE,cAAc;GACZ,GAAI,KAAK,gBAAgB,EAAE;GAC3B,qBAAqB;GACtB,EACF,GACD,EAAE;EACP;;AAGH,SAAS,qBAA0C;CACjD,MAAM,EAAE,QAAQ,WAAW,kBAAkB;CAC7C,MAAM,EAAE,WAAW,SAAS,oBAAoB;CAEhD,OAAO;EACL,QAAQ,UAAU;EAClB;EACA,SAAS;EACT,aAAa;EACd;;AAcH,eAAe,wBACb,SACA,QACe;CACf,MAAM,EAAE,QAAQ,SAAS,gBAAgB;CAEzC,IAAI,CAAC,QACH,OAAO,IAAI,MAAM,mBAAmB;EAClC;EACA;EACA;EACD,CAAC;CAGJ,IAAI,EAAE,WAAW,cACf,OAAO,IAAI,MAAM,sBAAsB,CACrC,qEACA,oJACD,CAAC;CAGJ,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAE1C,IAAI;EACF,MAAM,SAAS,MAAM,iBAAiB,SAAS;GAC7C,GAAG;GACH;GACA;GACA;GACD,CAAC;EAEF,IAAI,CAAC,OAAO,OAAO;GACjB,IAAI,KAAK,YAAY,CAAC,uBAAuB,CAAC;GAC9C;;EAGF,IAAI,KAAK,aAAa;GACpB,2BAA2B,OAAO,QAAQ,IAAI,KAAK,YAAY,OAAO,QAAQ,QAAQ;GACtF,YAAY,OAAO,SAAS,YAAY,QAAQ;GAChD,UAAU,OAAO;GACjB,cAAc,OAAO,UAAU;GAChC,CAAC;UACK,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;EAEtE,IAAI,KAAK,6BAA6B;GACpC;GACA;GACA;GACA,UAAU;GACX,CAAC;EAEF"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { capture, span } from "@interfere/react/api";
|
|
2
|
+
import * as _$_interfere_types_sdk_plugins_manifest0 from "@interfere/types/sdk/plugins/manifest";
|
|
3
|
+
import { ConsentCategory, ConsentState, GateableCategory } from "@interfere/types/sdk/plugins/manifest";
|
|
4
|
+
import * as _$_interfere_react_internal_kernel0 from "@interfere/react/internal/kernel";
|
|
5
|
+
import { Kernel, KernelInternalOptions, KernelOptions } from "@interfere/react/internal/kernel";
|
|
6
|
+
import * as _$_interfere_types_sdk_identify0 from "@interfere/types/sdk/identify";
|
|
2
7
|
|
|
3
8
|
//#region src/instrument-client.d.ts
|
|
4
|
-
declare
|
|
9
|
+
declare const close: () => Promise<void>, consent: {
|
|
10
|
+
get(): _$_interfere_types_sdk_plugins_manifest0.ConsentState | null;
|
|
11
|
+
set(value?: _$_interfere_types_sdk_plugins_manifest0.ConsentState): void;
|
|
12
|
+
}, getKernel: () => _$_interfere_react_internal_kernel0.Kernel, getKernelOrNull: () => _$_interfere_react_internal_kernel0.Kernel | null, identity: {
|
|
13
|
+
get(): _$_interfere_types_sdk_identify0.IdentifyParams | null;
|
|
14
|
+
set(params: _$_interfere_types_sdk_identify0.IdentifyParams): Promise<void>;
|
|
15
|
+
}, init: (opts?: _$_interfere_react_internal_kernel0.KernelOptions) => Promise<_$_interfere_react_internal_kernel0.Kernel | null>, subscribeToKernel: (listener: () => void) => () => void;
|
|
5
16
|
//#endregion
|
|
6
|
-
export { type
|
|
17
|
+
export { type ConsentCategory, type ConsentState, type GateableCategory, type Kernel, type KernelInternalOptions, type KernelOptions, capture, close, consent, getKernel, getKernelOrNull, identity, init, span, subscribeToKernel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-client.d.mts","names":[],"sources":["../src/instrument-client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrument-client.d.mts","names":[],"sources":["../src/instrument-client.ts"],"mappings":";;;;;;;;cAuBE,KAAA,QAAK,OAAA,QAAA,OAAA;WAAA,wCAAA,CAAA,YAAA;;0DAEI,MAAA,EAAA,eAAA,QAAA,mCAAA,CACM,MAAA,SAAA,QAAA;WAAA,gCAAA,CAAA,cAAA;;YAEX,IAAA,uCAAA,aAAA,KAAA,OAAA,CAAA,mCAAA,CAAA,MAAA,UAAA,iBAAA,GACa,QAAA"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { PRODUCER_VERSION } from "./internal/version.mjs";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
}
|
|
2
|
+
import { createWrapperSingleton } from "@interfere/react/internal/wrapper-singleton";
|
|
3
|
+
import { capture, span } from "@interfere/react/api";
|
|
4
|
+
const { close, consent, getKernel, getKernelOrNull, identity, init, subscribeToKernel } = createWrapperSingleton({
|
|
5
|
+
producerVersion: PRODUCER_VERSION,
|
|
6
|
+
initEntryName: "instrumentation-client"
|
|
7
|
+
});
|
|
10
8
|
//#endregion
|
|
11
|
-
export { consent, init };
|
|
9
|
+
export { capture, close, consent, getKernel, getKernelOrNull, identity, init, span, subscribeToKernel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-client.mjs","names":[],"sources":["../src/instrument-client.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"instrument-client.mjs","names":[],"sources":["../src/instrument-client.ts"],"sourcesContent":["import { createWrapperSingleton } from \"@interfere/react/internal/wrapper-singleton\";\n\nimport { PRODUCER_VERSION } from \"./internal/version.js\";\n\n// biome-ignore lint/performance/noBarrelFile: customer-facing one-import surface — `@interfere/next` re-exports the runtime helpers so callers don't have to also import `@interfere/react/api`.\nexport { capture, span } from \"@interfere/react/api\";\nexport type {\n Kernel,\n KernelInternalOptions,\n KernelOptions,\n} from \"@interfere/react/internal/kernel\";\nexport type {\n ConsentCategory,\n ConsentState,\n GateableCategory,\n} from \"@interfere/types/sdk/plugins/manifest\";\n\nconst wrapper = createWrapperSingleton({\n producerVersion: PRODUCER_VERSION,\n initEntryName: \"instrumentation-client\",\n});\n\nexport const {\n close,\n consent,\n getKernel,\n getKernelOrNull,\n identity,\n init,\n subscribeToKernel,\n} = wrapper;\n"],"mappings":";;;AAsBA,MAAa,EACX,OACA,SACA,WACA,iBACA,UACA,MACA,sBAZc,uBAAuB;CACrC,iBAAiB;CACjB,eAAe;CAChB,CAUG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { init } from "./instrument-client.mjs";
|
|
2
|
+
//#region src/instrumentation-client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Side-effect entry for Next.js 15.3+ which auto-loads `instrumentation-client.ts`
|
|
5
|
+
* on every page load. Customer's `instrumentation-client.ts` becomes:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import "@interfere/next/instrumentation-client";
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* That single import boots the kernel with sensible defaults. Customers who
|
|
12
|
+
* need overrides can call `init({...})` from `@interfere/next` directly —
|
|
13
|
+
* `init()` is idempotent so the side-effect call here turns into a no-op.
|
|
14
|
+
*
|
|
15
|
+
* The `.catch` surfaces sync boot errors in dev — production swallows them
|
|
16
|
+
* (a misconfigured SDK shouldn't take the customer's app down).
|
|
17
|
+
*/
|
|
18
|
+
init().catch((error) => {
|
|
19
|
+
if (process.env["NODE_ENV"] !== "production") console.warn("[interfere] init() threw during boot", error);
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation-client.mjs","names":[],"sources":["../src/instrumentation-client.ts"],"sourcesContent":["import { init } from \"./instrument-client.js\";\n\n/**\n * Side-effect entry for Next.js 15.3+ which auto-loads `instrumentation-client.ts`\n * on every page load. Customer's `instrumentation-client.ts` becomes:\n *\n * ```ts\n * import \"@interfere/next/instrumentation-client\";\n * ```\n *\n * That single import boots the kernel with sensible defaults. Customers who\n * need overrides can call `init({...})` from `@interfere/next` directly —\n * `init()` is idempotent so the side-effect call here turns into a no-op.\n *\n * The `.catch` surfaces sync boot errors in dev — production swallows them\n * (a misconfigured SDK shouldn't take the customer's app down).\n */\ninit().catch((error: unknown) => {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n console.warn(\"[interfere] init() threw during boot\", error);\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,CAAC,OAAO,UAAmB;CAC/B,IAAI,QAAQ,IAAI,gBAAgB,cAC9B,QAAQ,KAAK,wCAAwC,MAAM;EAE7D"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ServerInstrumentationOptions } from "./internal/server/instrumentation-options.mjs";
|
|
2
|
+
import { PrerenderSafeIdGenerator } from "./internal/server/id-generator.mjs";
|
|
3
|
+
import { AttributeValue, TextMapPropagator } from "@opentelemetry/api";
|
|
4
|
+
import { Instrumentation } from "@opentelemetry/instrumentation";
|
|
5
|
+
import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
|
|
6
|
+
import { MetricReader } from "@opentelemetry/sdk-metrics";
|
|
7
|
+
import { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
8
|
+
|
|
9
|
+
//#region src/instrumentation.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Composable building blocks the Interfere SDK contributes to OTel —
|
|
12
|
+
* span / log / metric processors, baggage propagator, undici
|
|
13
|
+
* instrumentation, plus the resource attributes and side-effect
|
|
14
|
+
* installers (console bridge + remote-config fetch).
|
|
15
|
+
*
|
|
16
|
+
* Use this when you want to plug Interfere into an existing OTel
|
|
17
|
+
* bootstrap (e.g. `@vercel/otel`'s `registerOTel({...})`, DataDog's
|
|
18
|
+
* `dd-trace-js`, or any custom `NodeTracerProvider` setup) instead of
|
|
19
|
+
* the standalone `register()` path. The kit holds no global state and
|
|
20
|
+
* touches no global slots — composition is the consumer's job.
|
|
21
|
+
*
|
|
22
|
+
* The standalone `register()` builds the kit internally and wires it
|
|
23
|
+
* into private providers, so customer DX stays a one-liner export.
|
|
24
|
+
*
|
|
25
|
+
* Returns `null` when `INTERFERE_API_KEY` is unset — callers can spread
|
|
26
|
+
* `kit?.spanProcessors ?? []` without a no-op guard.
|
|
27
|
+
*/
|
|
28
|
+
interface InterfereOtelKit {
|
|
29
|
+
/**
|
|
30
|
+
* Patches `console.{debug,log,info,warn,error}` to also emit OTel
|
|
31
|
+
* `LogRecord`s via the global `LoggerProvider`. Caller is responsible
|
|
32
|
+
* for ensuring a `LoggerProvider` is registered globally before
|
|
33
|
+
* calling — `register()` handles this; for composed setups, call
|
|
34
|
+
* after your bootstrap (`registerOTel({...})` etc.) has run. Returns
|
|
35
|
+
* a disposer that restores the original `console.*` methods.
|
|
36
|
+
*/
|
|
37
|
+
enableConsoleBridge: () => () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Fetches the SDK's remote plugin config and caches it for the
|
|
40
|
+
* runtime. Customer code's `isPluginEnabled(...)` checks read from
|
|
41
|
+
* the cache. Safe to call repeatedly.
|
|
42
|
+
*/
|
|
43
|
+
fetchRemoteConfig: () => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Instrumentations the SDK ships. Currently `UndiciInstrumentation`
|
|
46
|
+
* pre-configured with `propagateContextUrls` / `ignoreUrls` semantics
|
|
47
|
+
* from `ServerInstrumentationOptions`.
|
|
48
|
+
*
|
|
49
|
+
* **Composition with `@vercel/otel`**: `instrumentations: ["auto"]`
|
|
50
|
+
* registers Vercel's `globalThis.fetch` wrapper, which only
|
|
51
|
+
* auto-propagates `traceparent` to Vercel deployment URLs — outbound
|
|
52
|
+
* fetches to a different origin (e.g. `in.interfere.com`) get a
|
|
53
|
+
* span but no header injection unless
|
|
54
|
+
* `instrumentationConfig.fetch.propagateContextUrls` is set, and
|
|
55
|
+
* even then it doesn't cover the lower-level undici dispatcher path
|
|
56
|
+
* Next.js route handlers use. Spread `kit.instrumentations` after
|
|
57
|
+
* `"auto"` to layer this UndiciInstrumentation on top — propagation
|
|
58
|
+
* extends to every outbound undici call (filtered via `ignoreUrls`).
|
|
59
|
+
* Risk of double span emission on overlapping call sites is bounded:
|
|
60
|
+
* Vercel's fetch wraps `globalThis.fetch`, this hooks the undici
|
|
61
|
+
* dispatcher one layer lower, so duplicates only appear when both
|
|
62
|
+
* paths actually fire on the same call.
|
|
63
|
+
*/
|
|
64
|
+
instrumentations: Instrumentation[];
|
|
65
|
+
logRecordProcessors: LogRecordProcessor[];
|
|
66
|
+
metricReaders: MetricReader[];
|
|
67
|
+
/**
|
|
68
|
+
* W3C baggage propagator. Trace context is intentionally *not*
|
|
69
|
+
* included — `@vercel/otel`'s `propagators: ["auto"]` already
|
|
70
|
+
* registers it, and standalone `register()` adds it itself when
|
|
71
|
+
* the global slot is empty. Composing this on top extends rather
|
|
72
|
+
* than overrides.
|
|
73
|
+
*/
|
|
74
|
+
propagators: TextMapPropagator[];
|
|
75
|
+
/**
|
|
76
|
+
* Pre-built resource attribute set. Pass into your provider's
|
|
77
|
+
* `Resource` directly, or into `@vercel/otel`'s `attributes` field
|
|
78
|
+
* (which merges with Vercel's own auto-detected `vercel.*` attrs).
|
|
79
|
+
*/
|
|
80
|
+
resourceAttributes: Record<string, AttributeValue>;
|
|
81
|
+
spanProcessors: SpanProcessor[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Pure factory — no global registration, no provider construction. Returns
|
|
85
|
+
* the OTel primitives the SDK contributes so a host bootstrap (Vercel,
|
|
86
|
+
* DataDog, custom) can compose them in.
|
|
87
|
+
*
|
|
88
|
+
* Returns `null` when `INTERFERE_API_KEY` isn't set, so callers can
|
|
89
|
+
* unconditionally spread `kit?.spanProcessors ?? []` in dev where the
|
|
90
|
+
* SDK isn't configured.
|
|
91
|
+
*/
|
|
92
|
+
declare function buildInterfereOtelKit(opts?: ServerInstrumentationOptions): InterfereOtelKit | null;
|
|
93
|
+
/**
|
|
94
|
+
* One-line server-side bootstrap for Next.js. Customers' `instrumentation.ts`
|
|
95
|
+
* becomes:
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* export { register } from "@interfere/next/instrumentation";
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* Or, with overrides:
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { register as base } from "@interfere/next/instrumentation";
|
|
105
|
+
* export const register = () => base({ serviceName: "@my-org/api" });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* Customers who already run another OTel bootstrap (`@vercel/otel`,
|
|
109
|
+
* DataDog `dd-trace-js`, custom `NodeTracerProvider`) should use
|
|
110
|
+
* `buildInterfereOtelKit({...})` instead and compose the returned
|
|
111
|
+
* processors / readers / propagators into their existing setup —
|
|
112
|
+
* see the kit's JSDoc for examples.
|
|
113
|
+
*
|
|
114
|
+
* Constructs private `NodeTracerProvider` / `LoggerProvider` /
|
|
115
|
+
* `MeterProvider` and registers them on the global slots. Last writer
|
|
116
|
+
* wins on the globals, so customers running another OTel bootstrap
|
|
117
|
+
* alongside this one will end up with whichever booted last; the kit
|
|
118
|
+
* path avoids that fight entirely.
|
|
119
|
+
*
|
|
120
|
+
* Wired against the Node OTel SDK (`NodeTracerProvider`,
|
|
121
|
+
* `AsyncLocalStorageContextManager`) — so this entry only ships into the
|
|
122
|
+
* `nodejs` runtime bundle. The Edge runtime gets the no-op stub at
|
|
123
|
+
* `instrumentation.edge.ts` via `package.json`'s `edge-light` /
|
|
124
|
+
* `workerd` export conditions.
|
|
125
|
+
*
|
|
126
|
+
* Idempotent — repeat calls (e.g. HMR) short-circuit on the
|
|
127
|
+
* module-scoped `registered` flag.
|
|
128
|
+
*
|
|
129
|
+
* Bails silently when `INTERFERE_API_KEY` is unset so dev runs without
|
|
130
|
+
* the SDK configured don't crash.
|
|
131
|
+
*/
|
|
132
|
+
declare function register(opts?: ServerInstrumentationOptions): Promise<void>;
|
|
133
|
+
//#endregion
|
|
134
|
+
export { InterfereOtelKit, PrerenderSafeIdGenerator, type ServerInstrumentationOptions, buildInterfereOtelKit, register };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.mts","names":[],"sources":["../src/instrumentation.ts"],"mappings":";;;;;;;;;;AAoFA;;;;;;;;;;;;;;;;;UAAiB,gBAAA;EAqCf;;;;;;;;EA5BA,mBAAA;EA4CA;;;;AAYF;EAlDE,iBAAA,QAAyB,OAAA;;;;;;;;AA0M3B;;;;;;;;;;;;;EArLE,gBAAA,EAAkB,eAAA;EAClB,mBAAA,EAAqB,kBAAA;EACrB,aAAA,EAAe,YAAA;;;;;;;;EAQf,WAAA,EAAa,iBAAA;;;;;;EAMb,kBAAA,EAAoB,MAAA,SAAe,cAAA;EACnC,cAAA,EAAgB,aAAA;AAAA;;;;;;;;;;iBAYF,qBAAA,CACd,IAAA,GAAM,4BAAA,GACL,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsJmB,QAAA,CACpB,IAAA,GAAM,4BAAA,GACL,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ServerInstrumentationOptions } from "./internal/server/instrumentation-options.mjs";
|
|
2
|
+
import { InterfereOtelKit } from "./instrumentation.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/instrumentation.edge.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Edge-runtime entry for `@interfere/next/instrumentation`. Selected by
|
|
7
|
+
* `package.json`'s `edge-light` / `workerd` / `worker` export conditions
|
|
8
|
+
* — Next.js + Vercel pick this bundle when compiling
|
|
9
|
+
* `instrumentation.ts` for the Edge runtime.
|
|
10
|
+
*
|
|
11
|
+
* The Node entry (`instrumentation.ts`) is built around
|
|
12
|
+
* `NodeTracerProvider`, `AsyncLocalStorageContextManager`, undici
|
|
13
|
+
* instrumentation, and a console→OTel bridge — none of which work in
|
|
14
|
+
* the Edge runtime. Pulling that import graph into an Edge bundle would
|
|
15
|
+
* (a) trip Next's `node:*`-in-edge warnings (release-slug derivation
|
|
16
|
+
* uses `node:child_process` + `node:crypto`) and (b) crash on module
|
|
17
|
+
* load if the Edge bundle were ever actually invoked.
|
|
18
|
+
*
|
|
19
|
+
* Both `register()` and `buildInterfereOtelKit()` are exported as
|
|
20
|
+
* no-op stubs so customer TypeScript code compiles unchanged
|
|
21
|
+
* regardless of which runtime the file ends up in. Edge-runtime
|
|
22
|
+
* tracing (middleware spans, edge route handlers) needs an
|
|
23
|
+
* `@opentelemetry/sdk-trace-base`-based pipeline with a fetch-based
|
|
24
|
+
* exporter — tracked separately.
|
|
25
|
+
*/
|
|
26
|
+
declare function register(_opts?: ServerInstrumentationOptions): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Edge stub for the kit factory. Returns `null` so callers spreading
|
|
29
|
+
* `kit?.spanProcessors ?? []` into a host bootstrap behave as if the
|
|
30
|
+
* SDK is unconfigured — same shape as the Node entry returns when
|
|
31
|
+
* `INTERFERE_API_KEY` is unset.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildInterfereOtelKit(_opts?: ServerInstrumentationOptions): null;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type InterfereOtelKit, type ServerInstrumentationOptions, buildInterfereOtelKit, register };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.edge.d.mts","names":[],"sources":["../src/instrumentation.edge.ts"],"mappings":";;;;;AA0BA;;;;;;;;;AAYA;;;;;;;;;;;iBAZsB,QAAA,CACpB,KAAA,GAAO,4BAAA,GACN,OAAA;;;;;;;iBAUa,qBAAA,CACd,KAAA,GAAO,4BAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/instrumentation.edge.ts
|
|
2
|
+
/**
|
|
3
|
+
* Edge-runtime entry for `@interfere/next/instrumentation`. Selected by
|
|
4
|
+
* `package.json`'s `edge-light` / `workerd` / `worker` export conditions
|
|
5
|
+
* — Next.js + Vercel pick this bundle when compiling
|
|
6
|
+
* `instrumentation.ts` for the Edge runtime.
|
|
7
|
+
*
|
|
8
|
+
* The Node entry (`instrumentation.ts`) is built around
|
|
9
|
+
* `NodeTracerProvider`, `AsyncLocalStorageContextManager`, undici
|
|
10
|
+
* instrumentation, and a console→OTel bridge — none of which work in
|
|
11
|
+
* the Edge runtime. Pulling that import graph into an Edge bundle would
|
|
12
|
+
* (a) trip Next's `node:*`-in-edge warnings (release-slug derivation
|
|
13
|
+
* uses `node:child_process` + `node:crypto`) and (b) crash on module
|
|
14
|
+
* load if the Edge bundle were ever actually invoked.
|
|
15
|
+
*
|
|
16
|
+
* Both `register()` and `buildInterfereOtelKit()` are exported as
|
|
17
|
+
* no-op stubs so customer TypeScript code compiles unchanged
|
|
18
|
+
* regardless of which runtime the file ends up in. Edge-runtime
|
|
19
|
+
* tracing (middleware spans, edge route handlers) needs an
|
|
20
|
+
* `@opentelemetry/sdk-trace-base`-based pipeline with a fetch-based
|
|
21
|
+
* exporter — tracked separately.
|
|
22
|
+
*/
|
|
23
|
+
async function register(_opts = {}) {}
|
|
24
|
+
/**
|
|
25
|
+
* Edge stub for the kit factory. Returns `null` so callers spreading
|
|
26
|
+
* `kit?.spanProcessors ?? []` into a host bootstrap behave as if the
|
|
27
|
+
* SDK is unconfigured — same shape as the Node entry returns when
|
|
28
|
+
* `INTERFERE_API_KEY` is unset.
|
|
29
|
+
*/
|
|
30
|
+
function buildInterfereOtelKit(_opts = {}) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { buildInterfereOtelKit, register };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.edge.mjs","names":[],"sources":["../src/instrumentation.edge.ts"],"sourcesContent":["import type { ServerInstrumentationOptions } from \"./internal/server/instrumentation-options.js\";\n\nexport type { InterfereOtelKit } from \"./instrumentation.js\";\nexport type { ServerInstrumentationOptions } from \"./internal/server/instrumentation-options.js\";\n\n/**\n * Edge-runtime entry for `@interfere/next/instrumentation`. Selected by\n * `package.json`'s `edge-light` / `workerd` / `worker` export conditions\n * — Next.js + Vercel pick this bundle when compiling\n * `instrumentation.ts` for the Edge runtime.\n *\n * The Node entry (`instrumentation.ts`) is built around\n * `NodeTracerProvider`, `AsyncLocalStorageContextManager`, undici\n * instrumentation, and a console→OTel bridge — none of which work in\n * the Edge runtime. Pulling that import graph into an Edge bundle would\n * (a) trip Next's `node:*`-in-edge warnings (release-slug derivation\n * uses `node:child_process` + `node:crypto`) and (b) crash on module\n * load if the Edge bundle were ever actually invoked.\n *\n * Both `register()` and `buildInterfereOtelKit()` are exported as\n * no-op stubs so customer TypeScript code compiles unchanged\n * regardless of which runtime the file ends up in. Edge-runtime\n * tracing (middleware spans, edge route handlers) needs an\n * `@opentelemetry/sdk-trace-base`-based pipeline with a fetch-based\n * exporter — tracked separately.\n */\nexport async function register(\n _opts: ServerInstrumentationOptions = {}\n): Promise<void> {\n // Intentionally empty. See file header for the design rationale.\n}\n\n/**\n * Edge stub for the kit factory. Returns `null` so callers spreading\n * `kit?.spanProcessors ?? []` into a host bootstrap behave as if the\n * SDK is unconfigured — same shape as the Node entry returns when\n * `INTERFERE_API_KEY` is unset.\n */\nexport function buildInterfereOtelKit(\n _opts: ServerInstrumentationOptions = {}\n): null {\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0BA,eAAsB,SACpB,QAAsC,EAAE,EACzB;;;;;;;AAUjB,SAAgB,sBACd,QAAsC,EAAE,EAClC;CACN,OAAO"}
|