Compare commits
3 Commits
560f578b26
...
17e1415136
Author | SHA1 | Date | |
---|---|---|---|
17e1415136 | |||
a4a6fc4bb9 | |||
0eff71732e |
@@ -1,10 +1,10 @@
|
||||
import {td} from './telemetry';
|
||||
import {send} from './telemetry';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Functions to open and close a modal
|
||||
function openModal($el) {
|
||||
$el.classList.add('is-active');
|
||||
td.signal("Modal.open", {
|
||||
send("Modal.open", {
|
||||
modal: $el.id
|
||||
});
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import '@fortawesome/fontawesome-free/js/regular';
|
||||
import '@fortawesome/fontawesome-free/js/brands';
|
||||
import './feedback.js';
|
||||
import './main.scss';
|
||||
import {td} from './telemetry';
|
||||
import {send} from './telemetry';
|
||||
|
||||
/////////////////
|
||||
// TRANSLATION //
|
||||
@@ -363,7 +363,7 @@ function updateCageCheck() {
|
||||
resultsDiv.appendChild(result);
|
||||
|
||||
// Send telemetry
|
||||
td.signal("Update.CageCheck", {
|
||||
send("Update.CageCheck", {
|
||||
width: width,
|
||||
depth: depth,
|
||||
height: height,
|
||||
@@ -391,7 +391,7 @@ function updateCageCalc() {
|
||||
resultsDiv.appendChild(result);
|
||||
|
||||
// Send telemetry
|
||||
td.signal("Update.CageCalc", {
|
||||
send("Update.CageCalc", {
|
||||
numRats: numRats,
|
||||
});
|
||||
|
||||
@@ -432,7 +432,7 @@ function updateNumRatsCalculator() {
|
||||
|
||||
|
||||
// Send telemetry
|
||||
td.signal("Update.NumRatsCalc", {
|
||||
send("Update.NumRatsCalc", {
|
||||
width: width,
|
||||
depth: depth,
|
||||
height: height,
|
||||
|
@@ -7,12 +7,20 @@ import TelemetryDeck from '@telemetrydeck/sdk';
|
||||
|
||||
// Telemetry Deck only collects fully anonymized data!
|
||||
|
||||
const getCookieValueOrNull = (name) => {
|
||||
const cookie = document.cookie
|
||||
.split(";")
|
||||
.map(c => c.trim())
|
||||
.find(c => c.startsWith(name + "="));
|
||||
return cookie ? cookie.split("=")[1] : null;
|
||||
};
|
||||
|
||||
function getOrCreateUUID() {
|
||||
let cookie = document.cookie.split(";").some((item) => item.trim().startsWith("id="));
|
||||
let cookie_val = getCookieValueOrNull("id");
|
||||
if (
|
||||
cookie
|
||||
cookie_val
|
||||
) {
|
||||
return cookie.split("=")[1];
|
||||
return cookie_val;
|
||||
} else {
|
||||
let uuid =crypto.randomUUID();
|
||||
const days = 365;
|
||||
@@ -22,7 +30,28 @@ function getOrCreateUUID() {
|
||||
}
|
||||
}
|
||||
|
||||
export const td = new TelemetryDeck({
|
||||
appID: '4A88C6F5-2BDE-489E-9834-34D89FD5473F',
|
||||
clientUser: getOrCreateUUID()
|
||||
});
|
||||
// Send Test Signals when running locally
|
||||
function init() {
|
||||
const appId = "E453AAB8-B1AD-4F3E-87DF-97FC3A0400B9";
|
||||
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
||||
const td = new TelemetryDeck({
|
||||
appID: appId,
|
||||
clientUser: getOrCreateUUID(),
|
||||
testMode: true
|
||||
});
|
||||
return td;
|
||||
} else {
|
||||
const td = new TelemetryDeck({
|
||||
appID: appId,
|
||||
clientUser: getOrCreateUUID()
|
||||
});
|
||||
return td;
|
||||
}
|
||||
}
|
||||
|
||||
let td = init();
|
||||
|
||||
|
||||
export function send(type, payload) {
|
||||
td.signal(type, payload);
|
||||
}
|
||||
|
Reference in New Issue
Block a user