bugstack-sdk 2.2.1 → 2.3.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +139 -96
  2. package/README.md +496 -421
  3. package/bin/bugstack.cjs +6 -6
  4. package/dist/adapters/express/index.d.mts +2 -2
  5. package/dist/adapters/express/index.d.ts +2 -2
  6. package/dist/adapters/express/index.js +409 -43
  7. package/dist/adapters/express/index.js.map +1 -1
  8. package/dist/adapters/express/index.mjs +409 -43
  9. package/dist/adapters/express/index.mjs.map +1 -1
  10. package/dist/adapters/generic/index.d.mts +2 -2
  11. package/dist/adapters/generic/index.d.ts +2 -2
  12. package/dist/adapters/generic/index.js +457 -43
  13. package/dist/adapters/generic/index.js.map +1 -1
  14. package/dist/adapters/generic/index.mjs +454 -44
  15. package/dist/adapters/generic/index.mjs.map +1 -1
  16. package/dist/adapters/nextjs/index.d.mts +2 -2
  17. package/dist/adapters/nextjs/index.d.ts +2 -2
  18. package/dist/adapters/nextjs/index.js +409 -43
  19. package/dist/adapters/nextjs/index.js.map +1 -1
  20. package/dist/adapters/nextjs/index.mjs +409 -43
  21. package/dist/adapters/nextjs/index.mjs.map +1 -1
  22. package/dist/build/cli.js.map +1 -1
  23. package/dist/build/cli.mjs.map +1 -1
  24. package/dist/build/upload.js.map +1 -1
  25. package/dist/build/upload.mjs.map +1 -1
  26. package/dist/{client-DoqE7sNh.d.mts → client-B9WaTEYj.d.mts} +149 -2
  27. package/dist/{client-DoqE7sNh.d.ts → client-B9WaTEYj.d.ts} +149 -2
  28. package/dist/index.d.mts +2 -2
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +469 -55
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +466 -56
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/next-config/index.js.map +1 -1
  35. package/dist/next-config/index.mjs.map +1 -1
  36. package/package.json +107 -104
package/CHANGELOG.md CHANGED
@@ -1,96 +1,139 @@
1
- # Changelog
2
-
3
- All notable changes to `bugstack-sdk` are documented here.
4
- Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
-
6
- ## [2.2.1] — 2026-04-30
7
-
8
- ### Fixed
9
- - **`bugstack` CLI is now installed on the user's `PATH`.** In `2.2.0`,
10
- npm dropped the `bin[bugstack]` entry at publish time because the path
11
- was prefixed with `./`, so `npx bugstack sourcemaps upload` and global
12
- installs could not resolve the binary. Path normalized to
13
- `bin/bugstack.cjs`.
14
-
15
- ## [2.2.0] — 2026-04-29
16
-
17
- ### Added
18
- - **Source-map upload pipeline for production builds.** Customers can now
19
- upload server-side source maps to bugstack so the orchestrator resolves
20
- bundled stack frames (`.next/server/chunks/8393.js:1:8734`) back to
21
- source-file positions (`app/api/orders/route.ts:42:5`) — turning the
22
- "Could not identify primary file" failure mode into auto-fixable
23
- errors. Two-step setup:
24
- 1. Wrap your `next.config.js`:
25
- ```js
26
- const { withBugstack } = require('bugstack-sdk/next-config')
27
- module.exports = withBugstack({ /* your config */ })
28
- ```
29
- This enables `webpack.devtool = 'source-map'` for production
30
- server builds, preserving any existing webpack hook.
31
- 2. Append to your `build` script:
32
- ```json
33
- "build": "next build && bugstack sourcemaps upload"
34
- ```
35
- The CLI walks `.next/server/**/*.map`, uploads each with the
36
- active release identifier, and never fails the build.
37
- - New `bugstack` CLI binary (registered via `bin`) — `bugstack sourcemaps
38
- upload [--api-key X] [--release Y] [--endpoint Z] [--server-dir D]
39
- [--concurrency N] [--max-bytes N] [--quiet]`. Auto-detects release from
40
- `BUGSTACK_RELEASE`, `RENDER_GIT_COMMIT`, `VERCEL_GIT_COMMIT_SHA`,
41
- `GITHUB_SHA`, or `git rev-parse HEAD` in that order.
42
- - New programmatic API: `import { uploadSourceMaps } from 'bugstack-sdk/build'`
43
- for callers who want to invoke the uploader from a custom Node script
44
- rather than via the CLI.
45
- - New entry: `bugstack-sdk/next-config` exports `withBugstack(config,
46
- options?)` — the Next.js config wrapper. Idempotent and pass-through
47
- when `emitServerSourceMaps: false`.
48
-
49
- ### Internal
50
- - New tsup entries for `src/build/upload`, `src/build/cli`, and
51
- `src/next-config`. Bin stub at `bin/bugstack.cjs` requires the built
52
- CLI so the shebang concern stays in checked-in JavaScript and out of
53
- the bundler's hands.
54
-
55
- ## [2.1.0] — 2026-04-29
56
-
57
- ### Added
58
- - **Chunk-load error telemetry.** `ChunkLoadError` and the related family
59
- (`Loading chunk N failed`, `Loading CSS chunk N failed`,
60
- `Failed to fetch dynamically imported module`,
61
- `Importing a module script failed`) are now detected and routed to a
62
- lightweight telemetry endpoint instead of the main fix pipeline. They
63
- aren't real bugs (stale-tab artifacts after a redeploy) and have no
64
- source frames the orchestrator could fix, so they were wasting LLM
65
- cycles when they hit `/api/capture`. The new path lets the dashboard
66
- render a deploy-health spike detector while keeping the noise out of
67
- the bug feed.
68
- - New config option `dropChunkErrors` (default `false`) — set to `true`
69
- to disable telemetry forwarding entirely and silently discard chunk
70
- errors instead.
71
- - New config option `chunkErrorsEndpoint` (default auto-derived from the
72
- main `endpoint` — `/api/capture` becomes `/api/chunk-errors`). Override
73
- if your error service splits telemetry across hosts.
74
- - New exported helper `isChunkLoadError(error)` so callers can reuse the
75
- same detection logic in their own browser-side error boundaries (e.g.
76
- to soft-reload the page on first occurrence).
77
-
78
- ### Fixed
79
- - The wire header `X-BugStack-SDK-Version` reported `0.2.0` since pre-2.0,
80
- regardless of the actual installed version. Now injected at build time
81
- from `package.json` via `tsup`'s `define`, so it stays in sync on every
82
- release.
83
-
84
- ### Changed
85
- - Default behavior of `reportError` for chunk-load errors is now route-to-
86
- telemetry. Previously these went into the main capture pipeline (where
87
- they'd create unfixable rows the orchestrator would burn cycles on).
88
- This is a soft behavior change: customer code is unaffected, but the
89
- destination endpoint differs. Hosted customers (api.bugstack.ai) get
90
- the new endpoint automatically; self-hosted error-service deployments
91
- should pull the matching error-service release for the
92
- `/api/chunk-errors` ingest route.
93
-
94
- ## [2.0.2] — 2026-02-27
95
-
96
- Previous published baseline.
1
+ # Changelog
2
+
3
+ All notable changes to `bugstack-sdk` are documented here.
4
+ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+
6
+ ## [2.3.0] — 2026-11-23
7
+
8
+ ### Added
9
+ - **Caught-and-logged errors reach Bugstack.** A `catch` block that logs
10
+ an error with `console.error` and carries on was invisible: only uncaught
11
+ exceptions and the adapters' own wrappers reported anything. Once the
12
+ client is initialised, a `console.error` call carrying an `Error` (or a
13
+ string holding a stack trace) is now reported, anchored at the line that
14
+ logged it, with the original error as `metadata.causeName` /
15
+ `metadata.causeStack`. On by default; `captureConsoleErrors: false` turns
16
+ it off, and an options object tunes it (`messages`, `maxPerMinute`,
17
+ `repeatWindowMs`, `ignore`). The console line is written exactly as before.
18
+ Plain message lines, Node's process warnings and the SDK's own lines stay
19
+ console lines; forwards are capped at 20 a minute and once per site and
20
+ message per 5 minutes, then deduplicated by fingerprint as usual; logged
21
+ text is redacted with `redactFields`; forwarding never throws.
22
+ - **pino and winston.** `bugstackPinoHooks()` (pino `hooks`) and
23
+ `bugstackWinstonFormat()` (first in a winston format chain) forward
24
+ error-level logs under the same rules.
25
+ - **`markErrorReported(error)`** says an error was already sent, so the
26
+ console line for it is not sent again. The Next.js, Express and generic
27
+ adapters call it, so an error they report is not reported a second time
28
+ when the framework logs it. **`loggedErrorStats()`** returns forwarded and
29
+ dropped counts per rule.
30
+
31
+ ### Fixed
32
+ - **Windows paths are app frames.** The stack parser treated any file path
33
+ without a `/` as Node-internal, so on Windows no frame was an app frame and
34
+ `metadata.sourceLocation` was never set.
35
+
36
+ ## [2.2.2] — 2026-10-29
37
+
38
+ ### Fixed
39
+ - **Errors reach Bugstack without setting an endpoint.** The default
40
+ endpoint was `http://localhost:3001/api/capture`, so an app that did not
41
+ pass `endpoint` or set `BUGSTACK_ENDPOINT` reported nothing. It is now
42
+ `https://dashboard.bugstack.ai/api/ingest/sdk`, the ingest endpoint, which accepts this SDK's payload and its
43
+ `X-BugStack-API-Key` header. Source-map uploads derive
44
+ `https://dashboard.bugstack.ai/api/ingest/sdk/api/sourcemaps/upload` from it. An explicit `endpoint` or
45
+ `BUGSTACK_ENDPOINT` still wins.
46
+ - **The package's homepage is bugstack.ai.** npm listed the GitHub README
47
+ as the homepage; it now links to https://bugstack.ai.
48
+
49
+ ## [2.2.1] — 2026-04-30
50
+
51
+ ### Fixed
52
+ - **`bugstack` CLI is now installed on the user's `PATH`.** In `2.2.0`,
53
+ npm dropped the `bin[bugstack]` entry at publish time because the path
54
+ was prefixed with `./`, so `npx bugstack sourcemaps upload` and global
55
+ installs could not resolve the binary. Path normalized to
56
+ `bin/bugstack.cjs`.
57
+
58
+ ## [2.2.0] — 2026-04-29
59
+
60
+ ### Added
61
+ - **Source-map upload pipeline for production builds.** Customers can now
62
+ upload server-side source maps to Bugstack so the orchestrator resolves
63
+ bundled stack frames (`.next/server/chunks/8393.js:1:8734`) back to
64
+ source-file positions (`app/api/orders/route.ts:42:5`) — turning the
65
+ "Could not identify primary file" failure mode into auto-fixable
66
+ errors. Two-step setup:
67
+ 1. Wrap your `next.config.js`:
68
+ ```js
69
+ const { withBugstack } = require('bugstack-sdk/next-config')
70
+ module.exports = withBugstack({ /* your config */ })
71
+ ```
72
+ This enables `webpack.devtool = 'source-map'` for production
73
+ server builds, preserving any existing webpack hook.
74
+ 2. Append to your `build` script:
75
+ ```json
76
+ "build": "next build && bugstack sourcemaps upload"
77
+ ```
78
+ The CLI walks `.next/server/**/*.map`, uploads each with the
79
+ active release identifier, and never fails the build.
80
+ - New `bugstack` CLI binary (registered via `bin`) — `bugstack sourcemaps
81
+ upload [--api-key X] [--release Y] [--endpoint Z] [--server-dir D]
82
+ [--concurrency N] [--max-bytes N] [--quiet]`. Auto-detects release from
83
+ `BUGSTACK_RELEASE`, `RENDER_GIT_COMMIT`, `VERCEL_GIT_COMMIT_SHA`,
84
+ `GITHUB_SHA`, or `git rev-parse HEAD` in that order.
85
+ - New programmatic API: `import { uploadSourceMaps } from 'bugstack-sdk/build'`
86
+ for callers who want to invoke the uploader from a custom Node script
87
+ rather than via the CLI.
88
+ - New entry: `bugstack-sdk/next-config` exports `withBugstack(config,
89
+ options?)` — the Next.js config wrapper. Idempotent and pass-through
90
+ when `emitServerSourceMaps: false`.
91
+
92
+ ### Internal
93
+ - New tsup entries for `src/build/upload`, `src/build/cli`, and
94
+ `src/next-config`. Bin stub at `bin/bugstack.cjs` requires the built
95
+ CLI so the shebang concern stays in checked-in JavaScript and out of
96
+ the bundler's hands.
97
+
98
+ ## [2.1.0] — 2026-04-29
99
+
100
+ ### Added
101
+ - **Chunk-load error telemetry.** `ChunkLoadError` and the related family
102
+ (`Loading chunk N failed`, `Loading CSS chunk N failed`,
103
+ `Failed to fetch dynamically imported module`,
104
+ `Importing a module script failed`) are now detected and routed to a
105
+ lightweight telemetry endpoint instead of the main fix pipeline. They
106
+ aren't real bugs (stale-tab artifacts after a redeploy) and have no
107
+ source frames the orchestrator could fix, so they were wasting LLM
108
+ cycles when they hit `/api/capture`. The new path lets the dashboard
109
+ render a deploy-health spike detector while keeping the noise out of
110
+ the bug feed.
111
+ - New config option `dropChunkErrors` (default `false`) — set to `true`
112
+ to disable telemetry forwarding entirely and silently discard chunk
113
+ errors instead.
114
+ - New config option `chunkErrorsEndpoint` (default auto-derived from the
115
+ main `endpoint` — `/api/capture` becomes `/api/chunk-errors`). Override
116
+ if your error service splits telemetry across hosts.
117
+ - New exported helper `isChunkLoadError(error)` so callers can reuse the
118
+ same detection logic in their own browser-side error boundaries (e.g.
119
+ to soft-reload the page on first occurrence).
120
+
121
+ ### Fixed
122
+ - The wire header `X-BugStack-SDK-Version` reported `0.2.0` since pre-2.0,
123
+ regardless of the actual installed version. Now injected at build time
124
+ from `package.json` via `tsup`'s `define`, so it stays in sync on every
125
+ release.
126
+
127
+ ### Changed
128
+ - Default behavior of `reportError` for chunk-load errors is now route-to-
129
+ telemetry. Previously these went into the main capture pipeline (where
130
+ they'd create unfixable rows the orchestrator would burn cycles on).
131
+ This is a soft behavior change: customer code is unaffected, but the
132
+ destination endpoint differs. Hosted customers (api.bugstack.ai) get
133
+ the new endpoint automatically; self-hosted error-service deployments
134
+ should pull the matching error-service release for the
135
+ `/api/chunk-errors` ingest route.
136
+
137
+ ## [2.0.2] — 2026-02-27
138
+
139
+ Previous published baseline.