-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Enable GPP Multi-State Privacy String (MSPS) with U.S. Privacy (…
…#806) * Create stub_gpp_ccpa.js * Added stub_gpp_ccpa * Added reference * Added includeGppApi * Update stub.ts * Momentarily committing a changeset * Momentarily log * Fixing bug * Update sourcepoint.ts * Update sourcepoint.ts * Update sourcepoint.ts * Updated file name to stub_uspapi_ccpa * Update early-rocks-destroy.md * Update for aus and added _gpp * Update sourcepoint.test.js * Added GPPData interface * Create new function to get gpp data * using getGPPData * Removing gpp * Update getConsentState.ts * Using GPPData * Updated to minor * Using tcfv2 in unknown frameworks * Fixed test * Update stub.ts * Update sourcepoint.ts
- Loading branch information
1 parent
aad7433
commit 60b7d15
Showing
8 changed files
with
197 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@guardian/consent-management-platform': minor | ||
--- | ||
|
||
- Adding the includeGppApi param to the sourcepoint config for CCPA. | ||
- Updating type to include includeGppApi for the window object. | ||
- Refactoring stub.ts to load both \_\_uspapi and \_\_gpp stub for CCPA but only load \_\_uspapi for AUS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import { stub_ccpa } from './stub_ccpa'; | ||
import { stub_gpp_ccpa } from './stub_gpp_ccpa'; | ||
import { stub_tcfv2 } from './stub_tcfv2'; | ||
import { stub_uspapi_ccpa } from './stub_uspapi_ccpa'; | ||
import type { Framework } from './types'; | ||
|
||
export const stub = (framework: Framework): void => { | ||
// NOTE - Contrary to the SourcePoint documentation, it's important that we only run the stub file | ||
// for the framework currently in use. The presence of __tcfapi on the window object signals to GPT | ||
// that it should take precedence over __uspapi | ||
// documentation.sourcepoint.com/implementation/web-implementation/multi-campaign-web-implementation#stub-file | ||
if (framework === 'tcfv2') stub_tcfv2(); | ||
else stub_ccpa(); | ||
switch (framework) { | ||
case 'tcfv2': | ||
stub_tcfv2(); | ||
break; | ||
case 'ccpa': | ||
stub_uspapi_ccpa(); | ||
stub_gpp_ccpa(); | ||
break; | ||
case 'aus': | ||
stub_uspapi_ccpa(); | ||
break; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* eslint-disable -- this is third party code */ | ||
/* istanbul ignore file */ | ||
// Reference : https://docs.sourcepoint.com/hc/en-us/articles/18007731422099-Enable-GPP-Multi-State-Privacy-String-MSPS-with-U-S-Privacy-CCPA-solution | ||
export const stub_gpp_ccpa = () => { | ||
(window.__gpp_addFrame = function (e) { | ||
if (!window.frames[e]) { | ||
if (document.body) { | ||
var t = document.createElement('iframe'); | ||
(t.style.cssText = 'display:none'), | ||
(t.name = e), | ||
document.body.appendChild(t); | ||
} else window.setTimeout(window.__gpp_addFrame, 10, e); | ||
} | ||
}), | ||
(window.__gpp_stub = function () { | ||
var e = arguments; | ||
if ( | ||
((__gpp.queue = __gpp.queue || []), | ||
(__gpp.events = __gpp.events || []), | ||
!e.length || (1 == e.length && 'queue' == e[0])) | ||
) { | ||
return __gpp.queue; | ||
} | ||
if (1 == e.length && 'events' == e[0]) return __gpp.events; | ||
var t = e[0], | ||
p = e.length > 1 ? e[1] : null, | ||
n = e.length > 2 ? e[2] : null; | ||
if ('ping' === t) { | ||
return { | ||
gppVersion: '1.0', | ||
cmpStatus: 'stub', | ||
cmpDisplayStatus: 'hidden', | ||
supportedAPIs: ['tcfeuv2', 'tcfcav2', 'uspv1'], | ||
cmpId: 31, | ||
}; | ||
} | ||
if ('addEventListener' === t) { | ||
'lastId' in __gpp || (__gpp.lastId = 0), __gpp.lastId++; | ||
var a = __gpp.lastId; | ||
return ( | ||
__gpp.events.push({ id: a, callback: p, parameter: n }), | ||
{ | ||
eventName: 'listenerRegistered', | ||
listenerId: a, | ||
data: !0, | ||
pingData: { | ||
gppVersion: '1.0', | ||
cmpStatus: 'stub', | ||
cmpDisplayStatus: 'hidden', | ||
supportedAPIs: ['tcfeuv2', 'tcfva', 'usnat'], | ||
cmpId: 31, | ||
}, | ||
} | ||
); | ||
} | ||
if ('removeEventListener' === t) { | ||
for (var s = !1, i = 0; i < __gpp.events.length; i++) { | ||
if (__gpp.events[i].id == n) { | ||
__gpp.events.splice(i, 1), (s = !0); | ||
break; | ||
} | ||
} | ||
return { | ||
eventName: 'listenerRemoved', | ||
listenerId: n, | ||
data: s, | ||
pingData: { | ||
gppVersion: '1.0', | ||
cmpStatus: 'stub', | ||
cmpDisplayStatus: 'hidden', | ||
supportedAPIs: ['tcfeuv2', 'tcfva', 'usnat'], | ||
cmpId: 31, | ||
}, | ||
}; | ||
} | ||
return 'getGPPData' === t | ||
? { | ||
sectionId: 3, | ||
gppVersion: 1, | ||
sectionList: [], | ||
applicableSections: [0], | ||
gppString: '', | ||
pingData: { | ||
gppVersion: '1.0', | ||
cmpStatus: 'stub', | ||
cmpDisplayStatus: 'hidden', | ||
supportedAPIs: ['tcfeuv2', 'tcfva', 'usnat'], | ||
cmpId: 31, | ||
}, | ||
} | ||
: 'hasSection' === t || 'getSection' === t || 'getField' === t | ||
? null | ||
: void __gpp.queue.push([].slice.apply(e)); | ||
}), | ||
(window.__gpp_msghandler = function (e) { | ||
var t = 'string' == typeof e.data; | ||
try { | ||
var p = t ? JSON.parse(e.data) : e.data; | ||
} catch (e) { | ||
p = null; | ||
} | ||
if ('object' == typeof p && null !== p && '__gppCall' in p) { | ||
var n = p.__gppCall; | ||
window.__gpp( | ||
n.command, | ||
function (p, a) { | ||
var s = { | ||
__gppReturn: { | ||
returnValue: p, | ||
success: a, | ||
callId: n.callId, | ||
}, | ||
}; | ||
e.source.postMessage(t ? JSON.stringify(s) : s, '*'); | ||
}, | ||
'parameter' in n ? n.parameter : null, | ||
'version' in n ? n.version : 1, | ||
); | ||
} | ||
}), | ||
('__gpp' in window && 'function' == typeof window.__gpp) || | ||
((window.__gpp = window.__gpp_stub), | ||
window.addEventListener('message', window.__gpp_msghandler, !1), | ||
window.__gpp_addFrame('__gppLocator')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60b7d15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report
Test suite run success
328 tests passing in 16 suites.
Report generated by 🧪jest coverage report action from 60b7d15