Skip to content

Commit 3b4d95d

Browse files
ruifcnunesandreecosta
authored andcommitted
fix(react): remove unnecessary custom GA script validation
1 parent 7f5b35d commit 3b4d95d

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

packages/react/src/analytics/integrations/GA4/GA4.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,6 @@ class GA4 extends integrations.Integration {
670670
* Method that will be called when the GA4 script loads.
671671
*/
672672
scriptOnload = () => {
673-
if (!window.gtag && !!this.customLoadScriptFn) {
674-
throw new Error(
675-
`${MESSAGE_PREFIX}${INIT_ERROR} Custom load script function finished but 'window.gtag' is not defined.`,
676-
);
677-
}
678-
679673
if (this.initializePromiseResolve) {
680674
this.initializePromiseResolve();
681675
this.initializePromiseResolve = null;

packages/react/src/analytics/integrations/__tests__/GA4.test.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,6 @@ describe('GA4 Integration', () => {
150150
);
151151
}
152152
});
153-
154-
it('Should throw if custom script did not instantiate gtag properly', () => {
155-
const options = {
156-
...validOptions,
157-
[OPTION_LOAD_SCRIPT_FUNCTION]: () => Promise.resolve(),
158-
};
159-
160-
try {
161-
ga4Instance = createGA4Instance(options);
162-
} catch (e) {
163-
expect(e.message).toContain(
164-
`${MESSAGE_PREFIX}${INIT_ERROR}Custom load script function finished but 'window.gtag' is not defined.`,
165-
);
166-
}
167-
});
168153
});
169154

170155
it('Should throw when tracking event if gtag is not defined', async () => {

0 commit comments

Comments
 (0)