nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

index.js (1589B)


      1 import * as Sentry from '@sentry/browser';
      2 import './index.css';
      3 import * as App from './App';
      4 import config from './config';
      5 
      6 function getUid() {
      7     const cookie = document.cookie;
      8     const cookieUid = cookie.match(/\buid=([^;]+)/u)[1];
      9     const uidRaw = atob(cookieUid);
     10     const l = [];
     11     for (let i = 0; i < uidRaw.length; i++) {
     12         l.push(uidRaw.charCodeAt(i));
     13     }
     14     const l2 = [];
     15     l2.push(...l.slice(0, 4).reverse());
     16     l2.push(...l.slice(4, 8).reverse());
     17     l2.push(...l.slice(8, 12).reverse());
     18     l2.push(...l.slice(12).reverse());
     19     const uid = l2.map((c) => ("0" + c.toString(16)).slice(-2)).join('').toUpperCase();
     20     return uid;
     21 }
     22 
     23 function preconnect(url) {
     24     const preconnectLink = document.createElement('link');
     25     preconnectLink.rel = 'preconnect';
     26     preconnectLink.href = url;
     27     document.head.appendChild(preconnectLink);
     28 
     29     const dnsPrefetchLink = document.createElement('link');
     30     dnsPrefetchLink.rel = 'dns-prefetch';
     31     dnsPrefetchLink.href = url;
     32     document.head.appendChild(dnsPrefetchLink);
     33 }
     34 
     35 preconnect(config.elevationsServer);
     36 preconnect(config.CORSProxyUrl);
     37 preconnect(config.tracksStorageServer);
     38 
     39 if (NODE_ENV === 'production') {
     40     Sentry.init({
     41         dsn: config.sentryDSN,
     42         release: RELEASE_VER
     43     });
     44 }
     45 
     46 console.log('Version:', RELEASE_VER); // eslint-disable-line no-console
     47 
     48 let uid;
     49 try {
     50     uid = getUid();
     51 } catch (e) {
     52     // ignore error
     53 }
     54 console.log('UID:', uid); // eslint-disable-line no-console
     55 
     56 Sentry.configureScope(function(scope) {
     57     scope.setUser({id: uid});
     58 });
     59 
     60 App.setUp();
     61