nakarte

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

commit 25ed982035d42f3474183348d681c34f79af1472
parent e88b3dabf0fb8b4eeb088cd17f5ad2352e036e01
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Fri,  9 Nov 2018 08:56:27 +0100

log uids to sentry

Diffstat:
Msrc/index.js | 31++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/index.js b/src/index.js @@ -3,6 +3,23 @@ import './index.css'; import App from './App' import config from './config'; +function getUid() { + const cookie = document.cookie; + const cookieUid = cookie.match(/\buid=([^;]+)/)[1]; + const uidRaw = atob(cookieUid); + const l = []; + for (let i = 0; i < uidRaw.length; i++) { + l.push(uidRaw.charCodeAt(i)); + } + const l2 = []; + l2.push(...l.slice(0, 4).reverse()); + l2.push(...l.slice(4, 8).reverse()); + l2.push(...l.slice(8, 12).reverse()); + l2.push(...l.slice(12).reverse()); + const uid = l2.map((c) => ("0" + c.toString(16)).slice(-2)).join('').toUpperCase(); + return uid; +} + /* eslint-disable no-undef */ if (NODE_ENV === 'production') { Raven.config(config.sentryDSN, {release: RELEASE_VER}).install(); @@ -30,5 +47,17 @@ window.onunhandledrejection = (e) => { console.log('Version:', RELEASE_VER); /* eslint-enable no-undef */ -App.setUp(); +let uid; +try {uid = getUid()} catch (e) {} +console.log('UID:', uid); + +Raven.setUserContext({ + uid: uid, + cookie: document.cookie + } +); + +Raven.context(function() { + App.setUp(); +});