@castlabs/ui 7.11.0 → 7.13.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.
@@ -1,4 +1,4 @@
1
- /* @castlabs/ui v7.11.0 */
1
+ /* @castlabs/ui v7.13.0 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -114,8 +114,17 @@ function clSidenavInitiallyOpen () {
114
114
 
115
115
  const cookieName = 'cl_banner_nok'
116
116
 
117
- export function clCookieBannerSetup () {
118
- clMatomoSetup()
117
+ export function clCookieBannerSetup (siteId = 1, forced = false) {
118
+ if (
119
+ !window.location.hostname.match(/castlabs.com$/) &&
120
+ !window.location.search.match('mtm=DEBUG') &&
121
+ !forced
122
+ ) {
123
+ console.info(`skipping cookie banner on ${window.location.hostname ?? 'unknown domain'}`)
124
+ return
125
+ }
126
+
127
+ clMatomoSetup(siteId)
119
128
  let show = true
120
129
  for (const cookie of document?.cookie?.split(/; */) ?? []) {
121
130
  const [name, value] = cookie.split('=')
@@ -188,17 +197,17 @@ function clCookieBannerShow (accept = clCookieBannerAccept, decline = clCookieBa
188
197
  document.getElementById('cl-button-cookie-decline').addEventListener('click', decline)
189
198
  }
190
199
 
191
- function clMatomoSetup () {
200
+ function clMatomoSetup (siteId = 1, domain = 'castlabs.com') {
192
201
  const _paq = (window._paq = window._paq || [])
193
202
  _paq.push(['requireCookieConsent'])
194
203
  _paq.push(['setDocumentTitle', document.domain + '/' + document.title])
195
- _paq.push(['setCookieDomain', '*.castlabs.com'])
196
- _paq.push(['setDomains', ['*.castlabs.com']])
204
+ _paq.push(['setCookieDomain', `*.${domain}`])
205
+ _paq.push(['setDomains', [`*.${domain}`]])
197
206
  _paq.push(['trackPageView'])
198
207
  _paq.push(['enableLinkTracking'])
199
208
  ;(function () {
200
209
  _paq.push(['setTrackerUrl', 'https://castlabs.matomo.cloud/matomo.php'])
201
- _paq.push(['setSiteId', '1'])
210
+ _paq.push(['setSiteId', `${siteId}`])
202
211
  const g = document.createElement('script')
203
212
  const s = document.getElementsByTagName('script')[0]
204
213
  g.async = true