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

Manually bundling GTM integration causes error #807

Open
vrugtehagel opened this issue Oct 28, 2024 · 0 comments · May be fixed by segmentio/fmt#3
Open

Manually bundling GTM integration causes error #807

vrugtehagel opened this issue Oct 28, 2024 · 0 comments · May be fixed by segmentio/fmt#3

Comments

@vrugtehagel
Copy link

When manually bundling @segment/analytics-next together with the GTM plugin from @segment/analytics.js-integration-google-tag-manager, a runtime error is thrown;

ReferenceError: global is not defined

Somewhere deep down, this global variable is used to refer to globalThis, but this is Node-specific. Currently, I'm using a workaround that does something along the lines of

globalThis.global = globalThis;
const { default: GTM } = await import('@segment/analytics.js-integration-google-tag-manager');

This fixes the error and the bundle works properly. Of course, however, I shouldn't have to do this.

The issue originates from @segmentio/fmt and I took the liberty of opening a pull request: segmentio/fmt#3. This issue is mostly for visibility.

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

Successfully merging a pull request may close this issue.

1 participant