use window.mixpanel, remove eventEmitter

pull/512/head
Ryan Tharp 6 years ago
parent c921d3e3b3
commit 51eaa90823

@ -230,8 +230,7 @@
window.feeds = [];
window.lokiMessageAPI = new window.LokiMessageAPI(ourKey);
window.lokiPublicChatAPI = new window.LokiPublicChatAPI(ourKey);
// set up mixpanel
window.mixpanel = window.mixpanel || new window.LokiMixpanelAPI(); // incase account manager already set it up
// are there limits on tracking, is this unneeded?
// window.mixpanel.track("Desktop boot");
window.lokiP2pAPI = new window.LokiP2pAPI(ourKey);
window.lokiP2pAPI.on('pingContact', pubKey => {

@ -4,9 +4,6 @@
const _ = require('lodash');
const { rpc } = require('./loki_rpc');
const LokiMixpanelAPI = require('./loki_mixpanel.js');
const Mixpanel = new LokiMixpanelAPI();
const DEFAULT_CONNECTIONS = 3;
const MAX_ACCEPTABLE_FAILURES = 1;
@ -181,7 +178,7 @@ class LokiMessageAPI {
try {
// eslint-disable-next-line more/no-then
success = await firstTrue(promises);
Mixpanel.track('Sent Message Using Swarm API');
window.mixpanel.track('Sent Message Using Swarm API');
} catch (e) {
if (e instanceof textsecure.WrongDifficultyError) {
// Force nonce recalculation
@ -195,7 +192,7 @@ class LokiMessageAPI {
throw e;
}
if (!success) {
Mixpanel.track('Failed to Send Message Using Swarm API');
window.mixpanel.track('Failed to Send Message Using Swarm API');
throw new window.textsecure.EmptySwarmError(
pubKey,
'Ran out of swarm nodes to query'
@ -260,7 +257,7 @@ class LokiMessageAPI {
} catch (e) {
log.warn('Loki send message:', e);
if (e instanceof textsecure.WrongSwarmError) {
Mixpanel.track('Migrated Snode');
window.mixpanel.track('Migrated Snode');
const { newSwarm } = e;
await lokiSnodeAPI.updateSwarmNodes(params.pubKey, newSwarm);
this.sendingData[params.timestamp].swarm = newSwarm;

@ -1,12 +1,8 @@
/* eslint-disable class-methods-use-this */
const EventEmitter = require('events');
const Mixpanel = require('mixpanel');
// require('setimmediate');
class LokiMixpanelAPI extends EventEmitter {
class LokiMixpanelAPI {
constructor() {
super();
this.mixpanel = Mixpanel.init('736cd9a854a157591153efacd1164e9a');
}
track(label) {

@ -3,9 +3,6 @@ clearTimeout, MessageController */
const EventEmitter = require('events');
const nodeFetch = require('node-fetch');
const { URL, URLSearchParams } = require('url');
const LokiMixpanelAPI = require('./loki_mixpanel.js');
const Mixpanel = new LokiMixpanelAPI();
// Can't be less than 1200 if we have unauth'd requests
const PUBLICCHAT_MSG_POLL_EVERY = 1.5 * 1000; // 1.5s
@ -666,12 +663,12 @@ class LokiPublicChannelAPI {
objBody: payload,
});
if (!res.err && res.response) {
Mixpanel.track('Public Message Sent');
window.mixpanel.track('Public Message Sent');
return res.response.data.id;
}
// there's no retry on desktop
// this is supposed to be after retries
Mixpanel.track('Failed to Send Public Message');
window.mixpanel.track('Failed to Send Public Message');
return false;
}
}

@ -6,9 +6,6 @@ const dns = require('dns');
const process = require('process');
const { rpc } = require('./loki_rpc');
const natUpnp = require('nat-upnp');
const LokiMixpanelAPI = require('./loki_mixpanel.js');
const Mixpanel = new LokiMixpanelAPI();
const resolve4 = url =>
new Promise((resolve, reject) => {
@ -121,7 +118,7 @@ class LokiSnodeAPI {
port: snode.storage_port,
}));
} catch (e) {
Mixpanel.track('Seed Node Failed');
window.mixpanel.track('Seed Node Failed');
if (seedNodes.length === 0) {
throw new window.textsecure.SeedNodeError(
'Failed to contact seed node'
@ -137,7 +134,7 @@ class LokiSnodeAPI {
const filteredNodes = swarmNodes.filter(
node => node.address !== nodeUrl && node.ip !== nodeUrl
);
Mixpanel.track('Unreachable Snode');
window.mixpanel.track('Unreachable Snode');
await conversation.updateSwarmNodes(filteredNodes);
}

Loading…
Cancel
Save