@codecademy/tracking 1.1.2 → 1.1.3-alpha.d7bcd71238.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 +35 -34
- package/package.json +1 -1
|
@@ -4,48 +4,49 @@ 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
|
-
|
|
9
7
|
const ot_fides_mapping = encodeURIComponent(JSON.stringify({
|
|
10
8
|
C0001: ['essential'],
|
|
11
9
|
C0002: ['analytics'],
|
|
12
10
|
C0003: ['functional'],
|
|
13
11
|
C0004: ['marketing']
|
|
14
12
|
}));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
const importFides = async () => {
|
|
14
|
+
var _win$define;
|
|
15
|
+
const win = window;
|
|
16
|
+
// Disable AMD globals for the Fides script
|
|
17
|
+
const oldAmd = (_win$define = win.define) === null || _win$define === void 0 ? void 0 : _win$define.amd;
|
|
18
|
+
if (oldAmd) {
|
|
19
|
+
win.define.amd = undefined;
|
|
20
|
+
}
|
|
21
|
+
// Fides gets stored on the window object
|
|
22
|
+
await import(/* webpackIgnore: true */"https://skillsoft-codecademy.fides-cdn.ethyca.com/fides.js?property_id=".concat(PROPERTY_ID, "&ot_fides_mapping=").concat(ot_fides_mapping));
|
|
23
|
+
if (oldAmd) {
|
|
24
|
+
win.define.amd = oldAmd;
|
|
25
|
+
}
|
|
26
|
+
if (!win.Fides) {
|
|
27
|
+
throw new Error('Failed to import Fides');
|
|
28
|
+
}
|
|
29
|
+
return win.Fides;
|
|
30
|
+
};
|
|
31
|
+
export const initializeFides = async () => {
|
|
32
|
+
try {
|
|
33
|
+
const fides = await importFides();
|
|
34
|
+
fides.gtm();
|
|
35
|
+
const unsubscribe = fides.onFidesEvent('FidesUIShown', detail => {
|
|
36
|
+
if (detail.extraDetails.servingComponent === 'banner') {
|
|
37
|
+
const banner = document.getElementById('fides-banner');
|
|
38
|
+
if (banner) {
|
|
39
|
+
banner.setAttribute('tabIndex', '-1');
|
|
40
|
+
}
|
|
38
41
|
}
|
|
42
|
+
unsubscribe();
|
|
39
43
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
style.textContent = rawStyles;
|
|
47
|
-
document.body.appendChild(style);
|
|
48
|
-
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error('Error initializing Fides', err);
|
|
46
|
+
}
|
|
47
|
+
const style = document.createElement('style');
|
|
48
|
+
style.textContent = rawStyles;
|
|
49
|
+
document.body.appendChild(style);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
// For now, these three values duplicate theme colors from gamut-styles
|
package/package.json
CHANGED