Skip to content

feat: capture page_url in events#1276

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

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

Conversation

@khushi1033
Copy link
Copy Markdown
Contributor

@khushi1033 khushi1033 commented Jun 1, 2026

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
Copy link
Copy Markdown

cursor Bot commented Jun 1, 2026

PR Summary

Medium Risk
Every event now includes the full browser URL, which can carry query-string PII until server-side sanitization; the change touches the core event upload path but is additive and optional on the wire.

Overview
This PR adds page URL capture on outgoing web SDK events so analytics can see where on the site each event fired.

@mparticle/event-models is bumped to ^1.3.0 (dev + peer), aligning with page_url on CommonEventData. The internal SDKEvent type gains optional PageUrl, set from window.location.href when events are built in createEventObject and for background application-state-transition events in batchUploader. convertBaseEventData maps PageUrlpage_url on every converted event payload.

Tests assert capture at event creation, page_url on converted batches (including AST), and that page_url is omitted when PageUrl is unset.

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

Comment thread src/serverModel.ts
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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
Comment thread package.json
"@babel/preset-typescript": "^7.6.0",
"@mparticle/data-planning-models": "^0.1.0",
"@mparticle/event-models": "^1.1.9",
"@mparticle/event-models": "^1.3.0",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see you're importing event-models but they don't look like they're being used.

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