@codecademy/tracking 1.0.27-alpha.c59eaf00aa.0 → 1.0.27-alpha.e7527ab86d.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.
@@ -112,7 +112,6 @@ export type TrackingContentIds = {
112
112
  skill_benchmark_id?: string;
113
113
  track_id?: string;
114
114
  journey_id?: string;
115
- external_course_id?: string;
116
115
  };
117
116
  /**
118
117
  * Shared data relevant for all user events
@@ -0,0 +1,5 @@
1
+ import { TrackingWindow } from './types';
2
+ export declare function setGoogleConsentDefaults({ scope, optedOutExternalTracking, }: {
3
+ scope: TrackingWindow;
4
+ optedOutExternalTracking?: boolean;
5
+ }): void;
@@ -0,0 +1,49 @@
1
+ export function setGoogleConsentDefaults(_ref) {
2
+ var _scope$dataLayer;
3
+ let scope = _ref.scope,
4
+ optedOutExternalTracking = _ref.optedOutExternalTracking;
5
+ (_scope$dataLayer = scope.dataLayer) !== null && _scope$dataLayer !== void 0 ? _scope$dataLayer : scope.dataLayer = [];
6
+
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ function gtag() {
9
+ var _scope$dataLayer2;
10
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
11
+ _args[_key] = arguments[_key];
12
+ }
13
+ (_scope$dataLayer2 = scope.dataLayer) === null || _scope$dataLayer2 === void 0 ? void 0 : _scope$dataLayer2.push(arguments);
14
+ }
15
+ if (optedOutExternalTracking) {
16
+ gtag('consent', 'default', {
17
+ ad_storage: 'denied',
18
+ analytics_storage: 'denied',
19
+ functionality_storage: 'denied',
20
+ personalization_storage: 'denied',
21
+ security_storage: 'granted',
22
+ ad_user_data: 'denied',
23
+ ad_personalization: 'denied',
24
+ wait_for_update: 500
25
+ });
26
+ } else {
27
+ gtag('consent', 'default', {
28
+ ad_storage: 'granted',
29
+ analytics_storage: 'granted',
30
+ functionality_storage: 'granted',
31
+ personalization_storage: 'granted',
32
+ security_storage: 'granted',
33
+ ad_user_data: 'granted',
34
+ ad_personalization: 'granted',
35
+ wait_for_update: 500
36
+ });
37
+ }
38
+ gtag('consent', 'default', {
39
+ ad_storage: 'denied',
40
+ analytics_storage: 'denied',
41
+ functionality_storage: 'denied',
42
+ personalization_storage: 'denied',
43
+ security_storage: 'granted',
44
+ ad_user_data: 'denied',
45
+ ad_personalization: 'denied',
46
+ wait_for_update: 500,
47
+ region: ['DE', 'NO', 'BE', 'FI', 'PT', 'BG', 'DK', 'LT', 'LU', 'LV', 'HR', 'FR', 'HU', 'SE', 'MC', 'SI', 'SK', 'MF', 'SM', 'GB', 'YT', 'IE', 'GF', 'EE', 'MQ', 'MT', 'GP', 'IS', 'GR', 'IT', 'ES', 'RE', 'AT', 'CY', 'CZ', 'AX', 'PL', 'RO', 'LI', 'NL']
48
+ });
49
+ }
@@ -1,6 +1,7 @@
1
1
  import { conditionallyLoadAnalytics } from './conditionallyLoadAnalytics';
2
2
  import { fetchDestinationsForWriteKey } from './fetchDestinationsForWriteKey';
3
3
  import { getConsentDecision } from './getConsentDecision';
4
+ import { setGoogleConsentDefaults } from './googleConsent';
4
5
  import { mapDestinations } from './mapDestinations';
5
6
  import { initializeOneTrust } from './onetrust';
6
7
  import { runSegmentSnippet } from './runSegmentSnippet';
@@ -18,6 +19,10 @@ export const initializeTrackingIntegrations = async _ref => {
18
19
  await new Promise(resolve => setTimeout(resolve, 1000));
19
20
 
20
21
  // 2. Load in OneTrust's banner and wait for its `OptanonWrapper` callback
22
+ setGoogleConsentDefaults({
23
+ scope,
24
+ optedOutExternalTracking
25
+ });
21
26
  await initializeOneTrust({
22
27
  scope,
23
28
  production
@@ -5,7 +5,7 @@ export const initializeOneTrust = async _ref => {
5
5
  script.setAttribute('async', 'true');
6
6
  script.setAttribute('src', 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js');
7
7
  script.setAttribute('type', 'text/javascript');
8
- script.setAttribute('data-domain-script', "cfa7b129-f37b-4f5a-9991-3f75ba7b85fb".concat(production ? '' : '-test'));
8
+ script.setAttribute('data-domain-script', "cfa7b129-f37b-4f5a-9991-3f75ba7b85fb".concat(production ? '' : ''));
9
9
  document.body.appendChild(script);
10
10
  const style = document.createElement('style');
11
11
  style.textContent = rawStyles;
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.0.27-alpha.c59eaf00aa.0",
4
+ "version": "1.0.27-alpha.e7527ab86d.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "files": [
7
7
  "dist/**"
@@ -13,5 +13,5 @@
13
13
  "access": "public"
14
14
  },
15
15
  "repository": "git@github.com:codecademy-engineering/mono.git",
16
- "gitHead": "7fcf25b5603046f0e2eb69f41c45aad11bf4a2af"
16
+ "gitHead": "2e1ccd409f4affa737b69ecfbafe6d8fdb66cf60"
17
17
  }