@walkeros/web-source-cmp-usercentrics 2.2.0-next-1773136823705 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.d.mts +5 -1
- package/dist/dev.d.ts +5 -1
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +5 -1
- package/dist/examples/index.d.ts +5 -1
- package/dist/examples/index.js +40 -0
- package/dist/examples/index.mjs +40 -0
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +46 -1
- package/package.json +5 -5
package/dist/dev.d.mts
CHANGED
|
@@ -102,11 +102,15 @@ declare const noopLogger: Logger.Instance;
|
|
|
102
102
|
|
|
103
103
|
declare const fullConsent: Flow.StepExample;
|
|
104
104
|
declare const minimalConsent: Flow.StepExample;
|
|
105
|
+
declare const categoryMapOverride: Flow.StepExample;
|
|
106
|
+
declare const customEventName: Flow.StepExample;
|
|
105
107
|
|
|
108
|
+
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
109
|
+
declare const step_customEventName: typeof customEventName;
|
|
106
110
|
declare const step_fullConsent: typeof fullConsent;
|
|
107
111
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
108
112
|
declare namespace step {
|
|
109
|
-
export { step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
113
|
+
export { step_categoryMapOverride as categoryMapOverride, step_customEventName as customEventName, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */
|
package/dist/dev.d.ts
CHANGED
|
@@ -102,11 +102,15 @@ declare const noopLogger: Logger.Instance;
|
|
|
102
102
|
|
|
103
103
|
declare const fullConsent: Flow.StepExample;
|
|
104
104
|
declare const minimalConsent: Flow.StepExample;
|
|
105
|
+
declare const categoryMapOverride: Flow.StepExample;
|
|
106
|
+
declare const customEventName: Flow.StepExample;
|
|
105
107
|
|
|
108
|
+
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
109
|
+
declare const step_customEventName: typeof customEventName;
|
|
106
110
|
declare const step_fullConsent: typeof fullConsent;
|
|
107
111
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
108
112
|
declare namespace step {
|
|
109
|
-
export { step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
113
|
+
export { step_categoryMapOverride as categoryMapOverride, step_customEventName as customEventName, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(e,n)=>{for(var a in n)t(e,a,{get:n[a],enumerable:!0})},s={};o(s,{examples:()=>l}),module.exports=(e=s,((e,o,s,l)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of a(o))i.call(e,c)||c===s||t(e,c,{get:()=>o[c],enumerable:!(l=n(o,c))||l.enumerable});return e})(t({},"__esModule",{value:!0}),e));var l={};o(l,{createMockElbFn:()=>A,fullConsent:()=>c,fullConsentCustomMapped:()=>k,fullConsentMapped:()=>f,fullConsentUpperCase:()=>g,implicitConsent:()=>u,minimalConsent:()=>p,minimalConsentMapped:()=>C,nonConsentEvent:()=>y,noopLogger:()=>E,partialConsent:()=>r,partialConsentMapped:()=>v,serviceLevelConsent:()=>m,serviceLevelMapped:()=>d,setup:()=>S,step:()=>b});var c={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},r={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},p={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},u={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},g={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},m={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},y={event:"other_event",type:"explicit"},f={essential:!0,functional:!0,marketing:!0},v={essential:!0,functional:!0,marketing:!1},C={essential:!0,functional:!1,marketing:!1},k={functional:!0,marketing:!0},d={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},_=()=>{},A=()=>()=>Promise.resolve({ok:!0}),E={error:_,warn:_,info:_,debug:_,throw:e=>{throw"string"==typeof e?new Error(e):e},json:_,scope:()=>E},b={};o(b,{categoryMapOverride:()=>G,customEventName:()=>M,fullConsent:()=>x,minimalConsent:()=>w});var x={in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:{essential:!0,functional:!0,marketing:!0}},w={in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:{essential:!0,functional:!1,marketing:!1}},G={description:"Custom categoryMap remaps essential to functional and functional to analytics",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:{functional:!0,analytics:!0,marketing:!1}},M={description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:{essential:!0,functional:!0,marketing:!0}},S=(e,t)=>{if(e&&"object"==typeof e)return()=>{t.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts"],"sourcesContent":["/**\n * Development exports for testing and tooling.\n */\nexport * as examples from './examples';\n","export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { setup } from './setup';\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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IACP,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,YAAY;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AACF;;;ACjCO,IAAM,QAAwB,CAAC,OAAO,QAAQ;AACnD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,SAAO,MAAM;AACX,QAAI,OAAO,cAAc,IAAI,YAAY,WAAW,EAAE,QAAQ,MAAM,CAAC,CAAC;AAAA,EACxE;AACF;","names":["fullConsent","minimalConsent"]}
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts"],"sourcesContent":["/**\n * Development exports for testing and tooling.\n */\nexport * as examples from './examples';\n","export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { setup } from './setup';\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n description:\n 'Custom categoryMap remaps essential to functional and functional to analytics',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n },\n mapping: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n out: {\n functional: true,\n analytics: true,\n marketing: false,\n },\n};\n\nexport const customEventName: Flow.StepExample = {\n description: 'Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n mapping: { eventName: 'UC_SDK_EVENT' },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAMO,IAAM,kBAA2C;AAAA,EACtD,OAAO;AAAA,E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ACb;AAAA,EACF;AAAA,EACA,SAAS,EAAE,WAAW,eAAe;AAAA,EACrC,KAAK;AAAA,IACH,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AACF;;;AC1EO,IAAM,QAAwB,CAAC,OAAO,QAAQ;AACnD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,SAAO,MAAM;AACX,QAAI,OAAO,cAAc,IAAI,YAAY,WAAW,EAAE,QAAQ,MAAM,CAAC,CAAC;AAAA,EACxE;AACF;","names":["fullConsent","minimalConsent"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,n)=>{for(var a in n)e(t,a,{get:n[a],enumerable:!0})},n={};t(n,{createMockElbFn:()=>f,fullConsent:()=>a,fullConsentCustomMapped:()=>m,fullConsentMapped:()=>p,fullConsentUpperCase:()=>l,implicitConsent:()=>s,minimalConsent:()=>o,minimalConsentMapped:()=>
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{for(var a in n)e(t,a,{get:n[a],enumerable:!0})},n={};t(n,{createMockElbFn:()=>f,fullConsent:()=>a,fullConsentCustomMapped:()=>m,fullConsentMapped:()=>p,fullConsentUpperCase:()=>l,implicitConsent:()=>s,minimalConsent:()=>o,minimalConsentMapped:()=>g,nonConsentEvent:()=>r,noopLogger:()=>C,partialConsent:()=>i,partialConsentMapped:()=>u,serviceLevelConsent:()=>c,serviceLevelMapped:()=>y,setup:()=>x,step:()=>k});var a={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},i={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},o={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},s={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},l={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},c={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},r={event:"other_event",type:"explicit"},p={essential:!0,functional:!0,marketing:!0},u={essential:!0,functional:!0,marketing:!1},g={essential:!0,functional:!1,marketing:!1},m={functional:!0,marketing:!0},y={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},v=()=>{},f=()=>()=>Promise.resolve({ok:!0}),C={error:v,warn:v,info:v,debug:v,throw:e=>{throw"string"==typeof e?new Error(e):e},json:v,scope:()=>C},k={};t(k,{categoryMapOverride:()=>_,customEventName:()=>E,fullConsent:()=>d,minimalConsent:()=>A});var d={in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:{essential:!0,functional:!0,marketing:!0}},A={in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:{essential:!0,functional:!1,marketing:!1}},_={description:"Custom categoryMap remaps essential to functional and functional to analytics",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:{functional:!0,analytics:!0,marketing:!1}},E={description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:{essential:!0,functional:!0,marketing:!0}},x=(e,t)=>{if(e&&"object"==typeof e)return()=>{t.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}};export{n as examples};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts"],"sourcesContent":["export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { setup } from './setup';\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAA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{"version":3,"sources":["../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts"],"sourcesContent":["export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { setup } from './setup';\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n description:\n 'Custom categoryMap remaps essential to functional and functional to analytics',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n },\n mapping: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n out: {\n functional: true,\n analytics: true,\n marketing: false,\n },\n};\n\nexport const customEventName: Flow.StepExample = {\n description: 'Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n mapping: { eventName: 'UC_SDK_EVENT' },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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M;AAAA,IACN,QAAQ;AAAA,IACR,YAAY;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AACF;AAEO,IAAM,sBAAwC;AAAA,EACnD,aACE;AAAA,EACF,IAAI;AAAA,IACF,OAAO;AAAA,IACP,MAAM;AAAA,IACN,YAAY;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,aAAa,EAAE,WAAW,cAAc,YAAY,YAAY;AAAA,EAClE;AAAA,EACA,KAAK;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;AAEO,IAAM,kBAAoC;AAAA,EAC/C,aAAa;AAAA,EACb,IAAI;AAAA,IACF,OAAO;AAAA,IACP,MAAM;AAAA,IACN,YAAY;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,SAAS,EAAE,WAAW,eAAe;AAAA,EACrC,KAAK;AAAA,IACH,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AACF;;;AC1EO,IAAM,QAAwB,CAAC,OAAO,QAAQ;AACnD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,SAAO,MAAM;AACX,QAAI,OAAO,cAAc,IAAI,YAAY,WAAW,EAAE,QAAQ,MAAM,CAAC,CAAC;AAAA,EACxE;AACF;","names":["fullConsent","minimalConsent"]}
|
|
@@ -102,11 +102,15 @@ declare const noopLogger: Logger.Instance;
|
|
|
102
102
|
|
|
103
103
|
declare const fullConsent: Flow.StepExample;
|
|
104
104
|
declare const minimalConsent: Flow.StepExample;
|
|
105
|
+
declare const categoryMapOverride: Flow.StepExample;
|
|
106
|
+
declare const customEventName: Flow.StepExample;
|
|
105
107
|
|
|
108
|
+
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
109
|
+
declare const step_customEventName: typeof customEventName;
|
|
106
110
|
declare const step_fullConsent: typeof fullConsent;
|
|
107
111
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
108
112
|
declare namespace step {
|
|
109
|
-
export { step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
113
|
+
export { step_categoryMapOverride as categoryMapOverride, step_customEventName as customEventName, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -102,11 +102,15 @@ declare const noopLogger: Logger.Instance;
|
|
|
102
102
|
|
|
103
103
|
declare const fullConsent: Flow.StepExample;
|
|
104
104
|
declare const minimalConsent: Flow.StepExample;
|
|
105
|
+
declare const categoryMapOverride: Flow.StepExample;
|
|
106
|
+
declare const customEventName: Flow.StepExample;
|
|
105
107
|
|
|
108
|
+
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
109
|
+
declare const step_customEventName: typeof customEventName;
|
|
106
110
|
declare const step_fullConsent: typeof fullConsent;
|
|
107
111
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
108
112
|
declare namespace step {
|
|
109
|
-
export { step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
113
|
+
export { step_categoryMapOverride as categoryMapOverride, step_customEventName as customEventName, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */
|
package/dist/examples/index.js
CHANGED
|
@@ -167,6 +167,8 @@ var noopLogger = {
|
|
|
167
167
|
// src/examples/step.ts
|
|
168
168
|
var step_exports = {};
|
|
169
169
|
__export(step_exports, {
|
|
170
|
+
categoryMapOverride: () => categoryMapOverride,
|
|
171
|
+
customEventName: () => customEventName,
|
|
170
172
|
fullConsent: () => fullConsent2,
|
|
171
173
|
minimalConsent: () => minimalConsent2
|
|
172
174
|
});
|
|
@@ -204,6 +206,44 @@ var minimalConsent2 = {
|
|
|
204
206
|
marketing: false
|
|
205
207
|
}
|
|
206
208
|
};
|
|
209
|
+
var categoryMapOverride = {
|
|
210
|
+
description: "Custom categoryMap remaps essential to functional and functional to analytics",
|
|
211
|
+
in: {
|
|
212
|
+
event: "consent_status",
|
|
213
|
+
type: "explicit",
|
|
214
|
+
ucCategory: {
|
|
215
|
+
essential: true,
|
|
216
|
+
functional: true,
|
|
217
|
+
marketing: false
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
mapping: {
|
|
221
|
+
categoryMap: { essential: "functional", functional: "analytics" }
|
|
222
|
+
},
|
|
223
|
+
out: {
|
|
224
|
+
functional: true,
|
|
225
|
+
analytics: true,
|
|
226
|
+
marketing: false
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var customEventName = {
|
|
230
|
+
description: "Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",
|
|
231
|
+
in: {
|
|
232
|
+
event: "consent_status",
|
|
233
|
+
type: "explicit",
|
|
234
|
+
ucCategory: {
|
|
235
|
+
essential: true,
|
|
236
|
+
functional: true,
|
|
237
|
+
marketing: true
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
mapping: { eventName: "UC_SDK_EVENT" },
|
|
241
|
+
out: {
|
|
242
|
+
essential: true,
|
|
243
|
+
functional: true,
|
|
244
|
+
marketing: true
|
|
245
|
+
}
|
|
246
|
+
};
|
|
207
247
|
|
|
208
248
|
// src/examples/setup.ts
|
|
209
249
|
var setup = (input, env) => {
|
package/dist/examples/index.mjs
CHANGED
|
@@ -132,6 +132,8 @@ var noopLogger = {
|
|
|
132
132
|
// src/examples/step.ts
|
|
133
133
|
var step_exports = {};
|
|
134
134
|
__export(step_exports, {
|
|
135
|
+
categoryMapOverride: () => categoryMapOverride,
|
|
136
|
+
customEventName: () => customEventName,
|
|
135
137
|
fullConsent: () => fullConsent2,
|
|
136
138
|
minimalConsent: () => minimalConsent2
|
|
137
139
|
});
|
|
@@ -169,6 +171,44 @@ var minimalConsent2 = {
|
|
|
169
171
|
marketing: false
|
|
170
172
|
}
|
|
171
173
|
};
|
|
174
|
+
var categoryMapOverride = {
|
|
175
|
+
description: "Custom categoryMap remaps essential to functional and functional to analytics",
|
|
176
|
+
in: {
|
|
177
|
+
event: "consent_status",
|
|
178
|
+
type: "explicit",
|
|
179
|
+
ucCategory: {
|
|
180
|
+
essential: true,
|
|
181
|
+
functional: true,
|
|
182
|
+
marketing: false
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
mapping: {
|
|
186
|
+
categoryMap: { essential: "functional", functional: "analytics" }
|
|
187
|
+
},
|
|
188
|
+
out: {
|
|
189
|
+
functional: true,
|
|
190
|
+
analytics: true,
|
|
191
|
+
marketing: false
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var customEventName = {
|
|
195
|
+
description: "Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",
|
|
196
|
+
in: {
|
|
197
|
+
event: "consent_status",
|
|
198
|
+
type: "explicit",
|
|
199
|
+
ucCategory: {
|
|
200
|
+
essential: true,
|
|
201
|
+
functional: true,
|
|
202
|
+
marketing: true
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
mapping: { eventName: "UC_SDK_EVENT" },
|
|
206
|
+
out: {
|
|
207
|
+
essential: true,
|
|
208
|
+
functional: true,
|
|
209
|
+
marketing: true
|
|
210
|
+
}
|
|
211
|
+
};
|
|
172
212
|
|
|
173
213
|
// src/examples/setup.ts
|
|
174
214
|
var setup = (input, env) => {
|
package/dist/index.browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var SourceUsercentrics=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})},a={};i(a,{SourceUsercentrics:()=>
|
|
1
|
+
"use strict";var SourceUsercentrics=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})},a={};i(a,{SourceUsercentrics:()=>s,createMockElbFn:()=>b,default:()=>G,fullConsent:()=>l,fullConsentCustomMapped:()=>d,fullConsentMapped:()=>y,fullConsentUpperCase:()=>p,implicitConsent:()=>u,minimalConsent:()=>r,minimalConsentMapped:()=>m,nonConsentEvent:()=>v,noopLogger:()=>_,partialConsent:()=>c,partialConsentMapped:()=>f,serviceLevelConsent:()=>g,serviceLevelMapped:()=>C,setup:()=>h,sourceUsercentrics:()=>S,step:()=>E});var s={},l={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},c={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},r={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},u={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},p={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},g={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},v={event:"other_event",type:"explicit"},y={essential:!0,functional:!0,marketing:!0},f={essential:!0,functional:!0,marketing:!1},m={essential:!0,functional:!1,marketing:!1},d={functional:!0,marketing:!0},C={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},k=()=>{},b=()=>()=>Promise.resolve({ok:!0}),_={error:k,warn:k,info:k,debug:k,throw:e=>{throw"string"==typeof e?new Error(e):e},json:k,scope:()=>_},E={};i(E,{categoryMapOverride:()=>j,customEventName:()=>M,fullConsent:()=>A,minimalConsent:()=>O});var w,A={in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:{essential:!0,functional:!0,marketing:!0}},O={in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:{essential:!0,functional:!1,marketing:!1}},j={description:"Custom categoryMap remaps essential to functional and functional to analytics",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:{functional:!0,analytics:!0,marketing:!1}},M={description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:{essential:!0,functional:!0,marketing:!0}},h=(e,t)=>{if(e&&"object"==typeof e)return()=>{t.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}},x=["action","event","type","ucCategory"],S=async e=>{var t,n,o,i,a,s,l,c;const{config:r,env:u}=e,{elb:p}=u,g=null!=(t=u.window)?t:void 0!==globalThis.window?globalThis.window:void 0,v={eventName:null!=(o=null==(n=null==r?void 0:r.settings)?void 0:n.eventName)?o:"ucEvent",categoryMap:null!=(a=null==(i=null==r?void 0:r.settings)?void 0:i.categoryMap)?a:{},explicitOnly:null==(l=null==(s=null==r?void 0:r.settings)?void 0:s.explicitOnly)||l},y={settings:v};let f;if(g){const e=e=>Object.values(e).every(e=>"boolean"==typeof e),t=t=>{const n={};return t.ucCategory&&e(t.ucCategory)?Object.entries(t.ucCategory).forEach(([e,t])=>{var o,i;if("boolean"!=typeof t)return;const a=null!=(i=null==(o=v.categoryMap)?void 0:o[e])?i:e;n[a]=n[a]||t}):(t.ucCategory&&Object.entries(t.ucCategory).forEach(([e,t])=>{var o,i;if("boolean"==typeof t){const a=null!=(i=null==(o=v.categoryMap)?void 0:o[e])?i:e;n[a]=n[a]||t}}),Object.entries(t).forEach(([e,t])=>{if(x.includes(e))return;if("boolean"!=typeof t)return;const o=e.toLowerCase().replace(/ /g,"_");n[o]=t})),n},n=e=>{var n;if("consent_status"!==e.event)return;if(v.explicitOnly&&"explicit"!==(null==(n=e.type)?void 0:n.toLowerCase()))return;const o=t(e);Object.keys(o).length>0&&p("walker consent",o)},o=null!=(c=v.eventName)?c:"ucEvent";f=e=>{const t=e;t.detail&&n(t.detail)},g.addEventListener(o,f)}return{type:"usercentrics",config:y,push:p,destroy:async e=>{var t;if(g&&f){const e=null!=(t=v.eventName)?t:"ucEvent";g.removeEventListener(e,f)}}}},G=S;return w=a,((i,a,s,l)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of n(a))o.call(i,c)||c===s||e(i,c,{get:()=>a[c],enumerable:!(l=t(a,c))||l.enumerable});return i})(e({},"__esModule",{value:!0}),w)})();
|
package/dist/index.d.mts
CHANGED
|
@@ -174,11 +174,15 @@ declare const noopLogger: Logger.Instance;
|
|
|
174
174
|
|
|
175
175
|
declare const fullConsent: Flow.StepExample;
|
|
176
176
|
declare const minimalConsent: Flow.StepExample;
|
|
177
|
+
declare const categoryMapOverride: Flow.StepExample;
|
|
178
|
+
declare const customEventName: Flow.StepExample;
|
|
177
179
|
|
|
180
|
+
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
181
|
+
declare const step_customEventName: typeof customEventName;
|
|
178
182
|
declare const step_fullConsent: typeof fullConsent;
|
|
179
183
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
180
184
|
declare namespace step {
|
|
181
|
-
export { step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
185
|
+
export { step_categoryMapOverride as categoryMapOverride, step_customEventName as customEventName, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */
|
package/dist/index.d.ts
CHANGED
|
@@ -174,11 +174,15 @@ declare const noopLogger: Logger.Instance;
|
|
|
174
174
|
|
|
175
175
|
declare const fullConsent: Flow.StepExample;
|
|
176
176
|
declare const minimalConsent: Flow.StepExample;
|
|
177
|
+
declare const categoryMapOverride: Flow.StepExample;
|
|
178
|
+
declare const customEventName: Flow.StepExample;
|
|
177
179
|
|
|
180
|
+
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
181
|
+
declare const step_customEventName: typeof customEventName;
|
|
178
182
|
declare const step_fullConsent: typeof fullConsent;
|
|
179
183
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
180
184
|
declare namespace step {
|
|
181
|
-
export { step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
185
|
+
export { step_categoryMapOverride as categoryMapOverride, step_customEventName as customEventName, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent };
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */
|
package/dist/index.es5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var u=e[i](a),
|
|
1
|
+
"use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){asyncGeneratorStep(i,r,o,a,u,"next",e)}function u(e){asyncGeneratorStep(i,r,o,a,u,"throw",e)}a(void 0)})}}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}var SourceUsercentrics=function(){var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,o=function(t,n){for(var r in n)e(t,r,{get:n[r],enumerable:!0})},i={};o(i,{SourceUsercentrics:function(){return a},createMockElbFn:function(){return h},default:function(){return G},fullConsent:function(){return u},fullConsentCustomMapped:function(){return d},fullConsentMapped:function(){return v},fullConsentUpperCase:function(){return f},implicitConsent:function(){return s},minimalConsent:function(){return l},minimalConsentMapped:function(){return _},nonConsentEvent:function(){return p},noopLogger:function(){return C},partialConsent:function(){return c},partialConsentMapped:function(){return g},serviceLevelConsent:function(){return y},serviceLevelMapped:function(){return m},setup:function(){return j},sourceUsercentrics:function(){return M},step:function(){return k}});var a={},u={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},c={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},l={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},s={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},f={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},y={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},p={event:"other_event",type:"explicit"},v={essential:!0,functional:!0,marketing:!0},g={essential:!0,functional:!0,marketing:!1},_={essential:!0,functional:!1,marketing:!1},d={functional:!0,marketing:!0},m={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},b=function(){},h=function(){return function(){return Promise.resolve({ok:!0})}},C={error:b,warn:b,info:b,debug:b,throw:function(e){throw"string"==typeof e?new Error(e):e},json:b,scope:function(){return C}},k={};o(k,{categoryMapOverride:function(){return E},customEventName:function(){return O},fullConsent:function(){return S},minimalConsent:function(){return A}});var w,S={in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:{essential:!0,functional:!0,marketing:!0}},A={in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:{essential:!0,functional:!1,marketing:!1}},E={description:"Custom categoryMap remaps essential to functional and functional to analytics",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:{functional:!0,analytics:!0,marketing:!1}},O={description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:{essential:!0,functional:!0,marketing:!0}},j=function(e,t){if(e&&"object"===(void 0===e?"undefined":_type_of(e)))return function(){t.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}},x=["action","event","type","ucCategory"],M=function(e){return _async_to_generator(function(){var t,n,r,o,i,a,u,c,l,s,f,y,p,v,g,_,d,m,b;return _ts_generator(this,function(h){return c=e.config,l=e.env,s=l.elb,f=null!==(t=l.window)&&void 0!==t?t:void 0!==globalThis.window?globalThis.window:void 0,y={eventName:null!==(n=null==c||null===(i=c.settings)||void 0===i?void 0:i.eventName)&&void 0!==n?n:"ucEvent",categoryMap:null!==(r=null==c||null===(a=c.settings)||void 0===a?void 0:a.categoryMap)&&void 0!==r?r:{},explicitOnly:null===(o=null==c||null===(u=c.settings)||void 0===u?void 0:u.explicitOnly)||void 0===o||o},p={settings:y},f&&(_=function(e){return Object.values(e).every(function(e){return"boolean"==typeof e})},d=function(e){var t={};return e.ucCategory&&_(e.ucCategory)?Object.entries(e.ucCategory).forEach(function(e){var n,r,o=_sliced_to_array(e,2),i=o[0],a=o[1];if("boolean"==typeof a){var u=null!==(n=null===(r=y.categoryMap)||void 0===r?void 0:r[i])&&void 0!==n?n:i;t[u]=t[u]||a}}):(e.ucCategory&&Object.entries(e.ucCategory).forEach(function(e){var n=_sliced_to_array(e,2),r=n[0],o=n[1];if("boolean"==typeof o){var i,a,u=null!==(i=null===(a=y.categoryMap)||void 0===a?void 0:a[r])&&void 0!==i?i:r;t[u]=t[u]||o}}),Object.entries(e).forEach(function(e){var n=_sliced_to_array(e,2),r=n[0],o=n[1];if(!x.includes(r)&&"boolean"==typeof o){var i=r.toLowerCase().replace(/ /g,"_");t[i]=o}})),t},m=function(e){var t;if("consent_status"===e.event&&(!y.explicitOnly||"explicit"===(null===(t=e.type)||void 0===t?void 0:t.toLowerCase()))){var n=d(e);Object.keys(n).length>0&&s("walker consent",n)}},b=null!==(g=y.eventName)&&void 0!==g?g:"ucEvent",v=function(e){var t=e;t.detail&&m(t.detail)},f.addEventListener(b,v)),[2,{type:"usercentrics",config:p,push:s,destroy:function(e){return _async_to_generator(function(){var e,t;return _ts_generator(this,function(n){return f&&v&&(t=null!==(e=y.eventName)&&void 0!==e?e:"ucEvent",f.removeEventListener(t,v)),[2]})})()}}]})})()},G=M;return w=i,function(o,i,a,u){if(i&&"object"===(void 0===i?"undefined":_type_of(i))||"function"==typeof i){var c=!0,l=!1,s=void 0;try{for(var f,y=function(){var n=f.value;r.call(o,n)||n===a||e(o,n,{get:function(){return i[n]},enumerable:!(u=t(i,n))||u.enumerable})},p=n(i)[Symbol.iterator]();!(c=(f=p.next()).done);c=!0)y()}catch(e){l=!0,s=e}finally{try{c||null==p.return||p.return()}finally{if(l)throw s}}}return o}(e({},"__esModule",{value:!0}),w)}();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},s={};a(s,{SourceUsercentrics:()=>l,createMockElbFn:()=>_,default:()=>G,fullConsent:()=>c,fullConsentCustomMapped:()=>C,fullConsentMapped:()=>f,fullConsentUpperCase:()=>g,implicitConsent:()=>p,minimalConsent:()=>u,minimalConsentMapped:()=>d,nonConsentEvent:()=>y,noopLogger:()=>E,partialConsent:()=>r,partialConsentMapped:()=>m,serviceLevelConsent:()=>v,serviceLevelMapped:()=>k,setup:()=>M,sourceUsercentrics:()=>S,step:()=>w}),module.exports=(e=s,((e,a,s,l)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of o(a))i.call(e,c)||c===s||t(e,c,{get:()=>a[c],enumerable:!(l=n(a,c))||l.enumerable});return e})(t({},"__esModule",{value:!0}),e));var l={},c={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},r={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},u={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},p={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},g={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},v={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},y={event:"other_event",type:"explicit"},f={essential:!0,functional:!0,marketing:!0},m={essential:!0,functional:!0,marketing:!1},d={essential:!0,functional:!1,marketing:!1},C={functional:!0,marketing:!0},k={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},b=()=>{},_=()=>()=>Promise.resolve({ok:!0}),E={error:b,warn:b,info:b,debug:b,throw:e=>{throw"string"==typeof e?new Error(e):e},json:b,scope:()=>E},w={};a(w,{categoryMapOverride:()=>j,customEventName:()=>x,fullConsent:()=>A,minimalConsent:()=>O});var A={in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:{essential:!0,functional:!0,marketing:!0}},O={in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:{essential:!0,functional:!1,marketing:!1}},j={description:"Custom categoryMap remaps essential to functional and functional to analytics",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:{functional:!0,analytics:!0,marketing:!1}},x={description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:{essential:!0,functional:!0,marketing:!0}},M=(e,t)=>{if(e&&"object"==typeof e)return()=>{t.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}},h=["action","event","type","ucCategory"],S=async e=>{var t,n,o,i,a,s,l,c;const{config:r,env:u}=e,{elb:p}=u,g=null!=(t=u.window)?t:void 0!==globalThis.window?globalThis.window:void 0,v={eventName:null!=(o=null==(n=null==r?void 0:r.settings)?void 0:n.eventName)?o:"ucEvent",categoryMap:null!=(a=null==(i=null==r?void 0:r.settings)?void 0:i.categoryMap)?a:{},explicitOnly:null==(l=null==(s=null==r?void 0:r.settings)?void 0:s.explicitOnly)||l},y={settings:v};let f;if(g){const e=e=>Object.values(e).every(e=>"boolean"==typeof e),t=t=>{const n={};return t.ucCategory&&e(t.ucCategory)?Object.entries(t.ucCategory).forEach(([e,t])=>{var o,i;if("boolean"!=typeof t)return;const a=null!=(i=null==(o=v.categoryMap)?void 0:o[e])?i:e;n[a]=n[a]||t}):(t.ucCategory&&Object.entries(t.ucCategory).forEach(([e,t])=>{var o,i;if("boolean"==typeof t){const a=null!=(i=null==(o=v.categoryMap)?void 0:o[e])?i:e;n[a]=n[a]||t}}),Object.entries(t).forEach(([e,t])=>{if(h.includes(e))return;if("boolean"!=typeof t)return;const o=e.toLowerCase().replace(/ /g,"_");n[o]=t})),n},n=e=>{var n;if("consent_status"!==e.event)return;if(v.explicitOnly&&"explicit"!==(null==(n=e.type)?void 0:n.toLowerCase()))return;const o=t(e);Object.keys(o).length>0&&p("walker consent",o)},o=null!=(c=v.eventName)?c:"ucEvent";f=e=>{const t=e;t.detail&&n(t.detail)},g.addEventListener(o,f)}return{type:"usercentrics",config:y,push:p,destroy:async e=>{var t;if(g&&f){const e=null!=(t=v.eventName)?t:"ucEvent";g.removeEventListener(e,f)}}}},G=S;//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts"],"sourcesContent":["import type { Source, WalkerOS } from '@walkeros/core';\nimport type { Types, Settings, UsercentricsEventDetail } from './types';\n\n// Export types for external usage\nexport * as SourceUsercentrics from './types';\n\n// Export examples\nexport * from './examples';\n\n/** Reserved keys in event.detail that are not service names */\nconst RESERVED_KEYS = ['action', 'event', 'type', 'ucCategory'];\n\n/**\n * Usercentrics consent management source for walkerOS.\n *\n * This source listens to Usercentrics CMP events and translates\n * consent states to walkerOS consent commands.\n *\n * @example\n * ```typescript\n * import { sourceUsercentrics } from '@walkeros/web-source-cmp-usercentrics';\n *\n * await startFlow({\n * sources: {\n * consent: {\n * code: sourceUsercentrics,\n * config: {\n * settings: {\n * eventName: 'ucEvent',\n * categoryMap: {\n * essential: 'functional',\n * functional: 'functional',\n * marketing: 'marketing',\n * },\n * },\n * },\n * },\n * },\n * });\n * ```\n */\nexport const sourceUsercentrics: Source.Init<Types> = async (context) => {\n const { config, env } = context;\n const { elb } = env;\n\n // Resolve window with fallback to globalThis\n const actualWindow =\n env.window ??\n (typeof globalThis.window !== 'undefined' ? globalThis.window : undefined);\n\n // Merge user settings with defaults\n const settings: Settings = {\n eventName: config?.settings?.eventName ?? 'ucEvent',\n categoryMap: config?.settings?.categoryMap ?? {},\n explicitOnly: config?.settings?.explicitOnly ?? true,\n };\n\n const fullConfig: Source.Config<Types> = { settings };\n\n // Track listener reference for cleanup\n let consentListener: ((e: Event) => void) | undefined;\n\n // Only setup if in browser environment\n if (actualWindow) {\n /**\n * Determine if ucCategory represents group-level consent.\n * Group-level: all values are booleans.\n * Service-level: some values are non-boolean (e.g., 'partial').\n */\n const isGroupLevel = (\n ucCategory: Record<string, boolean | unknown>,\n ): boolean => {\n return Object.values(ucCategory).every((val) => typeof val === 'boolean');\n };\n\n /**\n * Parse consent from Usercentrics event detail.\n *\n * Two modes:\n * 1. Group-level: ucCategory has all booleans -> use ucCategory as consent\n * 2. Service-level: ucCategory has non-booleans -> extract individual\n * service keys from event.detail + boolean entries from ucCategory\n *\n * categoryMap is applied in both modes for ucCategory boolean entries.\n */\n const parseConsent = (\n detail: UsercentricsEventDetail,\n ): WalkerOS.Consent => {\n const state: WalkerOS.Consent = {};\n\n if (detail.ucCategory && isGroupLevel(detail.ucCategory)) {\n // Group-level consent: use ucCategory values\n Object.entries(detail.ucCategory).forEach(([category, value]) => {\n if (typeof value !== 'boolean') return;\n const mapped = settings.categoryMap?.[category] ?? category;\n // OR logic: if ANY source category is true, target group is true\n state[mapped] = state[mapped] || value;\n });\n } else {\n // Service-level consent: extract individual services\n // Include boolean entries from ucCategory (with categoryMap applied)\n if (detail.ucCategory) {\n Object.entries(detail.ucCategory).forEach(([key, value]) => {\n if (typeof value === 'boolean') {\n const mapped = settings.categoryMap?.[key] ?? key;\n state[mapped] = state[mapped] || value;\n }\n });\n }\n\n // Extract service keys (not reserved keys)\n Object.entries(detail).forEach(([key, value]) => {\n if (RESERVED_KEYS.includes(key)) return;\n if (typeof value !== 'boolean') return;\n // Normalize: lowercase, spaces to underscores\n const normalized = key.toLowerCase().replace(/ /g, '_');\n state[normalized] = value;\n });\n }\n\n return state;\n };\n\n /**\n * Handle a Usercentrics consent event.\n */\n const handleConsent = (detail: UsercentricsEventDetail) => {\n // Only process consent_status events\n if (detail.event !== 'consent_status') return;\n\n // Skip implicit consent if explicitOnly is true\n // Use case-insensitive comparison (Usercentrics docs show both 'explicit' and 'EXPLICIT')\n if (settings.explicitOnly && detail.type?.toLowerCase() !== 'explicit')\n return;\n\n const state = parseConsent(detail);\n\n // Only call if we have consent state to report\n if (Object.keys(state).length > 0) {\n elb('walker consent', state);\n }\n };\n\n // Listen for Usercentrics consent events\n const eventName = settings.eventName ?? 'ucEvent';\n consentListener = (e: Event) => {\n const customEvent = e as CustomEvent<UsercentricsEventDetail>;\n if (customEvent.detail) {\n handleConsent(customEvent.detail);\n }\n };\n actualWindow.addEventListener(eventName, consentListener);\n }\n\n return {\n type: 'usercentrics',\n config: fullConfig,\n push: elb,\n destroy: async (_context) => {\n if (actualWindow && consentListener) {\n const eventName = settings.eventName ?? 'ucEvent';\n actualWindow.removeEventListener(eventName, consentListener);\n }\n },\n };\n};\n\nexport default sourceUsercentrics;\n","import type { Source, Elb } from '@walkeros/core';\n\n/**\n * Usercentrics consent event detail structure.\n *\n * Fired as event.detail on the configured window event (e.g. 'ucEvent').\n * Contains both category-level (ucCategory) and service-level consent.\n */\nexport interface UsercentricsEventDetail {\n /** Always 'consent_status' for consent events */\n event: string;\n /** 'explicit' when user actively chose, 'implicit' for page-load defaults (casing may vary) */\n type: string;\n /** Action taken: 'onAcceptAllServices', 'onDenyAllServices', 'onUpdateServices' */\n action?: string;\n /** Category-level consent booleans (e.g. { marketing: true, functional: false }) */\n ucCategory?: Record<string, boolean | unknown>;\n /** Service-level consent as top-level keys (e.g. 'Google Analytics': true) */\n [service: string]: unknown;\n}\n\ndeclare global {\n interface WindowEventMap {\n ucEvent: CustomEvent<UsercentricsEventDetail>;\n }\n}\n\n/**\n * Settings for Usercentrics source\n */\nexport interface Settings {\n /**\n * Window event name to listen for.\n * Configured in Usercentrics admin under Implementation > Data Layer & Events.\n * Can also be set to 'UC_SDK_EVENT' for the built-in Browser SDK event.\n *\n * Default: 'ucEvent'\n */\n eventName?: string;\n\n /**\n * Map Usercentrics categories to walkerOS consent groups.\n * Keys: Usercentrics category names (from ucCategory)\n * Values: walkerOS consent group names\n *\n * Applied in both group-level and service-level consent modes.\n * When multiple source categories map to the same group, OR logic applies:\n * if ANY source category is true, the target group is true.\n *\n * Default: {} (pass through category names as-is)\n */\n categoryMap?: Record<string, string>;\n\n /**\n * Only process explicit consent (user made a choice).\n * When true: Ignores events where type !== 'explicit'\n * When false: Processes any consent_status event including implicit/defaults\n *\n * Default: true\n */\n explicitOnly?: boolean;\n}\n\n/**\n * User input settings (all optional)\n */\nexport type InitSettings = Partial<Settings>;\n\n/**\n * No mapping configuration for this source\n */\nexport interface Mapping {}\n\n/**\n * Push function type - uses elb for consent commands\n */\nexport type Push = Elb.Fn;\n\n/**\n * Environment interface for Usercentrics source\n */\nexport interface Env extends Source.BaseEnv {\n window?: Window & typeof globalThis;\n}\n\n/**\n * Types bundle for Usercentrics source\n */\nexport type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;\n\n/**\n * Config type alias\n */\nexport type Config = Source.Config<Types>;\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,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EACF;AACF;AAEA,IAAO,gBAAQ;","names":["fullConsent","minimalConsent","_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts"],"sourcesContent":["import type { Source, WalkerOS } from '@walkeros/core';\nimport type { Types, Settings, UsercentricsEventDetail } from './types';\n\n// Export types for external usage\nexport * as SourceUsercentrics from './types';\n\n// Export examples\nexport * from './examples';\n\n/** Reserved keys in event.detail that are not service names */\nconst RESERVED_KEYS = ['action', 'event', 'type', 'ucCategory'];\n\n/**\n * Usercentrics consent management source for walkerOS.\n *\n * This source listens to Usercentrics CMP events and translates\n * consent states to walkerOS consent commands.\n *\n * @example\n * ```typescript\n * import { sourceUsercentrics } from '@walkeros/web-source-cmp-usercentrics';\n *\n * await startFlow({\n * sources: {\n * consent: {\n * code: sourceUsercentrics,\n * config: {\n * settings: {\n * eventName: 'ucEvent',\n * categoryMap: {\n * essential: 'functional',\n * functional: 'functional',\n * marketing: 'marketing',\n * },\n * },\n * },\n * },\n * },\n * });\n * ```\n */\nexport const sourceUsercentrics: Source.Init<Types> = async (context) => {\n const { config, env } = context;\n const { elb } = env;\n\n // Resolve window with fallback to globalThis\n const actualWindow =\n env.window ??\n (typeof globalThis.window !== 'undefined' ? globalThis.window : undefined);\n\n // Merge user settings with defaults\n const settings: Settings = {\n eventName: config?.settings?.eventName ?? 'ucEvent',\n categoryMap: config?.settings?.categoryMap ?? {},\n explicitOnly: config?.settings?.explicitOnly ?? true,\n };\n\n const fullConfig: Source.Config<Types> = { settings };\n\n // Track listener reference for cleanup\n let consentListener: ((e: Event) => void) | undefined;\n\n // Only setup if in browser environment\n if (actualWindow) {\n /**\n * Determine if ucCategory represents group-level consent.\n * Group-level: all values are booleans.\n * Service-level: some values are non-boolean (e.g., 'partial').\n */\n const isGroupLevel = (\n ucCategory: Record<string, boolean | unknown>,\n ): boolean => {\n return Object.values(ucCategory).every((val) => typeof val === 'boolean');\n };\n\n /**\n * Parse consent from Usercentrics event detail.\n *\n * Two modes:\n * 1. Group-level: ucCategory has all booleans -> use ucCategory as consent\n * 2. Service-level: ucCategory has non-booleans -> extract individual\n * service keys from event.detail + boolean entries from ucCategory\n *\n * categoryMap is applied in both modes for ucCategory boolean entries.\n */\n const parseConsent = (\n detail: UsercentricsEventDetail,\n ): WalkerOS.Consent => {\n const state: WalkerOS.Consent = {};\n\n if (detail.ucCategory && isGroupLevel(detail.ucCategory)) {\n // Group-level consent: use ucCategory values\n Object.entries(detail.ucCategory).forEach(([category, value]) => {\n if (typeof value !== 'boolean') return;\n const mapped = settings.categoryMap?.[category] ?? category;\n // OR logic: if ANY source category is true, target group is true\n state[mapped] = state[mapped] || value;\n });\n } else {\n // Service-level consent: extract individual services\n // Include boolean entries from ucCategory (with categoryMap applied)\n if (detail.ucCategory) {\n Object.entries(detail.ucCategory).forEach(([key, value]) => {\n if (typeof value === 'boolean') {\n const mapped = settings.categoryMap?.[key] ?? key;\n state[mapped] = state[mapped] || value;\n }\n });\n }\n\n // Extract service keys (not reserved keys)\n Object.entries(detail).forEach(([key, value]) => {\n if (RESERVED_KEYS.includes(key)) return;\n if (typeof value !== 'boolean') return;\n // Normalize: lowercase, spaces to underscores\n const normalized = key.toLowerCase().replace(/ /g, '_');\n state[normalized] = value;\n });\n }\n\n return state;\n };\n\n /**\n * Handle a Usercentrics consent event.\n */\n const handleConsent = (detail: UsercentricsEventDetail) => {\n // Only process consent_status events\n if (detail.event !== 'consent_status') return;\n\n // Skip implicit consent if explicitOnly is true\n // Use case-insensitive comparison (Usercentrics docs show both 'explicit' and 'EXPLICIT')\n if (settings.explicitOnly && detail.type?.toLowerCase() !== 'explicit')\n return;\n\n const state = parseConsent(detail);\n\n // Only call if we have consent state to report\n if (Object.keys(state).length > 0) {\n elb('walker consent', state);\n }\n };\n\n // Listen for Usercentrics consent events\n const eventName = settings.eventName ?? 'ucEvent';\n consentListener = (e: Event) => {\n const customEvent = e as CustomEvent<UsercentricsEventDetail>;\n if (customEvent.detail) {\n handleConsent(customEvent.detail);\n }\n };\n actualWindow.addEventListener(eventName, consentListener);\n }\n\n return {\n type: 'usercentrics',\n config: fullConfig,\n push: elb,\n destroy: async (_context) => {\n if (actualWindow && consentListener) {\n const eventName = settings.eventName ?? 'ucEvent';\n actualWindow.removeEventListener(eventName, consentListener);\n }\n },\n };\n};\n\nexport default sourceUsercentrics;\n","import type { Source, Elb } from '@walkeros/core';\n\n/**\n * Usercentrics consent event detail structure.\n *\n * Fired as event.detail on the configured window event (e.g. 'ucEvent').\n * Contains both category-level (ucCategory) and service-level consent.\n */\nexport interface UsercentricsEventDetail {\n /** Always 'consent_status' for consent events */\n event: string;\n /** 'explicit' when user actively chose, 'implicit' for page-load defaults (casing may vary) */\n type: string;\n /** Action taken: 'onAcceptAllServices', 'onDenyAllServices', 'onUpdateServices' */\n action?: string;\n /** Category-level consent booleans (e.g. { marketing: true, functional: false }) */\n ucCategory?: Record<string, boolean | unknown>;\n /** Service-level consent as top-level keys (e.g. 'Google Analytics': true) */\n [service: string]: unknown;\n}\n\ndeclare global {\n interface WindowEventMap {\n ucEvent: CustomEvent<UsercentricsEventDetail>;\n }\n}\n\n/**\n * Settings for Usercentrics source\n */\nexport interface Settings {\n /**\n * Window event name to listen for.\n * Configured in Usercentrics admin under Implementation > Data Layer & Events.\n * Can also be set to 'UC_SDK_EVENT' for the built-in Browser SDK event.\n *\n * Default: 'ucEvent'\n */\n eventName?: string;\n\n /**\n * Map Usercentrics categories to walkerOS consent groups.\n * Keys: Usercentrics category names (from ucCategory)\n * Values: walkerOS consent group names\n *\n * Applied in both group-level and service-level consent modes.\n * When multiple source categories map to the same group, OR logic applies:\n * if ANY source category is true, the target group is true.\n *\n * Default: {} (pass through category names as-is)\n */\n categoryMap?: Record<string, string>;\n\n /**\n * Only process explicit consent (user made a choice).\n * When true: Ignores events where type !== 'explicit'\n * When false: Processes any consent_status event including implicit/defaults\n *\n * Default: true\n */\n explicitOnly?: boolean;\n}\n\n/**\n * User input settings (all optional)\n */\nexport type InitSettings = Partial<Settings>;\n\n/**\n * No mapping configuration for this source\n */\nexport interface Mapping {}\n\n/**\n * Push function type - uses elb for consent commands\n */\nexport type Push = Elb.Fn;\n\n/**\n * Environment interface for Usercentrics source\n */\nexport interface Env extends Source.BaseEnv {\n window?: Window & typeof globalThis;\n}\n\n/**\n * Types bundle for Usercentrics source\n */\nexport type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;\n\n/**\n * Config type alias\n */\nexport type Config = Source.Config<Types>;\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n description:\n 'Custom categoryMap remaps essential to functional and functional to analytics',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n },\n mapping: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n out: {\n functional: true,\n analytics: true,\n marketing: false,\n },\n};\n\nexport const customEventName: Flow.StepExample = {\n description: 'Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n mapping: { eventName: 'UC_SDK_EVENT' },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAMO,IAAM,kBAA2C;AAAA,EACtD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAMO,IAAM,uBAAgD;AAAA,EAC3D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;A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}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t={},n={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},
|
|
1
|
+
var e=Object.defineProperty,t={},n={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},i={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},a={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},o={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},s={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},l={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},c={event:"other_event",type:"explicit"},r={essential:!0,functional:!0,marketing:!0},u={essential:!0,functional:!0,marketing:!1},g={essential:!0,functional:!1,marketing:!1},y={functional:!0,marketing:!0},p={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},v=()=>{},f=()=>()=>Promise.resolve({ok:!0}),m={error:v,warn:v,info:v,debug:v,throw:e=>{throw"string"==typeof e?new Error(e):e},json:v,scope:()=>m},d={};((t,n)=>{for(var i in n)e(t,i,{get:n[i],enumerable:!0})})(d,{categoryMapOverride:()=>_,customEventName:()=>E,fullConsent:()=>k,minimalConsent:()=>C});var k={in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:{essential:!0,functional:!0,marketing:!0}},C={in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:{essential:!0,functional:!1,marketing:!1}},_={description:"Custom categoryMap remaps essential to functional and functional to analytics",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:{functional:!0,analytics:!0,marketing:!1}},E={description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:{essential:!0,functional:!0,marketing:!0}},A=(e,t)=>{if(e&&"object"==typeof e)return()=>{t.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}},b=["action","event","type","ucCategory"],w=async e=>{var t,n,i,a,o,s,l,c;const{config:r,env:u}=e,{elb:g}=u,y=null!=(t=u.window)?t:void 0!==globalThis.window?globalThis.window:void 0,p={eventName:null!=(i=null==(n=null==r?void 0:r.settings)?void 0:n.eventName)?i:"ucEvent",categoryMap:null!=(o=null==(a=null==r?void 0:r.settings)?void 0:a.categoryMap)?o:{},explicitOnly:null==(l=null==(s=null==r?void 0:r.settings)?void 0:s.explicitOnly)||l},v={settings:p};let f;if(y){const e=e=>Object.values(e).every(e=>"boolean"==typeof e),t=t=>{const n={};return t.ucCategory&&e(t.ucCategory)?Object.entries(t.ucCategory).forEach(([e,t])=>{var i,a;if("boolean"!=typeof t)return;const o=null!=(a=null==(i=p.categoryMap)?void 0:i[e])?a:e;n[o]=n[o]||t}):(t.ucCategory&&Object.entries(t.ucCategory).forEach(([e,t])=>{var i,a;if("boolean"==typeof t){const o=null!=(a=null==(i=p.categoryMap)?void 0:i[e])?a:e;n[o]=n[o]||t}}),Object.entries(t).forEach(([e,t])=>{if(b.includes(e))return;if("boolean"!=typeof t)return;const i=e.toLowerCase().replace(/ /g,"_");n[i]=t})),n},n=e=>{var n;if("consent_status"!==e.event)return;if(p.explicitOnly&&"explicit"!==(null==(n=e.type)?void 0:n.toLowerCase()))return;const i=t(e);Object.keys(i).length>0&&g("walker consent",i)},i=null!=(c=p.eventName)?c:"ucEvent";f=e=>{const t=e;t.detail&&n(t.detail)},y.addEventListener(i,f)}return{type:"usercentrics",config:v,push:g,destroy:async e=>{var t;if(y&&f){const e=null!=(t=p.eventName)?t:"ucEvent";y.removeEventListener(e,f)}}}},x=w;export{t as SourceUsercentrics,f as createMockElbFn,x as default,n as fullConsent,y as fullConsentCustomMapped,r as fullConsentMapped,s as fullConsentUpperCase,o as implicitConsent,a as minimalConsent,g as minimalConsentMapped,c as nonConsentEvent,m as noopLogger,i as partialConsent,u as partialConsentMapped,l as serviceLevelConsent,p as serviceLevelMapped,A as setup,w as sourceUsercentrics,d as step};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts","../src/index.ts"],"sourcesContent":["import type { Source, Elb } from '@walkeros/core';\n\n/**\n * Usercentrics consent event detail structure.\n *\n * Fired as event.detail on the configured window event (e.g. 'ucEvent').\n * Contains both category-level (ucCategory) and service-level consent.\n */\nexport interface UsercentricsEventDetail {\n /** Always 'consent_status' for consent events */\n event: string;\n /** 'explicit' when user actively chose, 'implicit' for page-load defaults (casing may vary) */\n type: string;\n /** Action taken: 'onAcceptAllServices', 'onDenyAllServices', 'onUpdateServices' */\n action?: string;\n /** Category-level consent booleans (e.g. { marketing: true, functional: false }) */\n ucCategory?: Record<string, boolean | unknown>;\n /** Service-level consent as top-level keys (e.g. 'Google Analytics': true) */\n [service: string]: unknown;\n}\n\ndeclare global {\n interface WindowEventMap {\n ucEvent: CustomEvent<UsercentricsEventDetail>;\n }\n}\n\n/**\n * Settings for Usercentrics source\n */\nexport interface Settings {\n /**\n * Window event name to listen for.\n * Configured in Usercentrics admin under Implementation > Data Layer & Events.\n * Can also be set to 'UC_SDK_EVENT' for the built-in Browser SDK event.\n *\n * Default: 'ucEvent'\n */\n eventName?: string;\n\n /**\n * Map Usercentrics categories to walkerOS consent groups.\n * Keys: Usercentrics category names (from ucCategory)\n * Values: walkerOS consent group names\n *\n * Applied in both group-level and service-level consent modes.\n * When multiple source categories map to the same group, OR logic applies:\n * if ANY source category is true, the target group is true.\n *\n * Default: {} (pass through category names as-is)\n */\n categoryMap?: Record<string, string>;\n\n /**\n * Only process explicit consent (user made a choice).\n * When true: Ignores events where type !== 'explicit'\n * When false: Processes any consent_status event including implicit/defaults\n *\n * Default: true\n */\n explicitOnly?: boolean;\n}\n\n/**\n * User input settings (all optional)\n */\nexport type InitSettings = Partial<Settings>;\n\n/**\n * No mapping configuration for this source\n */\nexport interface Mapping {}\n\n/**\n * Push function type - uses elb for consent commands\n */\nexport type Push = Elb.Fn;\n\n/**\n * Environment interface for Usercentrics source\n */\nexport interface Env extends Source.BaseEnv {\n window?: Window & typeof globalThis;\n}\n\n/**\n * Types bundle for Usercentrics source\n */\nexport type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;\n\n/**\n * Config type alias\n */\nexport type Config = Source.Config<Types>;\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n","import type { Source, WalkerOS } from '@walkeros/core';\nimport type { Types, Settings, UsercentricsEventDetail } from './types';\n\n// Export types for external usage\nexport * as SourceUsercentrics from './types';\n\n// Export examples\nexport * from './examples';\n\n/** Reserved keys in event.detail that are not service names */\nconst RESERVED_KEYS = ['action', 'event', 'type', 'ucCategory'];\n\n/**\n * Usercentrics consent management source for walkerOS.\n *\n * This source listens to Usercentrics CMP events and translates\n * consent states to walkerOS consent commands.\n *\n * @example\n * ```typescript\n * import { sourceUsercentrics } from '@walkeros/web-source-cmp-usercentrics';\n *\n * await startFlow({\n * sources: {\n * consent: {\n * code: sourceUsercentrics,\n * config: {\n * settings: {\n * eventName: 'ucEvent',\n * categoryMap: {\n * essential: 'functional',\n * functional: 'functional',\n * marketing: 'marketing',\n * },\n * },\n * },\n * },\n * },\n * });\n * ```\n */\nexport const sourceUsercentrics: Source.Init<Types> = async (context) => {\n const { config, env } = context;\n const { elb } = env;\n\n // Resolve window with fallback to globalThis\n const actualWindow =\n env.window ??\n (typeof globalThis.window !== 'undefined' ? globalThis.window : undefined);\n\n // Merge user settings with defaults\n const settings: Settings = {\n eventName: config?.settings?.eventName ?? 'ucEvent',\n categoryMap: config?.settings?.categoryMap ?? {},\n explicitOnly: config?.settings?.explicitOnly ?? true,\n };\n\n const fullConfig: Source.Config<Types> = { settings };\n\n // Track listener reference for cleanup\n let consentListener: ((e: Event) => void) | undefined;\n\n // Only setup if in browser environment\n if (actualWindow) {\n /**\n * Determine if ucCategory represents group-level consent.\n * Group-level: all values are booleans.\n * Service-level: some values are non-boolean (e.g., 'partial').\n */\n const isGroupLevel = (\n ucCategory: Record<string, boolean | unknown>,\n ): boolean => {\n return Object.values(ucCategory).every((val) => typeof val === 'boolean');\n };\n\n /**\n * Parse consent from Usercentrics event detail.\n *\n * Two modes:\n * 1. Group-level: ucCategory has all booleans -> use ucCategory as consent\n * 2. Service-level: ucCategory has non-booleans -> extract individual\n * service keys from event.detail + boolean entries from ucCategory\n *\n * categoryMap is applied in both modes for ucCategory boolean entries.\n */\n const parseConsent = (\n detail: UsercentricsEventDetail,\n ): WalkerOS.Consent => {\n const state: WalkerOS.Consent = {};\n\n if (detail.ucCategory && isGroupLevel(detail.ucCategory)) {\n // Group-level consent: use ucCategory values\n Object.entries(detail.ucCategory).forEach(([category, value]) => {\n if (typeof value !== 'boolean') return;\n const mapped = settings.categoryMap?.[category] ?? category;\n // OR logic: if ANY source category is true, target group is true\n state[mapped] = state[mapped] || value;\n });\n } else {\n // Service-level consent: extract individual services\n // Include boolean entries from ucCategory (with categoryMap applied)\n if (detail.ucCategory) {\n Object.entries(detail.ucCategory).forEach(([key, value]) => {\n if (typeof value === 'boolean') {\n const mapped = settings.categoryMap?.[key] ?? key;\n state[mapped] = state[mapped] || value;\n }\n });\n }\n\n // Extract service keys (not reserved keys)\n Object.entries(detail).forEach(([key, value]) => {\n if (RESERVED_KEYS.includes(key)) return;\n if (typeof value !== 'boolean') return;\n // Normalize: lowercase, spaces to underscores\n const normalized = key.toLowerCase().replace(/ /g, '_');\n state[normalized] = value;\n });\n }\n\n return state;\n };\n\n /**\n * Handle a Usercentrics consent event.\n */\n const handleConsent = (detail: UsercentricsEventDetail) => {\n // Only process consent_status events\n if (detail.event !== 'consent_status') return;\n\n // Skip implicit consent if explicitOnly is true\n // Use case-insensitive comparison (Usercentrics docs show both 'explicit' and 'EXPLICIT')\n if (settings.explicitOnly && detail.type?.toLowerCase() !== 'explicit')\n return;\n\n const state = parseConsent(detail);\n\n // Only call if we have consent state to report\n if (Object.keys(state).length > 0) {\n elb('walker consent', state);\n }\n };\n\n // Listen for Usercentrics consent events\n const eventName = settings.eventName ?? 'ucEvent';\n consentListener = (e: Event) => {\n const customEvent = e as CustomEvent<UsercentricsEventDetail>;\n if (customEvent.detail) {\n handleConsent(customEvent.detail);\n }\n };\n actualWindow.addEventListener(eventName, consentListener);\n }\n\n return {\n type: 'usercentrics',\n config: fullConfig,\n push: elb,\n destroy: async (_context) => {\n if (actualWindow && consentListener) {\n const eventName = settings.eventName ?? 'ucEvent';\n actualWindow.removeEventListener(eventName, consentListener);\n }\n },\n };\n};\n\nexport default sourceUsercentrics;\n"],"mappings":";;;;;;;AAAA;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAMO,IAAM,kBAA2C;AAAA,EACtD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAMO,IAAM,uBAAgD;AAAA,EAC3D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AACF;AAMO,IAAM,sBAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,I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;AACxC,sBAAkB,CAAC,MAAa;AAC9B,YAAM,cAAc;AACpB,UAAI,YAAY,QAAQ;AACtB,sBAAc,YAAY,MAAM;AAAA,MAClC;AAAA,IACF;AACA,iBAAa,iBAAiB,WAAW,eAAe;AAAA,EAC1D;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS,OAAO,aAAa;AA9JjC,UAAAA;AA+JM,UAAI,gBAAgB,iBAAiB;AACnC,cAAM,aAAYA,MAAA,SAAS,cAAT,OAAAA,MAAsB;AACxC,qBAAa,oBAAoB,WAAW,eAAe;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["fullConsent","minimalConsent","_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/setup.ts","../src/index.ts"],"sourcesContent":["import type { Source, Elb } from '@walkeros/core';\n\n/**\n * Usercentrics consent event detail structure.\n *\n * Fired as event.detail on the configured window event (e.g. 'ucEvent').\n * Contains both category-level (ucCategory) and service-level consent.\n */\nexport interface UsercentricsEventDetail {\n /** Always 'consent_status' for consent events */\n event: string;\n /** 'explicit' when user actively chose, 'implicit' for page-load defaults (casing may vary) */\n type: string;\n /** Action taken: 'onAcceptAllServices', 'onDenyAllServices', 'onUpdateServices' */\n action?: string;\n /** Category-level consent booleans (e.g. { marketing: true, functional: false }) */\n ucCategory?: Record<string, boolean | unknown>;\n /** Service-level consent as top-level keys (e.g. 'Google Analytics': true) */\n [service: string]: unknown;\n}\n\ndeclare global {\n interface WindowEventMap {\n ucEvent: CustomEvent<UsercentricsEventDetail>;\n }\n}\n\n/**\n * Settings for Usercentrics source\n */\nexport interface Settings {\n /**\n * Window event name to listen for.\n * Configured in Usercentrics admin under Implementation > Data Layer & Events.\n * Can also be set to 'UC_SDK_EVENT' for the built-in Browser SDK event.\n *\n * Default: 'ucEvent'\n */\n eventName?: string;\n\n /**\n * Map Usercentrics categories to walkerOS consent groups.\n * Keys: Usercentrics category names (from ucCategory)\n * Values: walkerOS consent group names\n *\n * Applied in both group-level and service-level consent modes.\n * When multiple source categories map to the same group, OR logic applies:\n * if ANY source category is true, the target group is true.\n *\n * Default: {} (pass through category names as-is)\n */\n categoryMap?: Record<string, string>;\n\n /**\n * Only process explicit consent (user made a choice).\n * When true: Ignores events where type !== 'explicit'\n * When false: Processes any consent_status event including implicit/defaults\n *\n * Default: true\n */\n explicitOnly?: boolean;\n}\n\n/**\n * User input settings (all optional)\n */\nexport type InitSettings = Partial<Settings>;\n\n/**\n * No mapping configuration for this source\n */\nexport interface Mapping {}\n\n/**\n * Push function type - uses elb for consent commands\n */\nexport type Push = Elb.Fn;\n\n/**\n * Environment interface for Usercentrics source\n */\nexport interface Env extends Source.BaseEnv {\n window?: Window & typeof globalThis;\n}\n\n/**\n * Types bundle for Usercentrics source\n */\nexport type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;\n\n/**\n * Config type alias\n */\nexport type Config = Source.Config<Types>;\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\nexport const minimalConsent: Flow.StepExample = {\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: {\n essential: true,\n functional: false,\n marketing: false,\n },\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n description:\n 'Custom categoryMap remaps essential to functional and functional to analytics',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n },\n mapping: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n out: {\n functional: true,\n analytics: true,\n marketing: false,\n },\n};\n\nexport const customEventName: Flow.StepExample = {\n description: 'Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2',\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n mapping: { eventName: 'UC_SDK_EVENT' },\n out: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n","import type { Source } from '@walkeros/core';\n\n/** Dispatches ucEvent CustomEvent after source init (trigger pattern). */\nexport const setup: Source.SetupFn = (input, env) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n env.window.dispatchEvent(new CustomEvent('ucEvent', { detail: input }));\n };\n};\n","import type { Source, WalkerOS } from '@walkeros/core';\nimport type { Types, Settings, UsercentricsEventDetail } from './types';\n\n// Export types for external usage\nexport * as SourceUsercentrics from './types';\n\n// Export examples\nexport * from './examples';\n\n/** Reserved keys in event.detail that are not service names */\nconst RESERVED_KEYS = ['action', 'event', 'type', 'ucCategory'];\n\n/**\n * Usercentrics consent management source for walkerOS.\n *\n * This source listens to Usercentrics CMP events and translates\n * consent states to walkerOS consent commands.\n *\n * @example\n * ```typescript\n * import { sourceUsercentrics } from '@walkeros/web-source-cmp-usercentrics';\n *\n * await startFlow({\n * sources: {\n * consent: {\n * code: sourceUsercentrics,\n * config: {\n * settings: {\n * eventName: 'ucEvent',\n * categoryMap: {\n * essential: 'functional',\n * functional: 'functional',\n * marketing: 'marketing',\n * },\n * },\n * },\n * },\n * },\n * });\n * ```\n */\nexport const sourceUsercentrics: Source.Init<Types> = async (context) => {\n const { config, env } = context;\n const { elb } = env;\n\n // Resolve window with fallback to globalThis\n const actualWindow =\n env.window ??\n (typeof globalThis.window !== 'undefined' ? globalThis.window : undefined);\n\n // Merge user settings with defaults\n const settings: Settings = {\n eventName: config?.settings?.eventName ?? 'ucEvent',\n categoryMap: config?.settings?.categoryMap ?? {},\n explicitOnly: config?.settings?.explicitOnly ?? true,\n };\n\n const fullConfig: Source.Config<Types> = { settings };\n\n // Track listener reference for cleanup\n let consentListener: ((e: Event) => void) | undefined;\n\n // Only setup if in browser environment\n if (actualWindow) {\n /**\n * Determine if ucCategory represents group-level consent.\n * Group-level: all values are booleans.\n * Service-level: some values are non-boolean (e.g., 'partial').\n */\n const isGroupLevel = (\n ucCategory: Record<string, boolean | unknown>,\n ): boolean => {\n return Object.values(ucCategory).every((val) => typeof val === 'boolean');\n };\n\n /**\n * Parse consent from Usercentrics event detail.\n *\n * Two modes:\n * 1. Group-level: ucCategory has all booleans -> use ucCategory as consent\n * 2. Service-level: ucCategory has non-booleans -> extract individual\n * service keys from event.detail + boolean entries from ucCategory\n *\n * categoryMap is applied in both modes for ucCategory boolean entries.\n */\n const parseConsent = (\n detail: UsercentricsEventDetail,\n ): WalkerOS.Consent => {\n const state: WalkerOS.Consent = {};\n\n if (detail.ucCategory && isGroupLevel(detail.ucCategory)) {\n // Group-level consent: use ucCategory values\n Object.entries(detail.ucCategory).forEach(([category, value]) => {\n if (typeof value !== 'boolean') return;\n const mapped = settings.categoryMap?.[category] ?? category;\n // OR logic: if ANY source category is true, target group is true\n state[mapped] = state[mapped] || value;\n });\n } else {\n // Service-level consent: extract individual services\n // Include boolean entries from ucCategory (with categoryMap applied)\n if (detail.ucCategory) {\n Object.entries(detail.ucCategory).forEach(([key, value]) => {\n if (typeof value === 'boolean') {\n const mapped = settings.categoryMap?.[key] ?? key;\n state[mapped] = state[mapped] || value;\n }\n });\n }\n\n // Extract service keys (not reserved keys)\n Object.entries(detail).forEach(([key, value]) => {\n if (RESERVED_KEYS.includes(key)) return;\n if (typeof value !== 'boolean') return;\n // Normalize: lowercase, spaces to underscores\n const normalized = key.toLowerCase().replace(/ /g, '_');\n state[normalized] = value;\n });\n }\n\n return state;\n };\n\n /**\n * Handle a Usercentrics consent event.\n */\n const handleConsent = (detail: UsercentricsEventDetail) => {\n // Only process consent_status events\n if (detail.event !== 'consent_status') return;\n\n // Skip implicit consent if explicitOnly is true\n // Use case-insensitive comparison (Usercentrics docs show both 'explicit' and 'EXPLICIT')\n if (settings.explicitOnly && detail.type?.toLowerCase() !== 'explicit')\n return;\n\n const state = parseConsent(detail);\n\n // Only call if we have consent state to report\n if (Object.keys(state).length > 0) {\n elb('walker consent', state);\n }\n };\n\n // Listen for Usercentrics consent events\n const eventName = settings.eventName ?? 'ucEvent';\n consentListener = (e: Event) => {\n const customEvent = e as CustomEvent<UsercentricsEventDetail>;\n if (customEvent.detail) {\n handleConsent(customEvent.detail);\n }\n };\n actualWindow.addEventListener(eventName, consentListener);\n }\n\n return {\n type: 'usercentrics',\n config: fullConfig,\n push: elb,\n destroy: async (_context) => {\n if (actualWindow && consentListener) {\n const eventName = settings.eventName ?? 'ucEvent';\n actualWindow.removeEventListener(eventName, consentListener);\n }\n },\n };\n};\n\nexport default sourceUsercentrics;\n"],"mappings":";;;;;;;AAAA;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAMO,IAAM,kBAA2C;AAAA,EACtD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,YAAY;A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AA,IACR,MAAM;AAAA,IACN,SAAS,OAAO,aAAa;AA9JjC,UAAAA;AA+JM,UAAI,gBAAgB,iBAAiB;AACnC,cAAM,aAAYA,MAAA,SAAS,cAAT,OAAAA,MAAsB;AACxC,qBAAa,oBAAoB,WAAW,eAAe;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["fullConsent","minimalConsent","_a","_b"]}
|
package/dist/walkerOS.json
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
"version": "2.1.1",
|
|
5
5
|
"type": "source",
|
|
6
6
|
"platform": "web",
|
|
7
|
-
"renderer": "codebox"
|
|
7
|
+
"renderer": "codebox",
|
|
8
|
+
"docs": "https://www.walkeros.io/docs/sources/web/cmps/usercentrics",
|
|
9
|
+
"source": "https://github.com/elbwalker/walkerOS/tree/main/packages/web/sources/cmps/usercentrics/src"
|
|
8
10
|
},
|
|
9
11
|
"schemas": {},
|
|
10
12
|
"examples": {
|
|
@@ -137,6 +139,49 @@
|
|
|
137
139
|
"$code": "(e,t)=>{if(e&&\"object\"==typeof e)return()=>{t.window.dispatchEvent(new CustomEvent(\"ucEvent\",{detail:e}))}}"
|
|
138
140
|
},
|
|
139
141
|
"step": {
|
|
142
|
+
"categoryMapOverride": {
|
|
143
|
+
"description": "Custom categoryMap remaps essential to functional and functional to analytics",
|
|
144
|
+
"in": {
|
|
145
|
+
"event": "consent_status",
|
|
146
|
+
"type": "explicit",
|
|
147
|
+
"ucCategory": {
|
|
148
|
+
"essential": true,
|
|
149
|
+
"functional": true,
|
|
150
|
+
"marketing": false
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"mapping": {
|
|
154
|
+
"categoryMap": {
|
|
155
|
+
"essential": "functional",
|
|
156
|
+
"functional": "analytics"
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"out": {
|
|
160
|
+
"functional": true,
|
|
161
|
+
"analytics": true,
|
|
162
|
+
"marketing": false
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"customEventName": {
|
|
166
|
+
"description": "Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",
|
|
167
|
+
"in": {
|
|
168
|
+
"event": "consent_status",
|
|
169
|
+
"type": "explicit",
|
|
170
|
+
"ucCategory": {
|
|
171
|
+
"essential": true,
|
|
172
|
+
"functional": true,
|
|
173
|
+
"marketing": true
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"mapping": {
|
|
177
|
+
"eventName": "UC_SDK_EVENT"
|
|
178
|
+
},
|
|
179
|
+
"out": {
|
|
180
|
+
"essential": true,
|
|
181
|
+
"functional": true,
|
|
182
|
+
"marketing": true
|
|
183
|
+
}
|
|
184
|
+
},
|
|
140
185
|
"fullConsent": {
|
|
141
186
|
"in": {
|
|
142
187
|
"event": "consent_status",
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/web-source-cmp-usercentrics",
|
|
3
3
|
"description": "Usercentrics consent management source for walkerOS",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"sideEffects": false,
|
|
7
6
|
"walkerOS": {
|
|
8
7
|
"type": "source",
|
|
9
8
|
"platform": "web",
|
|
10
|
-
"renderer": "codebox"
|
|
9
|
+
"renderer": "codebox",
|
|
10
|
+
"docs": "https://www.walkeros.io/docs/sources/web/cmps/usercentrics"
|
|
11
11
|
},
|
|
12
12
|
"main": "./dist/index.js",
|
|
13
13
|
"module": "./dist/index.mjs",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"update": "npx npm-check-updates -u && npm update"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@walkeros/core": "
|
|
45
|
-
"@walkeros/collector": "
|
|
44
|
+
"@walkeros/core": "^3.0.0",
|
|
45
|
+
"@walkeros/collector": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {},
|
|
48
48
|
"repository": {
|