-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix:add check and replace warn instead of error for setCustomNameStan… #55
fix:add check and replace warn instead of error for setCustomNameStan… #55
Conversation
packages/GA4Client/src/common.js
Outdated
'Error calling setCustomNameStandardization callback. Check your callback. Data will still be sent without user-defined standardization. See our docs for proper use - https://docs.mparticle.com/integrations/google-analytics-4/event/', | ||
e | ||
); | ||
if (window.GoogleAnalytics4Kit.setCustomNameStandardization(name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're checking if setCustomNameStandardization
exists, you might be better off using hasOwnProperty
instead of calling the function directly.
If the function does not exist, calling the function would throw an error before the try/catch block. Also, if the function does exist, you're essentially calling it twice.
if (window.GoogleAnalytics4Kit.setCustomNameStandardization(name)) { | |
if (window.GoogleAnalytics4Kit.hasOwnProperty(setCustomNameStandardization)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexs-mparticle thanks for correction, applying the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alex's comment is the only comment I have.
packages/GA4Client/src/common.js
Outdated
'Error calling setCustomNameStandardization callback. Check your callback. Data will still be sent without user-defined standardization. See our docs for proper use - https://docs.mparticle.com/integrations/google-analytics-4/event/', | ||
e | ||
); | ||
if (window.GoogleAnalytics4Kit.hasOwnProperty(setCustomNameStandardization)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setCustomNameStandardization
is not a variable, but rather, a string
if (window.GoogleAnalytics4Kit.hasOwnProperty(setCustomNameStandardization)) { | |
if (window.GoogleAnalytics4Kit.hasOwnProperty('setCustomNameStandardization')) { |
It looks like this test already does not have the callback when testing standardization, so the fact that this test doesn't break is sufficient and no additional test needs to be added. |
…dardization
Summary
#54
Testing Plan
Added code to local overrides and tested the warn instead error and then added the if statement to check the callback.
Master Issue
Closes https://go.mparticle.com/work/REPLACE