1import { property, state, customElement, LitElement } from '/en_GI/skins/lottoland/js/core/@lottoland/core/lit-element-1d494b120be4f08f.js'; 2import { subscribe, unsubscribe } from '/en_GI/skins/lottoland/js/cms/@lottoland/client-side-message-bus-dbc03ab893da6331.js'; 3 4/*! ***************************************************************************** 5Copyright (c) Microsoft Corporation. All rights reserved. 6Licensed under the Apache License, Version 2.0 (the "License"); you may not use 7this file except in compliance with the License. You may obtain a copy of the 8License at http://www.apache.org/licenses/LICENSE-2.0 9 10THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 12WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 13MERCHANTABLITY OR NON-INFRINGEMENT. 14 15See the Apache Version 2.0 License for specific language governing permissions 16and limitations under the License. 17***************************************************************************** */ 18/* global Reflect, Promise */ 19 20 21function __decorate(decorators, target, key, desc) { 22 var c = arguments.length, r = c < 3 ? target : desc, d; 23 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 24 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 25 return c > 3 && r && Object.defineProperty(target, key, r), r; 26} 27 28const FIBONACCI_VALUES = [0, 1, 1, 2, 3, 5, 8, 13]; 29const setDelay = delay => new Promise(resolve => setTimeout(resolve, delay)); 30async function createFibonacciTimer(_ref) { 31 let { 32 action, 33 successCondition, 34 successCallback = () => {}, 35 failedCallback = () => {} 36 } = _ref; 37 for (const value of FIBONACCI_VALUES) { 38 await setDelay(value * 1000); 39 if (action) { 40 await action(); 41 } 42 if (successCondition()) { 43 if (successCallback) { 44 successCallback(); 45 } 46 break; 47 } 48 } 49 if (!successCondition() && failedCallback) { 50 failedCallback(); 51 } 52} 53 54const whitelistCookieNames = ['pid', 'lottolapid', 'mc', 'obc', 'oc', 'dc', 'lct', 'partnerid', 'btag', 'clickref', 'sid', 'experimentId', 'experimentVariation', 'experimentSegment', 'spaction', 'affid', 'prd', 'nonce', 'utm_medium', 'utm_source', 'utm_term', 'utm_content', 'utm_campaign', 'tickets', 'flca', 'ticket', 'o', 'adjustTrackerName', 'adjustTrackerToken', 'advertisingId', 'Device', 'TargetId', 'CreativeId', 'referer', 'token', 'marketId', 'localeReference', 'showNewTipEngine', 'trck1', 'trck2', 'trck3', 'trck4', 'trck5', 'trck6', 'trck7', 'trck8', 'trck9', 'trckA', 'ctfx', 'rid', 'fbc', 'fbp', 'gclid', 'gcl_au', 'gbraid', 'wbraid', 'gclsrc', 'gads']; 55 56const defaultOptions = { 57 expires: undefined, 58 ['max-age']: undefined 59}; 60function getRootDomain() { 61 const hostname = window.location.hostname; 62 63 // If it's localhost or an IP address, return as-is 64 if (/^localhost(:\d+)?$|^[\d.]+$/.test(hostname)) { 65 return hostname; 66 } 67 68 // Split hostname into parts 69 const parts = hostname.split('.'); 70 71 // If it has 2 or fewer parts, return as-is 72 if (parts.length <= 2) { 73 return hostname; 74 } 75 76 // Strategy: If the second-to-last part has 2-3 characters AND the last part also has 2-3 characters, 77 // it's likely a two-level TLD (.co.uk, .com.br, .co.za, etc.) 78 const lastPart = parts[parts.length - 1]; 79 const secondLastPart = parts[parts.length - 2]; 80 if (parts.length >= 3 && secondLastPart.length <= 3 && lastPart.length <= 3) { 81 // Two-level TLD: take the last 3 parts 82 return parts.slice(-3).join('.'); 83 } 84 85 // Single-level TLD: take the last 2 parts 86 return parts.slice(-2).join('.'); 87} 88const cookieHelper = { 89 get: function get(name) { 90 const cookies = document.cookie.split(';'); 91 for (let i = 0; i < cookies.length; i++) { 92 if (cookies[i].indexOf(name) > -1) { 93 var regEx = new RegExp(' ?' + name + '='); 94 return cookies[i].replace(regEx, ''); 95 } 96 } 97 return null; 98 }, 99 set: function set(name, value, options) { 100 if (options === void 0) { 101 options = defaultOptions; 102 } 103 if (options.expires instanceof Date) { 104 options.expires = options.expires.toUTCString(); 105 } 106 let updatedCookie = encodeURIComponent(name) + '=' + encodeURIComponent(value); 107 108 // Add root domain if not localhost or IP address 109 const rootDomain = getRootDomain(); 110 if (!/^localhost(:\d+)?$|^[\d.]+$/.test(rootDomain)) { 111 updatedCookie += '; domain=.' + rootDomain; 112 } 113 for (let optionKey in options) { 114 updatedCookie += '; ' + optionKey; 115 let optionValue = options[optionKey]; 116 if (optionValue !== true) { 117 updatedCookie += '=' + optionValue; 118 } 119 } 120 updatedCookie += '; path=/'; 121 document.cookie = updatedCookie; 122 }, 123 getAllWhitelistedCookies: function getAllWhitelistedCookies() { 124 if (!document.cookie) return {}; 125 return document.cookie.split(';').reduce((cookies, cookie) => { 126 const parts = cookie.split('='); 127 if (parts.length < 2) { 128 return cookies; 129 } 130 const cookieName = parts[0].trim(); 131 const cookieValue = parts.slice(1).join('='); 132 if (cookieName.startsWith('_')) { 133 const nameWithoutUnderscore = cookieName.substring(1); 134 if (whitelistCookieNames.includes(nameWithoutUnderscore)) { 135 cookies[nameWithoutUnderscore] = cookieValue; 136 } 137 } else if (whitelistCookieNames.includes(cookieName)) { 138 cookies[cookieName] = cookieValue; 139 } 140 return cookies; 141 }, {}); 142 }, 143 getCookie: function getCookie(name) { 144 let matches = document.cookie.match(new RegExp('(?:^|; )' + name.replace(/([.$?*|{}()\[\]\\\/+^])/g, '\\$1') + '=([^;]*)')); 145 return matches ? decodeURIComponent(matches[1]) : undefined; 146 } 147}; 148 149const loginTopic = 'PlayerLoggedIn'; 150const registrationTopic = 'PlayerRegistered'; 151const SS_PLAYER_FIRST_NAME_KEY = 'optimoveTracker_playerFirstName'; 152let OptimoveTracker = class OptimoveTracker extends LitElement { 153 constructor() { 154 super(...arguments); 155 this.tenant = ''; 156 this.token = ''; 157 this.email = ''; 158 this.balance = '0'; 159 this.numDecimals = '0'; 160 this.registrationDate = ''; 161 this.lastLogin = ''; 162 this.loginDataSize = '0'; 163 this.platform = ''; 164 this.language = ''; 165 this.isMobile = 'false'; 166 this.status = ''; 167 this.emailPreference = 'true'; 168 this.phonePreference = 'false'; 169 this.postPreference = 'false'; 170 this.smsPreference = 'false'; 171 this.lotteryPreference = 'false'; 172 this.bingoPreference = 'true'; 173 this.casinoAndScratchcardsPreference = 'true'; 174 this.sportsbookPreference = 'false'; 175 this.playerId = ''; 176 this.currentUrl = ''; 177 this.registrationSubscriptionToken = ''; 178 this.loginSubscriptionToken = ''; 179 this.isPlayerJustRegistered = false;
180 this.isFirstLogin = () => { 181 const regDate = this.registrationDate ? new Date(this.registrationDate).getTime() : 0; 182 const firstLoginDate = this.lastLogin ? new Date(this.lastLogin).getTime() : 0; 183 const isLoginWithinAnHour = firstLoginDate - regDate < 60000; 184 return Boolean(Number(this.loginDataSize) === 1 && isLoginWithinAnHour); 185 }; 186 this.initTracking = () => { 187 if (!document.querySelector('script[src*="sdk.optimove.net/v2/websdk/"]')) { 188 const script = document.createElement('script'); 189 script.src = "https://sdk.optimove.net/v2/websdk/?tenant_id=" + encodeURIComponent(this.tenant) + "&tenant_token=" + encodeURIComponent(this.token); 190 (document.head || document.documentElement).appendChild(script); 191 } 192 }; 193 this.subscribeToNavigationEvents = () => { 194 this.navigationIntervalId = setInterval(() => { 195 if (this.currentUrl !== window.location.pathname) { 196 this.currentUrl = window.location.pathname; 197 this.trackEvent(this.trackPageVisitEvent); 198 } 199 }, 100); 200 }; 201 this.subscribeToAuthenticationEvents = () => { 202 if (!this.registrationSubscriptionToken) { 203 this.registrationSubscriptionToken = subscribe(registrationTopic, (_internalTopic, envelop) => { 204 const { 205 playerFirstName 206 } = envelop.payload || {}; 207 sessionStorage.setItem(SS_PLAYER_FIRST_NAME_KEY, playerFirstName); 208 if (this.isMobile === 'true') { 209 this.isPlayerJustRegistered = true; 210 } 211 }); 212 } 213 if (!this.loginSubscriptionToken) { 214 this.loginSubscriptionToken = subscribe(loginTopic, (_internalTopic, envelop) => { 215 var _a, _b; 216 const { 217 playerFirstName, 218 country 219 } = envelop.payload || {}; 220 this.playerId = ((_b = (_a = window.dla) === null || _a === void 0 ? void 0 : _a.resources) === null || _b === void 0 ? void 0 : _b.playerNr) || ''; 221 this.sendRegistrationEvent(); 222 this.isPlayerJustRegistered = false; 223 this.trackEvent(() => this.trackLoginEvent(playerFirstName, country)); 224 }); 225 } 226 }; 227 this.unsubscribeFromAuthenticationEvents = () => { 228 if (this.registrationSubscriptionToken) { 229 unsubscribe(this.registrationSubscriptionToken); 230 this.registrationSubscriptionToken = ''; 231 } 232 if (this.loginSubscriptionToken) { 233 unsubscribe(this.loginSubscriptionToken); 234 this.loginSubscriptionToken = ''; 235 } 236 }; 237 this.trackEvent = onEvent => { 238 createFibonacciTimer({ 239 successCondition: () => window.optimoveSDK !== undefined, 240 successCallback: onEvent 241 }); 242 }; 243 this.trackPageVisitEvent = () => { 244 if (!this.playerId) { 245 window.optimoveSDK.API.signOutUser(); 246 } 247 window.optimoveSDK.API.setPageVisit(window.location.href, document.title, null, this.playerId); 248 }; 249 this.trackRegistrationEvent = playerFirstName => { 250 setTimeout(() => this.trackRegistration(playerFirstName), 1000); 251 }; 252 this.trackLoginEvent = (playerFirstName, country) => { 253 if (this.playerId && playerFirstName) { 254 const timestamp = new Date().toISOString(); 255 setTimeout(() => this.trackLogin(timestamp, country), 1000); 256 } else { 257 this.trackLogout(); 258 } 259 }; 260 this.trackRegistration = playerFirstName => { 261 const acquisitionId = cookieHelper.get('sid'); 262 const territory = document.location.origin; 263 const { 264 bingoPreference, 265 casinoAndScratchcardsPreference, 266 country, 267 currency, 268 email, 269 emailPreference, 270 lotteryPreference, 271 phonePreference, 272 postPreference, 273 smsPreference, 274 sportsbookPreference, 275 status 276 } = this; 277 const registrationFields = { 278 account_status: status, 279 acquisition_id: acquisitionId, 280 bingo_preference: bingoPreference === 'true', 281 casino_scratchcards_preference: casinoAndScratchcardsPreference === 'true', 282 country, 283 currency, 284 email, 285 email_preference: emailPreference === 'true', 286 first_name: playerFirstName, 287 lottery_preference: lotteryPreference === 'true', 288 phone_preference: phonePreference === 'true', 289 post_preference: postPreference === 'true', 290 sms_preference: smsPreference === 'true', 291 sportsbook_preference: sportsbookPreference === 'true', 292 territory 293 }; 294 const getObjectWithPrefix = prefix => Object.entries(registrationFields).reduce((acc, _ref) => { 295 let [key, value] = _ref; 296 acc[prefix + "_" + key] = value; 297 return acc; 298 }, {}); 299 window.optimoveSDK.API.reportEvent('registration', registrationFields, null, this.playerId); 300 window.optimoveSDK.API.reportEvent('ootb_registration', getObjectWithPrefix('ootb'), null, this.playerId); 301 }; 302 this.trackLogin = (timestamp, country) => { 303 const balance = Number(this.balance) / Math.pow(10, Number(this.numDecimals)); 304 window.optimoveSDK.API.reportEvent('login', { 305 is_first_login: this.isFirstLogin(), 306 login_timestamp: timestamp, 307 language: this.language, 308 platform: this.platform, 309 country, 310 balance 311 }, null, this.playerId); 312 window.optimoveSDK.API.reportEvent('ootb_login', { 313 ootb_is_first_login: this.isFirstLogin(), 314 ootb_login_timestamp: timestamp, 315 ootb_language: this.language, 316 ootb_platform: this.platform, 317 ootb_country: country, 318 ootb_balance: balance 319 }, null, this.playerId); 320 }; 321 this.trackLogout = () => { 322 this.playerId = ''; 323 window.optimoveSDK.API.signOutUser(); 324 }; 325 } 326 connectedCallback() { 327 var _a, _b; 328 this.playerId = ((_b = (_a = window.dla) === null || _a === void 0 ? void 0 : _a.resources) === null || _b === void 0 ? void 0 : _b.playerNr) || ''; 329 this.currentUrl = window.location.pathname; 330 this.initTracking(); 331 this.trackEvent(this.trackPageVisitEvent); 332 this.subscribeToAuthenticationEvents(); 333 this.subscribeToNavigationEvents(); 334 super.connectedCallback(); 335 } 336 sendRegistrationEvent() { 337 const playerFirstName = sessionStorage.getItem(SS_PLAYER_FIRST_NAME_KEY); 338 if (playerFirstName && !this.isPlayerJustRegistered) { 339 this.trackEvent(() => this.trackRegistrationEvent(playerFirstName)); 340 sessionStorage.removeItem(SS_PLAYER_FIRST_NAME_KEY); 341 } 342 } 343 disconnectedCallback() { 344 this.unsubscribeFromAuthenticationEvents(); 345 clearInterval(this.navigationIntervalId); 346 super.disconnectedCallback(); 347 } 348}; 349__decorate([property({ 350 type: String 351})], OptimoveTracker.prototype, "tenant", void 0); 352__decorate([property({ 353 type: String 354})], OptimoveTracker.prototype, "token", void 0); 355__decorate([property({ 356 type: String 357})], OptimoveTracker.prototype, "email", void 0); 358__decorate([property({ 359 type: String 360})], OptimoveTracker.prototype, "balance", void 0); 361__decorate([property({ 362 type: String 363})], OptimoveTracker.prototype, "numDecimals", void 0); 364__decorate([property({ 365 type: String 366})], OptimoveTracker.prototype, "registrationDate", void 0); 367__decorate([property({ 368 type: String 369})], OptimoveTracker.prototype, "lastLogin", void 0); 370__decorate([property({ 371 type: String 372})], OptimoveTracker.prototype, "loginDataSize", void 0); 373__decorate([property({ 374 type: String 375})], OptimoveTracker.prototype, "platform", void 0); 376__decorate([property({ 377 type: String 378})], OptimoveTracker.prototype, "language", void 0); 379__decorate([property({ 380 type: String 381})], OptimoveTracker.prototype, "isMobile", void 0); 382__decorate([property({ 383 type: String 384})], OptimoveTracker.prototype, "status", void 0); 385__decorate([property({ 386 type: String 387})], OptimoveTracker.prototype, "currency", void 0); 388__decorate([property({ 389 type: String 390})], OptimoveTracker.prototype, "country", void 0); 391__decorate([property({ 392 type: String 393})], OptimoveTracker.prototype, "emailPreference", void 0); 394__decorate([property({ 395 type: String 396})], OptimoveTracker.prototype, "phonePreference", void 0); 397__decorate([property({ 398 type: String 399})], OptimoveTracker.prototype, "postPreference", void 0); 400__decorate([property({ 401 type: String 402})], OptimoveTracker.prototype, "smsPreference", void 0); 403__decorate([property({ 404 type: String 405})], OptimoveTracker.prototype, "lotteryPreference", void 0); 406__decorate([property({ 407 type: String 408})], OptimoveTracker.prototype, "bingoPreference", void 0); 409__decorate([property({ 410 type: String 411})], OptimoveTracker.prototype, "casinoAndScratchcardsPreference", void 0); 412__decorate([property({ 413 type: String 414})], OptimoveTracker.prototype, "sportsbookPreference", void 0); 415__decorate([state()], OptimoveTracker.prototype, "playerId", void 0); 416__decorate([state()], OptimoveTracker.prototype, "currentUrl", void 0); 417__decorate([state()], OptimoveTracker.prototype, "registrationSubscriptionToken", void 0); 418__decorate([state()], OptimoveTracker.prototype, "loginSubscriptionToken", void 0);
419OptimoveTracker = __decorate([customElement('ll-optimove-tracker')], OptimoveTracker);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.