-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
171 lines (149 loc) · 5.75 KB
/
index.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
let MetrixUtil = require("./src/metrix-util.js");
import { NativeEventEmitter } from "react-native";
import { Platform } from "react-native";
let Metrixx = require("react-native").NativeModules.MetrixReactNative;
var Metrix = {};
Metrix.onCreate = MetrixUtil.onCreate;
Metrix.newEvent = MetrixUtil.newEvent;
Metrix.newRevenue = MetrixUtil.newRevenue;
Metrix.screenDisplayed = MetrixUtil.screenDisplayed;
Metrix.addUserAttributes = MetrixUtil.addUserAttributes;
Metrix.addUserMetrics = MetrixUtil.addUserMetrics;
Metrix.appWillOpenUrl = MetrixUtil.appWillOpenUrl;
var MetrixConfig = function(appId) {
this.settings = {};
this.settings.appId = appId;
this.settings.shouldLunchDeeplink = false;
this.onAttributionChangeListener = function(e) {};
this.onDeeplinkResponseListener = function(e) {};
this.onReceiveUserIdListener = function(e) {};
this.onSessionIdListener = function(e) {};
const DeviceEventEmitter = new NativeEventEmitter(Metrixx);
DeviceEventEmitter.addListener("onAttributionChangedListener", val => {
this.onAttributionChangeListener(val);
});
DeviceEventEmitter.addListener("onReceiveUserIdListener", val => {
this.onReceiveUserIdListener(val);
});
if (Platform.OS === "android") {
DeviceEventEmitter.addListener("onSessionIdListener", val => {
this.onSessionIdListener(val);
});
DeviceEventEmitter.addListener("onDeeplinkResponseListener", val => {
this.onDeeplinkResponseListener(val);
});
}
};
MetrixConfig.prototype.setAppSecret = function(
secretId,
info1,
info2,
info3,
info4
) {
this.settings.appSecret = {
secretId: secretId.toString(),
info1: info1.toString(),
info2: info2.toString(),
info3: info3.toString(),
info4: info4.toString()
};
};
MetrixConfig.prototype.setShouldLaunchDeeplink = function(shouldLunchDeeplink) {
this.settings.shouldLunchDeeplink = shouldLunchDeeplink;
};
MetrixConfig.prototype.setLocationListening = function(locationListening) {
this.settings.locationListening = locationListening;
};
MetrixConfig.prototype.setEventUploadThreshold = function(
eventUploadThreshold
) {
this.settings.eventUploadThreshold = eventUploadThreshold;
};
MetrixConfig.prototype.setEventUploadMaxBatchSize = function(
eventUploadMaxBatchSize
) {
this.settings.eventUploadMaxBatchSize = eventUploadMaxBatchSize;
};
MetrixConfig.prototype.setFirebaseId = function(firebaseAppId, firebaseProjectId, firebaseApiKey) {
this.settings.firebaseAppId = firebaseAppId;
this.settings.firebaseProjectId = firebaseProjectId;
this.settings.firebaseApiKey = firebaseApiKey;
};
MetrixConfig.prototype.setEventMaxCount = function(eventMaxCount) {
this.settings.eventMaxCount = eventMaxCount;
};
MetrixConfig.prototype.setEventUploadPeriodMillis = function(
eventUploadPeriodMillis
) {
this.settings.eventUploadPeriodMillis = eventUploadPeriodMillis;
};
MetrixConfig.prototype.setSessionTimeoutMillis = function(
sessionTimeoutMillis
) {
this.settings.sessionTimeoutMillis = sessionTimeoutMillis;
};
MetrixConfig.prototype.setEnableLogging = function(enableLogging) {
this.settings.enableLogging = enableLogging;
};
MetrixConfig.prototype.setLogLevel = function(logLevel) {
this.settings.logLevel = logLevel;
};
MetrixConfig.prototype.setFlushEventsOnClose = function(flushEventsOnClose) {
this.settings.flushEventsOnClose = flushEventsOnClose;
};
MetrixConfig.prototype.setDefaultTrackerToken = function(defaultTrackerToken) {
this.settings.defaultTrackerToken = defaultTrackerToken;
};
MetrixConfig.prototype.setStore = function(store) {
this.settings.store = store;
};
MetrixConfig.prototype.setOnAttributionChangedListener = function(
onAttributionChangeListener
) {
this.settings.onAttributionChangedListener = true;
this.onAttributionChangeListener = onAttributionChangeListener;
};
MetrixConfig.prototype.setOnDeeplinkResponseListener = function(
onDeeplinkResponseListener
) {
this.settings.onDeeplinkResponseListener = true;
this.onDeeplinkResponseListener = onDeeplinkResponseListener;
};
MetrixConfig.prototype.setOnSessionIdListener = function(onSessionIdListener) {
this.settings.onSessionIdListener = true;
this.onSessionIdListener = onSessionIdListener;
};
MetrixConfig.prototype.setOnReceiveUserIdListener = function(
onReceiveUserIdListener
) {
this.settings.onReceiveUserIdListener = true;
this.onReceiveUserIdListener = onReceiveUserIdListener;
};
module.exports = {
Metrix,
MetrixConfig,
initialize: MetrixUtil.initialize,
enableLocationListening: MetrixUtil.enableLocationListening,
disableLocationListening: MetrixUtil.disableLocationListening,
setEventUploadThreshold: MetrixUtil.setEventUploadThreshold,
setEventUploadMaxBatchSize: MetrixUtil.setEventUploadMaxBatchSize,
setEventMaxCount: MetrixUtil.setEventMaxCount,
setEventUploadPeriodMillis: MetrixUtil.setEventUploadPeriodMillis,
setSessionTimeoutMillis: MetrixUtil.setSessionTimeoutMillis,
enableLogging: MetrixUtil.enableLogging,
setLogLevel: MetrixUtil.setLogLevel,
setFlushEventsOnClose: MetrixUtil.setFlushEventsOnClose,
newEvent: MetrixUtil.newEvent,
newRevenue: MetrixUtil.newRevenue,
screenDisplayed: MetrixUtil.screenDisplayed,
setScreenFlowsAutoFill: MetrixUtil.setScreenFlowsAutoFill,
setMetrixApiKey: MetrixUtil.setMetrixApiKey,
setDefaultTracker: MetrixUtil.setDefaultTracker,
getSessionNum: MetrixUtil.getSessionNum,
isScreenFlowsAutoFill: MetrixUtil.isScreenFlowsAutoFill,
addUserAttributes: MetrixUtil.addUserAttributes,
setUserMetrics: MetrixUtil.setUserMetrics,
setAppSecret: MetrixUtil.setAppSecret,
setOnAttributionChangedListener: MetrixUtil.setOnAttributionChangedListener
};