diff --git a/cypress/e2e/opting-out.cy.ts b/cypress/e2e/opting-out.cy.ts index 5bd6def94..e7bada65a 100644 --- a/cypress/e2e/opting-out.cy.ts +++ b/cypress/e2e/opting-out.cy.ts @@ -33,7 +33,7 @@ describe('opting out', () => { cy.get('[data-cy-input]').type('hello world! ') assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': false, '@session-recording': false, }) @@ -51,7 +51,7 @@ describe('opting out', () => { cy.posthogInit({ opt_out_capturing_by_default: true }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -69,7 +69,7 @@ describe('opting out', () => { cy.posthogInit({ disable_session_recording: true }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -87,7 +87,7 @@ describe('opting out', () => { cy.posthogInit({ opt_out_capturing_by_default: true }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -101,7 +101,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) @@ -117,7 +117,7 @@ describe('opting out', () => { cy.posthogInit({ disable_session_recording: true }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -134,7 +134,7 @@ describe('opting out', () => { cy.posthog().invoke('startSessionRecording') assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) @@ -163,7 +163,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -177,7 +177,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) @@ -206,7 +206,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -220,7 +220,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) @@ -262,7 +262,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -276,7 +276,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) @@ -323,7 +323,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': false, + '@recorder-script': false, '@decide': true, '@session-recording': false, }) @@ -337,7 +337,7 @@ describe('opting out', () => { }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) diff --git a/cypress/e2e/session-recording.cy.ts b/cypress/e2e/session-recording.cy.ts index 4c3fa0d03..6ffa67f05 100644 --- a/cypress/e2e/session-recording.cy.ts +++ b/cypress/e2e/session-recording.cy.ts @@ -183,7 +183,7 @@ describe('Session recording', () => { }, }) - cy.wait('@recorder') + cy.wait('@recorder-script') cy.intercept({ url: 'https://example.com', times: 1 }, (req) => { req.reply({ @@ -281,7 +281,7 @@ describe('Session recording', () => { }, url: './playground/cypress', }) - cy.wait('@recorder') + cy.wait('@recorder-script') }) it('captures session events', () => { @@ -406,7 +406,7 @@ describe('Session recording', () => { cy.reload() cy.posthogInit({}) cy.wait('@decide') - cy.wait('@recorder') + cy.wait('@recorder-script') cy.get('body') .trigger('mousemove', { clientX: 200, clientY: 300 }) @@ -564,7 +564,7 @@ describe('Session recording', () => { }, url: './playground/cypress', }) - cy.wait('@recorder') + cy.wait('@recorder-script') }) it('does not capture when sampling is set to 0', () => { @@ -594,7 +594,7 @@ describe('Session recording', () => { }).as('decide') assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, '@session-recording': false, }) @@ -606,7 +606,7 @@ describe('Session recording', () => { cy.posthog().invoke('startSessionRecording', { sampling: true }) assertWhetherPostHogRequestsWereCalled({ - '@recorder': true, + '@recorder-script': true, '@decide': true, // no call to session-recording yet }) @@ -637,7 +637,7 @@ describe('Session recording', () => { }, url: './playground/cypress', }) - cy.wait('@recorder') + cy.wait('@recorder-script') cy.get('[data-cy-input]').type('hello posthog!') diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index abff144f2..4754515dc 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -15,44 +15,22 @@ beforeEach(() => { cy.intercept('POST', '/ses/*', { status: 1 }).as('session-recording') cy.intercept('GET', '/surveys/*').as('surveys') - cy.readFile('dist/array.full.js').then((body) => { - cy.intercept('/static/array.full.js', { body }) - }) - - cy.readFile('dist/array.js').then((body) => { - cy.intercept('/static/array.js', { body }) - }) - - cy.readFile('dist/array.full.js.map').then((body) => { - cy.intercept('/static/array.full.js.map', { body }) - }) - - cy.readFile('dist/array.js.map').then((body) => { - cy.intercept('/static/array.js.map', { body }) - }) - - cy.readFile('dist/recorder.js').then((body) => { - cy.intercept('/static/recorder.js*', { body }).as('recorder') - cy.intercept('/static/recorder-v2.js*', { body }).as('recorderv2') - }) - - cy.readFile('dist/recorder.js.map').then((body) => { - cy.intercept('/static/recorder.js.map', { body }) - }) - - cy.readFile('dist/surveys.js').then((body) => { - cy.intercept('/static/surveys.js*', { body }) - }) - - cy.readFile('dist/surveys.js.map').then((body) => { - cy.intercept('/static/surveys.js.map', { body }) - }) - - cy.readFile('dist/exception-autocapture.js').then((body) => { - cy.intercept('/static/exception-autocapture.js*', { body }).as('exception-autocapture-script') - }) - - cy.readFile('dist/exception-autocapture.js.map').then((body) => { - cy.intercept('/static/exception-autocapture.js.map', { body }) + const lazyLoadedJSFiles = [ + 'array', + 'array.full', + 'recorder', + 'surveys', + 'exception-autocapture', + 'tracing-headers', + 'web-vitals', + ] + lazyLoadedJSFiles.forEach((key: string) => { + cy.readFile(`dist/${key}.js`).then((body) => { + cy.intercept(`/static/${key}.js*`, { body }).as(`${key}-script`) + }) + + cy.readFile(`dist/${key}.js.map`).then((body) => { + cy.intercept(`/static/${key}.js.map`, { body }) + }) }) }) diff --git a/cypress/support/setup.ts b/cypress/support/setup.ts index 655b3e070..ae9326a78 100644 --- a/cypress/support/setup.ts +++ b/cypress/support/setup.ts @@ -24,7 +24,7 @@ export const start = ({ // sometimes we have too many listeners in this test environment // that breaks the event emitter listeners in error tracking tests // we don't see the error in production, so it's fine to increase the limit here - EventEmitter.prototype._maxListeners = 100 + EventEmitter.prototype.setMaxListeners(100) const decideResponse = { editorParams: {},