forked from adjust/react_native_sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·226 lines (177 loc) · 7.26 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
'use strict';
import { DeviceEventEmitter } from 'react-native';
var ReactNative = require('react-native');
var {
NativeModules
} = ReactNative;
var module_adjust = NativeModules.Adjust;
var Adjust = {};
Adjust.create = function(adjustConfig) {
module_adjust.create(adjustConfig);
};
Adjust.trackEvent = function (adjustEvent) {
module_adjust.trackEvent(adjustEvent);
};
Adjust.setEnabled = function(enabled) {
module_adjust.setEnabled(enabled);
};
Adjust.isEnabled = function(callback) {
module_adjust.isEnabled(callback);
};
Adjust.setOfflineMode = function(enabled) {
module_adjust.setOfflineMode(enabled);
};
Adjust.setPushToken = function(token) {
module_adjust.setPushToken(token);
};
Adjust.appWillOpenUrl = function(uri) {
module_adjust.appWillOpenUrl(uri);
};
Adjust.sendFirstPackages = function() {
module_adjust.sendFirstPackages();
};
Adjust.addSessionCallbackParameter = function(key, value) {
module_adjust.addSessionCallbackParameter(key, value);
};
Adjust.addSessionPartnerParameter = function(key, value) {
module_adjust.addSessionPartnerParameter(key, value);
};
Adjust.removeSessionCallbackParameter = function(key) {
module_adjust.removeSessionCallbackParameter(key);
};
Adjust.removeSessionPartnerParameter = function(key) {
module_adjust.removeSessionPartnerParameter(key);
};
Adjust.resetSessionCallbackParameters = function() {
module_adjust.resetSessionCallbackParameters();
};
Adjust.resetSessionPartnerParameters = function() {
module_adjust.resetSessionPartnerParameters();
};
Adjust.getIdfa = function(callback) {
module_adjust.getIdfa(callback);
};
Adjust.getGoogleAdId = function(callback) {
module_adjust.getGoogleAdId(callback);
};
Adjust.getAdid = function(callback) {
module_adjust.getAdid(callback);
};
Adjust.getAttribution = function(callback) {
module_adjust.getAttribution(callback);
};
var AdjustEvent = function (eventToken) {
this.eventToken = eventToken;
this.revenue = null;
this.currency = null;
this.transactionId = null;
this.callbackParameters = {};
this.partnerParameters = {};
this.setRevenue = function(revenue, currency) {
this.revenue = revenue;
this.currency = currency;
};
this.addCallbackParameter = function(key, value) {
this.callbackParameters[key] = value;
};
this.addPartnerParameter = function(key, value) {
this.partnerParameters[key] = value;
};
this.setTransactionId = function(transactionId) {
this.transactionId = transactionId;
};
};
var AdjustConfig = function(appToken, environment) {
this.appToken = appToken;
this.environment = environment;
this.sdkPrefix = "react_native4.11.3";
this.logLevel = null;
this.eventBufferingEnabled = null;
this.shouldLaunchDeeplink = null;
this.sendInBackground = null;
this.delayStart = null;
this.defaultTracker = null;
this.referrer = null;
this.userAgent = null;
// Android only
this.processName = null;
};
AdjustConfig.EnvironmentSandbox = "sandbox";
AdjustConfig.EnvironmentProduction = "production";
AdjustConfig.LogLevelVerbose = "VERBOSE";
AdjustConfig.LogLevelDebug = "DEBUG";
AdjustConfig.LogLevelInfo = "INFO";
AdjustConfig.LogLevelWarn = "WARN";
AdjustConfig.LogLevelError = "ERROR";
AdjustConfig.LogLevelAssert = "ASSERT";
AdjustConfig.LogLevelSuppress = "SUPPRESS";
AdjustConfig.AttributionSubscription = null;
AdjustConfig.EventTrackingSucceededSubscription = null;
AdjustConfig.EventTrackingFailedSubscription = null;
AdjustConfig.SessionTrackingSucceededSubscription = null;
AdjustConfig.SessionTrackingFailedSubscription = null;
AdjustConfig.DeferredDeeplinkSubscription = null;
AdjustConfig.prototype.setEventBufferingEnabled = function(isEnabled) {
this.eventBufferingEnabled = isEnabled;
};
AdjustConfig.prototype.setLogLevel = function(logLevel) {
this.logLevel = logLevel;
};
AdjustConfig.prototype.setProcessName = function(processName) {
this.processName = processName;
};
AdjustConfig.prototype.setDefaultTracker = function(defaultTracker) {
this.defaultTracker = defaultTracker;
};
AdjustConfig.prototype.setUserAgent = function(userAgent) {
this.userAgent = userAgent;
};
AdjustConfig.prototype.setDelayStart = function(delayStart) {
this.delayStart = delayStart;
};
AdjustConfig.prototype.setReferrer = function(referrer) {
this.referrer = referrer;
};
AdjustConfig.prototype.setSendInBackground = function(sendInBackground) {
this.sendInBackground = sendInBackground;
};
AdjustConfig.prototype.setShouldLaunchDeeplink = function(shouldLaunchDeeplink) {
this.shouldLaunchDeeplink = shouldLaunchDeeplink;
};
AdjustConfig.prototype.setAttributionCallbackListener = function(attributionCallbackListener) {
if (null == AdjustConfig.AttributionSubscription) {
module_adjust.setAttributionCallbackListener();
AdjustConfig.AttributionSubscription = DeviceEventEmitter.addListener('adjust_attribution', attributionCallbackListener);
}
};
AdjustConfig.prototype.setEventTrackingSucceededCallbackListener = function(eventTrackingSucceededCallbackListener) {
if (null == AdjustConfig.EventTrackingSucceededSubscription) {
module_adjust.setEventTrackingSucceededCallbackListener();
AdjustConfig.EventTrackingSucceededSubscription = DeviceEventEmitter.addListener('adjust_eventTrackingSucceeded', eventTrackingSucceededCallbackListener);
}
};
AdjustConfig.prototype.setEventTrackingFailedCallbackListener = function(eventTrackingFailedCallbackListener) {
if (null == AdjustConfig.EventTrackingFailedSubscription) {
module_adjust.setEventTrackingFailedCallbackListener();
AdjustConfig.EventTrackingFailedSubscription = DeviceEventEmitter.addListener('adjust_eventTrackingFailed', eventTrackingFailedCallbackListener);
}
};
AdjustConfig.prototype.setSessionTrackingSucceededCallbackListener = function(sessionTrackingSucceededCallbackListener) {
if (null == AdjustConfig.SessionTrackingSucceededSubscription) {
module_adjust.setSessionTrackingSucceededCallbackListener();
AdjustConfig.SessionTrackingSucceededSubscription = DeviceEventEmitter.addListener('adjust_sessionTrackingSucceeded', sessionTrackingSucceededCallbackListener);
}
};
AdjustConfig.prototype.setSessionTrackingFailedCallbackListener = function(sessionTrackingFailedCallbackListener) {
if (null == AdjustConfig.SessionTrackingFailedSubscription) {
module_adjust.setSessionTrackingFailedCallbackListener();
AdjustConfig.SessionTrackingFailedSubscription = DeviceEventEmitter.addListener('adjust_sessionTrackingFailed', sessionTrackingFailedCallbackListener);
}
};
AdjustConfig.prototype.setDeferredDeeplinkCallbackListener = function(deferredDeeplinkCallbackListener) {
if (null == AdjustConfig.DeferredDeeplinkSubscription) {
module_adjust.setDeferredDeeplinkCallbackListener();
AdjustConfig.DeferredDeeplinkSubscription = DeviceEventEmitter.addListener('adjust_deferredDeeplink', deferredDeeplinkCallbackListener);
}
};
module.exports = { Adjust, AdjustEvent, AdjustConfig }