@react-native-firebase/analytics 18.1.0 → 18.2.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,13 @@
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
+ ## [18.2.0](https://github.com/invertase/react-native-firebase/compare/v18.1.0...v18.2.0) (2023-07-13)
7
+
8
+ ### Features
9
+
10
+ - **analytics, ios:** implement setSessionTimeoutDuration for ios ([b3ce13f](https://github.com/invertase/react-native-firebase/commit/b3ce13ff5f7922e4a253aa58377e5c3c436e74f0))
11
+ - **analytics:** implement getSessionId ([566470c](https://github.com/invertase/react-native-firebase/commit/566470cfc0e919a46c0a119835187257bf046df7))
12
+
6
13
  ## [18.1.0](https://github.com/invertase/react-native-firebase/compare/v18.0.0...v18.1.0) (2023-06-22)
7
14
 
8
15
  **Note:** Version bump only for package @react-native-firebase/analytics
@@ -60,6 +60,10 @@ public class UniversalFirebaseAnalyticsModule extends UniversalFirebaseModule {
60
60
  return FirebaseAnalytics.getInstance(getContext()).getAppInstanceId();
61
61
  }
62
62
 
63
+ Task<Long> getSessionId() {
64
+ return FirebaseAnalytics.getInstance(getContext()).getSessionId();
65
+ }
66
+
63
67
  Task<Void> setUserId(String id) {
64
68
  return Tasks.call(
65
69
  () -> {
@@ -93,6 +93,21 @@ public class ReactNativeFirebaseAnalyticsModule extends ReactNativeFirebaseModul
93
93
  });
94
94
  }
95
95
 
96
+ @ReactMethod
97
+ public void getSessionId(Promise promise) {
98
+ module
99
+ .getSessionId()
100
+ .addOnCompleteListener(
101
+ task -> {
102
+ if (task.isSuccessful()) {
103
+ Long result = task.getResult();
104
+ promise.resolve(result != null ? result.doubleValue() : null);
105
+ } else {
106
+ rejectPromiseWithExceptionMap(promise, task.getException());
107
+ }
108
+ });
109
+ }
110
+
96
111
  @ReactMethod
97
112
  public void setUserId(String id, Promise promise) {
98
113
  module
@@ -115,7 +115,7 @@ RCT_EXPORT_METHOD(setSessionTimeoutDuration
115
115
  : (double)milliseconds resolver
116
116
  : (RCTPromiseResolveBlock)resolve rejecter
117
117
  : (RCTPromiseRejectBlock)reject) {
118
- // Do nothing - this only exists in android
118
+ [FIRAnalytics setSessionTimeoutInterval:milliseconds / 1000];
119
119
  return resolve([NSNull null]);
120
120
  }
121
121
 
@@ -125,6 +125,19 @@ RCT_EXPORT_METHOD(getAppInstanceId
125
125
  return resolve([FIRAnalytics appInstanceID]);
126
126
  }
127
127
 
128
+ RCT_EXPORT_METHOD(getSessionId
129
+ : (RCTPromiseResolveBlock)resolve rejecter
130
+ : (RCTPromiseRejectBlock)reject) {
131
+ [FIRAnalytics sessionIDWithCompletion:^(int64_t sessionID, NSError *_Nullable error) {
132
+ if (error) {
133
+ DLog(@"Error getting session ID: %@", error);
134
+ return resolve([NSNull null]);
135
+ } else {
136
+ return resolve([NSNumber numberWithLongLong:sessionID]);
137
+ }
138
+ }];
139
+ }
140
+
128
141
  RCT_EXPORT_METHOD(setDefaultEventParameters
129
142
  : (NSDictionary *)params resolver
130
143
  : (RCTPromiseResolveBlock)resolve rejecter
package/lib/index.d.ts CHANGED
@@ -869,6 +869,20 @@ export namespace FirebaseAnalyticsTypes {
869
869
  */
870
870
  getAppInstanceId(): Promise<string | null>;
871
871
 
872
+ /**
873
+ * Retrieves the session id from the client.
874
+ * On iOS, Firebase SDK may return an error that is handled internally and may take many minutes to return a valid value. Check native debug logs for more details.
875
+ *
876
+ * #### Example
877
+ *
878
+ * ```js
879
+ * const sessionId = await firebase.analytics().getSessionId();
880
+ * ```
881
+ *
882
+ * @returns Returns the session id or null if session is expired, null on android if FirebaseAnalytics.ConsentType.ANALYTICS_STORAGE has been set to FirebaseAnalytics.ConsentStatus.DENIED and null on iOS if ConsentType.analyticsStorage has been set to ConsentStatus.denied.
883
+ */
884
+ getSessionId(): Promise<number | null>;
885
+
872
886
  /**
873
887
  * Gives a user a unique identification.
874
888
  *
package/lib/index.js CHANGED
@@ -43,6 +43,7 @@ export {
43
43
  setAnalyticsCollectionEnabled,
44
44
  setSessionTimeoutDuration,
45
45
  getAppInstanceId,
46
+ getSessionId,
46
47
  setUserId,
47
48
  setUserProperty,
48
49
  setUserProperties,
@@ -196,6 +197,10 @@ class FirebaseAnalyticsModule extends FirebaseModule {
196
197
  return this.native.getAppInstanceId();
197
198
  }
198
199
 
200
+ getSessionId() {
201
+ return this.native.getSessionId();
202
+ }
203
+
199
204
  setUserId(id) {
200
205
  if (!isNull(id) && !isString(id)) {
201
206
  throw new Error("firebase.analytics().setUserId(*) 'id' expected a string value.");
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '18.1.0';
2
+ module.exports = '18.2.0';
package/modular/index.js CHANGED
@@ -70,6 +70,16 @@ export function setSessionTimeoutDuration(analytics, milliseconds = 1800000) {
70
70
  export function getAppInstanceId(analytics) {
71
71
  return analytics.getAppInstanceId();
72
72
  }
73
+ /**
74
+ * Retrieves the session id from the client.
75
+ * On iOS, Firebase SDK may return an error that is handled internally and may take many minutes to return a valid value. Check native debug logs for more details.
76
+ *
77
+ * @param analytics Analytics instance.
78
+ * @returns Returns the session id or null if session is expired, null on android if FirebaseAnalytics.ConsentType.ANALYTICS_STORAGE has been set to FirebaseAnalytics.ConsentStatus.DENIED and null on iOS if ConsentType.analyticsStorage has been set to ConsentStatus.denied.
79
+ */
80
+ export function getSessionId(analytics) {
81
+ return analytics.getSessionId();
82
+ }
73
83
  /**
74
84
  * Gives a user a unique identification.
75
85
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/analytics",
3
- "version": "18.1.0",
3
+ "version": "18.2.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": "18.1.0"
25
+ "@react-native-firebase/app": "18.2.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "1c2dd42a9a2207a25e326be866ccc15f4d7b9c21"
30
+ "gitHead": "4c666df92028ddc3c0010a7ac102f54b600e6644"
31
31
  }