@codecademy/tracking 1.0.33 → 1.0.34-alpha.047539649d.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.
@@ -12,8 +12,12 @@ export type TrackingIntegrationsSettings = {
12
12
  * Whether user has opted out or is excluded from external tracking
13
13
  */
14
14
  optedOutExternalTracking?: boolean;
15
+ /**
16
+ * id for the one trust script being used, defaults to the script for `www.codecademy.com`
17
+ */
18
+ oneTrustScript?: string;
15
19
  };
16
20
  /**
17
21
  * @see README.md for details and usage.
18
22
  */
19
- export declare const initializeTrackingIntegrations: ({ environment, scope, optedOutExternalTracking, }: TrackingIntegrationsSettings) => Promise<void>;
23
+ export declare const initializeTrackingIntegrations: ({ environment, scope, optedOutExternalTracking, oneTrustScript, }: TrackingIntegrationsSettings) => Promise<void>;
@@ -6,14 +6,16 @@ import { initializeOneTrust } from './onetrust';
6
6
  export const initializeTrackingIntegrations = async _ref => {
7
7
  let environment = _ref.environment,
8
8
  scope = _ref.scope,
9
- optedOutExternalTracking = _ref.optedOutExternalTracking;
9
+ optedOutExternalTracking = _ref.optedOutExternalTracking,
10
+ oneTrustScript = _ref.oneTrustScript;
10
11
  // 1. Wait 1000ms to allow any other post-hydration logic to run first
11
12
  await new Promise(resolve => setTimeout(resolve, 1000));
12
13
 
13
14
  // 2. Load in OneTrust's banner and wait for its `OptanonWrapper` callback
14
15
  await initializeOneTrust({
15
16
  scope,
16
- environment
17
+ environment,
18
+ scriptId: oneTrustScript
17
19
  });
18
20
 
19
21
  // 3. Load GTM
@@ -2,5 +2,6 @@ import { TrackingWindow } from './types';
2
2
  export type OneTrustSettings = {
3
3
  environment: string;
4
4
  scope: TrackingWindow;
5
+ scriptId?: string;
5
6
  };
6
- export declare const initializeOneTrust: ({ environment, scope, }: OneTrustSettings) => Promise<void>;
7
+ export declare const initializeOneTrust: ({ environment, scope, scriptId, }: OneTrustSettings) => Promise<void>;
@@ -1,11 +1,17 @@
1
+ /**
2
+ * Onetrust script ID for `www.codecademy.com`, other domains require passing in a specific script ID
3
+ */
4
+ const DEFAULT_SCRIPT_ID = 'cfa7b129-f37b-4f5a-9991-3f75ba7b85fb';
1
5
  export const initializeOneTrust = async _ref => {
2
6
  let environment = _ref.environment,
3
- scope = _ref.scope;
7
+ scope = _ref.scope,
8
+ _ref$scriptId = _ref.scriptId,
9
+ scriptId = _ref$scriptId === void 0 ? DEFAULT_SCRIPT_ID : _ref$scriptId;
4
10
  const script = document.createElement('script');
5
11
  script.setAttribute('async', 'true');
6
12
  script.setAttribute('src', 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js');
7
13
  script.setAttribute('type', 'text/javascript');
8
- script.setAttribute('data-domain-script', "cfa7b129-f37b-4f5a-9991-3f75ba7b85fb".concat(environment === 'production' ? '' : '-test'));
14
+ script.setAttribute('data-domain-script', "".concat(scriptId).concat(environment === 'production' ? '' : '-test'));
9
15
  document.body.appendChild(script);
10
16
  const style = document.createElement('style');
11
17
  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.33",
4
+ "version": "1.0.34-alpha.047539649d.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": "99a2b4ab5102f5fdae829b44d754151d1baf069e"
16
+ "gitHead": "fa0790c68eb80b3ef6b1eeb69c4e86fd8e667d53"
17
17
  }