Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import asyncStorage from '../../platform/server/asyncStorage';
import { sha256String } from '../encryption-internals';
let uuid = require('../../platform/uuid');
let currentUniqueId;
let mixpanel;
let isEnabled = true;
export function toggle(trackUsage) {
isEnabled = trackUsage == null || trackUsage === 'true' ? true : false;
}
// TODO: Figure out location, send to EU data centers if in EU
// {
// host: "api-eu.mixpanel.com",
// },
// This must stay up-to-date with all apps that hit mixpanel! That includes the
// website and server. If changing this, make sure to change it everywhere
async function hash(userId) {
let hashed = await sha256String(userId);
return `user-${hashed.replace(/[=/]/g, '')}`;
}
function isAnonymous(id) {
return !id.startsWith('user-');
}
export async function init() {
}
export async function login(userId) {
}
let BUFFERING = false;
let BUFFER = [];
function startBuffering() {
BUFFERING = true;
BUFFER = [];
}
function stopBuffering() {
for (let call of BUFFER) {
call[0](...call[1]);
}
BUFFERING = false;
BUFFER = [];
}
function buffered(func) {
return (...args) => {
if (process.env.NODE_ENV !== 'development') {
if (BUFFERING) {
BUFFER.push([func, [currentUniqueId, ...args]]);
} else {
func(currentUniqueId, ...args);
}
}
};
}
export const track = buffered((distinct_id, name, props) => {});
export const setProfile = buffered((distinct_id, props) => {});