@@ -2,6 +2,35 @@ import React from "react";
22import Script from "next/script" ;
33import { isBrowser } from "@/modules/const" ;
44
5+ const hosts = [
6+ "tilavaraus.hel.fi" ,
7+ "tilavaraus.dev.hel.ninja" ,
8+ "tilavaraus.test.hel.ninja" ,
9+ "tilavaraus.stage.hel.ninja" ,
10+ ] ;
11+
12+ // Hack to make cookiehub not destroy our cookies
13+ // temporary for a few weeks to fix critical production issue
14+ const addCookieHubExceptions = `
15+ const cookies = ["csrftoken", "sessionid", "language"];
16+ for (let i = 0; i < cookies.length; i++) {
17+ window.__cookiehub.cookies.push({
18+ category: (window.__cookiehub.categories.find((c) => c.implicit).id),
19+ expiry: "365 {day}",
20+ display_name: cookies[i],
21+ hide: 0,
22+ hosts: ${ JSON . stringify ( hosts ) } ,
23+ http_only: 0,
24+ id: 99990 + i,
25+ name: cookies[i],
26+ path: "/",
27+ prefix: 0,
28+ secure: 0,
29+ third_party: 0,
30+ type: 1
31+ });
32+ }
33+ ` ;
534export function ExternalScripts ( {
635 cookiehubEnabled,
736 matomoEnabled,
@@ -25,7 +54,7 @@ export function ExternalScripts({
2554 __html : `
2655var cpm = {
2756 cookie: {
28- domain: ''
57+ domain: "",
2958 },
3059 language: document.documentElement.lang !== null
3160 ? document.documentElement.lang.substr(0, 2)
@@ -34,7 +63,10 @@ var cpm = {
3463(function(h,u,b){
3564var d=h.getElementsByTagName("script")[0],e=h.createElement("script");
3665e.async=true;e.src='https://cookiehub.net/c2/c7e96adf.js';
37- e.onload=function(){u.cookiehub.load(b);}
66+ e.onload=function(){
67+ u.cookiehub.load(b);
68+ ${ addCookieHubExceptions } ;
69+ }
3870d.parentNode.insertBefore(e,d);
3971})(document,window,cpm);
4072` ,
0 commit comments