Skip to content

feat: migrate reporting service contract from logging to reporting module#1221

Closed
alexs-mparticle wants to merge 5 commits intodevelopmentfrom
feat/reporting-service-migration-core
Closed

feat: migrate reporting service contract from logging to reporting module#1221
alexs-mparticle wants to merge 5 commits intodevelopmentfrom
feat/reporting-service-migration-core

Conversation

@alexs-mparticle
Copy link
Collaborator

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

Background

  • Migrates log reporting service into Rokt Web Kit to separate concerns
  • Defines contract for reporting services for future extensions

What Has Changed

  • 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

Screenshots/Video

  • {Include any screenshots or video demonstrating the new feature or fix, if applicable}

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)

…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 changed the base branch from master to development March 20, 2026 20:42
@alexs-mparticle alexs-mparticle marked this pull request as ready for review March 20, 2026 20:43
@alexs-mparticle alexs-mparticle requested a review from a team as a code owner March 20, 2026 20:43
@cursor
Copy link

cursor bot commented Mar 20, 2026

PR Summary

Medium Risk
Medium risk because it removes the existing ReportingLogger network reporting path and changes how identity failures are surfaced, while also adding new public registration APIs that integrations may start depending on.

Overview
Refactors SDK reporting/logging to separate concerns. Removes the concrete ReportingLogger (and its Rokt-specific /v1/log and /v1/errors endpoints) and makes Logger console-only.

Introduces reporting contracts (IErrorReportingService, ILoggingService, ISDKError, ISDKLogEntry) plus ErrorReportingDispatcher/LoggingDispatcher fan-out dispatchers, and wires them into the instance lifecycle.

Updates error handling in identityApiClient to call Logger.error() plus mpInstance._ErrorReportingDispatcher.report(...), and exposes registerErrorReportingService/registerLoggingService on the public mParticle API; tests are updated accordingly.

Written by Cursor Bugbot for commit 4adf5fa. This will update automatically on new commits. Configure here.


public report(error: ISDKError): void {
this.services.forEach(s => s.report(error));
}
Copy link

Choose a reason for hiding this comment

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

Dispatcher fan-out lacks error isolation between services

Medium Severity

ErrorReportingDispatcher.report() and LoggingDispatcher.log() iterate over registered services via forEach without any try-catch. If any externally registered service throws, subsequent services are skipped and the exception propagates to the caller. In identityApiClient.ts, report() is called inside a catch block before critical operations like processQueueOnIdentityFailure and invokeCallback — a throwing service would cause those to be silently skipped. The removed ReportingLogger had internal try-catch preventing this.

Additional Locations (2)
Fix in Cursor Fix in Web

- 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
@sonarqubecloud
Copy link

@alexs-mparticle
Copy link
Collaborator Author

Duplicate of #1224

@alexs-mparticle alexs-mparticle marked this as a duplicate of #1224 Mar 20, 2026
Copy link

@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.

There are 2 total unresolved issues (including 1 from previous review).

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.


this.registerLoggingService = function(service: ILoggingService) {
self._LoggingDispatcher.register(service);
};
Copy link

Choose a reason for hiding this comment

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

Register methods crash when called before init

High Severity

registerErrorReportingService and registerLoggingService access self._ErrorReportingDispatcher and self._LoggingDispatcher directly without null guards, but these dispatchers are only created inside runPreConfigFetchInitialization (called during init()). Calling either registration method before init() throws a TypeError. Other public API methods in this file (e.g., setAppVersion, _setWrapperSDKInfo) use queueIfNotInitialized to handle this scenario, but the new methods do not.

Additional Locations (1)
Fix in Cursor Fix in Web

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