@interfere/nest 0.0.1-canary.4 → 0.0.1-canary.5

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 CHANGED
@@ -1,26 +1,46 @@
1
1
  # @interfere/nest
2
2
 
3
- > **Status: canary.** Pre-1.0 API, expect breaking changes. Pin to a specific `10.0.0-canary.N` in CI.
4
-
5
- NestJS SDK for [Interfere](https://interfere.com). Wraps [`@interfere/node`](../node) with a global exception filter and OTel auto-instrumentation for controllers, guards, pipes, interceptors, and middleware.
3
+ NestJS SDK for [Interfere](https://interfere.com). Auto-captures uncaught exceptions and creates per-request spans for controllers, guards, pipes, interceptors, and middleware.
6
4
 
7
5
  ## Install
8
6
 
9
7
  ```sh
8
+ npm install @interfere/nest
9
+ # or
10
10
  bun add @interfere/nest
11
+ # or
12
+ pnpm add @interfere/nest
11
13
  ```
12
14
 
13
- ## Usage
15
+ ## Setup
16
+
17
+ The SDK uses two subpath imports to avoid loading `@nestjs/*` before instrumentation hooks are registered:
18
+
19
+ - `@interfere/nest/instrument` — SDK init, error capture, span utilities (no `@nestjs/*` imports)
20
+ - `@interfere/nest/module` — `InterfereModule` and `InterfereExceptionFilter` (imports `@nestjs/*`)
21
+
22
+ ### 1. Create `instrument.ts`
23
+
24
+ This file must be imported before any `@nestjs/*` module. It registers OTel instrumentation hooks that patch NestJS internals for automatic span creation.
14
25
 
15
26
  ```ts
16
- // instrument.ts — must run before @nestjs/core is imported
17
- import { init } from "@interfere/nest";
18
- init({ serviceName: "my-api", debug: true });
27
+ // src/instrument.ts
28
+ import { init } from "@interfere/nest/instrument";
29
+
30
+ init({
31
+ serviceName: "my-api",
32
+ debug: true, // logs init status and exporter results to stdout
33
+ });
19
34
  ```
20
35
 
36
+ `init()` is synchronous and works in both ESM and CJS projects.
37
+
38
+ ### 2. Import it first in `main.ts`
39
+
21
40
  ```ts
22
- // main.ts
41
+ // src/main.ts
23
42
  import "./instrument";
43
+
24
44
  import { NestFactory } from "@nestjs/core";
25
45
  import { AppModule } from "./app.module";
26
46
 
@@ -31,10 +51,14 @@ async function bootstrap() {
31
51
  bootstrap();
32
52
  ```
33
53
 
54
+ ### 3. Register the module in `app.module.ts`
55
+
56
+ `InterfereModule.forRoot()` registers a global exception filter that captures 5xx errors and uncaught throws. 4xx responses (client errors) are not reported — they still produce OTel request spans but don't create error events.
57
+
34
58
  ```ts
35
- // app.module.ts
59
+ // src/app.module.ts
36
60
  import { Module } from "@nestjs/common";
37
- import { InterfereModule } from "@interfere/nest";
61
+ import { InterfereModule } from "@interfere/nest/module";
38
62
 
39
63
  @Module({ imports: [InterfereModule.forRoot()] })
40
64
  export class AppModule {}
@@ -42,7 +66,11 @@ export class AppModule {}
42
66
 
43
67
  ## Build & Deploy
44
68
 
45
- Add a `postbuild` script so source maps are uploaded and the release is registered with the collector:
69
+ Install [`@interfere/cli`](../cli) as a dev dependency and add a `postbuild` script so source maps are uploaded and the release is registered with the collector. Without this step, the collector will reject spans from production deployments.
70
+
71
+ ```sh
72
+ npm install -D @interfere/cli
73
+ ```
46
74
 
47
75
  ```json
48
76
  {
@@ -53,11 +81,28 @@ Add a `postbuild` script so source maps are uploaded and the release is register
53
81
  }
54
82
  ```
55
83
 
84
+ The CLI derives the release slug from the same commit SHA the SDK uses at runtime (`INTERFERE_SOURCE_ID`, `GITHUB_SHA`, `VERCEL_GIT_COMMIT_SHA`, or `git rev-parse HEAD`). Both must see the same SHA for the slugs to match. See the [`@interfere/cli` README](../cli) for full options, Docker examples, and CI setup.
85
+
56
86
  ## Environment Variables
57
87
 
58
88
  | Variable | Where | Purpose |
59
89
  |---|---|---|
60
90
  | `INTERFERE_PUBLIC_KEY` | Runtime | Routes spans to your surface (`interfere_pk_*`) |
61
- | `INTERFERE_API_KEY` | CI / Build | Uploads source maps and registers releases (`interfere_ak_*`) |
91
+ | `INTERFERE_API_KEY` | CI / Build | Authenticates source map uploads and release registration (`interfere_ak_*`) |
92
+ | `INTERFERE_SOURCE_ID` | Both | Override the commit SHA used to derive the release slug. Falls back to `GITHUB_SHA`, `VERCEL_GIT_COMMIT_SHA`, or `git rev-parse HEAD`. |
93
+ | `INTERFERE_DEBUG` | Runtime | Set to `1` to enable debug logging without changing code. Equivalent to `debug: true` in `init()`. |
94
+
95
+ ## What gets captured
96
+
97
+ | Signal | When | Subpath |
98
+ |---|---|---|
99
+ | Request spans (middleware, guards, pipes, interceptors) | Every HTTP request | `@interfere/nest/instrument` |
100
+ | Error events (5xx, uncaught throws) | Exceptions that reach the global filter | `@interfere/nest/module` |
101
+ | Manual spans (`withSpan`, `captureError`) | Anywhere in your code | `@interfere/nest/instrument` |
102
+
103
+ ## Compatibility
62
104
 
63
- Full docs at <https://interfere.com/docs>.
105
+ - NestJS 10.x and 11.x
106
+ - Node.js >= 18.19.0
107
+ - Works with Express (default) and Fastify adapters
108
+ - CJS and ESM projects
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const require_init=require("./init.cjs");let _interfere_node=require("@interfere/node");Object.defineProperty(exports,"captureError",{enumerable:!0,get:function(){return _interfere_node.captureError}}),Object.defineProperty(exports,"captureMessage",{enumerable:!0,get:function(){return _interfere_node.captureMessage}}),Object.defineProperty(exports,"close",{enumerable:!0,get:function(){return _interfere_node.close}}),Object.defineProperty(exports,"flush",{enumerable:!0,get:function(){return _interfere_node.flush}}),exports.init=require_init.init,Object.defineProperty(exports,"withSpan",{enumerable:!0,get:function(){return _interfere_node.withSpan}});
@@ -0,0 +1,3 @@
1
+ import { InitOptions, init } from "./init.cjs";
2
+ import { CaptureErrorContext, captureError, captureMessage, close, flush, withSpan } from "@interfere/node";
3
+ export { type CaptureErrorContext, type InitOptions, captureError, captureMessage, close, flush, init, withSpan };
@@ -0,0 +1,3 @@
1
+ import { InitOptions, init } from "./init.mjs";
2
+ import { CaptureErrorContext, captureError, captureMessage, close, flush, withSpan } from "@interfere/node";
3
+ export { type CaptureErrorContext, type InitOptions, captureError, captureMessage, close, flush, init, withSpan };
@@ -0,0 +1 @@
1
+ import{init}from"./init.mjs";import{captureError,captureMessage,close,flush,withSpan}from"@interfere/node";export{captureError,captureMessage,close,flush,init,withSpan};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const require_exception_filter=require("./exception-filter.cjs"),require_module=require("./module.cjs");Object.defineProperty(exports,"InterfereExceptionFilter",{enumerable:!0,get:function(){return require_exception_filter.InterfereExceptionFilter}}),Object.defineProperty(exports,"InterfereModule",{enumerable:!0,get:function(){return require_module.InterfereModule}});
@@ -0,0 +1,3 @@
1
+ import { InterfereExceptionFilter } from "./exception-filter.cjs";
2
+ import { InterfereModule } from "./module.cjs";
3
+ export { InterfereExceptionFilter, InterfereModule };
@@ -0,0 +1,3 @@
1
+ import { InterfereExceptionFilter } from "./exception-filter.mjs";
2
+ import { InterfereModule } from "./module.mjs";
3
+ export { InterfereExceptionFilter, InterfereModule };
@@ -0,0 +1 @@
1
+ import{InterfereExceptionFilter}from"./exception-filter.mjs";import{InterfereModule}from"./module.mjs";export{InterfereExceptionFilter,InterfereModule};
package/dist/package.cjs CHANGED
@@ -1 +1 @@
1
- var name=`@interfere/nest`,version=`0.0.1-canary.4`;Object.defineProperty(exports,"name",{enumerable:!0,get:function(){return name}}),Object.defineProperty(exports,"version",{enumerable:!0,get:function(){return version}});
1
+ var name=`@interfere/nest`,version=`0.0.1-canary.5`;Object.defineProperty(exports,"name",{enumerable:!0,get:function(){return name}}),Object.defineProperty(exports,"version",{enumerable:!0,get:function(){return version}});
package/dist/package.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var name=`@interfere/nest`,version=`0.0.1-canary.4`;export{name,version};
1
+ var name=`@interfere/nest`,version=`0.0.1-canary.5`;export{name,version};
2
2
  //# sourceMappingURL=package.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interfere/nest",
3
- "version": "0.0.1-canary.4",
3
+ "version": "0.0.1-canary.5",
4
4
  "license": "MIT",
5
5
  "description": "NestJS SDK for Interfere. Auto-captures uncaught exceptions from controllers, providers, and middleware via a global ExceptionFilter, plus re-exports the @interfere/node OTel instrumentation.",
6
6
  "keywords": [
@@ -43,6 +43,28 @@
43
43
  "types": "./dist/index.d.cts",
44
44
  "default": "./dist/index.cjs"
45
45
  }
46
+ },
47
+ "./instrument": {
48
+ "monorepo": "./src/instrument.ts",
49
+ "import": {
50
+ "types": "./dist/instrument.d.mts",
51
+ "default": "./dist/instrument.mjs"
52
+ },
53
+ "require": {
54
+ "types": "./dist/instrument.d.cts",
55
+ "default": "./dist/instrument.cjs"
56
+ }
57
+ },
58
+ "./module": {
59
+ "monorepo": "./src/module-entry.ts",
60
+ "import": {
61
+ "types": "./dist/module-entry.d.mts",
62
+ "default": "./dist/module-entry.mjs"
63
+ },
64
+ "require": {
65
+ "types": "./dist/module-entry.d.cts",
66
+ "default": "./dist/module-entry.cjs"
67
+ }
46
68
  }
47
69
  },
48
70
  "sideEffects": false,
@@ -55,7 +77,7 @@
55
77
  "typecheck": "tsc --noEmit --incremental"
56
78
  },
57
79
  "dependencies": {
58
- "@interfere/node": "^0.0.1-canary.4",
80
+ "@interfere/node": "^0.0.1-canary.5",
59
81
  "@opentelemetry/api": "^1.9.1",
60
82
  "@opentelemetry/instrumentation": "^0.218.0",
61
83
  "@opentelemetry/instrumentation-nestjs-core": "^0.64.0"