@codecademy/tracking 1.0.38 → 1.0.39-alpha.a66d948689.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.
|
@@ -17,17 +17,14 @@ export const partytownConfig = () => ({
|
|
|
17
17
|
// Snap Pixel
|
|
18
18
|
/lightboxcdn/,
|
|
19
19
|
// Digioh
|
|
20
|
-
/reddit/,
|
|
21
|
-
// Reddit pixel
|
|
22
|
-
/pixel/,
|
|
23
|
-
// Used by Reddit pixel
|
|
24
20
|
/linkedin/ // linkedin
|
|
25
21
|
],
|
|
26
22
|
// This function runs in a worker and can't access other vars in this file.
|
|
27
23
|
resolveUrl(url, location, type) {
|
|
28
|
-
//
|
|
24
|
+
// Hoist GTM iframe out of Partytown so that GTM can create its own worker normally.
|
|
29
25
|
if (url.hostname === 'www.googletagmanager.com' && type === 'iframe') {
|
|
30
|
-
|
|
26
|
+
new BroadcastChannel('gtm-iframe').postMessage(url.href);
|
|
27
|
+
return new URL('data:'); // blank url to prevent iframe within Partytown
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
/*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function gtmDoubleFrame(src: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function hiddenFrame(doc) {
|
|
2
|
+
const f = doc.createElement('iframe');
|
|
3
|
+
f.setAttribute('height', '0');
|
|
4
|
+
f.setAttribute('width', '0');
|
|
5
|
+
f.setAttribute('style', 'display: none; visibility: hidden;');
|
|
6
|
+
doc.body.appendChild(f);
|
|
7
|
+
return f;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Double frame is what GTM would normally use without Partytown.
|
|
11
|
+
export function gtmDoubleFrame(src) {
|
|
12
|
+
const outerFrame = hiddenFrame(document);
|
|
13
|
+
const innerFrame = hiddenFrame(outerFrame.contentWindow.document);
|
|
14
|
+
innerFrame.src = src;
|
|
15
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { partytownSnippet } from '@builder.io/partytown/integration';
|
|
2
2
|
import { partytownConfig } from './config';
|
|
3
|
+
import { gtmDoubleFrame } from './gtmDoubleFrame';
|
|
3
4
|
|
|
4
5
|
// Encapsulate to avoid collision of global vars aliased in minification.
|
|
5
6
|
const encapsulate = js => `(() => {${js}})();`;
|
|
@@ -7,4 +8,8 @@ export function initializePartytown() {
|
|
|
7
8
|
const ptScript = document.createElement('script');
|
|
8
9
|
ptScript.innerHTML = encapsulate(partytownSnippet(partytownConfig()));
|
|
9
10
|
document.head.appendChild(ptScript);
|
|
11
|
+
new BroadcastChannel('gtm-iframe').onmessage = _ref => {
|
|
12
|
+
let data = _ref.data;
|
|
13
|
+
gtmDoubleFrame(data);
|
|
14
|
+
};
|
|
10
15
|
}
|
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.
|
|
4
|
+
"version": "1.0.39-alpha.a66d948689.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@builder.io/partytown": "^0.10.2"
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"repository": "git@github.com:codecademy-engineering/mono.git",
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "afc5f80a5d904b52a91798faca049afff4db8ce5"
|
|
20
20
|
}
|