Skip to content

feat: capture page_url in events#1276

Open
khushi1033 wants to merge 3 commits into
developmentfrom
feat/page-url-capture
Open

feat: capture page_url in events#1276
khushi1033 wants to merge 3 commits into
developmentfrom
feat/page-url-capture

Conversation

@khushi1033

@khushi1033 khushi1033 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Background

  • Events currently don't capture page_url, so we have no visibility into where on a site an event was fired.
  • This PR adds the capability to capture page_url from the client, and is related to PR1 and PR2— the mPServer PRs that handles the new field on the backend, propagating, sanitizing, and gating it for safety in case the URL contains PII.

What Has Changed

  • Bumped @mparticle/event-models to ^1.3.0 (adds page_url?: string on CommonEventData).
  • Added optional PageUrl?: string to the internal SDKEvent interface.
  • Captured on the standard createEventObject path and on the createBackgroundASTEvent path. External callers using the toEventAPIObject escape hatch own the full event shape and are not modified
  • convertBaseEventData maps sdkEvent.PageUrlpage_url in the events-API payload.
  • New tests cover converter mapping (set + omitted) and capture-time behavior; existing fixtures left as-is since PageUrl is optional.

Screenshots/Video

Screenshot 2026-06-01 at 9 45 55 AM

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • {Any additional information or context relevant to this PR}

Reference Issue (For employees only. Ignore if you are an outside contributor)

@khushi1033 khushi1033 changed the base branch from master to development June 1, 2026 13:24
@khushi1033 khushi1033 marked this pull request as ready for review June 1, 2026 13:58
@khushi1033 khushi1033 requested a review from a team as a code owner June 1, 2026 13:58
@cursor

cursor Bot commented Jun 1, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Every event may now carry full page URLs (potential query-string PII) until server-side sanitization/gating in related mPServer work; scope is additive across the main upload path but not security-critical infrastructure.

Overview
Adds page URL capture on the web SDK event pipeline so uploaded batches include where each event was fired, aligned with @mparticle/event-models 1.3.0 (page_url on common event data).

PageUrl is set on internal SDKEvent objects when events are built via createEventObject and on background application-state-transition events via getHref() (current window.location.href). convertBaseEventData maps that field to page_url in the events API payload. Dev/peer dependency on @mparticle/event-models is bumped from ^1.1.9 to ^1.3.0.

Tests assert capture at event creation, page_url on converted AST events, and converter behavior when PageUrl is present vs omitted.

Reviewed by Cursor Bugbot for commit 338cc8b. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/serverModel.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f5a180. Configure here.

Comment thread src/serverModel.ts Outdated
Comment thread package.json
Comment thread src/serverModel.ts Outdated
Comment thread dist/types/src/kitBlocking.d.ts Outdated
Comment thread src/batchUploader.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
44.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

2 participants