Skip to content

feat: define reporting service contracts and dispatchers#1224

Merged
alexs-mparticle merged 16 commits intodevelopmentfrom
feat/reporting-service-migration-core
Apr 6, 2026
Merged

feat: define reporting service contracts and dispatchers#1224
alexs-mparticle merged 16 commits intodevelopmentfrom
feat/reporting-service-migration-core

Conversation

@alexs-mparticle
Copy link
Copy Markdown
Collaborator

@alexs-mparticle alexs-mparticle commented Mar 20, 2026

Summary

  • Defines IErrorReportingService and ILoggingService interfaces in src/reporting/types.ts
  • Adds ErrorReportingDispatcher and LoggingDispatcher for multi-service fan-out
  • Decouples Logger from reporting — Logger is now console-only
  • Removes concrete ReportingLogger implementation (moves to Rokt kit)
  • Removes Rokt-specific URLs from constants
  • Renames src/logging/ to src/reporting/
  • Exposes registerErrorReportingService() and registerLoggingService() on mParticle API

Companion kit PR: mparticle-integrations/mparticle-javascript-integration-rokt#70

Test plan

  • Lint, build, Jest tests pass (495 tests)
  • Verify registration APIs exposed on window.mParticle
  • Verify Logger.error() no longer triggers remote reporting

…dule

- Define IErrorReportingService, ILoggingService, ISDKError, ISDKLogEntry contracts
- Add ErrorReportingDispatcher and LoggingDispatcher for multi-service fan-out
- Decouple Logger from reporting (console-only now)
- Remove concrete ReportingLogger implementation (moves to kit)
- Remove Rokt-specific URLs from constants
- Rename src/logging/ to src/reporting/
- Expose registerErrorReportingService/registerLoggingService on mParticle API
@alexs-mparticle alexs-mparticle requested a review from a team as a code owner March 20, 2026 20:45
@cursor
Copy link
Copy Markdown

cursor bot commented Mar 20, 2026

PR Summary

Medium Risk
Refactors error/log reporting by removing the built-in remote ReportingLogger and introducing dispatcher-based integrations, which can change what gets reported and when. Also adds new public registration APIs and adjusts identity/Rokt flows to emit structured reports, so integration regressions are possible.

Overview
Introduces a new pluggable reporting layer: adds IErrorReportingService/ILoggingService contracts plus ErrorReportingDispatcher and LoggingDispatcher to fan out structured errors/log entries to registered services.

Decouples Logger to be console-only (removes ReportingLogger and its tests), removes Rokt-specific loggingUrl/errorUrl config and default/CNAME constants, and updates identity and Rokt paths to explicitly call the error dispatcher for identity request failures and identity mismatch warnings.

Exposes _registerErrorReportingService and _registerLoggingService on mParticle/instance manager, wires dispatchers into mp-instance init/reset flows, and updates tests accordingly.

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

@alexs-mparticle alexs-mparticle marked this pull request as draft March 20, 2026 20:55
- Add optional chaining for _ErrorReportingDispatcher in identityApiClient
  so tests without a mock dispatcher don't crash
- Add registerErrorReportingService and registerLoggingService to the
  expected public API keys in instance manager test
…ning

Reverts optional chaining on _ErrorReportingDispatcher.report() which
was masking potential bugs. Instead, properly adds ErrorReportingDispatcher
instances to all mock mpInstance objects in identity API client tests.
…uctor

- Wrap each service call in try-catch in ErrorReportingDispatcher and
  LoggingDispatcher so one failing service doesn't break fan-out
- Move dispatcher instantiation from runPreConfigFetchInitialization to
  mParticleInstance constructor so registration works before init()
- Destructure errorReporter in identityApiClient for cleaner usage
Rename registerErrorReportingService/registerLoggingService to
_registerErrorReportingService/_registerLoggingService to signal
these are internal APIs consumed by kits, not public.
Pass ErrorReportingDispatcher and LoggingDispatcher into RoktManager.init()
from mp-instance. Add INFO log on kit attach (ROKT_KIT_ATTACHED) and
WARNING reports on identity mismatch (IDENTITY_MISMATCH) alongside
existing logger.warning calls. Add new error codes to reporting types.
… mocks

The identity API client test mocks were missing _ErrorReportingDispatcher,
causing a TypeError when report() was called on 5xx errors. Added optional
chaining to the call site and added the mock to both test cases.
@alexs-mparticle alexs-mparticle marked this pull request as ready for review March 24, 2026 15:12
Merge development into feat/reporting-service-migration-core,
resolving conflicts in dist/ bundle files by accepting development's
versions (CI will regenerate these after merge).
Copy link
Copy Markdown
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

minor nits

rmi22186 and others added 2 commits April 3, 2026 15:21
The TODO indicated this cast should be removed once removeCCPAState was
removed. Since removeCCPAState is being removed in this PR, the cast is
no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 2 potential issues.

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.

- Remove redundant "Logger.error() does not trigger any reporting" test
  that only asserted not.toThrow() (decoupling already proven by next test)
- Replace assertion-less no-op tests with proper assertions that create
  mock services, intentionally skip registration, and verify they are
  not called
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 6, 2026

@alexs-mparticle alexs-mparticle requested a review from rmi22186 April 6, 2026 18:03
@alexs-mparticle alexs-mparticle merged commit 79184e0 into development Apr 6, 2026
28 of 33 checks passed
@alexs-mparticle alexs-mparticle deleted the feat/reporting-service-migration-core branch April 6, 2026 18:08
github-actions bot pushed a commit that referenced this pull request Apr 7, 2026
# [2.61.0](v2.60.1...v2.61.0) (2026-04-07)

### Bug Fixes

* Coerce event name to string ([#1234](#1234)) ([fc40e4b](fc40e4b))

### Features

* add /verify skill for lint, build, and test validation ([#1222](#1222)) ([fc744e8](fc744e8))
* define reporting service contracts and dispatchers ([#1224](#1224)) ([79184e0](79184e0))
@mparticle-automation
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.61.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants