Skip to content

feat: add diagnostic logging for setter/selectPlacements timing - #130

Closed
alexs-mparticle wants to merge 2 commits into
developmentfrom
feat/diagnostic-setter-placement-timing
Closed

feat: add diagnostic logging for setter/selectPlacements timing#130
alexs-mparticle wants to merge 2 commits into
developmentfrom
feat/diagnostic-setter-placement-timing

Conversation

@alexs-mparticle

Copy link
Copy Markdown
Collaborator

Summary

  • Logs each attribute/identity setter call (setUserAttribute, removeUserAttribute, onUserIdentified, onLoginComplete, onLogoutComplete, onModifyComplete) via LoggingService.logDiagnostic() with the affected attribute keys (never values).
  • Logs each selectPlacements dispatch with the full set of placement attribute keys.
  • The two log calls are independent — no in-kit correlation or timing math. The delta between "attributes set" and "placement requested" is computed downstream using the logged timestamp-of-receipt and page URL that ReportingTransport already attaches to every log request.
  • logDiagnostic() ships at severity: "INFO" on the wire (same as log()) but under its own isolated rate-limit bucket, so a burst of setter/placement diagnostics can't starve the operational INFO budget shared with page-view/quota logging.
  • Only attribute keys are ever logged — never values — since setter payloads can carry customer PII and this ships over the network logging pipeline.

Example log messages

Rokt Kit: setUserAttribute called [attributeKeys=favoriteColor]
Rokt Kit: onUserIdentified called [attributeKeys=email,firstName,loyaltyTier]
Rokt Kit: selectPlacements dispatched [placementAttributeKeys=email,firstName,loyaltyTier,mpid]

Test plan

  • npm run lint passes
  • npm run build passes (pre-existing IUserIdentities/getMPID type errors reproduce identically on main — unrelated to this change)
  • npm run test — 340/340 passing, including new unit tests for diagnosticTiming.ts and integration coverage for every setter/identity call site and the selectPlacements dispatch

Logs attribute/identity setter calls (setUserAttribute, removeUserAttribute,
onUserIdentified, onLoginComplete, onLogoutComplete, onModifyComplete) and
selectPlacements dispatches independently via LoggingService, so the delta
between when attributes get set and when a placement call goes out can be
computed downstream from the logged timestamps and page URL.

Only attribute keys are logged, never values, to avoid shipping customer PII
into the logging pipeline. Diagnostic logs use their own rate-limit bucket
(still shipped at severity INFO) so they can't starve the operational INFO
budget shared with page-view/quota logging.
@alexs-mparticle
alexs-mparticle changed the base branch from main to development August 28, 2026 20:37
Reverts ReportingTransport.send() to its original signature and instead
gives LoggingService a dedicated ReportingTransport (its own RateLimiter,
reusing the existing optional constructor param) for logDiagnostic(), so
the rate-limit isolation lives entirely where it's needed instead of on
the shared send() method used by ErrorReportingService too.
@alexs-mparticle

Copy link
Copy Markdown
Collaborator Author

Superseded — the rokt kit now lives in the mparticle-web-sdk monorepo under kits/rokt. Relanded here: mParticle/mparticle-web-sdk#1386

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