ublo-lib 1.8.13 → 1.9.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.
|
@@ -2,8 +2,9 @@ import * as React from "react";
|
|
|
2
2
|
import * as ReactDOM from "react-dom";
|
|
3
3
|
import getConfig from "next/config";
|
|
4
4
|
import classnames from "classnames";
|
|
5
|
-
import * as Messages from "./messages";
|
|
6
5
|
import Button from "dt-design-system/es/button";
|
|
6
|
+
import * as Messages from "./messages";
|
|
7
|
+
import * as Utils from "./utils";
|
|
7
8
|
import css from "./cookie-consent.module.css";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -11,7 +12,8 @@ const {
|
|
|
11
12
|
publicRuntimeConfig
|
|
12
13
|
} = getConfig();
|
|
13
14
|
const {
|
|
14
|
-
gaAccount
|
|
15
|
+
gaAccount,
|
|
16
|
+
hotjar
|
|
15
17
|
} = publicRuntimeConfig;
|
|
16
18
|
const COOKIE_STORAGE = "cookie_allowed";
|
|
17
19
|
const CookieConsent = ({
|
|
@@ -20,7 +22,7 @@ const CookieConsent = ({
|
|
|
20
22
|
updateConsent
|
|
21
23
|
}) => {
|
|
22
24
|
const [mounted, setMounted] = React.useState(false);
|
|
23
|
-
const isEnabled = Boolean(gaAccount);
|
|
25
|
+
const isEnabled = Boolean(gaAccount || hotjar);
|
|
24
26
|
const cookieAllowed = value => () => {
|
|
25
27
|
updateConsent(value);
|
|
26
28
|
};
|
|
@@ -32,6 +34,24 @@ const CookieConsent = ({
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
}, [isEnabled, mounted, updateConsent]);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (mounted) {
|
|
39
|
+
const runEffect = async () => {
|
|
40
|
+
if (consent) {
|
|
41
|
+
const {
|
|
42
|
+
id,
|
|
43
|
+
version
|
|
44
|
+
} = hotjar;
|
|
45
|
+
await Utils.loadHotjar(id, version);
|
|
46
|
+
} else {
|
|
47
|
+
const script = document.querySelector('data-id="hotjar"');
|
|
48
|
+
if (script) script.remove();
|
|
49
|
+
if ("hj" in window) delete window.hj;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
runEffect();
|
|
53
|
+
}
|
|
54
|
+
}, [consent, mounted]);
|
|
35
55
|
if (!mounted) return null;
|
|
36
56
|
const classes = classnames(css.banner, {
|
|
37
57
|
[css.opened]: consent === null
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const messages = {
|
|
2
2
|
fr: {
|
|
3
3
|
"cookie-consent-title": "Nous utilisons des cookies",
|
|
4
|
-
"cookie-consent-text": "Ce site utilise des cookies <b>
|
|
4
|
+
"cookie-consent-text": "Ce site utilise des cookies uniquement <b>pour mesurer l'audience</b> dans le but d'<b>améliorer</b> nos services. En cliquant sur « J'accepte » vous nous aidez à <b>faciliter votre expérience</b>.",
|
|
5
5
|
"cookie-consent-revoke": "Je refuse",
|
|
6
6
|
"cookie-consent-agree": "J'accepte",
|
|
7
7
|
"no-cookie-title": "Nous n'utilisons plus de cookies",
|
|
@@ -9,7 +9,7 @@ const messages = {
|
|
|
9
9
|
},
|
|
10
10
|
en: {
|
|
11
11
|
"cookie-consent-title": "We use cookies",
|
|
12
|
-
"cookie-consent-text": "This site uses cookies <b>to measure its audience</b>, and also to <b>improve</b> our services and <b>facilitate its use</b> by our customers. By clicking on « Got it » you <b>help us improve it</b>.",
|
|
12
|
+
"cookie-consent-text": "This site uses cookies only <b>to measure its audience</b>, and also to <b>improve</b> our services and <b>facilitate its use</b> by our customers. By clicking on « Got it » you <b>help us improve it</b>.",
|
|
13
13
|
"cookie-consent-revoke": "Deny",
|
|
14
14
|
"cookie-consent-agree": "Got it",
|
|
15
15
|
"no-cookie-title": "We are no longer using cookies",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export async function loadHotjar(id, version, debug = false) {
|
|
2
|
+
(function (h, o, t, j, a, r) {
|
|
3
|
+
h.hj = h.hj || function () {
|
|
4
|
+
(h.hj.q = h.hj.q || []).push(arguments);
|
|
5
|
+
};
|
|
6
|
+
h._hjSettings = {
|
|
7
|
+
hjid: id,
|
|
8
|
+
hjsv: version,
|
|
9
|
+
hjDebug: debug
|
|
10
|
+
};
|
|
11
|
+
h._scriptPath = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
|
|
12
|
+
if (!document.querySelector('script[src*="' + h._scriptPath + '"]')) {
|
|
13
|
+
a = o.getElementsByTagName("head")[0];
|
|
14
|
+
r = o.createElement("script");
|
|
15
|
+
r.async = 1;
|
|
16
|
+
r.src = h._scriptPath;
|
|
17
|
+
r["data-id"] = "hotjar";
|
|
18
|
+
a.appendChild(r);
|
|
19
|
+
}
|
|
20
|
+
})(window, document, "https://static.hotjar.com/c/hotjar-", ".js?sv=");
|
|
21
|
+
}
|