From 90e1f9376bfd75c6a08463c92bccd9aaae82f925 Mon Sep 17 00:00:00 2001 From: Xinyi Ye Date: Wed, 29 Oct 2025 11:34:34 -0700 Subject: [PATCH] test(analytics-browser): autocapature config should work --- .../test/browser-client.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/analytics-browser/test/browser-client.test.ts b/packages/analytics-browser/test/browser-client.test.ts index 54f5727a7..b5bdb67af 100644 --- a/packages/analytics-browser/test/browser-client.test.ts +++ b/packages/analytics-browser/test/browser-client.test.ts @@ -644,6 +644,29 @@ describe('browser-client', () => { expect(webVitalsPlugin).toHaveBeenCalledTimes(1); }); + test.each([ + true, + { + resetSessionOnNewCampaign: true, + }, + ])('should add web attribution plugin when autocapture.attribution is configured', async (attributionOption) => { + await client.init(apiKey, userId, { + autocapture: { + attribution: attributionOption, + }, + }).promise; + expect(client.webAttribution).toBeDefined(); + }); + + test('should NOT add web attribution plugin when autocapture.attribution is false', async () => { + await client.init(apiKey, userId, { + autocapture: { + attribution: false, + }, + }).promise; + expect(client.webAttribution).toBeUndefined(); + }); + test('should listen for network change to online', async () => { jest.useFakeTimers(); const addEventListenerMock = jest.spyOn(window, 'addEventListener');