Skip to content

feat: export error helpers and a browser-safe ./scrub entry - #2

Merged
victor-carv merged 3 commits into
mainfrom
feat/export-error-helpers
Oct 13, 2026
Merged

victor-carv merged 3 commits into
mainfrom
feat/export-error-helpers

Conversation

@victor-carv

@victor-carv victor-carv commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Exports two helpers from the main entry so an app can send a scrubbed error to its own error tracker, and adds a browser-safe ./scrub entry for client-side redaction. Backbone's PostHog reporter needs them when it moves onto this package. Their behaviour does not change, and the version becomes 0.1.1.

  • serializeError(value): the same scrubbed error shape log exports under err. It serializes one error value, scrubs the message and stack, keeps only allowlisted fields, and never throws.
  • traceLogFields(): the active span's trace_id and span_id, or {} when there is no valid active span.
  • ./scrub, a new browser-safe entry: scrubMessage, scrubErrorText and stripQuery (the same function objects the server uses), plus TOKEN_PATH_TEMPLATES (frozen) and templateUrlPath. Backbone's web app redacts PostHog events with these instead of keeping its own copies, so the browser and server scrubs cannot drift. stripQuery moved unchanged into a pure module, and redact.ts re-exports it.

Testing

  • pnpm typecheck passes.
  • pnpm test: 39 files, 956 tests, all passing. The new tests compare serializeError with log's real err record, assert that the SSN and password value are absent, and check traceLogFields with a valid span, no span and an invalid span context. The import-graph test proves ./scrub loads no Node or OTel module, including side-effect imports; a same-object test proves its exports are the server's functions; and a freeze test proves TOKEN_PATH_TEMPLATES cannot be changed.
  • pnpm build matches the committed dist/.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@victor-carv

Copy link
Copy Markdown
Member Author

QA Check Report — codelittinc/otel-node feat/export-error-helpers (134dcf5..3d758fa)

Risk level: LOW

12 files, 72 insertions and 8 deletions. Most of that is dist/ regenerated from the source change. No escalations.

Spec discipline

  • Yes. Backbone's PostHog error reporter needs the package's scrubbed error serializer and trace-id helper. Ruling R219 amends the package's API list.

Complexity

  • Two re-exports, JSDoc, one new test file, version 0.1.1, one README row. No logic changes. No rework signals; this is the first touch of these files since v0.1.0.

Test integrity

  • No test changed or removed.
  • New tests (RED 3/3 before the exports):
    • serializeError output equals log's err field for the same Error, with the SSN and password value asserted absent.
    • traceLogFields returns the active span's ids, {} with no span, and {} with an invalid span context. The last case was mutation-checked.

Dependency provenance

  • No dependency changed. package.json changes only version.

Validation gaps

  • None. serializeError never throws; traceLogFields returns {} when there is nothing to report.

AI-specific concerns

  • None. The JSDoc matches the code after review: unlisted fields are dropped, and it serializes one error value.

Contract compliance

  • The exports are typed, and the main entry's .d.ts names no optional peer (guarded by types-without-bullmq.test.ts).

Architecture violations

  • None. This widens no PII surface: the same function backs log's err, and it has no mode or flag argument.

Recommended actions

  1. Merge, tag v0.1.1, and pin Backbone to the merged SHA.

@victor-carv
victor-carv marked this pull request as ready for review October 13, 2026 13:26
@victor-carv
victor-carv marked this pull request as draft October 13, 2026 14:02
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@victor-carv victor-carv changed the title feat: export serializeError and traceLogFields feat: export error helpers and a browser-safe ./scrub entry Oct 13, 2026
@victor-carv

Copy link
Copy Markdown
Member Author

QA Check Report — codelittinc/otel-node feat/export-error-helpers (134dcf5..623433e)

Risk level: LOW

12 files, 72 insertions and 8 deletions. Most of that is dist/ regenerated from the source change. No escalations.

Spec discipline

  • Yes. Backbone's PostHog error reporter needs the package's scrubbed error serializer and trace-id helper. Ruling R219 amends the package's API list.

Complexity

  • Two re-exports, JSDoc, one new test file, version 0.1.1, one README row. No logic changes. No rework signals; this is the first touch of these files since v0.1.0.

Test integrity

  • No test changed or removed.
  • New tests (RED 3/3 before the exports):
    • serializeError output equals log's err field for the same Error, with the SSN and password value asserted absent.
    • traceLogFields returns the active span's ids, {} with no span, and {} with an invalid span context. The last case was mutation-checked.

Dependency provenance

  • No dependency changed. package.json changes only version.

Validation gaps

  • None. serializeError never throws; traceLogFields returns {} when there is nothing to report.

AI-specific concerns

  • None. The JSDoc matches the code after review: unlisted fields are dropped, and it serializes one error value.

Contract compliance

  • The exports are typed, and the main entry's .d.ts names no optional peer (guarded by types-without-bullmq.test.ts).

Architecture violations

  • None. This widens no PII surface: the same function backs log's err, and it has no mode or flag argument.

Second commit: ./scrub

  • A browser-safe entry that re-exports the server's own scrub functions. The import-graph test covers side-effect imports, the same-object test asserts identity, and TOKEN_PATH_TEMPLATES is frozen and tested. stripQuery's body is unchanged after the move to strip-query.ts. Reviewed: Approved.

Recommended actions

  1. Merge, tag v0.1.1, and pin Backbone to the merged SHA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@victor-carv

Copy link
Copy Markdown
Member Author

QA Check Report — codelittinc/otel-node feat/export-error-helpers (134dcf5..cb5723c)

Risk level: LOW

12 files, 72 insertions and 8 deletions. Most of that is dist/ regenerated from the source change. No escalations.

Spec discipline

  • Yes. Backbone's PostHog error reporter needs the package's scrubbed error serializer and trace-id helper. Ruling R219 amends the package's API list.

Complexity

  • Two re-exports, JSDoc, one new test file, version 0.1.1, one README row. No logic changes. No rework signals; this is the first touch of these files since v0.1.0.

Test integrity

  • No test changed or removed.
  • New tests (RED 3/3 before the exports):
    • serializeError output equals log's err field for the same Error, with the SSN and password value asserted absent.
    • traceLogFields returns the active span's ids, {} with no span, and {} with an invalid span context. The last case was mutation-checked.

Dependency provenance

  • No dependency changed. package.json changes only version.

Validation gaps

  • None. serializeError never throws; traceLogFields returns {} when there is nothing to report.

AI-specific concerns

  • None. The JSDoc matches the code after review: unlisted fields are dropped, and it serializes one error value.

Contract compliance

  • The exports are typed, and the main entry's .d.ts names no optional peer (guarded by types-without-bullmq.test.ts).

Architecture violations

  • None. This widens no PII surface: the same function backs log's err, and it has no mode or flag argument.

Second commit: ./scrub

  • A browser-safe entry that re-exports the server's own scrub functions. The import-graph test covers side-effect imports, the same-object test asserts identity, and TOKEN_PATH_TEMPLATES is frozen and tested. stripQuery's body is unchanged after the move to strip-query.ts. Reviewed: Approved.

Recommended actions

  1. Merge, tag v0.1.1, and pin Backbone to the merged SHA.

Third commit

  • test: give the compiler-API type checks a CI-sized timeout: the two type tests timed out at 5 s on the runner, and now use 60 s with unchanged assertions.

@victor-carv
victor-carv marked this pull request as ready for review October 13, 2026 14:20
@victor-carv
victor-carv merged commit 57cddbc into main Oct 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant