add basic debugger analytics

This commit is contained in:
Dave Holoway
2020-07-03 00:15:39 +01:00
parent cc3b995de3
commit 33daf68649
3 changed files with 48 additions and 7 deletions

View File

@@ -8,10 +8,11 @@ const timeLabels = new Map();
let session_start = Date.now();
/**
* @param {string} t
* @param {string} u
* @param {string} s
* @param {{name:string,version:string}} package_json
* @param {string} [t]
* @param {string} [u]
* @param {string} [s]
* @param {{name:string,version:string}} [package_json]
* @param {*} [props]
*/
function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props) {
if (mp) {
@@ -20,10 +21,15 @@ function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props)
try {
mp = require('mixpanel').init(t);
}
catch {}
catch {
return;
}
uid = u;
sid = s;
if (!props) {
return;
}
const os = require('os');
event(`${package_json.name}-start`, {
extension: package_json.name,
@@ -56,7 +62,7 @@ function event(eventName, properties) {
...properties,
});
} else {
mp.track(eventName);
mp.track(eventName, properties);
}
} catch {}
}