Skip to content
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

After relinking Firebase project to analytics, get "The measurement ID in the local Firebase config does not match the measurement ID fetched from the server" #4291

Closed
arcticmatt opened this issue Jan 14, 2021 · 23 comments

Comments

@arcticmatt
Copy link

arcticmatt commented Jan 14, 2021

Describe your environment

  • Operating System version: macOS 10.15.2
  • Browser version: Chrome Version 87.0.4280.141 (Official Build) (x86_64)
  • Firebase SDK version: 8.2.1
  • Firebase Product: Analytics

Describe the problem

I unlinked and relinked Analytics from my project more than once following these instructions. Each time I relink, the Firebase console shows me a new measurementId.

However, when I try to use the new measurementId in my Firebase config, I see this error in the console:

@firebase/analytics: The measurement ID in the local Firebase config (G-foobar) does not match the measurement ID fetched from the server (G-helloworld). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.

The former ID is the ID I see in the Firebase console. The latter ID is the original measurementId before I unlinked and relinked. Based on this, it seems like the measurementId fetched automatically from the server is out-of-date and does not respect unlinking and relinking to analytics.

Note that I originally unlinked Analytics from Firebase because I wanted to configure enhanced measurements, but was unable to. https://stackoverflow.com/questions/63816141/how-can-i-configure-enhanced-measurements-for-a-google-analytics-app-web-prop describes the issue I was hitting. The fact that data is still going to the old measurementId, while a bug, also happens to solve this problem. That is, after unlinking, I can configure enhanced measurements (you can't do this when it's linked), and since data still goes to the old measurementId, those changes take effect.

Steps to reproduce:

Described above.

Relevant Code:

I'm basically doing something like this:

const firebaseConfig = {...};
firebase.initializeApp(firebaseConfig);
firebase.analytics();

Once default events like page_view start getting logged (which I see in the console since I'm using the Google Analytics Debugger extension), I see the aforementioned error in the console.

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@arcticmatt
Copy link
Author

Here's some more evidence that something screwy is going on with unlinking and relinking. Every time I unlink and relink, a new "property" is created under my Google Analytics account. I can see in the debug view for an old property that my data is still being logged there, since my code thinks it should be using an old measurementId. However, the logs don't show up in the Firebase debug view, because that view is for the new measurementId.

@hsubox76
Copy link
Contributor

Created an internal bug b/177555355 for the team that controls the dynamic config endpoint.

In the meantime, how long do you wait after relinking? I wonder if there's a delay for the dynamic config backend (that serves the fetched config) to update, after you relink.

@arcticmatt
Copy link
Author

@hsubox76 I was wondering if waiting would fix it, but it looks like it didn't. I tried again just now and am still seeing the same error. It's been 10+ hours since relinking.

Also just to clarify, is the bug you filed for the issue where you can't edit the stream configuration?
image

@hsubox76
Copy link
Contributor

I think that UI is intentional but it is out of scope of this repo.

The bug I filed is for the exact issue you brought up originally, which is that whatever populates the measurementId in the object fetched by the dynamic config fetch call is not updating when you unlink and relink a Google Analytics account. I referenced this issue.

@arcticmatt
Copy link
Author

Ah gotcha, thanks. Do you know where would be a good place to report a bug for the other issue (the one I screenshotted)? It prevents me from configuring enhanced measurements when Firebase is linked.

@arcticmatt
Copy link
Author

arcticmatt commented Jan 14, 2021

I just tried it again, and now it works! The behavior still seems buggy if you have to wait this long though.

Unfortunately, this also means that my enhanced measurements are no longer working as I'd like them to, since they're going to the property whose stream configurations are locked down (see screenshot above). So... actually, it was kinda nice to have the buggy behavior, since it nicely compounded with another bug—that is, it meant I could look at the Debug View in Google Analytics instead of Firebase and was able to edit the stream configurations. Oh well.

@rromanchuk
Copy link

should i just be using g4 web datastream? I dont understand the firebase web data stream. It wants to redirect back to firebase, but where are all the configuration settings like Enhanced measurement, Measurement Protocol API secrets, connected site tags, etc? I'm not using the firebase client to log events on web, so can i just kill firebase.analytics(); and use a measurement id of g4 web data stream.

zainfathoni added a commit to zainfathoni/rumahberbagi-app that referenced this issue Apr 6, 2021
@AadamZ5
Copy link

AadamZ5 commented Sep 13, 2021

I just ran into OP's issue as well. @arcticmatt, what were the steps you took to resolve this issue, or was it a seemingly random success?

Seems frustrating that there is no way to update the webConfig object that gets passed to the front end. I can see in the network inspector that it is sending the old measurement ID, and I'm getting the same error in the console. Additionally, using the archaic Google Analytics Debugger, I can see it posting events to the old measurement ID as well. However, Firebase console lists the new measurement ID in the configuration it generates for my app.

Why does the webConfig endpoint ( at https://firebase.googleapis.com/v1alpha/projects/-/apps/[your]:[app]:[id]:[here]/webConfig ) overwrite the measurement ID? I think that the developer would intend what they wrote, even if the webConfig object is different. Perhaps there is some reasoning for the current behavior.

@hsubox76 Any update on the status of the internal bug?

@hsubox76
Copy link
Contributor

hsubox76 commented Sep 14, 2021

It sounds like in his case there was just a delay in updating.

Setting the measurement ID from the local config is only used as a backup if the dynamic config cannot be fetched. The dynamic config is intended to be the main source of truth. The reasoning behind this decision was that the Firebase project's measurement ID may change due to moving streams, or linking and unlinking them, and that someone doing so on the backend shouldn't require any changes in the front end code. That said, the delay might be longer than is acceptable, or should at least be documented. Or if it's not updating at all, we should escalate the bug.

How long has it been since you unlinked/relinked and if you're able to get it working again, how long after was it? If there is a delay, and I can get an idea of how long it is, I can report it on the internal bug and try to get a response again.

@AadamZ5
Copy link

AadamZ5 commented Sep 14, 2021

@hsubox76

How long has it been since you unlinked/relinked and if you're able to get it working again, how long after was it? If there is a delay, and I can get an idea of how long it is, I can report it on the internal bug and try to get a response again.

The webConfig endpoint seems to be sending the updated measurement ID now, but I'm not sure of exactly when that changed. I obsessively checked until about an hour and a half after I changed it, so I guess we can only assume the update happened sometime within 1.5 to 20 hrs. after the relinking. I did unlink and relink multiple times, and it now has updated to the correct one even after the multiple relinks, so I think this is working correctly, albeit a bit slower than I expected.

You mentioned documentation about this delay (if it isn't a bug), and I think that would be awesome. I think the best approach would be some sort of notification on the UI about a possible discrepancy and/or delay, but I think that the UI is not in this particular issue's scope.

Setting the measurement ID from the local config is only used as a backup if the dynamic config cannot be fetched. The dynamic config is intended to be the main source of truth. The reasoning behind this decision was that the Firebase project's measurement ID may change due to moving streams, or linking and unlinking them, and that someone doing so on the backend shouldn't require any changes in the front end code.

That makes more sense from a larger multi-team perspective. I am in the full-stack mindset right now since we're a very small team with no dedicated front/back end teams right now.

Thanks for your speedy reply! Let me know if any other info would be useful.

@luisfelipesd
Copy link

I have the same issue now. Its been 10 hours and i still get the error what am I supposed to do?

@hsubox76
Copy link
Contributor

It seemed to take about a day for the other two people that reported it, so let me know if it doesn't fix itself within a day. I'll try to talk to the team that handles dynamic config and see if I can get any clarity on if this is intended behavior. It'll be good if I can gather as much info as possible on roughly how long the delay seems to be.

@luisfelipesd
Copy link

yeah it took a day. it is working now. thank you @hsubox76

@hsubox76
Copy link
Contributor

It looks like a 24 hour delay is standard. I'll try to find a way to add this to our documentation so no one else is taken by surprise.

@DustinJSilk
Copy link

I've hit this same issue now, going on 17 hours now and still not working.
Glad to see it'll come right in a few hours time.

@rajathvsm
Copy link

I'm facing the same issue. Hope this gets included in the documentation soon!

@EmmaDawsonDev
Copy link

I added analytics to a firebase project about 8 hours ago and I'm getting a similar issue, except it's not had analytics before so there's no old measurement id stored.
Screenshot 2021-11-08 161604

Would be nice if the documentation mentioned this problem as it's a whole day wasted trying to debug this.

@hsubox76
Copy link
Contributor

hsubox76 commented Nov 8, 2021

We're working on getting it added to documentation somewhere, thanks for alerting us to the additional case (no analytics, then linked it later).

@hsubox76
Copy link
Contributor

Added a note to the documentation here under "Link your Firebase project to Analytics": https://support.google.com/analytics/answer/9289234

@wilburx9
Copy link

Added a note to the documentation here under "Link your Firebase project to Analytics": https://support.google.com/analytics/answer/9289234

@hsubox76 Please, can this also be added to the setup guide on Firebase? Wasted a couple of hours head-scratching until I landed here. MIne was a first-time setup.

@firebase firebase locked and limited conversation to collaborators Jan 13, 2022
@hsubox76 hsubox76 reopened this Mar 25, 2022
@hsubox76
Copy link
Contributor

For people having trouble with a delay on a "first-time setup", can you describe the steps you took? Did you enable analytics when creating the project and still see a delay, or did you not initially enable analytics on your project, and then enabled it after the project had already been created, and then you saw a delay? Did you use the automatically provided measurement ID or did you link another measurement ID?

Just want to be clear so the documentation changes will be accurate. Thanks.

@hsubox76
Copy link
Contributor

Closing this, if anyone is having problems with a delay on a "first-time setup", if you can answer the questions in the comment directly above, I will update the documentation as needed or reopen this to make any fixes if needed. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants