-
Notifications
You must be signed in to change notification settings - Fork 891
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
Use Dynamic Measurement ID in Analytics #2800
Conversation
Binary Size ReportAffected SDKs
Test Logs
|
dba9ebe
to
65d673e
Compare
aed7e76
to
3890a69
Compare
1a55827
to
1ae1412
Compare
1ae1412
to
dd8c994
Compare
🦋 Changeset is good to goLatest commit: 1933243 We got this. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
fb62230
to
027600b
Compare
@@ -30,23 +30,27 @@ import { GtagCommand } from './constants'; | |||
* @param eventName Google Analytics event name, choose from standard list or use a custom string. | |||
* @param eventParams Analytics event parameters. | |||
*/ | |||
export function logEvent( | |||
export async function logEvent( |
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.
The other functions are not async. Should we make all of them the same?
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.
Does it make a difference as they all have to return a promise anyway? Changed them all for consistency in any case.
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.
No, it is only about consistency. You changed the signature of the functions to async but still use then
instead of await
. We should change them to use await
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.
Updated.
7931db6
to
4a8e6b6
Compare
8c382ef
to
6d369c1
Compare
packages/analytics/package.json
Outdated
@@ -37,7 +39,7 @@ | |||
"rollup-plugin-commonjs": "10.1.0", | |||
"rollup-plugin-json": "4.0.0", | |||
"rollup-plugin-node-resolve": "5.2.0", | |||
"rollup-plugin-typescript2": "0.27.1", | |||
"rollup-plugin-typescript2": "0.27.0", |
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.
We should upgrade to 0.27.1 which is the current version.
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.
Something always seems to go wrong with the rebasing. Fixed.
packages/analytics/src/factory.ts
Outdated
`"apiKey" field is empty in Firebase config. This is needed to fetch the latest` + | ||
` measurement id for this Firebase app. Falling back to measurement id ${app.options.measurementId}` + | ||
` provided in "measurementId" field.` |
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.
`"apiKey" field is empty in Firebase config. This is needed to fetch the latest` + | |
` measurement id for this Firebase app. Falling back to measurement id ${app.options.measurementId}` + | |
` provided in "measurementId" field.` | |
`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest` + | |
` measurement ID for this Firebase app. Falling back to the measurement ID ${app.options.measurementId}` + | |
` provided in the "measurementId" field in the local Firebase config.` |
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.
Done.
packages/analytics/src/get-config.ts
Outdated
`Timed out fetching this Firebase app's measurement id from the server.` + | ||
` Falling back to measurement id ${measurementId}` + | ||
` provided in "measurementId" field. [${e.message}]` |
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.
`Timed out fetching this Firebase app's measurement id from the server.` + | |
` Falling back to measurement id ${measurementId}` + | |
` provided in "measurementId" field. [${e.message}]` | |
`Timed out fetching this Firebase app's measurement ID from the server.` + | |
` Falling back to the measurement ID ${measurementId}` + | |
` provided in the "measurementId" field in the local Firebase config. [${e.message}]` |
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.
Done.
packages/analytics/src/get-config.ts
Outdated
`Failed to fetch this Firebase app's measurement id from the server.` + | ||
` Falling back to measurement id ${measurementId}` + | ||
` provided in "measurementId" field. [${e.message}]` |
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.
`Failed to fetch this Firebase app's measurement id from the server.` + | |
` Falling back to measurement id ${measurementId}` + | |
` provided in "measurementId" field. [${e.message}]` | |
`Failed to fetch this Firebase app's measurement ID from the server.` + | |
` Falling back to the measurement ID ${measurementId}` + | |
` provided in the "measurementId" field in the local Firebase config. [${e.message}]` |
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.
Done.
`Measurement ID in local firebase config (${app.options.measurementId})` + | ||
` does not match measurement ID fetched from server (${config.measurementId}).` + | ||
` To avoid analytics events being sent to the wrong measurement ID, update the` + | ||
` measurement ID field in the local config or remove it.` |
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.
`Measurement ID in local firebase config (${app.options.measurementId})` + | |
` does not match measurement ID fetched from server (${config.measurementId}).` + | |
` To avoid analytics events being sent to the wrong measurement ID, update the` + | |
` measurement ID field in the local config or remove it.` | |
`The measurement ID in the local Firebase config (${app.options.measurementId})` + | |
` does not match the measurement ID fetched from the server (${config.measurementId}).` + | |
` To avoid analytics events being sent to the wrong measurement ID, update the` + | |
` measurement ID field in the local config or remove it from the local config.` |
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.
Done.
packages/analytics/src/errors.ts
Outdated
'"apiKey" field is empty in Firebase config. Firebase Analytics requires this field to' + | ||
'contain a valid API key.', |
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.
'"apiKey" field is empty in Firebase config. Firebase Analytics requires this field to' + | |
'contain a valid API key.', | |
'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' + | |
'contain a valid API key.', |
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.
Done.
packages/analytics/src/errors.ts
Outdated
'"appId" field is empty in Firebase config. Firebase Analytics requires this field to' + | ||
'contain a valid app ID.', |
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.
'"appId" field is empty in Firebase config. Firebase Analytics requires this field to' + | |
'contain a valid app ID.', | |
'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' + | |
'contain a valid app ID.', |
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.
Done.
logger.warn( | ||
`The measurement ID in the local Firebase config (${app.options.measurementId})` + | ||
` does not match the measurement ID fetched from the server (${config.measurementId}).` + | ||
` To avoid analytics events being sent to the wrong measurement ID, update the` + |
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.
Question - is it that the events would be sent to the "wrong Analytics property", rather than the "wrong measurement ID". IIUC, the measurement ID is how the Web App is associated with its Analytics property, i.e., the actual entity that logs the events is the "Analytics property". Can anybody confirm this?
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.
It would be the wrong property. I suppose it could also be no property if it's an invalid measurement ID so I guess I was just trying to be very literal and not go any farther than saying it would make the gtag
call using the wrong measurement ID as a parameter, which could cause it to either be sent to the wrong property or no property at all if it's not a valid measurement ID (the previous expired one?).
I'm not sure if that distinction is important but I guess I imagined people not finding it in any of their properties and then saying they were misled or something.
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.
Maybe we can flip this statement and say:
To ensure analytics events are always sent to the correct Analytics property, update....
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.
Sounds good! Changed.
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.
Approving error message copy only.
b0119d2
to
9556daf
Compare
9556daf
to
27bb8c5
Compare
Size Analysis ReportAffected ProductsNo changes between base commit (d347c6c) and head commit (47deaa9). Test Logs
|
0ccfaba
to
ad2d2ed
Compare
b570e16
to
1933243
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Switch Analytics to using dynamic measurement ID fetched from REST endpoint. Previously it was using the ID provided in the user's config object. Measurement ID may change so we are switching to fetching it dynamically.