Skip to content

feat: add side-effect-free startView API for manual page views - #96

Closed
parker-edwards wants to merge 9 commits into
dash0hq:mainfrom
parker-edwards:feat/start-view
Closed

feat: add side-effect-free startView API for manual page views#96
parker-edwards wants to merge 9 commits into
dash0hq:mainfrom
parker-edwards:feat/start-view

Conversation

@parker-edwards

@parker-edwards parker-edwards commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What

Adds a side-effect-free startView(nameOrOptions) API for manually recording page views. This replaces #93 (closed), split per feature at the reviewing team's request — this is part 1 of 3, and it is fully independent of the other two (#97 XHR instrumentation, #98 interaction instrumentation).

Why

I work with single-page applications that the automatic page-view instrumentation cannot fully cover — for example, an Electron-style SPA served from one root URL: every screen reports as /, and the app owns its own router, so the SDK must not touch history/location.

startView gives these apps manual page views that are indistinguishable downstream from automatic virtual page views (same browser.page_view event, same type value) without any navigation side effects.

How

  • startView accepts a string shorthand (startView("Checkout")) or an options object (name, optional url override). Exported from both the npm-package and script entrypoints.
  • It never calls history.pushState/replaceState and never mutates location. The emitted page view carries no change_state value (no history mutation occurred) but is otherwise identical to an automatic virtual page view.
  • A shared page-view log builder was extracted in instrumentations/navigation/event.ts so manual and automatic page views cannot drift.
  • Documented in INSTALL.md.

Testing

  • pnpm run ci (lint, prettier, unit tests, build): green — 272 unit tests across 19 files, including new coverage for start-view.ts and the extracted log builder.
  • New e2e spec 08-start-view (string shorthand, options object, url override, no-side-effect assertions, coexistence with automatic instrumentation): green locally via pnpm run test:e2e:local.

Notes for reviewers

This is my own initiative rather than a scheduled roadmap item — happy to adjust naming, semantics, or scope to fit your conventions.

🤖 Generated with Claude Code

thiemok added a commit that referenced this pull request Jul 24, 2026
…on (#99)

What

Adds XMLHttpRequest instrumentation (@dash0/xhr) — HTTP client spans and trace-context propagation for XHR, matching the existing fetch instrumentation. This replaces #93 (closed), split per feature at the reviewing team's request — this is part 2 of 3 and independent of the startView PR (#96); the interaction-instrumentation PR (#98) is stacked on top of this one.
Why

axios's default browser adapter uses XMLHttpRequest, so today axios/XHR-based applications get no HTTP spans and no traceparent header — their frontend telemetry never joins backend traces.
How

    New @dash0/xhr instrumentation name, enabled by default alongside @dash0/fetch.
    First commit extracts the propagator/error helpers from fetch.ts into http/utils.ts, so fetch and XHR share one propagation code path (traceparent, X-Ray, propagators config, CORS URL allow-lists) — no behavior change for fetch.
    XHR spans cover the full lifecycle: success, error, timeout, and abort all end the span, and per-request event listeners are removed on completion to avoid leaks.
    Documented in INSTALL.md and the README feature list.
    axios is added as a devDependency only, for the e2e spec.

---------

Co-authored-by: Parker Hyland <parker.hyland@dash0.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@thiemok

thiemok commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot for this contribution @parker-edwards! We've moved it to an in-repo branch as #101 so the e2e suite can run (fork PRs don't receive the LambdaTest secrets — same as #97#99). All of your commits are preserved there with authorship intact, with a few review follow-ups added on top (signature aligned with the sibling APIs as startView(name, opts?), malformed-input guarding for the script bridge, attribute-override semantics matching sendEvent, and extra test coverage). Closing this one in favor of #101.

@thiemok thiemok closed this Jul 24, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants