Destiner / astro-analytics

Astro components for site analytics
MIT License
113 stars 11 forks source link

Unexpected Amplitude snipped included along with Google Analytics #25

Open iron-cherep opened 1 year ago

iron-cherep commented 1 year ago

Issue:

When using Google Analytics through astro-analytics, an unexpected Amplitude Analytics snippet is also being included

Repo with reproduction:

Included Google Analytics component: https://github.com/iron-cherep/astro-analytics-repro/blob/23314b745c3af5c326851746441d03e2b353ef47/src/pages/index.astro#L16

Amplitude snippet in resulting build: https://github.com/iron-cherep/astro-analytics-repro/blob/23314b745c3af5c326851746441d03e2b353ef47/dist/index.html#L9

nlxdodge commented 1 year ago

I tried to check the code, but I cannot see why this snippet is being included. But this is kind of breaking the Google Pagespeed score as well 😅

I will try to dig a little deeper tonight see if I can fix it.

aemmadi commented 1 year ago

Same issue for me. I am trying to use the Umami component but I see Amplitude errors in console and network tab on website. Not sure why it is being included by default.

nlxdodge commented 12 months ago

I checked it a while ago, it seems like the original JavaScript code from Amplitude auto injects itself in some way. But this would mean every time an update comes out, that we need to manually edit the code that they use if we try to change it our-self.

Eventually I switched away from astro-analytics, as this cannot be solved without modifying the code from Amplitude itself.

Fuzzyma commented 11 months ago

I tried importing the analytics directly from src/foo.astro but it wouldnt let me. The problem arises because the index.ts imports / exports all astro components. If we could import the component we need directly, it would work

mahdisoultana commented 10 months ago

same issue , when i want to use only google analytics and i had an error on the console that i miss an api key for amplitude ice_screenshot_20231124-142502