Desktop Analytics

This commit is contained in:
Ryan Tharp 2019-09-17 01:14:29 -07:00
parent 3152637cdc
commit 88b44390bf
11 changed files with 64 additions and 2 deletions

View File

@ -230,6 +230,8 @@
window.feeds = [];
window.lokiMessageAPI = new window.LokiMessageAPI(ourKey);
window.lokiPublicChatAPI = new window.LokiPublicChatAPI(ourKey);
window.mixpanel = new window.LokiMixpanelAPI();
// window.mixpanel.track("Desktop boot");
window.lokiP2pAPI = new window.LokiP2pAPI(ourKey);
window.lokiP2pAPI.on('pingContact', pubKey => {
const isPing = true;

View File

@ -4,6 +4,9 @@
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;
@ -178,6 +181,7 @@ class LokiMessageAPI {
try {
// eslint-disable-next-line more/no-then
success = await firstTrue(promises);
Mixpanel.track('Sent Message Using Swarm API');
} catch (e) {
if (e instanceof textsecure.WrongDifficultyError) {
// Force nonce recalculation
@ -191,6 +195,7 @@ class LokiMessageAPI {
throw e;
}
if (!success) {
Mixpanel.track('Failed to Send Message Using Swarm API');
throw new window.textsecure.EmptySwarmError(
pubKey,
'Ran out of swarm nodes to query'
@ -255,6 +260,7 @@ class LokiMessageAPI {
} catch (e) {
log.warn('Loki send message:', e);
if (e instanceof textsecure.WrongSwarmError) {
Mixpanel.track('Migrated Snode');
const { newSwarm } = e;
await lokiSnodeAPI.updateSwarmNodes(params.pubKey, newSwarm);
this.sendingData[params.timestamp].swarm = newSwarm;

View File

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

View File

@ -3,6 +3,9 @@ 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
@ -663,8 +666,12 @@ class LokiPublicChannelAPI {
objBody: payload,
});
if (!res.err && res.response) {
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');
return false;
}
}

View File

@ -6,6 +6,9 @@ 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) => {
@ -118,6 +121,7 @@ class LokiSnodeAPI {
port: snode.storage_port,
}));
} catch (e) {
Mixpanel.track('Seed Node Failed');
if (seedNodes.length === 0) {
throw new window.textsecure.SeedNodeError(
'Failed to contact seed node'
@ -133,6 +137,7 @@ class LokiSnodeAPI {
const filteredNodes = swarmNodes.filter(
node => node.address !== nodeUrl && node.ip !== nodeUrl
);
Mixpanel.track('Unreachable Snode');
await conversation.updateSwarmNodes(filteredNodes);
}

View File

@ -302,6 +302,15 @@
}
if (conversation) {
if (conversation.isRss()) {
window.mixpanel.track('RSS Feed Opened');
}
if (conversation.isPublic()) {
window.mixpanel.track('Loki Public Chat Opened');
}
if (conversation.isPrivate()) {
window.mixpanel.track('Conversation Opened');
}
conversation.updateProfileName();
}

View File

@ -27,6 +27,8 @@
function AccountManager(username, password) {
// this.server = window.WebAPI.connect({ username, password });
this.pending = Promise.resolve();
// set up mixpanel
window.mixpanel = new window.LokiMixpanelAPI();
}
function getNumber(numberId) {
@ -136,8 +138,10 @@
).toArrayBuffer();
return libsignal.Curve.async.createKeyPair(privKey);
};
window.mixpanel.track('Seed Restored');
} else {
generateKeypair = libsignal.KeyHelper.generateIdentityKeyPair;
window.mixpanel.track('Seed Created');
}
return this.queueTask(() =>
generateKeypair().then(async identityKeyPair =>

View File

@ -85,6 +85,7 @@
"libsodium-wrappers": "^0.7.4",
"linkify-it": "2.0.3",
"lodash": "4.17.11",
"mixpanel": "^0.10.2",
"mkdirp": "0.5.1",
"moment": "2.21.0",
"mustache": "2.3.0",

View File

@ -328,6 +328,8 @@ window.LokiPublicChatAPI = require('./js/modules/loki_public_chat_api');
window.LokiRssAPI = require('./js/modules/loki_rss_api');
window.LokiMixpanelAPI = require('./js/modules/loki_mixpanel.js');
window.LocalLokiServer = require('./libloki/modules/local_loki_server');
window.localServerPort = config.localServerPort;

View File

@ -11,6 +11,8 @@ import { StartNewConversation } from './StartNewConversation';
import { LocalizerType } from '../types/Util';
declare var mixpanel: any;
export type PropsData = {
contacts: Array<ConversationListItemPropsType>;
friends: Array<ConversationListItemPropsType>;
@ -36,7 +38,7 @@ type Props = PropsData & PropsHousekeeping;
export class SearchResults extends React.Component<Props> {
public handleStartNewConversation = () => {
const { regionCode, searchTerm, startNewConversation } = this.props;
mixpanel.track('New Conversation Started');
startNewConversation(searchTerm, { regionCode });
};

View File

@ -4466,7 +4466,7 @@ https-browserify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
https-proxy-agent@^2.2.1:
https-proxy-agent@2.2.1, https-proxy-agent@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==
@ -6022,6 +6022,13 @@ mixin-deep@^1.2.0:
for-in "^1.0.2"
is-extendable "^1.0.1"
mixpanel@^0.10.2:
version "0.10.2"
resolved "https://registry.yarnpkg.com/mixpanel/-/mixpanel-0.10.2.tgz#10ff6cd76034b262d469094ad3d8c99039345376"
integrity sha512-+zbBQGd/Q5LLRooqJ2iyEDzKz2/ly4TipH5tE9te0BDMJpROxUMGffPulyHbh4FtMcbJuPmIUSIfy//JhhnlnA==
dependencies:
https-proxy-agent "2.2.1"
mkdirp@0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12"