@react-native-firebase/analytics 21.4.1 → 21.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [21.6.0](https://github.com/invertase/react-native-firebase/compare/v21.5.0...v21.6.0) (2024-11-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **analytics:** update superstruct dependency / forward-port to new API ([#8153](https://github.com/invertase/react-native-firebase/issues/8153)) ([6db1fb4](https://github.com/invertase/react-native-firebase/commit/6db1fb471e62e2c7e434719f2616c76349f345be))
11
+
12
+ ## [21.5.0](https://github.com/invertase/react-native-firebase/compare/v21.4.1...v21.5.0) (2024-11-16)
13
+
14
+ **Note:** Version bump only for package @react-native-firebase/analytics
15
+
6
16
  ## [21.4.1](https://github.com/invertase/react-native-firebase/compare/v21.4.0...v21.4.1) (2024-11-13)
7
17
 
8
18
  ### Reverts
package/lib/index.js CHANGED
@@ -26,7 +26,6 @@ import {
26
26
  isString,
27
27
  isUndefined,
28
28
  } from '@react-native-firebase/app/lib/common';
29
- import { validateStruct, validateCompound } from '@react-native-firebase/app/lib/common/struct';
30
29
 
31
30
  import {
32
31
  createModuleNamespace,
@@ -36,6 +35,7 @@ import {
36
35
  import { setReactNativeModule } from '@react-native-firebase/app/lib/internal/nativeModule';
37
36
  import { isBoolean } from '@react-native-firebase/app/lib/common';
38
37
 
38
+ import { validateStruct, validateCompound } from './struct';
39
39
  import fallBackModule from './web/RNFBAnalyticsModule';
40
40
  import version from './version';
41
41
  import * as structs from './structs';
package/lib/struct.js ADDED
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { isUndefined } from '@react-native-firebase/app/lib/common/validate';
18
+ import { create } from 'superstruct';
19
+
20
+ export const validateStruct = (value = {}, struct, prefix = '') => {
21
+ try {
22
+ return create(value, struct);
23
+ } catch (e) {
24
+ const { path, message } = e;
25
+
26
+ const key = path[0];
27
+
28
+ if (message === undefined) {
29
+ throw new Error(`${prefix} unknown property '${key}'.`);
30
+ }
31
+ e.message = `${prefix} ${e.message}`;
32
+
33
+ throw e;
34
+ }
35
+ };
36
+
37
+ export const validateCompound = (source = {}, a, b, prefix = '') => {
38
+ if (
39
+ (isUndefined(source[a]) && !isUndefined(source[b])) ||
40
+ (!isUndefined(source[a]) && isUndefined(source[b]))
41
+ ) {
42
+ throw new Error(
43
+ `${prefix} if you supply the '${a}' parameter, you must also supply the '${b}' parameter.`,
44
+ );
45
+ }
46
+ };
package/lib/structs.js CHANGED
@@ -13,226 +13,232 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import struct from '@react-native-firebase/app/lib/common/struct';
17
16
 
18
- const Item = struct.interface({
19
- item_brand: 'string?',
20
- item_id: 'string?',
21
- item_name: 'string?',
22
- item_category: 'string?',
23
- item_category2: 'string?',
24
- item_category3: 'string?',
25
- item_category4: 'string?',
26
- item_category5: 'string?',
27
- item_list_id: 'string?',
28
- item_list_name: 'string?',
29
- item_location_id: 'string?',
30
- item_variant: 'string?',
31
- quantity: 'number?',
32
- price: 'number?',
17
+ import { object, string, number, array, optional, define, type } from 'superstruct';
18
+
19
+ const ShortDate = define(
20
+ 'ShortDate',
21
+ value => typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value),
22
+ );
23
+
24
+ const Item = type({
25
+ item_brand: optional(string()),
26
+ item_id: optional(string()),
27
+ item_name: optional(string()),
28
+ item_category: optional(string()),
29
+ item_category2: optional(string()),
30
+ item_category3: optional(string()),
31
+ item_category4: optional(string()),
32
+ item_category5: optional(string()),
33
+ item_list_id: optional(string()),
34
+ item_list_name: optional(string()),
35
+ item_location_id: optional(string()),
36
+ item_variant: optional(string()),
37
+ quantity: optional(number()),
38
+ price: optional(number()),
33
39
  });
34
40
 
35
- export const ScreenView = struct.interface({
36
- screen_class: 'string?',
37
- screen_name: 'string?',
41
+ export const ScreenView = type({
42
+ screen_class: optional(string()),
43
+ screen_name: optional(string()),
38
44
  });
39
45
 
40
- export const AddPaymentInfo = struct({
41
- items: struct.optional([Item]),
42
- value: 'number?',
43
- currency: 'string?',
44
- coupon: 'string?',
45
- payment_type: 'string?',
46
+ export const AddPaymentInfo = object({
47
+ items: optional(array(Item)),
48
+ value: optional(number()),
49
+ currency: optional(string()),
50
+ coupon: optional(string()),
51
+ payment_type: optional(string()),
46
52
  });
47
53
 
48
- export const AddShippingInfo = struct({
49
- items: struct.optional([Item]),
50
- value: 'number?',
51
- currency: 'string?',
52
- coupon: 'string?',
53
- shipping_tier: 'string?',
54
+ export const AddShippingInfo = object({
55
+ items: optional(array(Item)),
56
+ value: optional(number()),
57
+ currency: optional(string()),
58
+ coupon: optional(string()),
59
+ shipping_tier: optional(string()),
54
60
  });
55
61
 
56
- export const AddToCart = struct({
57
- items: struct.optional([Item]),
58
- value: 'number?',
59
- currency: 'string?',
62
+ export const AddToCart = object({
63
+ items: optional(array(Item)),
64
+ value: optional(number()),
65
+ currency: optional(string()),
60
66
  });
61
67
 
62
- export const AddToWishlist = struct({
63
- items: struct.optional([Item]),
64
- value: 'number?',
65
- currency: 'string?',
68
+ export const AddToWishlist = object({
69
+ items: optional(array(Item)),
70
+ value: optional(number()),
71
+ currency: optional(string()),
66
72
  });
67
73
 
68
- export const BeginCheckout = struct.interface({
69
- items: struct.optional([Item]),
70
- value: 'number?',
71
- currency: 'string?',
72
- coupon: 'string?',
74
+ export const BeginCheckout = type({
75
+ items: optional(array(Item)),
76
+ value: optional(number()),
77
+ currency: optional(string()),
78
+ coupon: optional(string()),
73
79
  });
74
80
 
75
- export const CampaignDetails = struct({
76
- source: 'string',
77
- medium: 'string',
78
- campaign: 'string',
79
- term: 'string?',
80
- content: 'string?',
81
- aclid: 'string?',
82
- cp1: 'string?',
81
+ export const CampaignDetails = object({
82
+ source: string(),
83
+ medium: string(),
84
+ campaign: string(),
85
+ term: optional(string()),
86
+ content: optional(string()),
87
+ aclid: optional(string()),
88
+ cp1: optional(string()),
83
89
  });
84
90
 
85
- export const EarnVirtualCurrency = struct({
86
- virtual_currency_name: 'string',
87
- value: 'number',
91
+ export const EarnVirtualCurrency = object({
92
+ virtual_currency_name: string(),
93
+ value: number(),
88
94
  });
89
95
 
90
- export const GenerateLead = struct({
91
- currency: 'string?',
92
- value: 'number?',
96
+ export const GenerateLead = object({
97
+ currency: optional(string()),
98
+ value: optional(number()),
93
99
  });
94
100
 
95
- export const JoinGroup = struct({
96
- group_id: 'string',
101
+ export const JoinGroup = object({
102
+ group_id: string(),
97
103
  });
98
104
 
99
- export const LevelEnd = struct({
100
- level: 'number',
101
- success: 'string?',
105
+ export const LevelEnd = object({
106
+ level: number(),
107
+ success: optional(string()),
102
108
  });
103
109
 
104
- export const LevelStart = struct({
105
- level: 'number',
110
+ export const LevelStart = object({
111
+ level: number(),
106
112
  });
107
113
 
108
- export const LevelUp = struct({
109
- level: 'number',
110
- character: 'string?',
114
+ export const LevelUp = object({
115
+ level: number(),
116
+ character: optional(string()),
111
117
  });
112
118
 
113
- export const Login = struct({
114
- method: 'string',
119
+ export const Login = object({
120
+ method: string(),
115
121
  });
116
122
 
117
- export const PostScore = struct({
118
- score: 'number',
119
- level: 'number?',
120
- character: 'string?',
123
+ export const PostScore = object({
124
+ score: number(),
125
+ level: optional(number()),
126
+ character: optional(string()),
121
127
  });
122
128
 
123
- export const Refund = struct({
124
- affiliation: 'string?',
125
- coupon: 'string?',
126
- currency: 'string?',
127
- items: struct.optional([Item]),
128
- shipping: 'number?',
129
- tax: 'number?',
130
- value: 'number?',
131
- transaction_id: 'string?',
129
+ export const Refund = object({
130
+ affiliation: optional(string()),
131
+ coupon: optional(string()),
132
+ currency: optional(string()),
133
+ items: optional(array(Item)),
134
+ shipping: optional(number()),
135
+ tax: optional(number()),
136
+ value: optional(number()),
137
+ transaction_id: optional(string()),
132
138
  });
133
139
 
134
- export const Purchase = struct.interface({
135
- affiliation: 'string?',
136
- coupon: 'string?',
137
- currency: 'string?',
138
- items: struct.optional([Item]),
139
- shipping: 'number?',
140
- tax: 'number?',
141
- value: 'number?',
142
- transaction_id: 'string?',
140
+ export const Purchase = type({
141
+ affiliation: optional(string()),
142
+ coupon: optional(string()),
143
+ currency: optional(string()),
144
+ items: optional(array(Item)),
145
+ shipping: optional(number()),
146
+ tax: optional(number()),
147
+ value: optional(number()),
148
+ transaction_id: optional(string()),
143
149
  });
144
150
 
145
- export const RemoveFromCart = struct({
146
- currency: 'string?',
147
- items: struct.optional([Item]),
148
- value: 'number?',
151
+ export const RemoveFromCart = object({
152
+ currency: optional(string()),
153
+ items: optional(array(Item)),
154
+ value: optional(number()),
149
155
  });
150
156
 
151
- export const Search = struct({
152
- search_term: 'string',
153
- number_of_nights: 'number?',
154
- number_of_rooms: 'number?',
155
- number_of_passengers: 'number?',
156
- origin: 'string?',
157
- destination: 'string?',
158
- start_date: 'shortDate?',
159
- end_date: 'shortDate?',
160
- travel_class: 'string?',
157
+ export const Search = object({
158
+ search_term: string(),
159
+ number_of_nights: optional(number()),
160
+ number_of_rooms: optional(number()),
161
+ number_of_passengers: optional(number()),
162
+ origin: optional(string()),
163
+ destination: optional(string()),
164
+ start_date: optional(ShortDate),
165
+ end_date: optional(ShortDate),
166
+ travel_class: optional(string()),
161
167
  });
162
168
 
163
- export const SelectContent = struct({
164
- content_type: 'string',
165
- item_id: 'string',
169
+ export const SelectContent = object({
170
+ content_type: string(),
171
+ item_id: string(),
166
172
  });
167
173
 
168
- export const SelectItem = struct({
169
- items: struct.optional([Item]),
170
- item_list_id: 'string?',
171
- item_list_name: 'string?',
172
- content_type: 'string?',
174
+ export const SelectItem = object({
175
+ items: optional(array(Item)),
176
+ item_list_id: optional(string()),
177
+ item_list_name: optional(string()),
178
+ content_type: optional(string()),
173
179
  });
174
180
 
175
- export const SelectPromotion = struct({
176
- creative_name: 'string',
177
- creative_slot: 'string',
178
- items: struct.optional([Item]),
179
- location_id: 'string',
180
- promotion_id: 'string',
181
- promotion_name: 'string',
181
+ export const SelectPromotion = object({
182
+ creative_name: string(),
183
+ creative_slot: string(),
184
+ items: optional(array(Item)),
185
+ location_id: string(),
186
+ promotion_id: string(),
187
+ promotion_name: string(),
182
188
  });
183
189
 
184
- export const SetCheckoutOption = struct({
185
- checkout_step: 'number',
186
- checkout_option: 'string',
190
+ export const SetCheckoutOption = object({
191
+ checkout_step: number(),
192
+ checkout_option: string(),
187
193
  });
188
194
 
189
- export const Share = struct({
190
- content_type: 'string',
191
- item_id: 'string',
192
- method: 'string',
195
+ export const Share = object({
196
+ content_type: string(),
197
+ item_id: string(),
198
+ method: string(),
193
199
  });
194
200
 
195
- export const SignUp = struct({
196
- method: 'string',
201
+ export const SignUp = object({
202
+ method: string(),
197
203
  });
198
204
 
199
- export const SpendVirtualCurrency = struct({
200
- item_name: 'string',
201
- virtual_currency_name: 'string',
202
- value: 'number',
205
+ export const SpendVirtualCurrency = object({
206
+ item_name: string(),
207
+ virtual_currency_name: string(),
208
+ value: number(),
203
209
  });
204
210
 
205
- export const UnlockAchievement = struct({
206
- achievement_id: 'string',
211
+ export const UnlockAchievement = object({
212
+ achievement_id: string(),
207
213
  });
208
214
 
209
- export const ViewCart = struct({
210
- currency: 'string?',
211
- items: struct.optional([Item]),
212
- value: 'number?',
215
+ export const ViewCart = object({
216
+ currency: optional(string()),
217
+ items: optional(array(Item)),
218
+ value: optional(number()),
213
219
  });
214
220
 
215
- export const ViewItem = struct({
216
- currency: 'string?',
217
- items: struct.optional([Item]),
218
- value: 'number?',
221
+ export const ViewItem = object({
222
+ currency: optional(string()),
223
+ items: optional(array(Item)),
224
+ value: optional(number()),
219
225
  });
220
226
 
221
- export const ViewItemList = struct({
222
- items: struct.optional([Item]),
223
- item_list_id: 'string?',
224
- item_list_name: 'string?',
227
+ export const ViewItemList = object({
228
+ items: optional(array(Item)),
229
+ item_list_id: optional(string()),
230
+ item_list_name: optional(string()),
225
231
  });
226
232
 
227
- export const ViewPromotion = struct({
228
- items: struct.optional([Item]),
229
- location_id: 'string?',
230
- creative_name: 'string?',
231
- creative_slot: 'string?',
232
- promotion_id: 'string?',
233
- promotion_name: 'string?',
233
+ export const ViewPromotion = object({
234
+ items: optional(array(Item)),
235
+ location_id: optional(string()),
236
+ creative_name: optional(string()),
237
+ creative_slot: optional(string()),
238
+ promotion_id: optional(string()),
239
+ promotion_name: optional(string()),
234
240
  });
235
241
 
236
- export const ViewSearchResults = struct({
237
- search_term: 'string',
242
+ export const ViewSearchResults = object({
243
+ search_term: string(),
238
244
  });
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '21.4.1';
2
+ module.exports = '21.6.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/analytics",
3
- "version": "21.4.1",
3
+ "version": "21.6.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - The analytics module provides out of the box support with Google Analytics for Firebase. Integration with the Android & iOS allows for in-depth analytical insight reporting, such as device information, location, user actions and more.",
6
6
  "main": "lib/index.js",
@@ -22,10 +22,13 @@
22
22
  "analytics"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@react-native-firebase/app": "21.4.1"
25
+ "@react-native-firebase/app": "21.6.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "1c4301c4f57fe6fe8235e73e13a523ad1af156ad"
30
+ "dependencies": {
31
+ "superstruct": "^2.0.2"
32
+ },
33
+ "gitHead": "0103e12714de3c106128859eeadaf0fe07f9674c"
31
34
  }