@metrixorg/react-native-plugin 1.5.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +10 -6
- package/android/src/main/java/ir/metrix/reactnative/MetrixModule.java +126 -55
- package/index.js +172 -28
- package/package.json +4 -4
package/android/build.gradle
CHANGED
|
@@ -2,14 +2,13 @@ apply plugin: 'com.android.library'
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
android {
|
|
5
|
-
compileSdkVersion
|
|
6
|
-
buildToolsVersion "28.0.3"
|
|
5
|
+
compileSdkVersion 31
|
|
7
6
|
|
|
8
7
|
defaultConfig {
|
|
9
8
|
minSdkVersion 16
|
|
10
|
-
targetSdkVersion
|
|
11
|
-
versionCode
|
|
12
|
-
versionName "
|
|
9
|
+
targetSdkVersion 31
|
|
10
|
+
versionCode 200000058
|
|
11
|
+
versionName "2.0.0.beta8"
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
buildTypes {
|
|
@@ -23,12 +22,17 @@ android {
|
|
|
23
22
|
|
|
24
23
|
rootProject.allprojects {
|
|
25
24
|
repositories {
|
|
25
|
+
google()
|
|
26
26
|
mavenCentral()
|
|
27
|
+
//noinspection JcenterRepositoryObsolete
|
|
28
|
+
jcenter()
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
dependencies {
|
|
31
33
|
implementation 'com.facebook.react:react-native:+'
|
|
32
|
-
implementation 'ir.metrix:metrix-reactnative:1.5.1'
|
|
33
34
|
|
|
35
|
+
implementation 'ir.metrix.analytics:metrix-reactnative:2.0.0.beta8'
|
|
36
|
+
implementation 'ir.metrix.attribution:metrix-reactnative:2.0.0.beta8'
|
|
37
|
+
api 'ir.metrix.notification:metrix-reactnative:2.0.0.beta8'
|
|
34
38
|
}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
package ir.metrix.reactnative;
|
|
2
2
|
|
|
3
|
-
import android.app.Application;
|
|
4
3
|
import android.net.Uri;
|
|
5
|
-
import android.os.Bundle;
|
|
6
4
|
|
|
7
5
|
import com.facebook.react.bridge.Arguments;
|
|
8
|
-
import com.facebook.react.bridge.Callback;
|
|
9
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
8
|
import com.facebook.react.bridge.ReactMethod;
|
|
12
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
13
10
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
14
11
|
import com.facebook.react.bridge.WritableMap;
|
|
15
|
-
|
|
16
12
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
17
13
|
|
|
18
|
-
import android.util.Log;
|
|
19
|
-
|
|
20
14
|
import java.util.HashMap;
|
|
21
15
|
import java.util.Map;
|
|
22
16
|
|
|
23
|
-
import ir.metrix.
|
|
24
|
-
import ir.metrix.
|
|
25
|
-
import ir.metrix.
|
|
26
|
-
import ir.metrix.
|
|
27
|
-
import ir.metrix.
|
|
28
|
-
import ir.metrix.
|
|
29
|
-
import ir.metrix.
|
|
17
|
+
import ir.metrix.analytics.SessionIdListener;
|
|
18
|
+
import ir.metrix.analytics.SessionNumberListener;
|
|
19
|
+
import ir.metrix.analytics.messaging.MessageChannel;
|
|
20
|
+
import ir.metrix.analytics.messaging.RevenueCurrency;
|
|
21
|
+
import ir.metrix.analytics.messaging.UserGender;
|
|
22
|
+
import ir.metrix.attribution.AttributionData;
|
|
23
|
+
import ir.metrix.attribution.OnAttributionChangeListener;
|
|
24
|
+
import ir.metrix.attribution.OnDeeplinkResponseListener;
|
|
25
|
+
import ir.metrix.attribution.UserIdListener;
|
|
30
26
|
|
|
31
27
|
public class MetrixModule extends ReactContextBaseJavaModule {
|
|
32
28
|
|
|
@@ -41,9 +37,17 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
41
37
|
return TAG;
|
|
42
38
|
}
|
|
43
39
|
|
|
40
|
+
// Required for rn built in EventEmitter Calls.
|
|
41
|
+
@ReactMethod
|
|
42
|
+
public void addListener(String eventName) { }
|
|
43
|
+
|
|
44
|
+
// Required for rn built in EventEmitter Calls.
|
|
45
|
+
@ReactMethod
|
|
46
|
+
public void removeListeners(Integer count) { }
|
|
47
|
+
|
|
44
48
|
@ReactMethod
|
|
45
49
|
public void newEvent(String eventName) {
|
|
46
|
-
ir.metrix.
|
|
50
|
+
ir.metrix.analytics.MetrixAnalytics.newEvent(eventName);
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
@ReactMethod
|
|
@@ -56,75 +60,143 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
56
60
|
customAttr.put(key, customAttributes.getString(key));
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
ir.metrix.
|
|
63
|
+
ir.metrix.analytics.MetrixAnalytics.newEvent(eventName, customAttr);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
@ReactMethod
|
|
63
67
|
public void newRevenueSimple(String slug, Double revenue) {
|
|
64
|
-
ir.metrix.
|
|
68
|
+
ir.metrix.analytics.MetrixAnalytics.newRevenue(slug, revenue);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
@ReactMethod
|
|
68
72
|
public void newRevenueCurrency(String slug, Double revenue, String currency) {
|
|
69
|
-
ir.metrix.
|
|
73
|
+
ir.metrix.analytics.MetrixAnalytics.newRevenue(slug, revenue, RevenueCurrency.valueOf(currency));
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
@ReactMethod
|
|
73
|
-
public void
|
|
74
|
-
ir.metrix.
|
|
77
|
+
public void setSessionNumberListener() {
|
|
78
|
+
ir.metrix.analytics.MetrixAnalytics.setSessionNumberListener(
|
|
79
|
+
new SessionNumberListener() {
|
|
80
|
+
@Override
|
|
81
|
+
public void onSessionNumberChanged(int sessionNumber) {
|
|
82
|
+
sendStringEvent("onSessionNumberChangedListener", String.valueOf(sessionNumber));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
@ReactMethod
|
|
78
|
-
public void
|
|
79
|
-
ir.metrix.
|
|
88
|
+
public void setSessionIdListener() {
|
|
89
|
+
ir.metrix.analytics.MetrixAnalytics.setSessionIdListener(
|
|
90
|
+
new SessionIdListener() {
|
|
91
|
+
@Override
|
|
92
|
+
public void onSessionIdChanged(String sessionId) {
|
|
93
|
+
sendStringEvent("onSessionIdChangedListener", sessionId);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
80
96
|
}
|
|
81
97
|
|
|
82
98
|
@ReactMethod
|
|
83
|
-
public void
|
|
84
|
-
|
|
85
|
-
Map<String, String> userAttrs = new HashMap<>();
|
|
86
|
-
|
|
99
|
+
public void setUserAttributes(ReadableMap userAttributes) {
|
|
87
100
|
ReadableMapKeySetIterator userAttributesMapKeySetIterator = userAttributes.keySetIterator();
|
|
88
101
|
while (userAttributesMapKeySetIterator.hasNextKey()) {
|
|
89
102
|
String key = userAttributesMapKeySetIterator.nextKey();
|
|
90
|
-
|
|
103
|
+
ir.metrix.analytics.MetrixAnalytics.User.setCustomAttribute(key, userAttributes.getString(key));
|
|
91
104
|
}
|
|
105
|
+
}
|
|
92
106
|
|
|
93
|
-
|
|
107
|
+
@ReactMethod
|
|
108
|
+
public void setUserCustomId(String id) {
|
|
109
|
+
ir.metrix.analytics.MetrixAnalytics.User.setUserCustomId(id);
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
@ReactMethod
|
|
97
|
-
public void
|
|
98
|
-
ir.metrix.
|
|
113
|
+
public void deleteUserCustomId() {
|
|
114
|
+
ir.metrix.analytics.MetrixAnalytics.User.deleteUserCustomId();
|
|
99
115
|
}
|
|
100
116
|
|
|
101
117
|
@ReactMethod
|
|
102
|
-
public void
|
|
103
|
-
ir.metrix.
|
|
104
|
-
new SessionNumberListener() {
|
|
105
|
-
@Override
|
|
106
|
-
public void onSessionNumberChanged(int sessionNumber) {
|
|
107
|
-
sendStringEvent("onSessionNumberChangedListener", String.valueOf(sessionNumber));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
);
|
|
118
|
+
public void setUserFirstName(String firstName) {
|
|
119
|
+
ir.metrix.analytics.MetrixAnalytics.User.setFirstName(firstName);
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
@ReactMethod
|
|
114
|
-
public void
|
|
115
|
-
ir.metrix.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
public void setUserLastName(String lastName) {
|
|
124
|
+
ir.metrix.analytics.MetrixAnalytics.User.setLastName(lastName);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@ReactMethod
|
|
128
|
+
public void setUserPhoneNumber(String phoneNumber) {
|
|
129
|
+
ir.metrix.analytics.MetrixAnalytics.User.setPhoneNumber(phoneNumber);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@ReactMethod
|
|
133
|
+
public void setUserHashedPhoneNumber(String hashedPhoneNumber) {
|
|
134
|
+
ir.metrix.analytics.MetrixAnalytics.User.setHashedPhoneNumber(hashedPhoneNumber);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@ReactMethod
|
|
138
|
+
public void setUserEmail(String email) {
|
|
139
|
+
ir.metrix.analytics.MetrixAnalytics.User.setEmail(email);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@ReactMethod
|
|
143
|
+
public void setUserHashedEmail(String hashedEmail) {
|
|
144
|
+
ir.metrix.analytics.MetrixAnalytics.User.setHashedEmail(hashedEmail);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@ReactMethod
|
|
148
|
+
public void setUserCountry(String country) {
|
|
149
|
+
ir.metrix.analytics.MetrixAnalytics.User.setCountry(country);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@ReactMethod
|
|
153
|
+
public void setUserCity(String city) {
|
|
154
|
+
ir.metrix.analytics.MetrixAnalytics.User.setCity(city);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@ReactMethod
|
|
158
|
+
public void setUserRegion(String region) {
|
|
159
|
+
ir.metrix.analytics.MetrixAnalytics.User.setRegion(region);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@ReactMethod
|
|
163
|
+
public void setUserLocality(String locality) {
|
|
164
|
+
ir.metrix.analytics.MetrixAnalytics.User.setLocality(locality);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@ReactMethod
|
|
168
|
+
public void setUserGender(String gender) {
|
|
169
|
+
ir.metrix.analytics.MetrixAnalytics.User.setGender(UserGender.valueOf(gender));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@ReactMethod
|
|
173
|
+
public void setUserBirthday(Number birthday) {
|
|
174
|
+
ir.metrix.analytics.MetrixAnalytics.User.setBirthday(birthday.longValue());
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@ReactMethod
|
|
178
|
+
public void setUserFcmToken(String fcmToken) {
|
|
179
|
+
ir.metrix.analytics.MetrixAnalytics.User.setFcmToken(fcmToken);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@ReactMethod
|
|
183
|
+
public void userChannelEnabled(String channel) {
|
|
184
|
+
ir.metrix.analytics.MetrixAnalytics.User.channelEnabled(MessageChannel.valueOf(channel));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@ReactMethod
|
|
188
|
+
public void userChannelDisabled(String channel) {
|
|
189
|
+
ir.metrix.analytics.MetrixAnalytics.User.channelDisabled(MessageChannel.valueOf(channel));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@ReactMethod
|
|
193
|
+
public void setPushToken(String token) {
|
|
194
|
+
ir.metrix.attribution.MetrixAttribution.setPushToken(token);
|
|
123
195
|
}
|
|
124
196
|
|
|
125
197
|
@ReactMethod
|
|
126
198
|
public void setOnAttributionChangedListener() {
|
|
127
|
-
ir.metrix.
|
|
199
|
+
ir.metrix.attribution.MetrixAttribution.setOnAttributionChangedListener(
|
|
128
200
|
new OnAttributionChangeListener() {
|
|
129
201
|
@Override
|
|
130
202
|
public void onAttributionChanged(AttributionData attributionData) {
|
|
@@ -137,7 +209,7 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
137
209
|
|
|
138
210
|
@ReactMethod
|
|
139
211
|
public void setUserIdListener() {
|
|
140
|
-
ir.metrix.
|
|
212
|
+
ir.metrix.attribution.MetrixAttribution.setUserIdListener(
|
|
141
213
|
new UserIdListener() {
|
|
142
214
|
@Override
|
|
143
215
|
public void onUserIdReceived(String userId) {
|
|
@@ -148,7 +220,7 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
148
220
|
|
|
149
221
|
@ReactMethod
|
|
150
222
|
public void setOnDeeplinkResponseListener(final boolean shouldLaunchDeeplink) {
|
|
151
|
-
ir.metrix.
|
|
223
|
+
ir.metrix.attribution.MetrixAttribution.setOnDeeplinkResponseListener(
|
|
152
224
|
new OnDeeplinkResponseListener() {
|
|
153
225
|
@Override
|
|
154
226
|
public boolean launchReceivedDeeplink(Uri deeplink) {
|
|
@@ -161,7 +233,6 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
161
233
|
private WritableMap getWritableMapFromAttributionModel(AttributionData attributionData) {
|
|
162
234
|
WritableMap map = Arguments.createMap();
|
|
163
235
|
|
|
164
|
-
|
|
165
236
|
if (attributionData.getAcquisitionAd() != null) {
|
|
166
237
|
map.putString("acquisitionAd", attributionData.getAcquisitionAd());
|
|
167
238
|
}
|
|
@@ -190,13 +261,13 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
190
261
|
|
|
191
262
|
private void sendObjectEvent(String eventName, WritableMap param) {
|
|
192
263
|
getReactApplicationContext()
|
|
193
|
-
|
|
194
|
-
|
|
264
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
265
|
+
.emit(eventName, param);
|
|
195
266
|
}
|
|
196
267
|
|
|
197
268
|
private void sendStringEvent(String eventName, String param) {
|
|
198
269
|
getReactApplicationContext()
|
|
199
|
-
|
|
200
|
-
|
|
270
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
271
|
+
.emit(eventName, param);
|
|
201
272
|
}
|
|
202
273
|
}
|
package/index.js
CHANGED
|
@@ -6,48 +6,48 @@ import {
|
|
|
6
6
|
|
|
7
7
|
let module_metrix = NativeModules.Metrix;
|
|
8
8
|
const eventEmitter = new NativeEventEmitter(module_metrix);
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
var Metrix = {};
|
|
11
11
|
|
|
12
12
|
Metrix.shouldLaunchDeeplink = true
|
|
13
13
|
|
|
14
14
|
// not used in android
|
|
15
|
-
Metrix.initialize = function(appId) {
|
|
15
|
+
Metrix.initialize = function (appId) {
|
|
16
16
|
if (Platform.OS === "ios") {
|
|
17
17
|
module_metrix.initialize(appId)
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
Metrix.setPushToken = function(token) {
|
|
21
|
+
Metrix.setPushToken = function (token) {
|
|
22
22
|
module_metrix.setPushToken(token);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
Metrix.setSessionNumberListener = function(callback) {
|
|
25
|
+
Metrix.setSessionNumberListener = function (callback) {
|
|
26
26
|
eventEmitter.addListener('onSessionNumberChangedListener', callback);
|
|
27
27
|
module_metrix.setSessionNumberListener();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
Metrix.setSessionIdListener = function(callback) {
|
|
30
|
+
Metrix.setSessionIdListener = function (callback) {
|
|
31
31
|
eventEmitter.addListener('onSessionIdChangedListener', callback);
|
|
32
32
|
module_metrix.setSessionIdListener();
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
Metrix.setOnAttributionChangedListener = function(callback) {
|
|
35
|
+
Metrix.setOnAttributionChangedListener = function (callback) {
|
|
36
36
|
eventEmitter.addListener('onAttributionChangedListener', callback);
|
|
37
37
|
module_metrix.setOnAttributionChangedListener();
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
Metrix.setOnDeeplinkResponseListener = function(callback) {
|
|
40
|
+
Metrix.setOnDeeplinkResponseListener = function (callback) {
|
|
41
41
|
eventEmitter.addListener('onDeeplinkResponseListener', callback);
|
|
42
42
|
module_metrix.setOnDeeplinkResponseListener(this.shouldLaunchDeeplink);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
Metrix.setUserIdListener = function(callback) {
|
|
45
|
+
Metrix.setUserIdListener = function (callback) {
|
|
46
46
|
eventEmitter.addListener('onUserIdListener', callback);
|
|
47
47
|
module_metrix.setUserIdListener();
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
Metrix.newEvent = function(eventName, customAttributes) {
|
|
50
|
+
Metrix.newEvent = function (eventName, customAttributes) {
|
|
51
51
|
if (customAttributes) {
|
|
52
52
|
module_metrix.newCustomEvent(eventName, customAttributes);
|
|
53
53
|
} else {
|
|
@@ -55,42 +55,160 @@ Metrix.newEvent = function(eventName, customAttributes) {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
Metrix.newRevenue = function(slug, revenue,
|
|
59
|
-
if (
|
|
58
|
+
Metrix.newRevenue = function (slug, revenue, currency) {
|
|
59
|
+
if (currency == null) {
|
|
60
60
|
module_metrix.newRevenueSimple(slug, revenue);
|
|
61
|
-
} else if (
|
|
62
|
-
if (typeof
|
|
63
|
-
module_metrix.newRevenueOrderId(slug, revenue,
|
|
61
|
+
} else if (currency != null) {
|
|
62
|
+
if (typeof currency === 'string') {
|
|
63
|
+
module_metrix.newRevenueOrderId(slug, revenue, currency);
|
|
64
64
|
} else {
|
|
65
|
-
let
|
|
66
|
-
module_metrix.newRevenueCurrency(slug, revenue,
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
let currency = getCurrency(currencyOrderId)
|
|
70
|
-
module_metrix.newRevenueFull(slug, revenue, currency, orderId);
|
|
65
|
+
let currencyValue = getCurrency(currency)
|
|
66
|
+
module_metrix.newRevenueCurrency(slug, revenue, currencyValue);
|
|
67
|
+
}
|
|
71
68
|
}
|
|
72
69
|
};
|
|
73
70
|
|
|
74
|
-
Metrix.
|
|
75
|
-
|
|
71
|
+
Metrix.setUserAttributes = function (userAttributes) {
|
|
72
|
+
if (Platform.OS === "android") {
|
|
73
|
+
module_metrix.setUserAttributes(userAttributes);
|
|
74
|
+
} else if (Platform.OS === "ios") {
|
|
75
|
+
module_metrix.addUserAttributes(userAttributes);
|
|
76
|
+
}
|
|
76
77
|
};
|
|
77
78
|
|
|
79
|
+
Metrix.setUserCustomId = function (id) {
|
|
80
|
+
if (Platform.OS === "android") {
|
|
81
|
+
module_metrix.setUserCustomId(id);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Metrix.deleteUserCustomId = function () {
|
|
86
|
+
if (Platform.OS === "android") {
|
|
87
|
+
module_metrix.deleteUserCustomId();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Metrix.setUserFirstName = function (firstName) {
|
|
92
|
+
if (Platform.OS === "android") {
|
|
93
|
+
module_metrix.setUserFirstName(firstName);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Metrix.setUserLastName = function (lastName) {
|
|
98
|
+
if (Platform.OS === "android") {
|
|
99
|
+
module_metrix.setUserLastName(lastName);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Metrix.setUserPhoneNumber = function (phoneNumber) {
|
|
104
|
+
if (Platform.OS === "android") {
|
|
105
|
+
module_metrix.setUserPhoneNumber(phoneNumber);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Metrix.setUserHashedPhoneNumber = function (hashedPhoneNumber) {
|
|
110
|
+
if (Platform.OS === "android") {
|
|
111
|
+
module_metrix.setUserHashedPhoneNumber(hashedPhoneNumber);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Metrix.setUserEmail = function (email) {
|
|
116
|
+
if (Platform.OS === "android") {
|
|
117
|
+
module_metrix.setUserEmail(email);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Metrix.setUserHashedEmail = function (hashedEmail) {
|
|
122
|
+
if (Platform.OS === "android") {
|
|
123
|
+
module_metrix.setUserHashedEmail(hashedEmail);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
Metrix.setUserCountry = function (country) {
|
|
128
|
+
if (Platform.OS === "android") {
|
|
129
|
+
module_metrix.setUserCountry(country);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Metrix.setUserCity = function (city) {
|
|
134
|
+
if (Platform.OS === "android") {
|
|
135
|
+
module_metrix.setUserCity(city);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Metrix.setUserRegion = function (region) {
|
|
140
|
+
if (Platform.OS === "android") {
|
|
141
|
+
module_metrix.setUserRegion(region);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Metrix.setUserLocality = function (locality) {
|
|
146
|
+
if (Platform.OS === "android") {
|
|
147
|
+
module_metrix.setUserLocality(locality);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
Metrix.setUserGender = function (gender) {
|
|
152
|
+
if (Platform.OS === "android") {
|
|
153
|
+
if (typeof channel === 'string') {
|
|
154
|
+
module_metrix.setUserGender(gender);
|
|
155
|
+
} else {
|
|
156
|
+
let genderValue = getGender(gender)
|
|
157
|
+
module_metrix.setUserGender(genderValue);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Metrix.setUserBirthday = function (birthday) {
|
|
163
|
+
if (Platform.OS === "android") {
|
|
164
|
+
module_metrix.setUserBirthday(birthday);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Metrix.setUserFcmToken = function (fcmToken) {
|
|
169
|
+
if (Platform.OS === "android") {
|
|
170
|
+
module_metrix.setUserFcmToken(fcmToken);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Metrix.userChannelEnabled = function (channel) {
|
|
175
|
+
if (Platform.OS === "android") {
|
|
176
|
+
if (typeof channel === 'string') {
|
|
177
|
+
module_metrix.userChannelEnabled(channel);
|
|
178
|
+
} else {
|
|
179
|
+
let channelValue = getChannel(channel)
|
|
180
|
+
module_metrix.userChannelEnabled(channelValue);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
Metrix.userChannelDisabled = function (channel) {
|
|
186
|
+
if (Platform.OS === "android") {
|
|
187
|
+
if (typeof channel === 'string') {
|
|
188
|
+
module_metrix.userChannelDisabled(channel);
|
|
189
|
+
} else {
|
|
190
|
+
let channelValue = getChannel(channel)
|
|
191
|
+
module_metrix.userChannelDisabled(channelValue);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
78
196
|
// not used in android
|
|
79
|
-
Metrix.setStore = function(storeName) {
|
|
197
|
+
Metrix.setStore = function (storeName) {
|
|
80
198
|
if (Platform.OS === "ios") {
|
|
81
199
|
module_metrix.setStore(storeName);
|
|
82
200
|
}
|
|
83
201
|
};
|
|
84
202
|
|
|
85
203
|
// not used in android
|
|
86
|
-
Metrix.setAppSecret = function(secretId, info1, info2, info3, info4) {
|
|
204
|
+
Metrix.setAppSecret = function (secretId, info1, info2, info3, info4) {
|
|
87
205
|
if (Platform.OS === "ios") {
|
|
88
206
|
module_metrix.setAppSecret(secretId, info1, info2, info3, info4);
|
|
89
207
|
}
|
|
90
208
|
};
|
|
91
209
|
|
|
92
210
|
// not used in android
|
|
93
|
-
Metrix.setDefaultTracker = function(trackerToken) {
|
|
211
|
+
Metrix.setDefaultTracker = function (trackerToken) {
|
|
94
212
|
if (Platform.OS === "ios") {
|
|
95
213
|
module_metrix.setDefaultTracker(trackerToken);
|
|
96
214
|
}
|
|
@@ -98,7 +216,6 @@ Metrix.setDefaultTracker = function(trackerToken) {
|
|
|
98
216
|
|
|
99
217
|
module.exports = { Metrix }
|
|
100
218
|
|
|
101
|
-
|
|
102
219
|
function getCurrency(currency) {
|
|
103
220
|
let cr = null;
|
|
104
221
|
if (Platform.OS === "android") {
|
|
@@ -108,14 +225,41 @@ function getCurrency(currency) {
|
|
|
108
225
|
cr = "USD";
|
|
109
226
|
} else {
|
|
110
227
|
cr = "IRR";
|
|
111
|
-
}
|
|
228
|
+
}
|
|
112
229
|
} else {
|
|
113
230
|
if (currency === 2 || currency === 1) {
|
|
114
231
|
cr = currency;
|
|
115
232
|
} else {
|
|
116
233
|
cr = 0;
|
|
117
|
-
}
|
|
234
|
+
}
|
|
118
235
|
}
|
|
119
236
|
|
|
120
237
|
return cr;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function getChannel(channel) {
|
|
241
|
+
let ch = null;
|
|
242
|
+
if (channel === 2) {
|
|
243
|
+
ch = "SMS";
|
|
244
|
+
} else if (channel === 1) {
|
|
245
|
+
ch = "PUSH";
|
|
246
|
+
} else {
|
|
247
|
+
ch = "EMAIL";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return ch;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function getGender(gender) {
|
|
254
|
+
let g = null;
|
|
255
|
+
|
|
256
|
+
if (gender === 2) {
|
|
257
|
+
g = "Male";
|
|
258
|
+
} else if (gender === 1) {
|
|
259
|
+
g = "Female";
|
|
260
|
+
} else {
|
|
261
|
+
g = "Other";
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return g;
|
|
121
265
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metrixorg/react-native-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Metrix React native plugin",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"deploy": "git checkout master && git pull && git merge develop",
|
|
9
|
-
"major": "
|
|
10
|
-
"minor": "
|
|
11
|
-
"patch": "
|
|
9
|
+
"major": "2",
|
|
10
|
+
"minor": "0",
|
|
11
|
+
"patch": "1"
|
|
12
12
|
},
|
|
13
13
|
"author": "Metrix",
|
|
14
14
|
"license": "Apache 2.0",
|