react-native-insider 6.6.0 → 6.7.0

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.
@@ -1,14 +1,8 @@
1
1
  import { NativeModules } from 'react-native';
2
2
 
3
- const Insider = NativeModules.RNInsider;
4
-
5
- function shouldNotProceed() {
6
- return Insider == null;
7
- }
3
+ import { shouldNotProceed, generateJSONErrorString, checkParameters, showParameterWarningLog } from './Util';
8
4
 
9
- function generateJSONErrorString(error) {
10
- return '[JavaScript Error] ' + error;
11
- }
5
+ const Insider = NativeModules.RNInsider;
12
6
 
13
7
  export default class RNInsiderEvent {
14
8
  name = '';
@@ -19,7 +13,11 @@ export default class RNInsiderEvent {
19
13
  }
20
14
 
21
15
  addParameterWithString(key, value) {
22
- if (shouldNotProceed() || key == null || value == null) return this;
16
+ if (shouldNotProceed()) return this;
17
+ if (checkParameters([{ type: 'string', value: key }, { type: 'string', value }])) {
18
+ showParameterWarningLog("addParameterWithString", [{ type: 'string', value: key }, { type: 'string', value }]);
19
+ return this;
20
+ }
23
21
  try {
24
22
  this.parameters[key] = value;
25
23
  return this;
@@ -30,7 +28,11 @@ export default class RNInsiderEvent {
30
28
  }
31
29
 
32
30
  addParameterWithInt(key, value) {
33
- if (shouldNotProceed() || key == null || value == null) return this;
31
+ if (shouldNotProceed()) return this;
32
+ if (checkParameters([{ type: 'string', value: key }, { type: 'number', value }])) {
33
+ showParameterWarningLog("addParameterWithInt", [{ type: 'string', value: key }, { type: 'number', value }]);
34
+ return this;
35
+ }
34
36
  try {
35
37
  this.parameters[key] = value;
36
38
  return this;
@@ -41,7 +43,11 @@ export default class RNInsiderEvent {
41
43
  }
42
44
 
43
45
  addParameterWithDouble(key, value) {
44
- if (shouldNotProceed() || key == null || value == null) return this;
46
+ if (shouldNotProceed()) return this;
47
+ if (checkParameters([{ type: 'string', value: key }, { type: 'number', value }])) {
48
+ showParameterWarningLog("addParameterWithDouble", [{ type: 'string', value: key }, { type: 'number', value }]);
49
+ return this;
50
+ }
45
51
  try {
46
52
  this.parameters[key] = value;
47
53
  return this;
@@ -52,7 +58,11 @@ export default class RNInsiderEvent {
52
58
  }
53
59
 
54
60
  addParameterWithBoolean(key, value) {
55
- if (shouldNotProceed() || key == null || value == null) return this;
61
+ if (shouldNotProceed()) return this;
62
+ if (checkParameters([{ type: 'string', value: key }, { type: 'boolean', value }])) {
63
+ showParameterWarningLog("addParameterWithBoolean", [{ type: 'string', value: key }, { type: 'boolean', value }]);
64
+ return this;
65
+ }
56
66
  try {
57
67
  this.parameters[key] = value;
58
68
  return this;
@@ -63,7 +73,11 @@ export default class RNInsiderEvent {
63
73
  }
64
74
 
65
75
  addParameterWithDate(key, value) {
66
- if (shouldNotProceed() || key == null || value == null) return this;
76
+ if (shouldNotProceed()) return this;
77
+ if (checkParameters([{ type: 'string', value: key }, { type: 'object', value }])) {
78
+ showParameterWarningLog("addParameterWithDate", [{ type: 'string', value: key }, { type: 'object', value }]);
79
+ return this;
80
+ }
67
81
  try {
68
82
  this.parameters[key] = value.toISOString();
69
83
  return this;
@@ -74,7 +88,11 @@ export default class RNInsiderEvent {
74
88
  }
75
89
 
76
90
  addParameterWithArray(key, value) {
77
- if (shouldNotProceed() || key == null || value == null) return this;
91
+ if (shouldNotProceed()) return this;
92
+ if (checkParameters([{ type: 'string', value: key }, { type: 'object', value }])) {
93
+ showParameterWarningLog("addParameterWithArray", [{ type: 'string', value: key }, { type: 'object', value }]);
94
+ return this;
95
+ }
78
96
  try {
79
97
  this.parameters[key] = value;
80
98
  return this;
@@ -1,15 +1,8 @@
1
1
  import { NativeModules } from 'react-native';
2
2
 
3
- const Insider = NativeModules.RNInsider;
4
-
5
- function shouldNotProceed() {
6
- return Insider == null;
7
- }
8
-
9
- function generateJSONErrorString(error) {
10
- return '[JavaScript Error] ' + error;
11
- }
3
+ import { shouldNotProceed, generateJSONErrorString, checkParameters, showParameterWarningLog } from './Util';
12
4
 
5
+ const Insider = NativeModules.RNInsider;
13
6
 
14
7
  const ADD_EMAIL = 'addEmail';
15
8
  const ADD_PHONE_NUMBER = 'addPhoneNumber';
@@ -23,7 +16,11 @@ export default class RNInsiderIdentifier {
23
16
  }
24
17
 
25
18
  addEmail(email) {
26
- if (shouldNotProceed() || email == null) return this;
19
+ if (shouldNotProceed()) return this;
20
+ if (checkParameters([{ type: 'string', value: email }])) {
21
+ showParameterWarningLog("addEmail", [{ type: 'string', value: email }]);
22
+ return this;
23
+ }
27
24
  try {
28
25
  this.identifiers[ADD_EMAIL] = email.toString();
29
26
  } catch (error) {
@@ -33,7 +30,11 @@ export default class RNInsiderIdentifier {
33
30
  }
34
31
 
35
32
  addPhoneNumber(phoneNumber) {
36
- if (shouldNotProceed() || phoneNumber == null) return this;
33
+ if (shouldNotProceed()) return this;
34
+ if (checkParameters([{ type: 'string', value: phoneNumber }])) {
35
+ showParameterWarningLog("addPhoneNumber", [{ type: 'string', value: phoneNumber }]);
36
+ return this;
37
+ }
37
38
  try {
38
39
  this.identifiers[ADD_PHONE_NUMBER] = phoneNumber.toString();
39
40
  } catch (error) {
@@ -43,7 +44,11 @@ export default class RNInsiderIdentifier {
43
44
  }
44
45
 
45
46
  addUserID(userID) {
46
- if (shouldNotProceed() || userID == null) return this;
47
+ if (shouldNotProceed()) return this;
48
+ if (checkParameters([{ type: 'string', value: userID }])) {
49
+ showParameterWarningLog("addUserID", [{ type: 'string', value: userID }]);
50
+ return this;
51
+ }
47
52
  try {
48
53
  this.identifiers[ADD_USER_ID] = userID.toString();
49
54
  } catch (error) {
@@ -53,7 +58,11 @@ export default class RNInsiderIdentifier {
53
58
  }
54
59
 
55
60
  addCustomIdentifier(key, value) {
56
- if (shouldNotProceed() || key == null || value == null) return this;
61
+ if (shouldNotProceed()) return this;
62
+ if (checkParameters([{ type: 'string', value: key }, { type: 'string', value }])) {
63
+ showParameterWarningLog("addCustomIdentifier", [{ type: 'string', value: key }, { type: 'string', value }]);
64
+ return this;
65
+ }
57
66
  try {
58
67
  this.identifiers[key.toString()] = value.toString();
59
68
  } catch (error) {
@@ -1,14 +1,8 @@
1
1
  import { NativeModules } from 'react-native';
2
2
 
3
- const Insider = NativeModules.RNInsider;
4
-
5
- function shouldNotProceed() {
6
- return Insider == null;
7
- }
3
+ import { shouldNotProceed, generateJSONErrorString, checkParameters, showParameterWarningLog } from './Util';
8
4
 
9
- function generateJSONErrorString(error) {
10
- return '[JavaScript Error] ' + error;
11
- }
5
+ const Insider = NativeModules.RNInsider;
12
6
 
13
7
  // Must
14
8
  const PRODUCT_ID = 'product_id';
@@ -47,7 +41,11 @@ export default class RNInsiderProduct {
47
41
  }
48
42
 
49
43
  setColor(color) {
50
- if (shouldNotProceed() || color == null) return this;
44
+ if (shouldNotProceed()) return this;
45
+ if (checkParameters([{ type: 'string', value: color }])) {
46
+ showParameterWarningLog("setColor", [{ type: 'string', value: color }]);
47
+ return this;
48
+ }
51
49
  try {
52
50
  this.productOptMap[COLOR] = color;
53
51
  } catch (error) {
@@ -57,7 +55,11 @@ export default class RNInsiderProduct {
57
55
  }
58
56
 
59
57
  setVoucherName(voucherName) {
60
- if (shouldNotProceed() || voucherName == null) return this;
58
+ if (shouldNotProceed()) return this;
59
+ if (checkParameters([{ type: 'string', value: voucherName }])) {
60
+ showParameterWarningLog("setVoucherName", [{ type: 'string', value: voucherName }]);
61
+ return this;
62
+ }
61
63
  try {
62
64
  this.productOptMap[VOUCHER_NAME] = voucherName;
63
65
  } catch (error) {
@@ -67,7 +69,11 @@ export default class RNInsiderProduct {
67
69
  }
68
70
 
69
71
  setPromotionName(promotionName) {
70
- if (shouldNotProceed() || promotionName == null) return this;
72
+ if (shouldNotProceed()) return this;
73
+ if (checkParameters([{ type: 'string', value: promotionName }])) {
74
+ showParameterWarningLog("setPromotionName", [{ type: 'string', value: promotionName }]);
75
+ return this;
76
+ }
71
77
  try {
72
78
  this.productOptMap[PROMOTION_NAME] = promotionName;
73
79
  } catch (error) {
@@ -77,7 +83,11 @@ export default class RNInsiderProduct {
77
83
  }
78
84
 
79
85
  setSize(size) {
80
- if (shouldNotProceed() || size == null) return this;
86
+ if (shouldNotProceed()) return this;
87
+ if (checkParameters([{ type: 'string', value: size }])) {
88
+ showParameterWarningLog("setSize", [{ type: 'string', value: size }]);
89
+ return this;
90
+ }
81
91
  try {
82
92
  this.productOptMap[SIZE] = size;
83
93
  } catch (error) {
@@ -87,7 +97,11 @@ export default class RNInsiderProduct {
87
97
  }
88
98
 
89
99
  setSalePrice(salePrice) {
90
- if (shouldNotProceed() || salePrice == null) return this;
100
+ if (shouldNotProceed()) return this;
101
+ if (checkParameters([{ type: 'number', value: salePrice }])) {
102
+ showParameterWarningLog("setSalePrice", [{ type: 'number', value: salePrice }]);
103
+ return this;
104
+ }
91
105
  try {
92
106
  this.productOptMap[SALE_PRICE] = salePrice;
93
107
  } catch (error) {
@@ -97,7 +111,11 @@ export default class RNInsiderProduct {
97
111
  }
98
112
 
99
113
  setShippingCost(shippingCost) {
100
- if (shouldNotProceed() || shippingCost == null) return this;
114
+ if (shouldNotProceed()) return this;
115
+ if (checkParameters([{ type: 'number', value: shippingCost }])) {
116
+ showParameterWarningLog("setShippingCost", [{ type: 'number', value: shippingCost }]);
117
+ return this;
118
+ }
101
119
  try {
102
120
  this.productOptMap[SHIPPING_COST] = shippingCost;
103
121
  } catch (error) {
@@ -107,7 +125,11 @@ export default class RNInsiderProduct {
107
125
  }
108
126
 
109
127
  setVoucherDiscount(voucherDiscount) {
110
- if (shouldNotProceed() || voucherDiscount == null) return this;
128
+ if (shouldNotProceed()) return this;
129
+ if (checkParameters([{ type: 'number', value: voucherDiscount }])) {
130
+ showParameterWarningLog("setVoucherDiscount", [{ type: 'number', value: voucherDiscount }]);
131
+ return this;
132
+ }
111
133
  try {
112
134
  this.productOptMap[VOUCHER_DISCOUNT] = voucherDiscount;
113
135
  } catch (error) {
@@ -117,7 +139,11 @@ export default class RNInsiderProduct {
117
139
  }
118
140
 
119
141
  setPromotionDiscount(promotionDiscount) {
120
- if (shouldNotProceed() || promotionDiscount == null) return this;
142
+ if (shouldNotProceed()) return this;
143
+ if (checkParameters([{ type: 'number', value: promotionDiscount }])) {
144
+ showParameterWarningLog("setPromotionDiscount", [{ type: 'number', value: promotionDiscount }]);
145
+ return this;
146
+ }
121
147
  try {
122
148
  this.productOptMap[PROMOTION_DISCOUNT] = promotionDiscount;
123
149
  } catch (error) {
@@ -127,7 +153,11 @@ export default class RNInsiderProduct {
127
153
  }
128
154
 
129
155
  setStock(stock) {
130
- if (shouldNotProceed() || stock == null) return this;
156
+ if (shouldNotProceed()) return this;
157
+ if (checkParameters([{ type: 'number', value: stock }])) {
158
+ showParameterWarningLog("setStock", [{ type: 'number', value: stock }]);
159
+ return this;
160
+ }
131
161
  try {
132
162
  this.productOptMap[STOCK] = stock;
133
163
  } catch (error) {
@@ -137,7 +167,11 @@ export default class RNInsiderProduct {
137
167
  }
138
168
 
139
169
  setQuantity(quantity) {
140
- if (shouldNotProceed() || quantity == null) return this;
170
+ if (shouldNotProceed()) return this;
171
+ if (checkParameters([{ type: 'number', value: quantity }])) {
172
+ showParameterWarningLog("setQuantity", [{ type: 'number', value: quantity }]);
173
+ return this;
174
+ }
141
175
  try {
142
176
  this.productOptMap[QUANTITY] = quantity;
143
177
  } catch (error) {
@@ -147,7 +181,11 @@ export default class RNInsiderProduct {
147
181
  }
148
182
 
149
183
  setGroupCode(groupCode) {
150
- if (shouldNotProceed() || groupCode == null) return this;
184
+ if (shouldNotProceed()) return this;
185
+ if (checkParameters([{ type: 'string', value: groupCode }])) {
186
+ showParameterWarningLog("setGroupCode", [{ type: 'string', value: groupCode }]);
187
+ return this;
188
+ }
151
189
  try {
152
190
  this.productOptMap[GROUP_CODE] = groupCode;
153
191
  } catch (error) {
@@ -157,7 +195,11 @@ export default class RNInsiderProduct {
157
195
  }
158
196
 
159
197
  setCustomAttributeWithString(key, value) {
160
- if (shouldNotProceed() || key == null || value == null) return this;
198
+ if (shouldNotProceed()) return this;
199
+ if (checkParameters([{ type: 'string', value: key }, { type: 'string', value }])) {
200
+ showParameterWarningLog("setCustomAttributeWithString", [{ type: 'string', value: key }, { type: 'string', value }]);
201
+ return this;
202
+ }
161
203
  try {
162
204
  this.productOptMap[key] = value;
163
205
  } catch (error) {
@@ -167,7 +209,11 @@ export default class RNInsiderProduct {
167
209
  }
168
210
 
169
211
  setCustomAttributeWithInt(key, value) {
170
- if (shouldNotProceed() || key == null || value == null) return this;
212
+ if (shouldNotProceed()) return this;
213
+ if (checkParameters([{ type: 'string', value: key }, { type: 'number', value }])) {
214
+ showParameterWarningLog("setCustomAttributeWithInt", [{ type: 'string', value: key }, { type: 'number', value }]);
215
+ return this;
216
+ }
171
217
  try {
172
218
  this.productOptMap[key] = value;
173
219
  } catch (error) {
@@ -177,7 +223,11 @@ export default class RNInsiderProduct {
177
223
  }
178
224
 
179
225
  setCustomAttributeWithBoolean(key, value) {
180
- if (shouldNotProceed() || key == null || value == null) return this;
226
+ if (shouldNotProceed()) return this;
227
+ if (checkParameters([{ type: 'string', value: key }, { type: 'boolean', value }])) {
228
+ showParameterWarningLog("setCustomAttributeWithBoolean", [{ type: 'string', value: key }, { type: 'boolean', value }]);
229
+ return this;
230
+ }
181
231
  try {
182
232
  this.productOptMap[key] = value;
183
233
  } catch (error) {
@@ -187,7 +237,11 @@ export default class RNInsiderProduct {
187
237
  }
188
238
 
189
239
  setCustomAttributeWithDouble(key, value) {
190
- if (shouldNotProceed() || key == null || value == null) return this;
240
+ if (shouldNotProceed()) return this;
241
+ if (checkParameters([{ type: 'string', value: key }, { type: 'number', value }])) {
242
+ showParameterWarningLog("setCustomAttributeWithDouble", [{ type: 'string', value: key }, { type: 'number', value }]);
243
+ return this;
244
+ }
191
245
  try {
192
246
  this.productOptMap[key] = value;
193
247
  } catch (error) {
@@ -197,7 +251,11 @@ export default class RNInsiderProduct {
197
251
  }
198
252
 
199
253
  setCustomAttributeWithDate(key, value) {
200
- if (shouldNotProceed() || key == null || value == null) return this;
254
+ if (shouldNotProceed()) return this;
255
+ if (checkParameters([{ type: 'string', value: key }, { type: 'object', value }])) {
256
+ showParameterWarningLog("setCustomAttributeWithDate", [{ type: 'string', value: key }, { type: 'object', value }]);
257
+ return this;
258
+ }
201
259
  try {
202
260
  this.productOptMap[key] = value.toISOString();
203
261
  } catch (error) {
@@ -207,7 +265,11 @@ export default class RNInsiderProduct {
207
265
  }
208
266
 
209
267
  setCustomAttributeWithArray(key, value) {
210
- if (shouldNotProceed() || key == null || value == null) return this;
268
+ if (shouldNotProceed()) return this;
269
+ if (checkParameters([{ type: 'string', value: key }, { type: 'object', value }])) {
270
+ showParameterWarningLog("setCustomAttributeWithArray", [{ type: 'string', value: key }, { type: 'object', value }]);
271
+ return this;
272
+ }
211
273
  try {
212
274
  this.productOptMap[key] = value;
213
275
  } catch (error) {