nakarte

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

commit 8db64f9cf2c214c844fb777bf08f2ddf9ca50e51
parent 275a5c4cf4c18951e33c1c101f20d79e9258ac85
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Sat, 15 Dec 2018 12:57:10 +0100

[logging] better events logging

 * send address with every event
 * same session id length for all browsers
 * export function for random strings

Diffstat:
Msrc/lib/logging/index.js | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/lib/logging/index.js b/src/lib/logging/index.js @@ -1,6 +1,10 @@ import Raven from 'raven-js'; -const sessionId = Math.random().toString(36).substring(2); +function randId() { + return Math.random().toString(36).substring(2, 13); +} + +const sessionId = randId(); function captureException(e, options) { console.log('captureException', e, options); @@ -34,7 +38,11 @@ function logEvent(eventName, extra) { const url = 'https://nakarte.me/event'; const data = {event: eventName.toString()}; - data.data = Object.assign({}, extra, {beacon: true, session: sessionId}); + data.data = Object.assign({}, extra, { + beacon: true, + session: sessionId, + address: window.location.toString() + }); let s = JSON.stringify(data); try { navigator.sendBeacon(url, s); @@ -50,4 +58,4 @@ function logEvent(eventName, extra) { export default {captureMessage, captureException, setExtraContext, captureBreadcrumbWithUrl, captureBreadcrumb, - captureMessageWithUrl, logEvent} -\ No newline at end of file + captureMessageWithUrl, logEvent, randId} +\ No newline at end of file