diff --git a/cypress/e2e/session-recording.cy.ts b/cypress/e2e/session-recording.cy.ts index 0875c32dd..3c4f57327 100644 --- a/cypress/e2e/session-recording.cy.ts +++ b/cypress/e2e/session-recording.cy.ts @@ -249,7 +249,7 @@ describe('Session recording', () => { [/http:\/\/localhost:\d+\/static\/array.js/, 'script'], [ /http:\/\/localhost:\d+\/decide\/\?v=3&ip=1&_=\d+&ver=1\.\d\d\d\.\d+&compression=base64/, - 'xmlhttprequest', + 'fetch', ], [/http:\/\/localhost:\d+\/static\/recorder.js\?v=1\.\d\d\d\.\d+/, 'script'], [/https:\/\/example.com/, 'fetch'], @@ -304,7 +304,7 @@ describe('Session recording', () => { [/http:\/\/localhost:\d+\/static\/array.js/, 'script'], [ /http:\/\/localhost:\d+\/decide\/\?v=3&ip=1&_=\d+&ver=1\.\d\d\d\.\d+&compression=base64/, - 'xmlhttprequest', + 'fetch', ], [/http:\/\/localhost:\d+\/static\/recorder.js\?v=1\.\d\d\d\.\d+/, 'script'], [/https:\/\/example.com/, 'xmlhttprequest'], diff --git a/src/__tests__/featureflags.test.ts b/src/__tests__/featureflags.test.ts index a54ada8fd..4eb07e9dd 100644 --- a/src/__tests__/featureflags.test.ts +++ b/src/__tests__/featureflags.test.ts @@ -475,7 +475,7 @@ describe('featureflags', () => { expect(instance._send_request).toHaveBeenCalledWith({ url: 'https://us.i.posthog.com/api/early_access_features/?token=random fake token', method: 'GET', - transport: 'XHR', + transport: 'fetch', callback: expect.any(Function), }) expect(instance._send_request).toHaveBeenCalledTimes(1) @@ -507,7 +507,7 @@ describe('featureflags', () => { url: 'https://us.i.posthog.com/api/early_access_features/?token=random fake token', method: 'GET', callback: expect.any(Function), - transport: 'XHR', + transport: 'fetch', }) expect(instance._send_request).toHaveBeenCalledTimes(1) diff --git a/src/__tests__/surveys.test.ts b/src/__tests__/surveys.test.ts index 6a4fa6916..f0e57fec0 100644 --- a/src/__tests__/surveys.test.ts +++ b/src/__tests__/surveys.test.ts @@ -236,7 +236,7 @@ describe('surveys', () => { expect(instance._send_request).toHaveBeenCalledWith({ url: 'https://us.i.posthog.com/api/surveys/?token=testtoken', method: 'GET', - transport: 'XHR', + transport: 'fetch', callback: expect.any(Function), }) expect(instance._send_request).toHaveBeenCalledTimes(1) @@ -281,7 +281,7 @@ describe('surveys', () => { expect(instance._send_request).toHaveBeenCalledWith({ url: 'https://us.i.posthog.com/api/surveys/?token=testtoken', method: 'GET', - transport: 'XHR', + transport: 'fetch', callback: expect.any(Function), }) expect(instance._send_request).toHaveBeenCalledTimes(1) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index 725a98daf..af4f22cbf 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -1717,7 +1717,7 @@ export class PostHog { * // or any way to know the result of the request. PostHog * // capturing via sendBeacon will not support any event- * // batching or retry mechanisms. - * api_transport: 'XHR' + * api_transport: 'fetch' * * // super properties cookie expiration (in days) * cookie_expiration: 365 diff --git a/src/posthog-featureflags.ts b/src/posthog-featureflags.ts index e8d2e9c3e..910a5c48e 100644 --- a/src/posthog-featureflags.ts +++ b/src/posthog-featureflags.ts @@ -433,7 +433,7 @@ export class PostHogFeatureFlags { if (!existing_early_access_features || force_reload) { this.instance._send_request({ - transport: 'XHR', + transport: 'fetch', url: this.instance.requestRouter.endpointFor( 'api', `/api/early_access_features/?token=${this.instance.config.token}` diff --git a/src/posthog-surveys.ts b/src/posthog-surveys.ts index f33fe4f4a..3e3b13ffe 100644 --- a/src/posthog-surveys.ts +++ b/src/posthog-surveys.ts @@ -118,7 +118,7 @@ export class PostHogSurveys { `/api/surveys/?token=${this.instance.config.token}` ), method: 'GET', - transport: 'XHR', + transport: 'fetch', callback: (response) => { if (response.statusCode !== 200 || !response.json) { return callback([]) diff --git a/src/request.ts b/src/request.ts index ea4ab1343..f9fd9fdaf 100644 --- a/src/request.ts +++ b/src/request.ts @@ -250,7 +250,7 @@ export const request = (_options: RequestOptions) => { compression: options.compression, }) - const transport = options.transport ?? 'XHR' + const transport = options.transport ?? 'fetch' const transportMethod = find(AVAILABLE_TRANSPORTS, (t) => t.transport === transport)?.method ?? AVAILABLE_TRANSPORTS[0].method diff --git a/src/web-experiments.ts b/src/web-experiments.ts index 74bbc904b..a275b2113 100644 --- a/src/web-experiments.ts +++ b/src/web-experiments.ts @@ -151,7 +151,7 @@ export class WebExperiments { `/api/web_experiments/?token=${this.instance.config.token}` ), method: 'GET', - transport: 'XHR', + transport: 'fetch', callback: (response) => { if (response.statusCode !== 200 || !response.json) { return callback([])