@metrixorg/react-native-plugin 2.0.0 → 2.0.2

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.
@@ -7,8 +7,8 @@ android {
7
7
  defaultConfig {
8
8
  minSdkVersion 16
9
9
  targetSdkVersion 31
10
- versionCode 200000055
11
- versionName "2.0.0.beta5"
10
+ versionCode 200000058
11
+ versionName "2.0.0.beta8"
12
12
  }
13
13
 
14
14
  buildTypes {
@@ -22,13 +22,17 @@ android {
22
22
 
23
23
  rootProject.allprojects {
24
24
  repositories {
25
+ google()
25
26
  mavenCentral()
27
+ //noinspection JcenterRepositoryObsolete
28
+ jcenter()
26
29
  }
27
30
  }
28
31
 
29
32
  dependencies {
30
33
  implementation 'com.facebook.react:react-native:+'
31
34
 
32
- implementation 'ir.metrix.analytics:metrix-reactnative:2.0.0.beta5'
33
- implementation 'ir.metrix.attribution:metrix-reactnative:2.0.0.beta5'
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
  }
@@ -37,6 +37,14 @@ public class MetrixModule extends ReactContextBaseJavaModule {
37
37
  return TAG;
38
38
  }
39
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
+
40
48
  @ReactMethod
41
49
  public void newEvent(String eventName) {
42
50
  ir.metrix.analytics.MetrixAnalytics.newEvent(eventName);
@@ -73,8 +81,7 @@ public class MetrixModule extends ReactContextBaseJavaModule {
73
81
  public void onSessionNumberChanged(int sessionNumber) {
74
82
  sendStringEvent("onSessionNumberChangedListener", String.valueOf(sessionNumber));
75
83
  }
76
- }
77
- );
84
+ });
78
85
  }
79
86
 
80
87
  @ReactMethod
@@ -85,8 +92,7 @@ public class MetrixModule extends ReactContextBaseJavaModule {
85
92
  public void onSessionIdChanged(String sessionId) {
86
93
  sendStringEvent("onSessionIdChangedListener", sessionId);
87
94
  }
88
- }
89
- );
95
+ });
90
96
  }
91
97
 
92
98
  @ReactMethod
@@ -99,13 +105,13 @@ public class MetrixModule extends ReactContextBaseJavaModule {
99
105
  }
100
106
 
101
107
  @ReactMethod
102
- public void setUserId(String id) {
103
- ir.metrix.analytics.MetrixAnalytics.User.setUserId(id);
108
+ public void setUserCustomId(String id) {
109
+ ir.metrix.analytics.MetrixAnalytics.User.setUserCustomId(id);
104
110
  }
105
111
 
106
112
  @ReactMethod
107
- public void deleteUserId() {
108
- ir.metrix.analytics.MetrixAnalytics.User.deleteUserId();
113
+ public void deleteUserCustomId() {
114
+ ir.metrix.analytics.MetrixAnalytics.User.deleteUserCustomId();
109
115
  }
110
116
 
111
117
  @ReactMethod
@@ -159,13 +165,13 @@ public class MetrixModule extends ReactContextBaseJavaModule {
159
165
  }
160
166
 
161
167
  @ReactMethod
162
- public void setUserGender(UserGender gender) {
163
- ir.metrix.analytics.MetrixAnalytics.User.setGender(gender);
168
+ public void setUserGender(String gender) {
169
+ ir.metrix.analytics.MetrixAnalytics.User.setGender(UserGender.valueOf(gender));
164
170
  }
165
171
 
166
172
  @ReactMethod
167
- public void setUserBirthday(Long birthday) {
168
- ir.metrix.analytics.MetrixAnalytics.User.setBirthday(birthday);
173
+ public void setUserBirthday(double birthday) {
174
+ ir.metrix.analytics.MetrixAnalytics.User.setBirthday(Double.valueOf(birthday).longValue());
169
175
  }
170
176
 
171
177
  @ReactMethod
@@ -183,7 +189,6 @@ public class MetrixModule extends ReactContextBaseJavaModule {
183
189
  ir.metrix.analytics.MetrixAnalytics.User.channelDisabled(MessageChannel.valueOf(channel));
184
190
  }
185
191
 
186
-
187
192
  @ReactMethod
188
193
  public void setPushToken(String token) {
189
194
  ir.metrix.attribution.MetrixAttribution.setPushToken(token);
@@ -228,7 +233,6 @@ public class MetrixModule extends ReactContextBaseJavaModule {
228
233
  private WritableMap getWritableMapFromAttributionModel(AttributionData attributionData) {
229
234
  WritableMap map = Arguments.createMap();
230
235
 
231
-
232
236
  if (attributionData.getAcquisitionAd() != null) {
233
237
  map.putString("acquisitionAd", attributionData.getAcquisitionAd());
234
238
  }
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,7 +55,7 @@ Metrix.newEvent = function(eventName, customAttributes) {
55
55
  }
56
56
  };
57
57
 
58
- Metrix.newRevenue = function(slug, revenue, currency) {
58
+ Metrix.newRevenue = function (slug, revenue, currency) {
59
59
  if (currency == null) {
60
60
  module_metrix.newRevenueSimple(slug, revenue);
61
61
  } else if (currency != null) {
@@ -64,11 +64,11 @@ Metrix.newRevenue = function(slug, revenue, currency) {
64
64
  } else {
65
65
  let currencyValue = getCurrency(currency)
66
66
  module_metrix.newRevenueCurrency(slug, revenue, currencyValue);
67
- }
67
+ }
68
68
  }
69
69
  };
70
70
 
71
- Metrix.setUserAttributes = function(userAttributes) {
71
+ Metrix.setUserAttributes = function (userAttributes) {
72
72
  if (Platform.OS === "android") {
73
73
  module_metrix.setUserAttributes(userAttributes);
74
74
  } else if (Platform.OS === "ios") {
@@ -76,97 +76,102 @@ Metrix.setUserAttributes = function(userAttributes) {
76
76
  }
77
77
  };
78
78
 
79
- Metrix.setUserId = function(id) {
79
+ Metrix.setUserCustomId = function (id) {
80
80
  if (Platform.OS === "android") {
81
- module_metrix.setUserId(id);
81
+ module_metrix.setUserCustomId(id);
82
82
  }
83
83
  }
84
84
 
85
- Metrix.deleteUserId = function() {
85
+ Metrix.deleteUserCustomId = function () {
86
86
  if (Platform.OS === "android") {
87
- module_metrix.deleteUserId();
87
+ module_metrix.deleteUserCustomId();
88
88
  }
89
89
  }
90
90
 
91
- Metrix.setUserFirstName = function(firstName) {
91
+ Metrix.setUserFirstName = function (firstName) {
92
92
  if (Platform.OS === "android") {
93
93
  module_metrix.setUserFirstName(firstName);
94
94
  }
95
95
  }
96
96
 
97
- Metrix.setUserLastName = function(lastName) {
97
+ Metrix.setUserLastName = function (lastName) {
98
98
  if (Platform.OS === "android") {
99
99
  module_metrix.setUserLastName(lastName);
100
100
  }
101
101
  }
102
102
 
103
- Metrix.setUserPhoneNumber = function(phoneNumber) {
103
+ Metrix.setUserPhoneNumber = function (phoneNumber) {
104
104
  if (Platform.OS === "android") {
105
105
  module_metrix.setUserPhoneNumber(phoneNumber);
106
106
  }
107
107
  }
108
108
 
109
- Metrix.setUserHashedPhoneNumber = function(hashedPhoneNumber) {
109
+ Metrix.setUserHashedPhoneNumber = function (hashedPhoneNumber) {
110
110
  if (Platform.OS === "android") {
111
111
  module_metrix.setUserHashedPhoneNumber(hashedPhoneNumber);
112
112
  }
113
113
  }
114
114
 
115
- Metrix.setUserEmail = function(email) {
115
+ Metrix.setUserEmail = function (email) {
116
116
  if (Platform.OS === "android") {
117
117
  module_metrix.setUserEmail(email);
118
118
  }
119
119
  }
120
120
 
121
- Metrix.setUserHashedEmail = function(hashedEmail) {
121
+ Metrix.setUserHashedEmail = function (hashedEmail) {
122
122
  if (Platform.OS === "android") {
123
123
  module_metrix.setUserHashedEmail(hashedEmail);
124
124
  }
125
125
  }
126
126
 
127
- Metrix.setUserCountry = function(country) {
127
+ Metrix.setUserCountry = function (country) {
128
128
  if (Platform.OS === "android") {
129
129
  module_metrix.setUserCountry(country);
130
130
  }
131
131
  }
132
132
 
133
- Metrix.setUserCity = function(city) {
133
+ Metrix.setUserCity = function (city) {
134
134
  if (Platform.OS === "android") {
135
135
  module_metrix.setUserCity(city);
136
136
  }
137
137
  }
138
138
 
139
- Metrix.setUserRegion = function(region) {
139
+ Metrix.setUserRegion = function (region) {
140
140
  if (Platform.OS === "android") {
141
141
  module_metrix.setUserRegion(region);
142
142
  }
143
143
  }
144
144
 
145
- Metrix.setUserLocality = function(locality) {
145
+ Metrix.setUserLocality = function (locality) {
146
146
  if (Platform.OS === "android") {
147
147
  module_metrix.setUserLocality(locality);
148
148
  }
149
149
  }
150
150
 
151
- Metrix.setUserGender = function(gender) {
151
+ Metrix.setUserGender = function (gender) {
152
152
  if (Platform.OS === "android") {
153
- module_metrix.setUserGender(gender);
153
+ if (typeof channel === 'string') {
154
+ module_metrix.setUserGender(gender);
155
+ } else {
156
+ let genderValue = getGender(gender)
157
+ module_metrix.setUserGender(genderValue);
158
+ }
154
159
  }
155
160
  }
156
161
 
157
- Metrix.setUserBirthday = function(birthday) {
162
+ Metrix.setUserBirthday = function (birthday) {
158
163
  if (Platform.OS === "android") {
159
164
  module_metrix.setUserBirthday(birthday);
160
165
  }
161
166
  }
162
167
 
163
- Metrix.setUserFcmToken = function(fcmToken) {
168
+ Metrix.setUserFcmToken = function (fcmToken) {
164
169
  if (Platform.OS === "android") {
165
170
  module_metrix.setUserFcmToken(fcmToken);
166
171
  }
167
172
  }
168
173
 
169
- Metrix.userChannelEnabled = function(channel) {
174
+ Metrix.userChannelEnabled = function (channel) {
170
175
  if (Platform.OS === "android") {
171
176
  if (typeof channel === 'string') {
172
177
  module_metrix.userChannelEnabled(channel);
@@ -177,7 +182,7 @@ Metrix.userChannelEnabled = function(channel) {
177
182
  }
178
183
  }
179
184
 
180
- Metrix.userChannelDisabled = function(channel) {
185
+ Metrix.userChannelDisabled = function (channel) {
181
186
  if (Platform.OS === "android") {
182
187
  if (typeof channel === 'string') {
183
188
  module_metrix.userChannelDisabled(channel);
@@ -189,21 +194,21 @@ Metrix.userChannelDisabled = function(channel) {
189
194
  }
190
195
 
191
196
  // not used in android
192
- Metrix.setStore = function(storeName) {
197
+ Metrix.setStore = function (storeName) {
193
198
  if (Platform.OS === "ios") {
194
199
  module_metrix.setStore(storeName);
195
200
  }
196
201
  };
197
202
 
198
203
  // not used in android
199
- Metrix.setAppSecret = function(secretId, info1, info2, info3, info4) {
204
+ Metrix.setAppSecret = function (secretId, info1, info2, info3, info4) {
200
205
  if (Platform.OS === "ios") {
201
206
  module_metrix.setAppSecret(secretId, info1, info2, info3, info4);
202
207
  }
203
208
  };
204
209
 
205
210
  // not used in android
206
- Metrix.setDefaultTracker = function(trackerToken) {
211
+ Metrix.setDefaultTracker = function (trackerToken) {
207
212
  if (Platform.OS === "ios") {
208
213
  module_metrix.setDefaultTracker(trackerToken);
209
214
  }
@@ -220,13 +225,13 @@ function getCurrency(currency) {
220
225
  cr = "USD";
221
226
  } else {
222
227
  cr = "IRR";
223
- }
228
+ }
224
229
  } else {
225
230
  if (currency === 2 || currency === 1) {
226
231
  cr = currency;
227
232
  } else {
228
233
  cr = 0;
229
- }
234
+ }
230
235
  }
231
236
 
232
237
  return cr;
@@ -240,7 +245,21 @@ function getChannel(channel) {
240
245
  ch = "PUSH";
241
246
  } else {
242
247
  ch = "EMAIL";
243
- }
248
+ }
244
249
 
245
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;
246
265
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metrixorg/react-native-plugin",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Metrix React native plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "deploy": "git checkout master && git pull && git merge develop",
9
9
  "major": "2",
10
10
  "minor": "0",
11
- "patch": "0"
11
+ "patch": "2"
12
12
  },
13
13
  "author": "Metrix",
14
14
  "license": "Apache 2.0",