-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixpanel_instance.js
More file actions
executable file
·60 lines (53 loc) · 1.55 KB
/
Copy pathmixpanel_instance.js
File metadata and controls
executable file
·60 lines (53 loc) · 1.55 KB
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
import Mixpanel from 'react-native-mixpanel';
import DataUtil from './data_util';
import Global from './../global';
import { USER_MODE } from './../consts';
module.exports = {
init: function (token) {
Mixpanel.sharedInstanceWithToken(token);
},
track: function (eventName, props) {
if (Global.getEnvironment() !== Global.APP_ENV_TYPE.production) {
return;
}
var p = DataUtil.isNotNull(props) ? props : {};
Mixpanel.trackWithProperties(eventName, p);
},
setUser: function (props) {
Mixpanel.set(props);
},
setAlias: function (alias) {
Mixpanel.createAlias(String(alias));
},
identifyAlias: function (alias) {
Mixpanel.identify(String(alias));
},
logUser: function (user, currentUserMode) {
var userMode = currentUserMode === USER_MODE.RecruiterMode ? 'recruiter' : 'jobSeeker';
Mixpanel.identify(String(user.userId));
Mixpanel.set({
"$first_name": user.firstName,
"$last_name": user.lastName,
"$email": user.email,
"$phone": user.phoneNumber,
"Age": user.age,
"Gender": user.gender,
"Roles": user.roles.map(r => r === USER_MODE.RecruiterMode ? 'Recruiter' : 'Job Seeker').join()
});
}
};
/*
MixpanelInstance.setAlias('testuser2');
MixpanelInstance.identifyAlias('testuser2');
MixpanelInstance.setUser({
$first_name: 'Test',
$last_name: 'User2',
$email: 'test2@email.com',
props1: 'test',
props2: 1
});
MixpanelInstance.track('test_event', {
event_props1: 'testing',
event_props2: 2
});
*/