3 ms·
I think the point is that Google Analytics shouldn't be an essential part of your site, so it totally breaking for any reason should be unnoticeable to the end
by josephcsible 6y ago
I think the point is that Google Analytics shouldn't be an essential part of your site, so it totally breaking for any reason should be unnoticeable to the end user.
- bastawhiz 6y agoIf it had broken, the code in the post would have worked. How exactly is code supposed to handle a dependency existing, but not being the API shape that it should be because a browser extension added an incomplete stub? Should every line of code get wrapped in try/catch? There's a big difference between "resilient against a missing dependency" and "being resilient in the face of getting literally any object instead of the dependency you expected to get."
- josephcsible 6y ago> Should every line of code get wrapped in try/catch? Everything Google Analytics does is expendable, so the block of code that deals with it should be wrapped in try/catch. > There's a big difference between "resilient against a missing dependency" and "being resilient in the face of getting literally any object instead of the dependency you expected to get." If Google pushes a breaking change to the Google Analytics API tomorrow, that shouldn't break checkout either.
- ratww 6y ago> Should every line of code get wrapped in try/catch? For third party dependencies that might not get loaded for whatever reason? Yes, sure. There are better ways to do it, but that's the idea.
- bastawhiz 6y agoThe code listed does check if it's been loaded. The stub that gets loaded is wrong. How do you guard against that?
- jasonlotito 6y agoIt's not. It can work without it. The issue is something is pretending to be Google Analytics just enough to cause problems.