Analytics autoTrack "event" fails with Gatsby (SSR) #6208
Labels
Analytics
Related to analytics
feature-request
Request a new feature
SSR
Issues related to Server Side Rendering
Describe the bug
following this setup: https://docs.amplify.aws/lib/analytics/autotrack/q/platform/js#page-event-tracking
while Analytics.autoTrack("pageView") and Analytics.autoTrack("session") work fine with Gatsbys Server Side rendering (SSR)
Adding Analytics.autoTrack("event") produces the following error during production builds:
In development mode everything works fine.
I guess that autoTrack uses a variable like (window / location) that is not known at compile time.
The failure only occurs when being called within a React component.
Outside of components it works fine. However in order to be able to turn Analytics on and off I need it to be inside React.
This here could be the reason for failure:
https://github.com/aws-amplify/amplify-js/blob/main/packages/analytics/src/trackers/EventTracker.ts#L33
Related issues:
#5435
Env:
"aws-amplify": "^3.0.10",
"gatsby": "^2.21.9",
The text was updated successfully, but these errors were encountered: