1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Analyze sessions with logrocket

This commit is contained in:
tobspr
2020-06-03 14:32:02 +02:00
parent 604988c352
commit 692eb36f50
3 changed files with 36 additions and 0 deletions

View File

@@ -18,6 +18,36 @@ if (window.coreThreadLoadedCb) {
window.coreThreadLoadedCb();
}
if (!G_IS_DEV && !G_IS_STANDALONE) {
const monthlyUsers = 300; // thousand
const logrocketLimit = 10; // thousand
const percentageOfUsers = logrocketLimit / monthlyUsers;
if (Math.random() <= percentageOfUsers) {
logger.log("Analyzing this session with logrocket");
const logrocket = require("logrocket");
logrocket.init("p1x9zh/shapezio");
try {
logrocket.getSessionURL(function (sessionURL) {
logger.log("Connected lockrocket to GA");
// @ts-ignore
try {
window.ga("send", {
hitType: "event",
eventCategory: "LogRocket",
eventAction: sessionURL,
});
} catch (ex) {
logger.warn("Logrocket connection to analytics failed:", ex);
}
});
} catch (ex) {
logger.warn("Logrocket connection to analytics failed:", ex);
}
}
}
console.log(
`%cshapez.io %c\n© 2020 Tobias Springer IT Solutions\nCommit %c${G_BUILD_COMMIT_HASH}%c on %c${new Date(
G_BUILD_TIME