@react-native-firebase/analytics 20.2.0 → 20.3.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.
- package/CHANGELOG.md +10 -0
- package/lib/version.js +1 -1
- package/lib/web/api.js +40 -3
- package/package.json +3 -3
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
|
+
## [20.3.0](https://github.com/invertase/react-native-firebase/compare/v20.2.1...v20.3.0) (2024-07-19)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
- **analytics,other:** persist analytics client id where possible ([94a8198](https://github.com/invertase/react-native-firebase/commit/94a8198e9d4f5a689bcc9ec879e5d4bec83acd66))
|
11
|
+
|
12
|
+
## [20.2.1](https://github.com/invertase/react-native-firebase/compare/v20.2.0...v20.2.1) (2024-07-17)
|
13
|
+
|
14
|
+
**Note:** Version bump only for package @react-native-firebase/analytics
|
15
|
+
|
6
16
|
## [20.2.0](https://github.com/invertase/react-native-firebase/compare/v20.1.0...v20.2.0) (2024-07-15)
|
7
17
|
|
8
18
|
### Features
|
package/lib/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// Generated by genversion.
|
2
|
-
module.exports = '20.
|
2
|
+
module.exports = '20.3.0';
|
package/lib/web/api.js
CHANGED
@@ -6,6 +6,12 @@ import {
|
|
6
6
|
getInstallations,
|
7
7
|
makeIDBAvailable,
|
8
8
|
} from '@react-native-firebase/app/lib/internal/web/firebaseInstallations';
|
9
|
+
import {
|
10
|
+
getItem,
|
11
|
+
setItem,
|
12
|
+
isMemoryStorage,
|
13
|
+
} from '@react-native-firebase/app/lib/internal/asyncStorage';
|
14
|
+
|
9
15
|
import { isNumber } from '@react-native-firebase/app/lib/common';
|
10
16
|
|
11
17
|
/**
|
@@ -47,8 +53,6 @@ class AnalyticsApi {
|
|
47
53
|
this.debug = false;
|
48
54
|
this.currentScreen = null;
|
49
55
|
|
50
|
-
// TODO this should be persisted once we have a way to do so in app internals
|
51
|
-
this.cid = generateGAClientId();
|
52
56
|
this._getInstallationId().catch(error => {
|
53
57
|
if (global.RNFBDebug) {
|
54
58
|
console.debug('[RNFB->Analytics][🔴] Error getting Firebase Installation Id:', error);
|
@@ -158,13 +162,46 @@ class AnalyticsApi {
|
|
158
162
|
}
|
159
163
|
}
|
160
164
|
|
165
|
+
async _getCid() {
|
166
|
+
this.cid = await getItem('analytics:cid');
|
167
|
+
if (this.cid) {
|
168
|
+
return this.cid;
|
169
|
+
}
|
170
|
+
this.cid = generateGAClientId();
|
171
|
+
await setItem('analytics:cid', this.cid);
|
172
|
+
if (isMemoryStorage()) {
|
173
|
+
console.warn(
|
174
|
+
```
|
175
|
+
Firebase Analytics is using in memory persistence. This means that the analytics
|
176
|
+
client ID is reset every time your app is restarted which may result in
|
177
|
+
inaccurate data being shown on the Firebase Analytics dashboard.
|
178
|
+
|
179
|
+
To enable persistence, provide an Async Storage implementation.
|
180
|
+
|
181
|
+
For example, to use React Native Async Storage:
|
182
|
+
|
183
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
184
|
+
|
185
|
+
// Before initializing Firebase set the Async Storage implementation
|
186
|
+
// that will be used to persist user sessions.
|
187
|
+
firebase.setReactNativeAsyncStorage(AsyncStorage);
|
188
|
+
|
189
|
+
// Then initialize Firebase as normal.
|
190
|
+
await firebase.initializeApp({ ... });
|
191
|
+
```,
|
192
|
+
);
|
193
|
+
}
|
194
|
+
return this.cid;
|
195
|
+
}
|
196
|
+
|
161
197
|
async _sendEvents(events) {
|
198
|
+
const cid = this.cid || (await this._getCid());
|
162
199
|
for (const event of events) {
|
163
200
|
const queryParams = new URLSearchParams({
|
164
201
|
v: '2',
|
165
202
|
tid: this.measurementId,
|
166
203
|
en: event.name,
|
167
|
-
cid
|
204
|
+
cid,
|
168
205
|
pscdl: 'noapi',
|
169
206
|
sid: this.sessionId,
|
170
207
|
'ep.origin': 'firebase',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-firebase/analytics",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.3.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,10 @@
|
|
22
22
|
"analytics"
|
23
23
|
],
|
24
24
|
"peerDependencies": {
|
25
|
-
"@react-native-firebase/app": "20.
|
25
|
+
"@react-native-firebase/app": "20.3.0"
|
26
26
|
},
|
27
27
|
"publishConfig": {
|
28
28
|
"access": "public"
|
29
29
|
},
|
30
|
-
"gitHead": "
|
30
|
+
"gitHead": "a916b37b022cf40588fa0fd915b7ab901e2458d0"
|
31
31
|
}
|