From 613d8de14ab078f94084840e26b322b7f562af83 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:24:28 -0500 Subject: [PATCH 01/56] wip --- .github/workflows/ci.yml | 8 - .vscode/launch.json | 2 +- packages/browser/src/core/analytics/index.ts | 6 +- packages/browser/src/index.ts | 6 +- .../consent-tools-integration-tests/README.md | 9 + .../public/consent-tools-vanilla-opt-out.html | 10 + .../public/consent-tools-vanilla.html | 6 +- .../public/onetrust.html | 4 +- .../consent-tools-vanilla-opt-out/index.ts | 17 + .../consent-tools-vanilla/index.ts | 17 +- .../page-bundles/helpers/mock-cmp-wrapper.ts | 21 + .../src/page-bundles/helpers/mock-cmp.ts | 110 +++++ .../src/page-objects/base-page.ts | 67 ++- .../src/page-objects/consent-tools-vanilla.ts | 19 +- .../src/page-objects/onetrust.ts | 18 - .../consent-tools-vanilla-opt-out.test.ts | 60 +++ .../src/tests/consent-tools-vanilla.test.ts | 33 +- .../src/tests/onetrust.test.ts | 17 +- .../wdio.conf.local.ts | 20 +- .../domain/__tests__/consent-stamping.test.ts | 5 +- .../domain/__tests__/create-wrapper.test.ts | 202 ++------- .../domain/__tests__/disable-segment.test.ts | 2 +- .../__tests__/analytics-service.test.ts | 393 ++++++++++++++++-- .../src/domain/analytics/analytics-service.ts | 102 +++-- .../src/domain/blocking-helpers.ts | 118 ++++++ .../src/domain/blocking-middleware.ts | 81 ++++ .../src/domain/config-helpers.ts | 22 + .../src/domain/consent-stamping.ts | 15 +- .../src/domain/create-wrapper.ts | 183 +++----- .../src/domain/disable-segment.ts | 18 - .../src/domain/load-cancellation.ts | 31 -- .../consent-tools/src/domain/load-context.ts | 81 ++++ .../consent-tools/src/domain/logger.ts | 20 + .../src/domain/pruned-categories.ts | 37 +- .../domain/validation/options-validators.ts | 6 +- .../src/test-helpers/mocks/analytics-mock.ts | 2 +- .../consent-tools/src/types/settings.ts | 13 +- .../consent-tools/src/types/wrapper.ts | 59 ++- .../src/domain/__tests__/wrapper.test.ts | 19 +- .../src/domain/consent-model.ts | 15 + .../src/domain/wrapper.ts | 24 +- .../src/lib/onetrust-api.ts | 11 + .../src/test-helpers/mocks.ts | 24 +- .../pages/index-consent-opt-out.html | 201 +++++++++ .../pages/index-consent.html | 7 +- 45 files changed, 1566 insertions(+), 575 deletions(-) create mode 100644 packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html create mode 100644 packages/consent/consent-tools-integration-tests/src/page-bundles/consent-tools-vanilla-opt-out/index.ts create mode 100644 packages/consent/consent-tools-integration-tests/src/page-bundles/helpers/mock-cmp-wrapper.ts create mode 100644 packages/consent/consent-tools-integration-tests/src/page-bundles/helpers/mock-cmp.ts create mode 100644 packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts create mode 100644 packages/consent/consent-tools/src/domain/blocking-helpers.ts create mode 100644 packages/consent/consent-tools/src/domain/blocking-middleware.ts create mode 100644 packages/consent/consent-tools/src/domain/config-helpers.ts delete mode 100644 packages/consent/consent-tools/src/domain/disable-segment.ts delete mode 100644 packages/consent/consent-tools/src/domain/load-cancellation.ts create mode 100644 packages/consent/consent-tools/src/domain/load-context.ts create mode 100644 packages/consent/consent-tools/src/domain/logger.ts create mode 100644 packages/consent/consent-wrapper-onetrust/src/domain/consent-model.ts create mode 100644 playgrounds/standalone-playground/pages/index-consent-opt-out.html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e27e2ab49..e3a49f5f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,18 +54,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: browser-actions/setup-chrome@v1 - uses: actions/setup-node@v3 with: node-version: 16 cache: 'yarn' - run: yarn install --immutable - - name: Turbo cache - uses: actions/cache@v3 - with: - path: node_modules/.cache/turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-turbo- - run: yarn turbo run --filter='consent-tools-integration-tests' test:int diff --git a/.vscode/launch.json b/.vscode/launch.json index 248b1f89d..d4571ebbb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -48,7 +48,7 @@ "internalConsoleOptions": "neverOpen", "program": "${workspaceFolder}/node_modules/jest/bin/jest", "skipFiles": [ - "/**" + "/**" ] }, { diff --git a/packages/browser/src/core/analytics/index.ts b/packages/browser/src/core/analytics/index.ts index a7675c131..f66a20d1e 100644 --- a/packages/browser/src/core/analytics/index.ts +++ b/packages/browser/src/core/analytics/index.ts @@ -64,14 +64,14 @@ const global: any = getGlobal() const _analytics = global?.analytics function createDefaultQueue( - name: string, + writeKey: string, retryQueue = false, disablePersistance = false ) { const maxAttempts = retryQueue ? 10 : 1 const priorityQueue = disablePersistance ? new PriorityQueue(maxAttempts, []) - : new PersistedPriorityQueue(maxAttempts, name) + : new PersistedPriorityQueue(maxAttempts, `${writeKey}:event-queue`) return new EventQueue(priorityQueue) } @@ -184,7 +184,7 @@ export class Analytics this.queue = queue ?? createDefaultQueue( - `${settings.writeKey}:event-queue`, + settings.writeKey, options?.retryQueue, disablePersistance ) diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index fdd552aa8..26a3987a4 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -8,6 +8,10 @@ export * from './core/plugin' export * from './core/user' export type { AnalyticsSnippet } from './browser/standalone-interface' -export type { MiddlewareFunction } from './plugins/middleware' +export type { + MiddlewareFunction, + DestinationMiddlewareFunction, + MiddlewareParams, +} from './plugins/middleware' export { getGlobalAnalytics } from './lib/global-analytics-helper' export { UniversalStorage, Store, StorageObject } from './core/storage' diff --git a/packages/consent/consent-tools-integration-tests/README.md b/packages/consent/consent-tools-integration-tests/README.md index 65e606551..ad5181ac2 100644 --- a/packages/consent/consent-tools-integration-tests/README.md +++ b/packages/consent/consent-tools-integration-tests/README.md @@ -18,3 +18,12 @@ Why is this using wd.io instead of playwright? ``` yarn . test:int ``` + +### Debugging Tips: +- Webdriver.io has the handy `browser.debug()` command. + +- You can serve the static pages by themselves (without webdriver.io) with the following: +``` +yarn webpack -w & +npx live-server . +``` diff --git a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html new file mode 100644 index 000000000..a17c8329a --- /dev/null +++ b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html @@ -0,0 +1,10 @@ + + + + +

Hello World - Serving Analytics (Consent Tools Vanilla Opt Out)

+

Please Check Network tab

+

This page can used as playground or run by webdriver.io

+ + + diff --git a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html index b7ba6dcc3..997fa47ed 100644 --- a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html +++ b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html @@ -1,14 +1,10 @@ - - - -

Hello World - Serving Analytics

Please Check Network tab

This page can used as playground or run by webdriver.io

+ - diff --git a/packages/consent/consent-tools-integration-tests/public/onetrust.html b/packages/consent/consent-tools-integration-tests/public/onetrust.html index 4bed046ee..11065d04e 100644 --- a/packages/consent/consent-tools-integration-tests/public/onetrust.html +++ b/packages/consent/consent-tools-integration-tests/public/onetrust.html @@ -5,7 +5,7 @@ - + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

Consent Changed Event

+ +

Logs

+

+
+  
+  
+
+
+
\ No newline at end of file
diff --git a/playgrounds/standalone-playground/pages/index-consent.html b/playgrounds/standalone-playground/pages/index-consent.html
index 64afa1da5..3471dc423 100644
--- a/playgrounds/standalone-playground/pages/index-consent.html
+++ b/playgrounds/standalone-playground/pages/index-consent.html
@@ -29,7 +29,8 @@
 
   
   
+    data-domain-script="189ebd49-0e43-4cd1-8f88-c3f40f8e4996-test">
+
 
   
   
-
+    data-domain-script="80ca7b5c-e72f-4bd0-972a-b74d052a0820-test">
 
   
   
   
 
   
@@ -54,6 +54,7 @@ If you don't see a "Consent Management" option like the one below, please contac
 ```
 
 #### ⚠️ Reminder: _you must modify_ `analytics.load('....')` from the original Segment snippet. See markup comment in example above.
+
 ## For `npm` library users
 
 1. Ensure that OneTrust Snippet is loaded. [See example above.](#add-onetrust-snippet-and-integration-to-your-page)
@@ -83,6 +84,23 @@ withOneTrust(analytics).load({ writeKey: ' })
 
 ```
 
+## Settings
+
+### Consent Models
+
+The wrapper has different behavior based on the consent-model returned by onetrust consent-models:
+
+- "opt-in" - (strict, GDPR scenario) -- wait for explicit consent (i.e. alert )
+- "opt-out" - load as usual and then rely on the consent blocking middleware to block events
+
+By default, opt-in / opt-out are based on the following table:
+
+Default behavior can be _manually_ set by doing:
+
+```ts
+withOneTrust(analytics).load(..., { consentModel: () => 'opt-in' | 'opt-out' })
+```
+
 ## Other examples:
 
 > Note: Playgrounds are meant for experimentation / testing, and as such, may be a bit overly complicated.

From 682cf5eda91b40bd5795e2d825cff39795ee7745 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 14:11:53 -0500
Subject: [PATCH 12/56] update readme

---
 packages/consent/consent-tools/README.md      | 31 +++++++++++++++----
 .../consent-wrapper-onetrust/README.md        |  7 +++--
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/packages/consent/consent-tools/README.md b/packages/consent/consent-tools/README.md
index 83b12b762..825a9e0f1 100644
--- a/packages/consent/consent-tools/README.md
+++ b/packages/consent/consent-tools/README.md
@@ -12,19 +12,26 @@ export const withCMP = createWrapper({
     await resolveWhen(() => window.CMP !== undefined, 500)
   },
 
-  // Wrapper waits to load segment / get categories until this function returns / resolves
+  // Allow for control over wrapper + analytics initialization.
+  // Delay any calls to analytics.load() until this function returns / resolves.
   shouldLoadSegment: async (ctx) => {
-    await resolveWhen(
-      () => !window.CMP.popUpVisible(),
-      500
-    )
-
+    /*
     // Optional -- for granular control of initialization
     if (noConsentNeeded) {
       ctx.abort({ loadSegmentNormally: true })
     } else if (allTrackingDisabled) {
       ctx.abort({ loadSegmentNormally: false })
     }
+    */
+    if (window.CMP.ConsentModel === 'opt-out') {
+      return ctx.load({ consentModel: 'opt-out' })
+    } else {
+      await resolveWhen(
+        () => !window.CMP.popUpVisible() && window.CMP.categories.length,
+        500
+      )
+      return ctx.load({ consentModel: 'opt-in' })
+    }
   },
 
   getCategories: () => {
@@ -39,6 +46,17 @@ export const withCMP = createWrapper({
 })
 ```
 
+### Settings / Configuration
+
+See: [settings.ts](src/types/settings.ts)
+
+### Consent Models
+
+The wrapper has different behavior based on the consent-model:
+
+- **opt-in** - (strict, GDPR scenario) -- Unconsented device mode destinations are removed
+- **opt-out** - Device mode destinations are loaded, but with blocking middleware
+
 ## Wrapper Usage API
 
 ## `npm`
@@ -56,6 +74,7 @@ withCMP(analytics).load({
 ```
 
 ## Snippet users (window.analytics)
+
 ### Note: This assumes a project that can consume the library via es6 imports, using a like Webpack.
 
 1. Delete the `analytics.load()` line from the snippet
diff --git a/packages/consent/consent-wrapper-onetrust/README.md b/packages/consent/consent-wrapper-onetrust/README.md
index 7da9d5ad3..b81ae91fa 100644
--- a/packages/consent/consent-wrapper-onetrust/README.md
+++ b/packages/consent/consent-wrapper-onetrust/README.md
@@ -90,10 +90,11 @@ withOneTrust(analytics).load({ writeKey: ' })
 
 The wrapper has different behavior based on the consent-model returned by onetrust consent-models:
 
-- "opt-in" - (strict, GDPR scenario) -- wait for explicit consent (i.e. alert )
-- "opt-out" - load as usual and then rely on the consent blocking middleware to block events
+- **opt-in** - (strict, GDPR scenario) -- wait for explicit consent (i.e. alert box to be closed) before loading device mode destinations and initializing Segment. If consent is not given (no mapped categories are consented to), then Segment is not loaded.
 
-By default, opt-in / opt-out are based on the following table:
+- **opt-out** - Load segment immediately and all destinations, based on default categories. For device mode destinations, any analytics.js-originated events (e.g analytics.track) will be filtered based on consent.
+
+- **default/other** - opt-out
 
 Default behavior can be _manually_ set by doing:
 

From df678de7a07287c9a45d904f964a93651fc44bb5 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 14:12:39 -0500
Subject: [PATCH 13/56] wip

---
 packages/consent/consent-wrapper-onetrust/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/consent/consent-wrapper-onetrust/README.md b/packages/consent/consent-wrapper-onetrust/README.md
index b81ae91fa..f659cc45f 100644
--- a/packages/consent/consent-wrapper-onetrust/README.md
+++ b/packages/consent/consent-wrapper-onetrust/README.md
@@ -96,7 +96,7 @@ The wrapper has different behavior based on the consent-model returned by onetru
 
 - **default/other** - opt-out
 
-Default behavior can be _manually_ set by doing:
+This wrapper uses the `OneTrust.getDomainData()` API to get the consent model for a given geolocation. Default behavior can be overridden by doing:
 
 ```ts
 withOneTrust(analytics).load(..., { consentModel: () => 'opt-in' | 'opt-out' })

From 3c89acd6b3ea2a55cb124d0e9f5f52a6e00c4720 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 14:13:50 -0500
Subject: [PATCH 14/56] wip

---
 packages/consent/consent-wrapper-onetrust/README.md | 2 --
 1 file changed, 2 deletions(-)

diff --git a/packages/consent/consent-wrapper-onetrust/README.md b/packages/consent/consent-wrapper-onetrust/README.md
index f659cc45f..77b7fc438 100644
--- a/packages/consent/consent-wrapper-onetrust/README.md
+++ b/packages/consent/consent-wrapper-onetrust/README.md
@@ -88,8 +88,6 @@ withOneTrust(analytics).load({ writeKey: ' })
 
 ### Consent Models
 
-The wrapper has different behavior based on the consent-model returned by onetrust consent-models:
-
 - **opt-in** - (strict, GDPR scenario) -- wait for explicit consent (i.e. alert box to be closed) before loading device mode destinations and initializing Segment. If consent is not given (no mapped categories are consented to), then Segment is not loaded.
 
 - **opt-out** - Load segment immediately and all destinations, based on default categories. For device mode destinations, any analytics.js-originated events (e.g analytics.track) will be filtered based on consent.

From d6c18710adb35ecb419ae989ad2835f3fba9c07f Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 15:55:13 -0500
Subject: [PATCH 15/56] wip

---
 .../pages/index-consent-opt-out.html             | 13 +++++++++++--
 .../pages/index-consent.html                     | 16 +++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/playgrounds/standalone-playground/pages/index-consent-opt-out.html b/playgrounds/standalone-playground/pages/index-consent-opt-out.html
index b6bd43277..6e2a8ed55 100644
--- a/playgrounds/standalone-playground/pages/index-consent-opt-out.html
+++ b/playgrounds/standalone-playground/pages/index-consent-opt-out.html
@@ -28,8 +28,17 @@
   
 
   
-  
+  
 
   
   
+  
 
   
   
-
-  
-  
-  
-
-
-  
-  
-  
-  
-  
-  
-  
-
-
-
-
-  
- -
- - -
-
-

Consent Changed Event

- -

Logs

-

-
-  
-  
-
-
-

From 5bc7e18a9e6e3a20ad17e54b246db234b1b87576 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 16:23:41 -0500
Subject: [PATCH 18/56] wip

---
 .../src/domain/__tests__/wrapper.test.ts      | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts b/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts
index fbb9785ff..996cf42ab 100644
--- a/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts
+++ b/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts
@@ -56,6 +56,88 @@ describe('High level "integration" tests', () => {
   })
 
   describe('shouldLoadSegment', () => {
+    describe('consent model', () => {
+      it('should support opt-in', async () => {
+        withOneTrust(analyticsMock)
+
+        getConsentedGroupIdsSpy.mockImplementation(() => [
+          domainGroupMock.StrictlyNeccessary.CustomGroupId,
+        ])
+
+        OneTrustMockGlobal.GetDomainData.mockReturnValue({
+          ...domainDataMock,
+          ConsentModel: {
+            Name: OneTrustAPI.OtConsentModel.optIn,
+          },
+        })
+        OneTrustMockGlobal.IsAlertBoxClosed.mockReturnValueOnce(true)
+
+        const load = jest.fn()
+        const shouldLoadSegP = createWrapperSpyHelper.shouldLoadSegment({
+          load,
+        } as any)
+        checkResolveWhen()
+        await shouldLoadSegP
+        expect(load).toHaveBeenCalledWith({ consentModel: 'opt-in' })
+      })
+
+      it('should not wait for alert box to be closed if opt-out', async () => {
+        withOneTrust(analyticsMock)
+
+        OneTrustMockGlobal.IsAlertBoxClosed.mockReturnValue(false)
+
+        OneTrustMockGlobal.GetDomainData.mockReturnValue({
+          ...domainDataMock,
+          ConsentModel: {
+            Name: OneTrustAPI.OtConsentModel.optOut,
+          },
+        })
+        const load = jest.fn()
+        void createWrapperSpyHelper.shouldLoadSegment({
+          load,
+        } as any)
+        expect(load).toHaveBeenCalledWith({ consentModel: 'opt-out' })
+      })
+
+      it('should default to opt-out consent model if OneTrust.ConsentModel.Name is unrecognized', async () => {
+        withOneTrust(analyticsMock)
+
+        OneTrustMockGlobal.GetDomainData.mockReturnValue({
+          ...domainDataMock,
+          ConsentModel: {
+            Name: 'foo' as any,
+          },
+        })
+        OneTrustMockGlobal.IsAlertBoxClosed.mockReturnValueOnce(true)
+
+        const load = jest.fn()
+        void createWrapperSpyHelper.shouldLoadSegment({
+          load,
+        } as any)
+        expect(load).toHaveBeenCalledWith({ consentModel: 'opt-out' })
+      })
+      it('should support a configuration that overrides the consent model', async () => {
+        withOneTrust(analyticsMock, { consentModel: () => 'opt-in' })
+        OneTrustMockGlobal.GetDomainData.mockReturnValue({
+          ...domainDataMock,
+          ConsentModel: {
+            Name: OneTrustAPI.OtConsentModel.optOut,
+          },
+        })
+        OneTrustMockGlobal.IsAlertBoxClosed.mockReturnValueOnce(true)
+        getConsentedGroupIdsSpy.mockImplementation(() => [
+          domainGroupMock.StrictlyNeccessary.CustomGroupId,
+        ])
+        const load = jest.fn()
+        const shouldLoadSegP = createWrapperSpyHelper.shouldLoadSegment({
+          load,
+        } as any)
+        checkResolveWhen()
+        await shouldLoadSegP
+        expect(load).toHaveBeenCalledWith({ consentModel: 'opt-in' })
+      })
+    })
+
     it('should load if alert box is closed and groups are defined', async () => {
       withOneTrust(analyticsMock)
 

From 4951ab0140fe17e503cdd5768bdf37bf6e144668 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 16:33:22 -0500
Subject: [PATCH 19/56] remove mockClear because not needed

---
 .../src/page-objects/base-page.ts                                | 1 -
 1 file changed, 1 deletion(-)

diff --git a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
index 3c34a4862..e9568eb84 100644
--- a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
+++ b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
@@ -18,7 +18,6 @@ export abstract class BasePage {
 
   async load(): Promise {
     const baseURL = browser.options.baseUrl
-    await browser.mockClearAll()
     await this.mockCDNSettingsEndpoint()
     await this.listenForSegmentTrackCalls()
     assert(baseURL)

From 39bacb03a94bb5f86c4e6520311b36052a8edfa7 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 16:34:01 -0500
Subject: [PATCH 20/56] wip

---
 .../src/tests/consent-tools-vanilla-opt-out.test.ts            | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts
index 7f5f2d50e..4d86e041b 100644
--- a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts
+++ b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts
@@ -24,7 +24,6 @@ it('should not wait for consent before sending track call', async () => {
     page.getAllTrackingEvents().find((el) => el.event === 'hello')
 
   await browser.waitUntil(() => getHelloTrackEvent(), {
-    interval: 500,
     timeout: 20000,
     timeoutMsg: 'Expected a "hello" track call to be made',
   })
@@ -35,7 +34,6 @@ it('should not wait for consent before sending track call', async () => {
 
   await page.clickGiveConsent()
   await browser.waitUntil(() => page.getConsentChangedEvents().length, {
-    interval: 500,
     timeout: 20000,
     timeoutMsg: 'Expected a consent change call to be made',
   })
@@ -48,7 +46,6 @@ it('should not wait for consent before sending track call', async () => {
   const getSupTrackEvent = () =>
     page.getAllTrackingEvents().find((el) => el.event === 'sup')
   await browser.waitUntil(() => getSupTrackEvent(), {
-    interval: 500,
     timeout: 20000,
     timeoutMsg: 'Expected a "sup" track call to be made',
   })

From 7345b8efd10284dfb5e695fc87155b520875d2c1 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 16:36:35 -0500
Subject: [PATCH 21/56] wip

---
 .../src/domain/__tests__/wrapper.test.ts                        | 2 --
 1 file changed, 2 deletions(-)

diff --git a/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts b/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts
index 996cf42ab..240230518 100644
--- a/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts
+++ b/packages/consent/consent-wrapper-onetrust/src/domain/__tests__/wrapper.test.ts
@@ -149,7 +149,6 @@ describe('High level "integration" tests', () => {
       const shouldLoadSegment = Promise.resolve(
         createWrapperSpyHelper.shouldLoadSegment({
           load: jest.fn(),
-          abort: jest.fn(),
         } as any)
       )
       checkResolveWhen()
@@ -180,7 +179,6 @@ describe('High level "integration" tests', () => {
       const shouldLoadSegment = Promise.resolve(
         createWrapperSpyHelper.shouldLoadSegment({
           load: jest.fn(),
-          abort: jest.fn(),
         } as any)
       )
       OneTrustMockGlobal.IsAlertBoxClosed.mockReturnValueOnce(false) // alert box is _never open

From fdcb90b7d22595f459152eee6d92e777264656b2 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 18:46:43 -0500
Subject: [PATCH 22/56] wip

---
 .../consent-tools-integration-tests/wdio.conf.local.ts       | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packages/consent/consent-tools-integration-tests/wdio.conf.local.ts b/packages/consent/consent-tools-integration-tests/wdio.conf.local.ts
index 48e7e9887..9c7a9f734 100644
--- a/packages/consent/consent-tools-integration-tests/wdio.conf.local.ts
+++ b/packages/consent/consent-tools-integration-tests/wdio.conf.local.ts
@@ -51,7 +51,10 @@ export const config: Options.Testrunner = {
       maxInstances: 5,
       browserName: 'chrome',
       'goog:chromeOptions': {
-        args: process.env.CI ? ['headless', 'disable-gpu'] : [],
+        args: [
+          ...(process.env.CI ? ['headless', 'disable-gpu'] : []),
+          'user-data-dir=/tmp',
+        ],
       },
       acceptInsecureCerts: true,
     },

From 5cf6a5072c9fc0364fc50bc16a56e4b3c205e5fb Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 19:08:49 -0500
Subject: [PATCH 23/56] attempt to fix flaky ci tests

---
 .../src/page-objects/consent-tools-vanilla.ts          | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts b/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts
index bdf7e3dac..56e79a16c 100644
--- a/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts
+++ b/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts
@@ -1,11 +1,13 @@
 import { BasePage } from './base-page'
 
 export class ConsentToolsVanilla extends BasePage {
-  clickGiveConsent() {
-    return $('#give-consent').click()
+  async clickGiveConsent() {
+    const button = await $('#give-consent')
+    return button.click()
   }
-  clickDenyConsent() {
-    return $('#deny-consent').click()
+  async clickDenyConsent() {
+    const button = await $('#give-consent')
+    return button.click()
   }
 }
 

From 972ea89fea153962fff3577c40089f1ff98ce3eb Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 19:32:12 -0500
Subject: [PATCH 24/56] add additional mock APIs

---
 .../src/page-objects/base-page.ts             | 32 +++++++++++++++----
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
index e9568eb84..0c2ab0033 100644
--- a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
+++ b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
@@ -15,12 +15,12 @@ export abstract class BasePage {
   constructor(protected page: string) {}
 
   segmentTrackingApiReqs: Matches[] = []
+  integrationApiReqs: Matches[] = []
 
   async load(): Promise {
     const baseURL = browser.options.baseUrl
-    await this.mockCDNSettingsEndpoint()
-    await this.listenForSegmentTrackCalls()
     assert(baseURL)
+    await this.mockAPIs()
     await browser.url(baseURL + '/public/' + this.page)
     await waitUntilReady()
   }
@@ -47,10 +47,17 @@ export abstract class BasePage {
 
   async cleanup() {
     this.segmentTrackingApiReqs = []
+    this.integrationApiReqs = []
     await this.clearStorage()
   }
 
-  async listenForSegmentTrackCalls(): Promise {
+  async mockAPIs() {
+    await this.mockSegmentTrackingAPI()
+    await this.mockCDNSettingsAPI()
+    await this.mockNextIntegrationsAPI()
+  }
+
+  private async mockSegmentTrackingAPI(): Promise {
     const mock = await browser.mock('https://api.segment.io/v1/t', {
       method: 'post',
     })
@@ -62,24 +69,35 @@ export abstract class BasePage {
         body: JSON.stringify({ success: true }),
       })
     })
-    return
   }
 
-  /**
-   * Mock the CDN Settings endpoint so that this can run offline
+  private async mockNextIntegrationsAPI(): Promise {
+    const mock = await browser.mock('**/next-integrations/**')
+    mock.respond((mock) => {
+      this.integrationApiReqs.push(mock)
+      return Promise.resolve({
+        statusCode: 200,
+        body: 'console.log("mocked next-integrations")',
+      })
+    })
+  }
+
+  /**   * Mock the CDN Settings endpoint so that this can run offline
    */
-  private async mockCDNSettingsEndpoint(): Promise {
+  private async mockCDNSettingsAPI(): Promise {
     const settings = new CDNSettingsBuilder({
       writeKey: 'something',
     })
       .addActionDestinationSettings(
         {
+          url: 'https://cdn.segment.com/next-integrations/actions/fullstory-plugins/foo.js',
           creationName: 'FullStory',
           consentSettings: {
             categories: ['FooCategory2'],
           },
         },
         {
+          url: 'https://cdn.segment.com/next-integrations/actions/amplitude-plugins/foo.js',
           creationName: 'Actions Amplitude',
           consentSettings: {
             categories: ['FooCategory1'],

From 9c99d6980a1db6fde5c2b97a3529169754b6c49f Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 19:49:58 -0500
Subject: [PATCH 25/56] Update
 packages/consent/consent-tools/src/domain/blocking-middleware.ts

Co-authored-by: Christopher Radek <14189820+chrisradek@users.noreply.github.com>
---
 .../consent/consent-tools/src/domain/blocking-middleware.ts     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/consent/consent-tools/src/domain/blocking-middleware.ts b/packages/consent/consent-tools/src/domain/blocking-middleware.ts
index 176dd8451..59ae1d7d2 100644
--- a/packages/consent/consent-tools/src/domain/blocking-middleware.ts
+++ b/packages/consent/consent-tools/src/domain/blocking-middleware.ts
@@ -47,7 +47,7 @@ export const addBlockingMiddleware = (
   }
   analyticsInstance.addDestinationMiddleware('*', blockDeviceMode)
 
-  // Block segment itsel (Segment.io isn't currently allowed in addDestinationMiddleware)
+  // Block segment itself (Segment.io isn't currently allowed in addDestinationMiddleware)
   const blockSegmentAndEverythingElse: SourceMiddlewareFunction = async ({
     payload,
     next,

From 568a42d26c06e70af1aa7c3b12867b5aeca8d2a9 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 20:06:54 -0500
Subject: [PATCH 26/56] mock integrations

---
 .../src/page-objects/base-page.ts                         | 8 ++++----
 .../src/tests/consent-tools-vanilla.test.ts               | 5 +++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
index 0c2ab0033..b676e6c02 100644
--- a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
+++ b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts
@@ -15,7 +15,7 @@ export abstract class BasePage {
   constructor(protected page: string) {}
 
   segmentTrackingApiReqs: Matches[] = []
-  integrationApiReqs: Matches[] = []
+  fetchIntegrationReqs: Matches[] = []
 
   async load(): Promise {
     const baseURL = browser.options.baseUrl
@@ -47,7 +47,7 @@ export abstract class BasePage {
 
   async cleanup() {
     this.segmentTrackingApiReqs = []
-    this.integrationApiReqs = []
+    this.fetchIntegrationReqs = []
     await this.clearStorage()
   }
 
@@ -74,10 +74,10 @@ export abstract class BasePage {
   private async mockNextIntegrationsAPI(): Promise {
     const mock = await browser.mock('**/next-integrations/**')
     mock.respond((mock) => {
-      this.integrationApiReqs.push(mock)
+      this.fetchIntegrationReqs.push(mock)
       return Promise.resolve({
         statusCode: 200,
-        body: 'console.log("mocked next-integrations")',
+        body: 'console.log("mocking action and classic destinations")',
       })
     })
   }
diff --git a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla.test.ts b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla.test.ts
index 0e139ab78..7aee1ce88 100644
--- a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla.test.ts
+++ b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla.test.ts
@@ -39,6 +39,11 @@ it('should send a track call after waiting for explicit consent', async () => {
   expect(consentChangeEvents.length).toBe(1)
   expect(consentChangeEvents[0].event).toEqual('Segment Consent Preference')
 
+  await browser.waitUntil(() => page.fetchIntegrationReqs.length, {
+    timeout: 20000,
+    timeoutMsg: 'Expected integrations/destinations to be fetched',
+  })
+
   await browser.execute(() => {
     return window.analytics.track('hello')
   })

From d0036bab86603f5882c78def796937ee46b6eadf Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 15 Apr 2024 20:08:36 -0500
Subject: [PATCH 27/56] wip

---
 .../src/tests/consent-tools-vanilla-opt-out.test.ts          | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts
index 4d86e041b..aa5ac764f 100644
--- a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts
+++ b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-out.test.ts
@@ -13,6 +13,11 @@ afterEach(async () => {
 it('should not wait for consent before sending track call', async () => {
   await page.load()
 
+  await browser.waitUntil(() => page.fetchIntegrationReqs.length, {
+    timeout: 20000,
+    timeoutMsg: 'Expected integrations/destinations to be fetched',
+  })
+
   await browser.execute(() => {
     return window.analytics.track('hello')
   })

From 2943b5b0a7c09c1cb0c76a7a8542f63f89a1a6ef Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 11:55:30 -0500
Subject: [PATCH 28/56] wip

---
 .../src/domain/analytics/analytics-service.ts         |  3 ++-
 .../consent-tools/src/domain/blocking-middleware.ts   |  2 +-
 .../consent-tools/src/domain/config-helpers.ts        | 11 +++++++++++
 .../consent-tools/src/domain/pruned-categories.ts     | 11 ++---------
 .../consent-wrapper-onetrust/src/domain/wrapper.ts    |  5 +++++
 5 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
index c98df5a67..5b4bf413c 100644
--- a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
@@ -11,9 +11,10 @@ import {
 import { pipe } from '../../utils'
 import { addBlockingMiddleware } from '../blocking-middleware'
 import { createConsentStampingMiddleware } from '../consent-stamping'
-import { parseAllCategories, getPrunedCategories } from '../pruned-categories'
+import { getPrunedCategories } from '../pruned-categories'
 import { validateAnalyticsInstance, validateCategories } from '../validation'
 import { logger } from '../logger'
+import { parseAllCategories } from '../config-helpers'
 
 export interface AnalyticsServiceOptions {
   getCategories: GetCategoriesFunction
diff --git a/packages/consent/consent-tools/src/domain/blocking-middleware.ts b/packages/consent/consent-tools/src/domain/blocking-middleware.ts
index 59ae1d7d2..734fb17ea 100644
--- a/packages/consent/consent-tools/src/domain/blocking-middleware.ts
+++ b/packages/consent/consent-tools/src/domain/blocking-middleware.ts
@@ -11,7 +11,7 @@ import {
   segmentShouldBeDisabled,
 } from './blocking-helpers'
 import { logger } from './logger'
-import { parseAllCategories } from './pruned-categories'
+import { parseAllCategories } from './config-helpers'
 
 // Block all device mode destinations
 export const addBlockingMiddleware = (
diff --git a/packages/consent/consent-tools/src/domain/config-helpers.ts b/packages/consent/consent-tools/src/domain/config-helpers.ts
index 83dacf211..9ead9b06d 100644
--- a/packages/consent/consent-tools/src/domain/config-helpers.ts
+++ b/packages/consent/consent-tools/src/domain/config-helpers.ts
@@ -1,3 +1,6 @@
+import { IntegrationCategoryMappings } from '../types'
+import { uniq } from '../utils'
+
 /**
  * Parse list of categories from `cdnSettings.integration.myIntegration` object
  * @example
@@ -20,3 +23,11 @@ export const parseConsentCategories = (
 
   return undefined
 }
+
+export const parseAllCategories = (
+  integrationCategoryMappings: IntegrationCategoryMappings
+) => {
+  return uniq(
+    Object.values(integrationCategoryMappings).reduce((p, n) => p.concat(n))
+  )
+}
diff --git a/packages/consent/consent-tools/src/domain/pruned-categories.ts b/packages/consent/consent-tools/src/domain/pruned-categories.ts
index 7870726fe..9acb76d75 100644
--- a/packages/consent/consent-tools/src/domain/pruned-categories.ts
+++ b/packages/consent/consent-tools/src/domain/pruned-categories.ts
@@ -1,14 +1,7 @@
-import { uniq, pick } from '../utils'
-import { Categories, IntegrationCategoryMappings } from '../types'
+import { pick } from '../utils'
+import { Categories } from '../types'
 import { ValidationError } from './validation/validation-error'
 
-export const parseAllCategories = (
-  integrationCategoryMappings: IntegrationCategoryMappings
-) => {
-  return uniq(
-    Object.values(integrationCategoryMappings).reduce((p, n) => p.concat(n))
-  )
-}
 export const getPrunedCategories = (
   categories: Categories,
   allCategories: string[]
diff --git a/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts b/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
index 6524b86ef..3cf474464 100644
--- a/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
+++ b/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
@@ -23,6 +23,10 @@ export interface OneTrustSettings {
    * By default, the value is determined by `OneTrust.GetDomainData().ConsentModel` which is set in the OneTrust UI.
    */
   consentModel?: () => 'opt-in' | 'opt-out'
+  /**
+   * Enable debug logging for OneTrust wrapper
+   */
+  enableDebugLogging?: boolean
 }
 
 /**
@@ -78,5 +82,6 @@ export const withOneTrust = (
           })
         },
     integrationCategoryMappings: settings.integrationCategoryMappings,
+    enableDebugLogging: settings.enableDebugLogging,
   })(analyticsInstance)
 }

From bf5bc5ccd8e4b50035fc618cd848b256dca5bd51 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 12:50:15 -0500
Subject: [PATCH 29/56] remove remotePlugins check

---
 .../domain/__tests__/assertions/integrations-assertions.ts    | 2 +-
 packages/consent/consent-tools/src/domain/create-wrapper.ts   | 4 ----
 packages/consent/consent-tools/src/types/wrapper.ts           | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts b/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts
index a5ff8f31d..fa8935d19 100644
--- a/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts
+++ b/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts
@@ -18,7 +18,7 @@ export const assertIntegrationsContainOnly = (
   updatedCDNSettings: CDNSettings
 ) => {
   expect(updatedCDNSettings.remotePlugins).toEqual(
-    originalCDNSettings.remotePlugins?.filter((p) =>
+    originalCDNSettings.remotePlugins.filter((p) =>
       // enabled consent
       creationNames.includes(p.creationName)
     )
diff --git a/packages/consent/consent-tools/src/domain/create-wrapper.ts b/packages/consent/consent-tools/src/domain/create-wrapper.ts
index e4b04b7b2..02428a3a6 100644
--- a/packages/consent/consent-tools/src/domain/create-wrapper.ts
+++ b/packages/consent/consent-tools/src/domain/create-wrapper.ts
@@ -92,10 +92,6 @@ export const createWrapper = (
         analyticsService.load(settings, {
           ...options,
           updateCDNSettings: pipe((cdnSettings) => {
-            if (!cdnSettings.remotePlugins) {
-              return cdnSettings
-            }
-
             return filterDeviceModeDestinationsForOptIn(
               cdnSettings,
               initialCategories,
diff --git a/packages/consent/consent-tools/src/types/wrapper.ts b/packages/consent/consent-tools/src/types/wrapper.ts
index 5573dd7c0..b0ae549f7 100644
--- a/packages/consent/consent-tools/src/types/wrapper.ts
+++ b/packages/consent/consent-tools/src/types/wrapper.ts
@@ -134,7 +134,7 @@ export interface CDNSettingsConsent {
 
 export interface CDNSettings {
   integrations: CDNSettingsIntegrations
-  remotePlugins?: CDNSettingsRemotePlugin[]
+  remotePlugins: CDNSettingsRemotePlugin[]
   consentSettings?: CDNSettingsConsent
 }
 

From 9cecb91dc7e897bd162e23e6255d9e1752bedece Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 12:52:49 -0500
Subject: [PATCH 30/56] wip

---
 .../assertions/integrations-assertions.ts     |  2 +-
 .../src/domain/analytics/analytics-service.ts | 51 +++++++++++++++++-
 .../src/domain/create-wrapper.ts              | 53 +++----------------
 .../consent-tools/src/types/wrapper.ts        |  2 +-
 .../src/domain/wrapper.ts                     |  6 +--
 5 files changed, 62 insertions(+), 52 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts b/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts
index fa8935d19..a5ff8f31d 100644
--- a/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts
+++ b/packages/consent/consent-tools/src/domain/__tests__/assertions/integrations-assertions.ts
@@ -18,7 +18,7 @@ export const assertIntegrationsContainOnly = (
   updatedCDNSettings: CDNSettings
 ) => {
   expect(updatedCDNSettings.remotePlugins).toEqual(
-    originalCDNSettings.remotePlugins.filter((p) =>
+    originalCDNSettings.remotePlugins?.filter((p) =>
       // enabled consent
       creationNames.includes(p.creationName)
     )
diff --git a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
index 5b4bf413c..7e6166ccd 100644
--- a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
@@ -5,6 +5,7 @@ import {
   CDNSettings,
   CreateWrapperSettings,
   GetCategoriesFunction,
+  InitOptions,
   IntegrationCategoryMappings,
   MaybeInitializedAnalytics,
 } from '../../types'
@@ -15,6 +16,10 @@ import { getPrunedCategories } from '../pruned-categories'
 import { validateAnalyticsInstance, validateCategories } from '../validation'
 import { logger } from '../logger'
 import { parseAllCategories } from '../config-helpers'
+import {
+  filterDeviceModeDestinationsForOptIn,
+  segmentShouldBeDisabled,
+} from '../blocking-helpers'
 
 export interface AnalyticsServiceOptions {
   getCategories: GetCategoriesFunction
@@ -48,6 +53,12 @@ export class AnalyticsService {
     return allCategories ?? []
   }
 
+  private async getCategories(): Promise {
+    const categories = await this.options.getCategories()
+    validateCategories(categories)
+    return categories
+  }
+
   private uninitializedAnalytics: AnyAnalytics
 
   constructor(analytics: AnyAnalytics, options: AnalyticsServiceOptions) {
@@ -59,6 +70,45 @@ export class AnalyticsService {
     this.ogAnalyticsLoad = analytics.load.bind(this.uninitializedAnalytics)
   }
 
+  /**
+   * Allow for gracefully passing a custom disable function (without clobbering the default behavior)
+   */
+  private createDisableOption = (
+    categories: Categories,
+    disable: InitOptions['disable']
+  ): NonNullable => {
+    if (disable === true) {
+      return true
+    }
+    return (cdnSettings: CDNSettings) => {
+      return (
+        segmentShouldBeDisabled(categories, cdnSettings.consentSettings) ||
+        (typeof disable === 'function' ? disable(cdnSettings) : false)
+      )
+    }
+  }
+
+  async loadWithFilteredDeviceModeDestinations(
+    ...[settings, options]: Parameters
+  ): Promise> {
+    const initialCategories = await this.getCategories()
+
+    const _filterDeviceModeDestinationsForOptIn = (cdnSettings: CDNSettings) =>
+      filterDeviceModeDestinationsForOptIn(cdnSettings, initialCategories, {
+        shouldEnableIntegration: this.options.shouldEnableIntegration,
+        integrationCategoryMappings: this.options.integrationCategoryMappings,
+      })
+
+    return this.load(settings, {
+      ...options,
+      updateCDNSettings: pipe(
+        _filterDeviceModeDestinationsForOptIn,
+        options?.updateCDNSettings ?? ((id) => id)
+      ),
+      disable: this.createDisableOption(initialCategories, options?.disable),
+    })
+  }
+
   /**
    * The orignal analytics load function, but also stores the CDN settings on the instance.
    */
@@ -72,7 +122,6 @@ export class AnalyticsService {
         (cdnSettings) => {
           logger.debug('CDN settings loaded', cdnSettings)
           // extract the CDN settings from this call and store it on the instance.
-          // there is an 'initialize' event emitter, but it's called too late for our purposes.
           this.cdnSettingsDeferred.resolve(cdnSettings)
           return cdnSettings
         }
diff --git a/packages/consent/consent-tools/src/domain/create-wrapper.ts b/packages/consent/consent-tools/src/domain/create-wrapper.ts
index 02428a3a6..e0e1917ef 100644
--- a/packages/consent/consent-tools/src/domain/create-wrapper.ts
+++ b/packages/consent/consent-tools/src/domain/create-wrapper.ts
@@ -1,18 +1,8 @@
-import {
-  Categories,
-  CreateWrapper,
-  AnyAnalytics,
-  InitOptions,
-  CDNSettings,
-} from '../types'
-import { validateCategories, validateSettings } from './validation'
-import { assertNever, pipe } from '../utils'
+import { CreateWrapper, AnyAnalytics } from '../types'
+import { validateSettings } from './validation'
+import { assertNever } from '../utils'
 import { normalizeShouldLoadSegment } from './load-context'
 import { AnalyticsService } from './analytics'
-import {
-  filterDeviceModeDestinationsForOptIn,
-  segmentShouldBeDisabled,
-} from './blocking-helpers'
 import { logger } from './logger'
 
 export const createWrapper = (
@@ -34,6 +24,7 @@ export const createWrapper = (
   return (analytics: Analytics) => {
     const analyticsService = new AnalyticsService(analytics, {
       integrationCategoryMappings,
+      shouldEnableIntegration,
       getCategories,
     })
 
@@ -86,20 +77,10 @@ export const createWrapper = (
       // if opt-out, we load as usual and then rely on the consent blocking middleware to block events
       // if opt-in, we remove all destinations that are not explicitly consented to so they never load in the first place
       if (loadCtx.loadOptions.consentModel === 'opt-in') {
-        const initialCategories = await getCategories()
-        validateCategories(initialCategories)
-
-        analyticsService.load(settings, {
-          ...options,
-          updateCDNSettings: pipe((cdnSettings) => {
-            return filterDeviceModeDestinationsForOptIn(
-              cdnSettings,
-              initialCategories,
-              { integrationCategoryMappings, shouldEnableIntegration }
-            )
-          }, options?.updateCDNSettings || ((id) => id)),
-          disable: createDisableOption(initialCategories, options?.disable),
-        })
+        await analyticsService.loadWithFilteredDeviceModeDestinations(
+          settings,
+          options
+        )
         return undefined
       } else if (loadCtx.loadOptions.consentModel === 'opt-out') {
         analyticsService.configureBlockingMiddlewareForOptOut()
@@ -115,21 +96,3 @@ export const createWrapper = (
     return analytics
   }
 }
-
-/**
- * Allow for gracefully passing a custom disable function (without clobbering the default behavior)
- */
-const createDisableOption = (
-  initialCategories: Categories,
-  disable: InitOptions['disable']
-): NonNullable => {
-  if (disable === true) {
-    return true
-  }
-  return (cdnSettings: CDNSettings) => {
-    return (
-      segmentShouldBeDisabled(initialCategories, cdnSettings.consentSettings) ||
-      (typeof disable === 'function' ? disable(cdnSettings) : false)
-    )
-  }
-}
diff --git a/packages/consent/consent-tools/src/types/wrapper.ts b/packages/consent/consent-tools/src/types/wrapper.ts
index b0ae549f7..5573dd7c0 100644
--- a/packages/consent/consent-tools/src/types/wrapper.ts
+++ b/packages/consent/consent-tools/src/types/wrapper.ts
@@ -134,7 +134,7 @@ export interface CDNSettingsConsent {
 
 export interface CDNSettings {
   integrations: CDNSettingsIntegrations
-  remotePlugins: CDNSettingsRemotePlugin[]
+  remotePlugins?: CDNSettingsRemotePlugin[]
   consentSettings?: CDNSettingsConsent
 }
 
diff --git a/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts b/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
index 3cf474464..f482c3140 100644
--- a/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
+++ b/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
@@ -17,10 +17,8 @@ export interface OneTrustSettings {
   disableConsentChangedEvent?: boolean
   /**
    * Override configured consent model
-   * - opt-in  (default) - load segment and all destinations without waiting for explicit consent.
-   * - opt-out (strict/GDPR) - wait for explicit consent before loading segment
-   *
-   * By default, the value is determined by `OneTrust.GetDomainData().ConsentModel` which is set in the OneTrust UI.
+   * - `opt-in` (strict/GDPR) - wait for explicit consent before loading segment and all destinations.
+   * - `opt-out`  (default) - load segment and all destinations without waiting for explicit consent.
    */
   consentModel?: () => 'opt-in' | 'opt-out'
   /**

From 419c571775c68d42c19e9ee7433830cbdcde9cd3 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:36:39 -0500
Subject: [PATCH 31/56] wip

---
 .../src/domain/analytics/analytics-service.ts | 38 +++++++++----------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
index 7e6166ccd..a35492138 100644
--- a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
@@ -4,9 +4,7 @@ import {
   Categories,
   CDNSettings,
   CreateWrapperSettings,
-  GetCategoriesFunction,
   InitOptions,
-  IntegrationCategoryMappings,
   MaybeInitializedAnalytics,
 } from '../../types'
 import { pipe } from '../../utils'
@@ -21,17 +19,19 @@ import {
   segmentShouldBeDisabled,
 } from '../blocking-helpers'
 
-export interface AnalyticsServiceOptions {
-  getCategories: GetCategoriesFunction
-  pruneUnmappedCategories?: boolean
-  integrationCategoryMappings?: IntegrationCategoryMappings
-  shouldEnableIntegration?: CreateWrapperSettings['shouldEnableIntegration']
-}
+export type AnalyticsServiceSettings = Pick<
+  CreateWrapperSettings,
+  | 'getCategories'
+  | 'pruneUnmappedCategories'
+  | 'integrationCategoryMappings'
+  | 'shouldEnableIntegration'
+>
+
 /**
  * This class is a wrapper around the analytics.js library.
  */
 export class AnalyticsService {
-  private options: AnalyticsServiceOptions
+  private settings: AnalyticsServiceSettings
 
   private cdnSettingsDeferred = createDeferred()
 
@@ -46,24 +46,24 @@ export class AnalyticsService {
   }
 
   private async getAllCategories(): Promise {
-    const allCategories = this.options.integrationCategoryMappings
-      ? parseAllCategories(this.options.integrationCategoryMappings)
+    const allCategories = this.settings.integrationCategoryMappings
+      ? parseAllCategories(this.settings.integrationCategoryMappings)
       : (await this.cdnSettings).consentSettings?.allCategories
 
     return allCategories ?? []
   }
 
   private async getCategories(): Promise {
-    const categories = await this.options.getCategories()
+    const categories = await this.settings.getCategories()
     validateCategories(categories)
     return categories
   }
 
   private uninitializedAnalytics: AnyAnalytics
 
-  constructor(analytics: AnyAnalytics, options: AnalyticsServiceOptions) {
+  constructor(analytics: AnyAnalytics, options: AnalyticsServiceSettings) {
     validateAnalyticsInstance(analytics)
-    this.options = options
+    this.settings = options
     this.uninitializedAnalytics = analytics
 
     // store the raw analytics load instance, because we may replace it later
@@ -95,8 +95,8 @@ export class AnalyticsService {
 
     const _filterDeviceModeDestinationsForOptIn = (cdnSettings: CDNSettings) =>
       filterDeviceModeDestinationsForOptIn(cdnSettings, initialCategories, {
-        shouldEnableIntegration: this.options.shouldEnableIntegration,
-        integrationCategoryMappings: this.options.integrationCategoryMappings,
+        shouldEnableIntegration: this.settings.shouldEnableIntegration,
+        integrationCategoryMappings: this.settings.integrationCategoryMappings,
       })
 
     return this.load(settings, {
@@ -142,13 +142,13 @@ export class AnalyticsService {
 
   configureBlockingMiddlewareForOptOut(): void {
     addBlockingMiddleware(this.cdnSettings, this.analytics, {
-      integrationCategoryMappings: this.options.integrationCategoryMappings,
-      shouldEnableIntegration: this.options.shouldEnableIntegration,
+      integrationCategoryMappings: this.settings.integrationCategoryMappings,
+      shouldEnableIntegration: this.settings.shouldEnableIntegration,
     })
   }
 
   configureConsentStampingMiddleware(): void {
-    const { getCategories, pruneUnmappedCategories } = this.options
+    const { getCategories, pruneUnmappedCategories } = this.settings
     // normalize getCategories pruning is turned on or off
     const getCategoriesForConsentStamping = async (): Promise => {
       const categories = await getCategories()

From b5156b3d5387fbe371506f62765797b5dd43a31f Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:39:34 -0500
Subject: [PATCH 32/56] wip

---
 .../consent-tools/src/domain/analytics/analytics-service.ts   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
index a35492138..6c8f27c77 100644
--- a/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/analytics-service.ts
@@ -148,10 +148,10 @@ export class AnalyticsService {
   }
 
   configureConsentStampingMiddleware(): void {
-    const { getCategories, pruneUnmappedCategories } = this.settings
+    const { pruneUnmappedCategories } = this.settings
     // normalize getCategories pruning is turned on or off
     const getCategoriesForConsentStamping = async (): Promise => {
-      const categories = await getCategories()
+      const categories = await this.getCategories()
       if (pruneUnmappedCategories) {
         return getPrunedCategories(categories, await this.getAllCategories())
       }

From 17b68994fe94efb1d2b3197a06686d2b90fcab78 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:40:01 -0500
Subject: [PATCH 33/56] wip

---
 .../consent/consent-tools/src/domain/consent-stamping.ts    | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/consent-stamping.ts b/packages/consent/consent-tools/src/domain/consent-stamping.ts
index 22101fd96..337844b56 100644
--- a/packages/consent/consent-tools/src/domain/consent-stamping.ts
+++ b/packages/consent/consent-tools/src/domain/consent-stamping.ts
@@ -1,5 +1,4 @@
 import { Categories, SourceMiddlewareFunction } from '../types'
-import { validateCategories } from './validation'
 
 type CreateConsentMw = (
   getCategories: () => Promise
@@ -12,12 +11,9 @@ export const createConsentStampingMiddleware: CreateConsentMw = (
   getCategories
 ) => {
   const fn: SourceMiddlewareFunction = async ({ payload, next }) => {
-    const categories = await getCategories()
-
-    validateCategories(categories)
     payload.obj.context.consent = {
       ...payload.obj.context.consent,
-      categoryPreferences: categories,
+      categoryPreferences: await getCategories(),
     }
 
     next(payload)

From 7aaae280e1cc7c0b493e8e6080d4b530d204251f Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:54:42 -0500
Subject: [PATCH 34/56] wip

---
 .../domain/__tests__/consent-stamping.test.ts | 26 --------
 .../__tests__/analytics-service.test.ts       | 66 +++++++++++++++++++
 2 files changed, 66 insertions(+), 26 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/__tests__/consent-stamping.test.ts b/packages/consent/consent-tools/src/domain/__tests__/consent-stamping.test.ts
index 81fe24056..9dcf7f91c 100644
--- a/packages/consent/consent-tools/src/domain/__tests__/consent-stamping.test.ts
+++ b/packages/consent/consent-tools/src/domain/__tests__/consent-stamping.test.ts
@@ -41,30 +41,4 @@ describe(createConsentStampingMiddleware, () => {
       Advertising: true,
     })
   })
-
-  it('should throw an error if getCategories returns an invalid value', async () => {
-    middlewareFn = createConsentStampingMiddleware(getCategories)
-    getCategories.mockReturnValue(null as any)
-    await expect(() =>
-      middlewareFn({
-        next: nextFn,
-        // @ts-ignore
-        payload,
-      })
-    ).rejects.toThrowError(/Validation/)
-    expect(nextFn).not.toHaveBeenCalled()
-  })
-
-  it('should throw an error if getCategories returns an invalid async value', async () => {
-    middlewareFn = createConsentStampingMiddleware(getCategories)
-    getCategories.mockResolvedValue(null as any)
-    await expect(() =>
-      middlewareFn({
-        next: nextFn,
-        // @ts-ignore
-        payload,
-      })
-    ).rejects.toThrowError(/Validation/)
-    expect(nextFn).not.toHaveBeenCalled()
-  })
 })
diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 9b7a59c58..87de2d343 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -1,6 +1,8 @@
 import { AnalyticsService, getInitializedAnalytics } from '../analytics-service'
 import { analyticsMock } from '../../../test-helpers/mocks'
 import { ValidationError } from '../../validation/validation-error'
+import { add } from 'lodash'
+import { Context } from '@segment/analytics-next'
 
 describe(AnalyticsService, () => {
   let analyticsService: AnalyticsService
@@ -13,6 +15,70 @@ describe(AnalyticsService, () => {
       )
     })
   })
+  // eslint-disable-next-line jest/valid-describe-callback
+  describe('getCategories validation', () => {
+    ;[() => null, () => Promise.resolve(null)].forEach((getCategories) => {
+      it(`should throw an error if getCategories returns an invalid value like ${getCategories.toString()} in addSourceMiddleware`, async () => {
+        analyticsService = new AnalyticsService(analyticsMock, {
+          getCategories: () => null as any,
+        })
+        analyticsService.configureConsentStampingMiddleware()
+        const addSourceMiddlewareSpy = jest.spyOn(
+          analyticsMock,
+          'addSourceMiddleware'
+        )
+        const middlewareFn = addSourceMiddlewareSpy.mock.calls[0][0]
+        const nextFn = jest.fn()
+        await expect(() =>
+          middlewareFn({
+            next: nextFn,
+            payload: {
+              // @ts-ignore
+              obj: {
+                context: {
+                  ...new Context({ type: 'track' }),
+                  consent: {
+                    categoryPreferences: { C0001: true },
+                  },
+                },
+              },
+            },
+          })
+        ).rejects.toThrowError(/Validation/)
+        expect(nextFn).not.toHaveBeenCalled()
+      })
+    })
+  })
+
+  it('should throw an error if getCategories returns an invalid async value', async () => {
+    analyticsService = new AnalyticsService(analyticsMock, {
+      getCategories: () => null as any,
+    })
+    analyticsService.configureConsentStampingMiddleware()
+    const addSourceMiddlewareSpy = jest.spyOn(
+      analyticsMock,
+      'addSourceMiddleware'
+    )
+    const middlewareFn = addSourceMiddlewareSpy.mock.calls[0][0]
+    const nextFn = jest.fn()
+    await expect(() =>
+      middlewareFn({
+        next: nextFn,
+        payload: {
+          // @ts-ignore
+          obj: {
+            context: {
+              ...new Context({ type: 'track' }),
+              consent: {
+                categoryPreferences: { C0001: true },
+              },
+            },
+          },
+        },
+      })
+    ).rejects.toThrowError(/Validation/)
+    expect(nextFn).not.toHaveBeenCalled()
+  })
 
   describe('load', () => {
     it('loads normally', () => {

From 1781ec06513649ad3f9b8d51f2abaacbaa37ad2d Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:54:53 -0500
Subject: [PATCH 35/56] wip

---
 .../src/domain/analytics/__tests__/analytics-service.test.ts     | 1 -
 1 file changed, 1 deletion(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 87de2d343..c6c7a788a 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -33,7 +33,6 @@ describe(AnalyticsService, () => {
           middlewareFn({
             next: nextFn,
             payload: {
-              // @ts-ignore
               obj: {
                 context: {
                   ...new Context({ type: 'track' }),

From 2cd726538cd74fe7fe065259e490b26f19ebdf0f Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:55:31 -0500
Subject: [PATCH 36/56] wip

---
 .../__tests__/analytics-service.test.ts       | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index c6c7a788a..a018d8ff2 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -29,19 +29,20 @@ describe(AnalyticsService, () => {
         )
         const middlewareFn = addSourceMiddlewareSpy.mock.calls[0][0]
         const nextFn = jest.fn()
+        const payload = {
+          obj: {
+            context: {
+              ...new Context({ type: 'track' }),
+              consent: {
+                categoryPreferences: { C0001: true },
+              },
+            },
+          },
+        }
         await expect(() =>
           middlewareFn({
             next: nextFn,
-            payload: {
-              obj: {
-                context: {
-                  ...new Context({ type: 'track' }),
-                  consent: {
-                    categoryPreferences: { C0001: true },
-                  },
-                },
-              },
-            },
+            payload,
           })
         ).rejects.toThrowError(/Validation/)
         expect(nextFn).not.toHaveBeenCalled()

From 21bc59b7a9dac3d6b3ae9f2b01e618e3c5490b7b Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:56:33 -0500
Subject: [PATCH 37/56] wip

---
 .../domain/analytics/__tests__/analytics-service.test.ts | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index a018d8ff2..caa3845c0 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -15,12 +15,13 @@ describe(AnalyticsService, () => {
       )
     })
   })
-  // eslint-disable-next-line jest/valid-describe-callback
+
   describe('getCategories validation', () => {
-    ;[() => null, () => Promise.resolve(null)].forEach((getCategories) => {
-      it(`should throw an error if getCategories returns an invalid value like ${getCategories.toString()} in addSourceMiddleware`, async () => {
+    ;[() => null, () => Promise.resolve(null)].forEach((getCategoriesFn) => {
+      it(`should throw an error if getCategories returns an invalid value like ${getCategoriesFn.toString()} in addSourceMiddleware`, async () => {
         analyticsService = new AnalyticsService(analyticsMock, {
-          getCategories: () => null as any,
+          // @ts-ignore
+          getCategories: getCategoriesFn,
         })
         analyticsService.configureConsentStampingMiddleware()
         const addSourceMiddlewareSpy = jest.spyOn(

From bc78dce3385d90830471550ad36a74133fd3ef14 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 14:57:08 -0500
Subject: [PATCH 38/56] wip

---
 .../src/domain/analytics/__tests__/analytics-service.test.ts     | 1 -
 1 file changed, 1 deletion(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index caa3845c0..7ba51315b 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -1,7 +1,6 @@
 import { AnalyticsService, getInitializedAnalytics } from '../analytics-service'
 import { analyticsMock } from '../../../test-helpers/mocks'
 import { ValidationError } from '../../validation/validation-error'
-import { add } from 'lodash'
 import { Context } from '@segment/analytics-next'
 
 describe(AnalyticsService, () => {

From 1fc0f4c2b003dcff9e16fc91acbaf1279aaff19a Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:06:43 -0500
Subject: [PATCH 39/56] wip

---
 .../domain/analytics/__tests__/analytics-service.test.ts | 9 +++++----
 .../src/domain/validation/options-validators.ts          | 7 ++++++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 7ba51315b..82f02d2fc 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -16,8 +16,9 @@ describe(AnalyticsService, () => {
   })
 
   describe('getCategories validation', () => {
-    ;[() => null, () => Promise.resolve(null)].forEach((getCategoriesFn) => {
-      it(`should throw an error if getCategories returns an invalid value like ${getCategoriesFn.toString()} in addSourceMiddleware`, async () => {
+    it.each([[() => null], [() => Promise.resolve(null)]])(
+      'should throw an error if getCategories returns an invalid value: %p',
+      async (getCategoriesFn) => {
         analyticsService = new AnalyticsService(analyticsMock, {
           // @ts-ignore
           getCategories: getCategoriesFn,
@@ -46,8 +47,8 @@ describe(AnalyticsService, () => {
           })
         ).rejects.toThrowError(/Validation/)
         expect(nextFn).not.toHaveBeenCalled()
-      })
-    })
+      }
+    )
   })
 
   it('should throw an error if getCategories returns an invalid async value', async () => {
diff --git a/packages/consent/consent-tools/src/domain/validation/options-validators.ts b/packages/consent/consent-tools/src/domain/validation/options-validators.ts
index ac1128a3c..7d236a67f 100644
--- a/packages/consent/consent-tools/src/domain/validation/options-validators.ts
+++ b/packages/consent/consent-tools/src/domain/validation/options-validators.ts
@@ -58,7 +58,12 @@ export function validateAnalyticsInstance(
   analytics: unknown
 ): asserts analytics is AnyAnalytics {
   assertIsObject(analytics, 'analytics')
-  if ('load' in analytics && 'addSourceMiddleware' in analytics) {
+  if (
+    'load' in analytics &&
+    'addSourceMiddleware' in analytics &&
+    'addDestinationMiddleware' in analytics &&
+    'track' in analytics
+  ) {
     return
   }
   throw new ValidationError('analytics is not an Analytics instance', analytics)

From 044211a049ab9d359d5467c4f3c0ebe286f5fb33 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:20:48 -0500
Subject: [PATCH 40/56] wip

---
 .../domain/analytics/__tests__/analytics-service.test.ts | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 82f02d2fc..b042ff398 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -16,9 +16,12 @@ describe(AnalyticsService, () => {
   })
 
   describe('getCategories validation', () => {
-    it.each([[() => null], [() => Promise.resolve(null)]])(
-      'should throw an error if getCategories returns an invalid value: %p',
-      async (getCategoriesFn) => {
+    it.each([
+      { fn: () => null, label: 'sync' },
+      { fn: () => Promise.resolve(null), label: 'async' },
+    ])(
+      'should throw an error if getCategories returns an invalid value: $label',
+      async ({ fn: getCategoriesFn }) => {
         analyticsService = new AnalyticsService(analyticsMock, {
           // @ts-ignore
           getCategories: getCategoriesFn,

From edf16aaa85b0111ecac5bf33a841acdaae59fad8 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:21:16 -0500
Subject: [PATCH 41/56] wip

---
 .../src/domain/analytics/__tests__/analytics-service.test.ts    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index b042ff398..750226f63 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -48,7 +48,7 @@ describe(AnalyticsService, () => {
             next: nextFn,
             payload,
           })
-        ).rejects.toThrowError(/Validation/)
+        ).rejects.toThrow(/Validation/)
         expect(nextFn).not.toHaveBeenCalled()
       }
     )

From 68b2744d52e03d0b549894c1674f637c778cabe1 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:21:46 -0500
Subject: [PATCH 42/56] wip

---
 .../src/domain/analytics/__tests__/analytics-service.test.ts    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 750226f63..8679813e1 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -20,7 +20,7 @@ describe(AnalyticsService, () => {
       { fn: () => null, label: 'sync' },
       { fn: () => Promise.resolve(null), label: 'async' },
     ])(
-      'should throw an error if getCategories returns an invalid value: $label',
+      'should throw an error in configureConsentStampingMiddleware if getCategories returns an invalid value: $label',
       async ({ fn: getCategoriesFn }) => {
         analyticsService = new AnalyticsService(analyticsMock, {
           // @ts-ignore

From 5528f9b8af37d2cab1881773c8a370bc429e7f7c Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:22:07 -0500
Subject: [PATCH 43/56] wip

---
 .../src/domain/analytics/__tests__/analytics-service.test.ts    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 8679813e1..c6717d6cf 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -20,7 +20,7 @@ describe(AnalyticsService, () => {
       { fn: () => null, label: 'sync' },
       { fn: () => Promise.resolve(null), label: 'async' },
     ])(
-      'should throw an error in configureConsentStampingMiddleware if getCategories returns an invalid value: $label',
+      'should throw an error in addSourceMiddleware if getCategories returns an invalid value: $label',
       async ({ fn: getCategoriesFn }) => {
         analyticsService = new AnalyticsService(analyticsMock, {
           // @ts-ignore

From eed0621619089492ca4c8ad0441acd1793c0924e Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:22:31 -0500
Subject: [PATCH 44/56] wip

---
 .../domain/analytics/__tests__/analytics-service.test.ts  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index c6717d6cf..9414e359b 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -17,14 +17,14 @@ describe(AnalyticsService, () => {
 
   describe('getCategories validation', () => {
     it.each([
-      { fn: () => null, label: 'sync' },
-      { fn: () => Promise.resolve(null), label: 'async' },
+      { getCategories: () => null, label: 'sync' },
+      { getCategories: () => Promise.resolve(null), label: 'async' },
     ])(
       'should throw an error in addSourceMiddleware if getCategories returns an invalid value: $label',
-      async ({ fn: getCategoriesFn }) => {
+      async ({ getCategories }) => {
         analyticsService = new AnalyticsService(analyticsMock, {
           // @ts-ignore
-          getCategories: getCategoriesFn,
+          getCategories,
         })
         analyticsService.configureConsentStampingMiddleware()
         const addSourceMiddlewareSpy = jest.spyOn(

From 930474fde480ee9a5a55464a6b99afe5f390468d Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:23:18 -0500
Subject: [PATCH 45/56] wip

---
 .../domain/analytics/__tests__/analytics-service.test.ts    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
index 9414e359b..e589a21cf 100644
--- a/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
+++ b/packages/consent/consent-tools/src/domain/analytics/__tests__/analytics-service.test.ts
@@ -17,10 +17,10 @@ describe(AnalyticsService, () => {
 
   describe('getCategories validation', () => {
     it.each([
-      { getCategories: () => null, label: 'sync' },
-      { getCategories: () => Promise.resolve(null), label: 'async' },
+      { test: 'sync', getCategories: () => null },
+      { test: 'async', getCategories: () => Promise.resolve(null) },
     ])(
-      'should throw an error in addSourceMiddleware if getCategories returns an invalid value: $label',
+      'should throw an error in addSourceMiddleware if getCategories returns an invalid value: $test',
       async ({ getCategories }) => {
         analyticsService = new AnalyticsService(analyticsMock, {
           // @ts-ignore

From 3115e4626705c8de646cd5e412a9ce802affff87 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:28:53 -0500
Subject: [PATCH 46/56] wip

---
 packages/consent/consent-tools/package.json   |  1 +
 .../src/domain/wrapper.ts                     |  1 +
 yarn.lock                                     | 25 +++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/packages/consent/consent-tools/package.json b/packages/consent/consent-tools/package.json
index 1ce4507fe..f218a6b1e 100644
--- a/packages/consent/consent-tools/package.json
+++ b/packages/consent/consent-tools/package.json
@@ -47,6 +47,7 @@
     "url": "https://github.com/segmentio/analytics-next"
   },
   "dependencies": {
+    "changeset": "^0.2.6",
     "tslib": "^2.4.1"
   }
 }
diff --git a/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts b/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
index f482c3140..039e1f032 100644
--- a/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
+++ b/packages/consent/consent-wrapper-onetrust/src/domain/wrapper.ts
@@ -12,6 +12,7 @@ import {
   getOneTrustGlobal,
 } from '../lib/onetrust-api'
 import { coerceConsentModel } from './consent-model'
+
 export interface OneTrustSettings {
   integrationCategoryMappings?: CreateWrapperSettings['integrationCategoryMappings']
   disableConsentChangedEvent?: boolean
diff --git a/yarn.lock b/yarn.lock
index 576eea9a3..e20b11e26 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3909,6 +3909,7 @@ __metadata:
     "@internal/config": "workspace:^"
     "@internal/test-helpers": "workspace:^"
     "@segment/analytics-next": "workspace:^"
+    changeset: ^0.2.6
     tslib: ^2.4.1
   peerDependencies:
     "@segment/analytics-next": ">=1.53.1"
@@ -8751,6 +8752,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"changeset@npm:^0.2.6":
+  version: 0.2.6
+  resolution: "changeset@npm:0.2.6"
+  dependencies:
+    udc: ^1.0.0
+    underscore: ^1.8.3
+  checksum: bb916eff7dc8d281f91762a4e0d324cc3a527535263fd4d0345be9def20e1b112184c29e4312bec4de34814574b33c271ca5d759c4466acd5dc9b9f1733b434f
+  languageName: node
+  linkType: hard
+
 "char-regex@npm:^1.0.2":
   version: 1.0.2
   resolution: "char-regex@npm:1.0.2"
@@ -21308,6 +21319,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"udc@npm:^1.0.0":
+  version: 1.0.1
+  resolution: "udc@npm:1.0.1"
+  checksum: 302b4bd08feab3f75683bcebfe0dde9eabdb2579400ef3feef09132169842ea83e64441e075b0523c91be3ba1f4668fbb8c7d6918e3032be56a967629c4e7db2
+  languageName: node
+  linkType: hard
+
 "unbox-primitive@npm:^1.0.2":
   version: 1.0.2
   resolution: "unbox-primitive@npm:1.0.2"
@@ -21330,6 +21348,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"underscore@npm:^1.8.3":
+  version: 1.13.6
+  resolution: "underscore@npm:1.13.6"
+  checksum: d5cedd14a9d0d91dd38c1ce6169e4455bb931f0aaf354108e47bd46d3f2da7464d49b2171a5cf786d61963204a42d01ea1332a903b7342ad428deaafaf70ec36
+  languageName: node
+  linkType: hard
+
 "undici@npm:^5.22.1":
   version: 5.28.3
   resolution: "undici@npm:5.28.3"

From 8035379fc37c6cd1c5f08238fce417b994ca6c20 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:30:24 -0500
Subject: [PATCH 47/56] wip

---
 .../standalone-playground/pages/index-consent-opt-out.html     | 3 +--
 playgrounds/standalone-playground/pages/index-consent.html     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/playgrounds/standalone-playground/pages/index-consent-opt-out.html b/playgrounds/standalone-playground/pages/index-consent-opt-out.html
index 6e2a8ed55..ea4d34e80 100644
--- a/playgrounds/standalone-playground/pages/index-consent-opt-out.html
+++ b/playgrounds/standalone-playground/pages/index-consent-opt-out.html
@@ -110,8 +110,7 @@
             }
             analytics.SNIPPET_VERSION = '4.13.1'
             analytics._writeKey = writeKey
-            window['SEGMENT_CONSENT_WRAPPER_DEBUG_MODE'] = true
-            withOneTrust(analytics, { consentModel: () => 'opt-out' }).load()
+            withOneTrust(analytics, { consentModel: () => 'opt-out', enableDebugLogging: true }).load()
             analytics.page()
           }
       })()
diff --git a/playgrounds/standalone-playground/pages/index-consent.html b/playgrounds/standalone-playground/pages/index-consent.html
index c76b94972..8e234d4af 100644
--- a/playgrounds/standalone-playground/pages/index-consent.html
+++ b/playgrounds/standalone-playground/pages/index-consent.html
@@ -110,8 +110,7 @@
             }
             analytics.SNIPPET_VERSION = '4.13.1'
             analytics._writeKey = writeKey
-            window['SEGMENT_CONSENT_WRAPPER_DEBUG_MODE'] = true
-            withOneTrust(analytics).load()
+            withOneTrust(analytics, { enableDebugLogging: true }).load()
             analytics.page()
           }
       })()

From acd7d53f9d800ade8da35f4c46b6bbe9f8438502 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:31:46 -0500
Subject: [PATCH 48/56] wip

---
 ...tools-vanilla.test.ts => consent-tools-vanilla-opt-in.test.ts} | 0
 .../pages/{index-consent.html => index-consent-opt-in.html}       | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename packages/consent/consent-tools-integration-tests/src/tests/{consent-tools-vanilla.test.ts => consent-tools-vanilla-opt-in.test.ts} (100%)
 rename playgrounds/standalone-playground/pages/{index-consent.html => index-consent-opt-in.html} (100%)

diff --git a/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla.test.ts b/packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-in.test.ts
similarity index 100%
rename from packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla.test.ts
rename to packages/consent/consent-tools-integration-tests/src/tests/consent-tools-vanilla-opt-in.test.ts
diff --git a/playgrounds/standalone-playground/pages/index-consent.html b/playgrounds/standalone-playground/pages/index-consent-opt-in.html
similarity index 100%
rename from playgrounds/standalone-playground/pages/index-consent.html
rename to playgrounds/standalone-playground/pages/index-consent-opt-in.html

From 64c44ed55ac0105f209f70a47e3f9edd4527a965 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:52:50 -0500
Subject: [PATCH 49/56] wip

---
 .../consent/consent-tools/src/domain/blocking-helpers.ts    | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/packages/consent/consent-tools/src/domain/blocking-helpers.ts b/packages/consent/consent-tools/src/domain/blocking-helpers.ts
index 2ddb45ea1..71453fe63 100644
--- a/packages/consent/consent-tools/src/domain/blocking-helpers.ts
+++ b/packages/consent/consent-tools/src/domain/blocking-helpers.ts
@@ -81,10 +81,6 @@ export const filterDeviceModeDestinationsForOptIn = (
   const { integrationCategoryMappings, shouldEnableIntegration } =
     filterSettings
 
-  if (!remotePlugins) {
-    return cdnSettings
-  }
-
   const cdnSettingsCopy: CDNSettings = {
     ...cdnSettings,
     remotePlugins: [...(remotePlugins || [])],
@@ -105,7 +101,7 @@ export const filterDeviceModeDestinationsForOptIn = (
   for (const creationName in integrations) {
     if (!_shouldEnableIntegrationHelper(creationName)) {
       logger.debug(`Disabled (opt-in): ${creationName}`)
-      cdnSettingsCopy.remotePlugins = remotePlugins.filter(
+      cdnSettingsCopy.remotePlugins = remotePlugins?.filter(
         (p) => p.creationName !== creationName
       )
       // remove disabled classic destinations and locally-installed action destinations

From 2eb40f7bf7d95e086f92e2ab017e85310bef335d Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Tue, 16 Apr 2024 16:32:01 -0500
Subject: [PATCH 50/56] wip

---
 ...nt-tools-vanilla.html => consent-tools-vanilla-opt-in.html} | 3 ++-
 .../public/consent-tools-vanilla-opt-out.html                  | 1 +
 .../index.ts                                                   | 0
 .../src/page-objects/consent-tools-vanilla.ts                  | 2 +-
 4 files changed, 4 insertions(+), 2 deletions(-)
 rename packages/consent/consent-tools-integration-tests/public/{consent-tools-vanilla.html => consent-tools-vanilla-opt-in.html} (69%)
 rename packages/consent/consent-tools-integration-tests/src/page-bundles/{consent-tools-vanilla => consent-tools-vanilla-opt-in}/index.ts (100%)

diff --git a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-in.html
similarity index 69%
rename from packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html
rename to packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-in.html
index 997fa47ed..dccc86d97 100644
--- a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla.html
+++ b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-in.html
@@ -5,6 +5,7 @@
   

Hello World - Serving Analytics

Please Check Network tab

This page can used as playground or run by webdriver.io

- + + \ No newline at end of file diff --git a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html index a17c8329a..084a52de9 100644 --- a/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html +++ b/packages/consent/consent-tools-integration-tests/public/consent-tools-vanilla-opt-out.html @@ -8,3 +8,4 @@

Please Check Network tab

+ \ No newline at end of file diff --git a/packages/consent/consent-tools-integration-tests/src/page-bundles/consent-tools-vanilla/index.ts b/packages/consent/consent-tools-integration-tests/src/page-bundles/consent-tools-vanilla-opt-in/index.ts similarity index 100% rename from packages/consent/consent-tools-integration-tests/src/page-bundles/consent-tools-vanilla/index.ts rename to packages/consent/consent-tools-integration-tests/src/page-bundles/consent-tools-vanilla-opt-in/index.ts diff --git a/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts b/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts index 56e79a16c..a6fc473e5 100644 --- a/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts +++ b/packages/consent/consent-tools-integration-tests/src/page-objects/consent-tools-vanilla.ts @@ -19,6 +19,6 @@ export class ConsentToolsVanillaOptOut extends ConsentToolsVanilla { export class ConsentToolsVanillaOptIn extends ConsentToolsVanilla { constructor() { - super('consent-tools-vanilla.html') + super('consent-tools-vanilla-opt-in.html') } } From db8e044dd694568eff1a9f8e265756df2fe68552 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:36:26 -0500 Subject: [PATCH 51/56] wip --- packages/browser/src/index.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index 26a3987a4..fdd552aa8 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -8,10 +8,6 @@ export * from './core/plugin' export * from './core/user' export type { AnalyticsSnippet } from './browser/standalone-interface' -export type { - MiddlewareFunction, - DestinationMiddlewareFunction, - MiddlewareParams, -} from './plugins/middleware' +export type { MiddlewareFunction } from './plugins/middleware' export { getGlobalAnalytics } from './lib/global-analytics-helper' export { UniversalStorage, Store, StorageObject } from './core/storage' From 0c9fc266a5b493ebb42c901971534d278afca07b Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:43:13 -0500 Subject: [PATCH 52/56] update changeset --- .changeset/tall-hornets-do.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/tall-hornets-do.md diff --git a/.changeset/tall-hornets-do.md b/.changeset/tall-hornets-do.md new file mode 100644 index 000000000..242411abd --- /dev/null +++ b/.changeset/tall-hornets-do.md @@ -0,0 +1,6 @@ +--- +'@segment/analytics-consent-tools': major +'@segment/analytics-consent-wrapper-onetrust': major +--- + +Add opt-out consent-model support, and use opt-out by default From 465435b3fa75bd03f7770459d86695597428f2a6 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:58:10 -0500 Subject: [PATCH 53/56] wip --- packages/consent/consent-tools/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/consent/consent-tools/src/index.ts b/packages/consent/consent-tools/src/index.ts index 23bcb2ed4..e7e7594a7 100644 --- a/packages/consent/consent-tools/src/index.ts +++ b/packages/consent/consent-tools/src/index.ts @@ -4,8 +4,8 @@ */ export { createWrapper } from './domain/create-wrapper' export { resolveWhen } from './utils' - export type { ConsentModel } from './domain/load-context' + export type { Wrapper, CreateWrapper, From 18e78cc81039ab70ce6be47deac10126ac48b7a6 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:58:47 -0500 Subject: [PATCH 54/56] update optional peer dep --- packages/consent/consent-tools/package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/consent/consent-tools/package.json b/packages/consent/consent-tools/package.json index f218a6b1e..375a36a72 100644 --- a/packages/consent/consent-tools/package.json +++ b/packages/consent/consent-tools/package.json @@ -27,7 +27,7 @@ "jest": "yarn run -T jest" }, "peerDependencies": { - "@segment/analytics-next": ">=1.53.1" + "@segment/analytics-next": ">=1.67.0" }, "peerDependenciesMeta": { "@segment/analytics-next": { diff --git a/yarn.lock b/yarn.lock index e20b11e26..91989dc5f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3912,7 +3912,7 @@ __metadata: changeset: ^0.2.6 tslib: ^2.4.1 peerDependencies: - "@segment/analytics-next": ">=1.53.1" + "@segment/analytics-next": ">=1.67.0" peerDependenciesMeta: "@segment/analytics-next": optional: true From 3174b4f0709ff031a073e5cf239cae1b209022e7 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:01:05 -0500 Subject: [PATCH 55/56] remove accidental changeset dep --- packages/consent/consent-tools/package.json | 1 - yarn.lock | 25 --------------------- 2 files changed, 26 deletions(-) diff --git a/packages/consent/consent-tools/package.json b/packages/consent/consent-tools/package.json index 375a36a72..7704e9320 100644 --- a/packages/consent/consent-tools/package.json +++ b/packages/consent/consent-tools/package.json @@ -47,7 +47,6 @@ "url": "https://github.com/segmentio/analytics-next" }, "dependencies": { - "changeset": "^0.2.6", "tslib": "^2.4.1" } } diff --git a/yarn.lock b/yarn.lock index 91989dc5f..5bc62d89f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3909,7 +3909,6 @@ __metadata: "@internal/config": "workspace:^" "@internal/test-helpers": "workspace:^" "@segment/analytics-next": "workspace:^" - changeset: ^0.2.6 tslib: ^2.4.1 peerDependencies: "@segment/analytics-next": ">=1.67.0" @@ -8752,16 +8751,6 @@ __metadata: languageName: node linkType: hard -"changeset@npm:^0.2.6": - version: 0.2.6 - resolution: "changeset@npm:0.2.6" - dependencies: - udc: ^1.0.0 - underscore: ^1.8.3 - checksum: bb916eff7dc8d281f91762a4e0d324cc3a527535263fd4d0345be9def20e1b112184c29e4312bec4de34814574b33c271ca5d759c4466acd5dc9b9f1733b434f - languageName: node - linkType: hard - "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -21319,13 +21308,6 @@ __metadata: languageName: node linkType: hard -"udc@npm:^1.0.0": - version: 1.0.1 - resolution: "udc@npm:1.0.1" - checksum: 302b4bd08feab3f75683bcebfe0dde9eabdb2579400ef3feef09132169842ea83e64441e075b0523c91be3ba1f4668fbb8c7d6918e3032be56a967629c4e7db2 - languageName: node - linkType: hard - "unbox-primitive@npm:^1.0.2": version: 1.0.2 resolution: "unbox-primitive@npm:1.0.2" @@ -21348,13 +21330,6 @@ __metadata: languageName: node linkType: hard -"underscore@npm:^1.8.3": - version: 1.13.6 - resolution: "underscore@npm:1.13.6" - checksum: d5cedd14a9d0d91dd38c1ce6169e4455bb931f0aaf354108e47bd46d3f2da7464d49b2171a5cf786d61963204a42d01ea1332a903b7342ad428deaafaf70ec36 - languageName: node - linkType: hard - "undici@npm:^5.22.1": version: 5.28.3 resolution: "undici@npm:5.28.3" From f294612a13f501793c9ce8246d858b9429bf5db8 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:03:01 -0500 Subject: [PATCH 56/56] tweak opt peer dep --- packages/consent/consent-wrapper-onetrust/package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/consent/consent-wrapper-onetrust/package.json b/packages/consent/consent-wrapper-onetrust/package.json index c4fac1b85..a839ba4ae 100644 --- a/packages/consent/consent-wrapper-onetrust/package.json +++ b/packages/consent/consent-wrapper-onetrust/package.json @@ -45,7 +45,7 @@ "tslib": "^2.4.1" }, "peerDependencies": { - "@segment/analytics-next": ">=1.53.1" + "@segment/analytics-next": ">=1.67.0" }, "peerDependenciesMeta": { "@segment/analytics-next": { diff --git a/yarn.lock b/yarn.lock index 5bc62d89f..8ec12b1d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3927,7 +3927,7 @@ __metadata: "@segment/analytics-consent-tools": 1.2.0 tslib: ^2.4.1 peerDependencies: - "@segment/analytics-next": ">=1.53.1" + "@segment/analytics-next": ">=1.67.0" peerDependenciesMeta: "@segment/analytics-next": optional: true