@codecademy/tracking 1.1.1-alpha.d7121cda5d.0 → 1.1.2-alpha.fa2232522c.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/integrations/fides.js +34 -35
- package/package.json +1 -1
|
@@ -4,49 +4,48 @@ import { theme } from '@codecademy/gamut-styles';
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const PROPERTY_ID = 'FDS-3RC5S1';
|
|
7
|
+
const FIDES_TIMEOUT = 10000; // 10 seconds
|
|
8
|
+
|
|
7
9
|
const ot_fides_mapping = encodeURIComponent(JSON.stringify({
|
|
8
10
|
C0001: ['essential'],
|
|
9
11
|
C0002: ['analytics'],
|
|
10
12
|
C0003: ['functional'],
|
|
11
13
|
C0004: ['marketing']
|
|
12
14
|
}));
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (detail.extraDetails.servingComponent === 'banner') {
|
|
37
|
-
const banner = document.getElementById('fides-banner');
|
|
38
|
-
if (banner) {
|
|
39
|
-
banner.setAttribute('tabIndex', '-1');
|
|
40
|
-
}
|
|
15
|
+
export const initializeFides = () => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const timeout = setTimeout(() => {
|
|
18
|
+
reject(new Error('Fides initialization timed out'));
|
|
19
|
+
}, FIDES_TIMEOUT);
|
|
20
|
+
window.addEventListener('FidesInitialized', () => {
|
|
21
|
+
clearTimeout(timeout);
|
|
22
|
+
const fides = window.Fides;
|
|
23
|
+
try {
|
|
24
|
+
fides.gtm();
|
|
25
|
+
const unsubscribe = fides.onFidesEvent('FidesUIShown', detail => {
|
|
26
|
+
if (detail.extraDetails.servingComponent === 'banner') {
|
|
27
|
+
const banner = document.getElementById('fides-banner');
|
|
28
|
+
if (banner) {
|
|
29
|
+
banner.setAttribute('tabIndex', '-1');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
unsubscribe();
|
|
33
|
+
});
|
|
34
|
+
resolve();
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error('Error initializing Fides', err);
|
|
37
|
+
reject(err);
|
|
41
38
|
}
|
|
42
|
-
unsubscribe();
|
|
43
39
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
const script = document.createElement('script');
|
|
41
|
+
script.setAttribute('async', 'true');
|
|
42
|
+
script.setAttribute('src', "https://skillsoft-codecademy.fides-cdn.ethyca.com/fides.js?property_id=".concat(PROPERTY_ID, "&ot_fides_mapping=").concat(ot_fides_mapping));
|
|
43
|
+
script.setAttribute('type', 'text/javascript');
|
|
44
|
+
document.body.appendChild(script);
|
|
45
|
+
const style = document.createElement('style');
|
|
46
|
+
style.textContent = rawStyles;
|
|
47
|
+
document.body.appendChild(style);
|
|
48
|
+
});
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
// For now, these three values duplicate theme colors from gamut-styles
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/tracking",
|
|
3
3
|
"description": "Tracking library for Codecademy",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2-alpha.fa2232522c.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@qwik.dev/partytown": "0.11.0"
|