gatsby-core-theme 25.0.10 → 25.0.11
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/CHANGELOG.md +10 -0
- package/gatsby-browser.js +51 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [25.0.11](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v25.0.10...v25.0.11) (2023-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* move optin and facebook pixel to core ([85d804c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/85d804c5ea84ac3f964ed8e50c5ed9c05fa799f5))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* Merge branch 'optin-monster' into 'master' ([2e8c6a9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2e8c6a923516fef9663d4c7688c9295d4dba5830))
|
|
10
|
+
|
|
1
11
|
## [25.0.10](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v25.0.9...v25.0.10) (2023-08-01)
|
|
2
12
|
|
|
3
13
|
|
package/gatsby-browser.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
/* eslint-disable no-unused-expressions */
|
|
3
|
+
/* eslint-disable no-underscore-dangle */
|
|
4
|
+
/* eslint-disable prefer-destructuring */
|
|
5
|
+
|
|
1
6
|
// Main Vars
|
|
2
7
|
require('./src/styles/utils/variables/_colors.scss');
|
|
3
8
|
require('./src/styles/utils/variables/_main.scss');
|
|
@@ -41,13 +46,54 @@ function initGTM() {
|
|
|
41
46
|
document.body.appendChild(noscript);
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
function
|
|
49
|
+
function optinMonster() {
|
|
50
|
+
const script = document.createElement('script');
|
|
51
|
+
script.id = 'optin-monstr';
|
|
52
|
+
script.setAttribute('data-user', process.env.OPTINMONSTR_USER);
|
|
53
|
+
script.setAttribute('data-account', process.env.OPTINMONSTR_ACC);
|
|
54
|
+
script.src = 'https://a.omappapi.com/app/js/api.min.js';
|
|
55
|
+
script.async = true;
|
|
56
|
+
document.body.appendChild(script);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const loadFacebookPixel = () => {
|
|
60
|
+
!(function (f, b, e, v, n, t, s) {
|
|
61
|
+
// eslint-disable-next-line no-multi-assign
|
|
62
|
+
if (f.fbq) return;
|
|
63
|
+
n = f.fbq = function () {
|
|
64
|
+
n.callMethod
|
|
65
|
+
? // eslint-disable-next-line prefer-spread, prefer-rest-params
|
|
66
|
+
n.callMethod.apply(n, arguments)
|
|
67
|
+
: n.queue.push(arguments);
|
|
68
|
+
};
|
|
69
|
+
if (!f._fbq) f._fbq = n;
|
|
70
|
+
n.push = n;
|
|
71
|
+
n.loaded = !0;
|
|
72
|
+
n.version = '2.0';
|
|
73
|
+
n.queue = [];
|
|
74
|
+
t = b.createElement(e);
|
|
75
|
+
t.async = !0;
|
|
76
|
+
t.src = v;
|
|
77
|
+
s = b.getElementsByTagName(e)[0];
|
|
78
|
+
s.parentNode.insertBefore(t, s);
|
|
79
|
+
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function scrollEvent(event) {
|
|
83
|
+
if (process.env.ENABLE_OPTINMONSTR === 'true') optinMonster();
|
|
84
|
+
if (process.env.ENABLE_PIXEL === 'true') {
|
|
85
|
+
loadFacebookPixel();
|
|
86
|
+
// Initialize and track the PageView event
|
|
87
|
+
fbq('init', process.env.PIXEL_ID);
|
|
88
|
+
fbq('track', 'PageView');
|
|
89
|
+
}
|
|
90
|
+
|
|
45
91
|
initGTM();
|
|
46
|
-
event.currentTarget.removeEventListener(event.type,
|
|
92
|
+
event.currentTarget.removeEventListener(event.type, scrollEvent); // remove the event listener that got triggered
|
|
47
93
|
}
|
|
48
94
|
|
|
49
95
|
exports.onClientEntry = () => {
|
|
50
|
-
document.addEventListener('scroll',
|
|
51
|
-
document.addEventListener('mousemove',
|
|
52
|
-
document.addEventListener('touchstart',
|
|
96
|
+
document.addEventListener('scroll', scrollEvent);
|
|
97
|
+
document.addEventListener('mousemove', scrollEvent);
|
|
98
|
+
document.addEventListener('touchstart', scrollEvent, { passive: true });
|
|
53
99
|
};
|