Skip to content

feat: Migrate Logger to Typescript (#1120) SDKE-605#1141

Merged
gtamanaha merged 1 commit into
developmentfrom
feat/SDKE-605-migrate-logger-to-ts-cherry-pick
Jan 16, 2026
Merged

feat: Migrate Logger to Typescript (#1120) SDKE-605#1141
gtamanaha merged 1 commit into
developmentfrom
feat/SDKE-605-migrate-logger-to-ts-cherry-pick

Conversation

@gtamanaha

Copy link
Copy Markdown
Contributor

Background

Cherry pick from c48930e

As part of the ongoing effort to migrate the mParticle Web SDK codebase to TypeScript, the logger.js module needed to be converted to TypeScript to improve type safety, code maintainability, and developer experience. The logger is a core component used throughout the SDK for handling different log levels (none, error, warning, verbose) and custom logger implementations.

What Has Changed

  • Migrated src/logger.js to src/logger.ts
    • Converted the Logger class to TypeScript with proper type annotations
    • All methods now have explicit parameter and return types
  • Added Type Definitions
    • Created ILoggerConfig type that picks logLevel and logger properties from SDKInitConfig
    • Created IConsoleLogger type that picks error, warning, and verbose methods from SDKLoggerApi and wraps them in Partial<> to make methods optional
    • Both types reuse existing SDK interfaces to maintain consistency
  • Enhanced Type Safety
    • Used Partial<Pick<>> utility types to ensure IConsoleLogger matches the optional method signature pattern from MPConfiguration.Logger
    • Properly typed the logLevel property using the LogLevelType enum constants (LogLevelType.Warning, LogLevelType.None, etc.) instead of string literals
    • Maintained the safe hasOwnProperty check in the constructor to handle edge cases with falsy logger values
  • Exported ConsoleLogger
    • Made ConsoleLogger class exportable for potential reuse in tests and other modules
  • Updated Test Files
    • Modified test/src/tests-audience-manager.ts and test/src/tests-batchUploader.ts to work with the new TypeScript logger implementation
  • Built Distribution Files
    • Regenerated dist/mparticle.common.js, dist/mparticle.esm.js, and dist/mparticle.js to include the TypeScript-compiled logger

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)

@gtamanaha gtamanaha self-assigned this Jan 15, 2026
@sonarqubecloud

Copy link
Copy Markdown

@rmi22186 rmi22186 changed the base branch from master to development January 15, 2026 18:40
@gtamanaha gtamanaha changed the title feat: Migrate Logger to Typescript (#1120) feat: Migrate Logger to Typescript (#1120) SDKE-605 Jan 15, 2026
@gtamanaha gtamanaha merged commit e8d1ef1 into development Jan 16, 2026
35 of 42 checks passed
github-actions Bot pushed a commit that referenced this pull request Jan 20, 2026
# [2.53.0](v2.52.0...v2.53.0) (2026-01-20)

### Features

* map Rokt Privacy flags in cookieSyncManager ([#1140](#1140)) ([3840afa](3840afa))
* Migrate Logger to Typescript ([#1120](#1120)) ([#1141](#1141)) ([e8d1ef1](e8d1ef1))
@mparticle-automation

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.53.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