feat: Report deprecated method usage through logging dispatcher#1270
Conversation
8ffea9d to
c44f7e2
Compare
PR SummaryLow Risk Overview Routes several existing deprecated entry points (Consent Reviewed by Cursor Bugbot for commit b596fbd. Bugbot is set up for automated code reviews on this repo. Configure here. |
| export function logDeprecatedApiUsage( | ||
| mpInstance: DeprecatedApiLoggerInstance, | ||
| usage: DeprecatedApiUsage | ||
| ): void { | ||
| mpInstance.Logger?.warning(usage.warningMessage); | ||
| mpInstance._LoggingDispatcher?.log({ | ||
| message: usage.methodName, | ||
| code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Consistency: We're switching between Deprecated Method vs Deprecated API in this logger, let's stick to one.
| export function logDeprecatedApiUsage( | |
| mpInstance: DeprecatedApiLoggerInstance, | |
| usage: DeprecatedApiUsage | |
| ): void { | |
| mpInstance.Logger?.warning(usage.warningMessage); | |
| mpInstance._LoggingDispatcher?.log({ | |
| message: usage.methodName, | |
| code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE, | |
| }); | |
| } | |
| export function logDeprecatedMethodUsage( | |
| mpInstance: DeprecatedMethodLoggerInstance, | |
| usage: DeprecatedMethodUsage | |
| ): void { | |
| mpInstance.Logger?.warning(usage.warningMessage); | |
| mpInstance._LoggingDispatcher?.log({ | |
| message: usage.methodName, | |
| code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE, | |
| }); | |
| } |
| logDeprecatedApiUsage(self, { | ||
| methodName: 'eCommerce.Cart.add()', | ||
| warningMessage: generateDeprecationMessage( |
There was a problem hiding this comment.
Nit: Maybe we reference the module in the log so we know where the entry point was?
| logDeprecatedApiUsage(self, { | |
| methodName: 'eCommerce.Cart.add()', | |
| warningMessage: generateDeprecationMessage( | |
| logDeprecatedApiUsage(self, { | |
| methodName: 'mPInstance.eCommerce.Cart.add()', | |
| warningMessage: generateDeprecationMessage( |
| identityApiData, | ||
| mpInstance.Logger | ||
| ); | ||
| tryOnUserAlias(prevUser, newUser, identityApiData, mpInstance); |
There was a problem hiding this comment.
Wy reimport the whole mPInstance?
There was a problem hiding this comment.
because logDeprecatedApiUsage takes it as an argument in order to pass both Logger and _LoggingDispatcher. Would you prefer logDeprecatedApiUsage take Logger and _LoggingDispatcher directly?
There was a problem hiding this comment.
Yes, I think that would be preferable.
| 'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead' | ||
| ); | ||
| logDeprecatedApiUsage(mpInstance, { | ||
| methodName: 'removeCCPAState', |
There was a problem hiding this comment.
| methodName: 'removeCCPAState', | |
| methodName: 'Consent.removeCCPAState', |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 4495494. Configure here.
| self.Logger.warning( | ||
| generateDeprecationMessage( | ||
| logDeprecatedMethodUsage(self, { | ||
| methodName: 'mPInstance.eCommerce.Cart.add()', |
There was a problem hiding this comment.
Inconsistent methodName prefix across structured log entries
Low Severity
The methodName values in the same file use two different prefixes: mPInstance for Cart methods (e.g. mPInstance.eCommerce.Cart.add()) and mParticle for others (e.g. mParticle.logCheckout). mPInstance isn't a public API name or a variable name used in the codebase — it appears to be an internal shorthand. Since these values are emitted as structured log entries for downstream consumption, the inconsistent prefix makes filtering and aggregating deprecation events unreliable.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4495494. Configure here.
4495494 to
29be20b
Compare
29be20b to
b53796c
Compare
|





Summary
Verification
Notes