@react-native-firebase/analytics 20.4.0 → 21.0.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.0.0](https://github.com/invertase/react-native-firebase/compare/v20.5.0...v21.0.0) (2024-09-26)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/analytics
9
+
10
+ ## [20.5.0](https://github.com/invertase/react-native-firebase/compare/v20.4.0...v20.5.0) (2024-09-11)
11
+
12
+ ### Features
13
+
14
+ - **analytics:** initiate on device measurement with sha256-hashed values ([#7963](https://github.com/invertase/react-native-firebase/issues/7963)) ([5ce51e1](https://github.com/invertase/react-native-firebase/commit/5ce51e1b8b225bb509b4a0d444f42fa4c5f3effc))
15
+
6
16
  ## [20.4.0](https://github.com/invertase/react-native-firebase/compare/v20.3.0...v20.4.0) (2024-08-13)
7
17
 
8
18
  ### Bug Fixes
@@ -50,7 +50,9 @@ import {
50
50
  logViewSearchResults,
51
51
  setDefaultEventParameters,
52
52
  initiateOnDeviceConversionMeasurementWithEmailAddress,
53
+ initiateOnDeviceConversionMeasurementWithHashedEmailAddress,
53
54
  initiateOnDeviceConversionMeasurementWithPhoneNumber,
55
+ initiateOnDeviceConversionMeasurementWithHashedPhoneNumber,
54
56
  isSupported,
55
57
  setConsent,
56
58
  settings,
@@ -650,6 +652,38 @@ describe('Analytics', function () {
650
652
  });
651
653
  });
652
654
 
655
+ describe('initiateOnDeviceConversionMeasurementWithHashedEmailAddress()', function () {
656
+ it('throws if not a string', function () {
657
+ expect(() =>
658
+ // @ts-ignore
659
+ firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedEmailAddress(true),
660
+ ).toThrowError(
661
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedEmailAddress(*) 'hashedEmailAddress' expected a string value.",
662
+ );
663
+ });
664
+ });
665
+
666
+ describe('initiateOnDeviceConversionMeasurementWithHashedPhoneNumber()', function () {
667
+ it('throws if not a string', function () {
668
+ expect(() =>
669
+ // @ts-ignore
670
+ firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(1234),
671
+ ).toThrowError(
672
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(*) 'hashedPhoneNumber' expected a string value.",
673
+ );
674
+ });
675
+
676
+ it('throws if hashed value is a phone number in E.164 format', function () {
677
+ expect(() =>
678
+ firebase
679
+ .analytics()
680
+ .initiateOnDeviceConversionMeasurementWithHashedPhoneNumber('+1234567890'),
681
+ ).toThrowError(
682
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(*) 'hashedPhoneNumber' expected a sha256-hashed value of a phone number in E.164 format.",
683
+ );
684
+ });
685
+ });
686
+
653
687
  describe('modular', function () {
654
688
  it('`getAnalytics` function is properly exposed to end user', function () {
655
689
  expect(getAnalytics).toBeDefined();
@@ -843,10 +877,35 @@ describe('Analytics', function () {
843
877
  expect(initiateOnDeviceConversionMeasurementWithEmailAddress).toBeDefined();
844
878
  });
845
879
 
880
+ it('`initiateOnDeviceConversionMeasurementWithHashedEmailAddress` function is properly exposed to end user', function () {
881
+ expect(initiateOnDeviceConversionMeasurementWithHashedEmailAddress).toBeDefined();
882
+ });
883
+
884
+ it('`initiateOnDeviceConversionMeasurementWithHashedEmailAddress` throws if not a string', function () {
885
+ expect(() =>
886
+ // @ts-ignore
887
+ initiateOnDeviceConversionMeasurementWithHashedEmailAddress(getAnalytics(), true),
888
+ ).toThrowError(
889
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedEmailAddress(*) 'hashedEmailAddress' expected a string value.",
890
+ );
891
+ });
892
+
893
+ it('`initiateOnDeviceConversionMeasurementWithHashedPhoneNumber` should throw if the value is in E.164 format', function () {
894
+ expect(() =>
895
+ initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(getAnalytics(), '+1234567890'),
896
+ ).toThrowError(
897
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(*) 'hashedPhoneNumber' expected a sha256-hashed value of a phone number in E.164 format.",
898
+ );
899
+ });
900
+
846
901
  it('`initiateOnDeviceConversionMeasurementWithPhoneNumber` function is properly exposed to end user', function () {
847
902
  expect(initiateOnDeviceConversionMeasurementWithPhoneNumber).toBeDefined();
848
903
  });
849
904
 
905
+ it('`initiateOnDeviceConversionMeasurementWithHashedPhoneNumber` function is properly exposed to end user', function () {
906
+ expect(initiateOnDeviceConversionMeasurementWithHashedPhoneNumber).toBeDefined();
907
+ });
908
+
850
909
  it('`isSupported` function is properly exposed to end user', function () {
851
910
  expect(isSupported).toBeDefined();
852
911
  });
@@ -164,6 +164,20 @@ RCT_EXPORT_METHOD(initiateOnDeviceConversionMeasurementWithEmailAddress
164
164
  return resolve([NSNull null]);
165
165
  }
166
166
 
167
+ RCT_EXPORT_METHOD(initiateOnDeviceConversionMeasurementWithHashedEmailAddress
168
+ : (NSString *)hashedEmailAddress resolver
169
+ : (RCTPromiseResolveBlock)resolve rejecter
170
+ : (RCTPromiseRejectBlock)reject) {
171
+ @try {
172
+ NSData *emailAddress = [hashedEmailAddress dataUsingEncoding:NSUTF8StringEncoding];
173
+ [FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedEmailAddress:emailAddress];
174
+ } @catch (NSException *exception) {
175
+ return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception];
176
+ }
177
+
178
+ return resolve([NSNull null]);
179
+ }
180
+
167
181
  RCT_EXPORT_METHOD(initiateOnDeviceConversionMeasurementWithPhoneNumber
168
182
  : (NSString *)phoneNumber resolver
169
183
  : (RCTPromiseResolveBlock)resolve rejecter
@@ -177,6 +191,20 @@ RCT_EXPORT_METHOD(initiateOnDeviceConversionMeasurementWithPhoneNumber
177
191
  return resolve([NSNull null]);
178
192
  }
179
193
 
194
+ RCT_EXPORT_METHOD(initiateOnDeviceConversionMeasurementWithHashedPhoneNumber
195
+ : (NSString *)hashedPhoneNumber resolver
196
+ : (RCTPromiseResolveBlock)resolve rejecter
197
+ : (RCTPromiseRejectBlock)reject) {
198
+ @try {
199
+ NSData *phoneNumber = [hashedPhoneNumber dataUsingEncoding:NSUTF8StringEncoding];
200
+ [FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:phoneNumber];
201
+ } @catch (NSException *exception) {
202
+ return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception];
203
+ }
204
+
205
+ return resolve([NSNull null]);
206
+ }
207
+
180
208
  RCT_EXPORT_METHOD(setConsent
181
209
  : (NSDictionary *)consentSettings resolver
182
210
  : (RCTPromiseResolveBlock)resolve rejecter
package/lib/index.d.ts CHANGED
@@ -1755,23 +1755,51 @@ export namespace FirebaseAnalyticsTypes {
1755
1755
  setDefaultEventParameters(params?: { [key: string]: any }): Promise<void>;
1756
1756
 
1757
1757
  /**
1758
- * start privacy-sensitive on-device conversion management.
1758
+ * Start privacy-sensitive on-device conversion management.
1759
1759
  * This is iOS-only.
1760
- * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
1760
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1761
1761
  *
1762
+ * @platform ios
1762
1763
  * @param emailAddress email address, properly formatted complete with domain name e.g, 'user@example.com'
1763
1764
  */
1764
1765
  initiateOnDeviceConversionMeasurementWithEmailAddress(emailAddress: string): Promise<void>;
1765
1766
 
1766
1767
  /**
1767
- * start privacy-sensitive on-device conversion management.
1768
+ * Start privacy-sensitive on-device conversion management.
1768
1769
  * This is iOS-only.
1769
- * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
1770
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1771
+ * You need to pass the sha256-hashed of normalized email address to this function. See [this link](https://firebase.google.com/docs/tutorials/ads-ios-on-device-measurement/step-3#use-hashed-credentials) for more information.
1770
1772
  *
1773
+ * @platform ios
1774
+ * @param hashedEmailAddress sha256-hashed of normalized email address, properly formatted complete with domain name e.g, 'user@example.com'
1775
+ */
1776
+ initiateOnDeviceConversionMeasurementWithHashedEmailAddress(
1777
+ hashedEmailAddress: string,
1778
+ ): Poromise<void>;
1779
+
1780
+ /**
1781
+ * Start privacy-sensitive on-device conversion management.
1782
+ * This is iOS-only.
1783
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1784
+ *
1785
+ * @platform ios
1771
1786
  * @param phoneNumber phone number in E.164 format - that is a leading + sign, then up to 15 digits, no dashes or spaces.
1772
1787
  */
1773
1788
  initiateOnDeviceConversionMeasurementWithPhoneNumber(phoneNumber: string): Promise<void>;
1774
1789
 
1790
+ /**
1791
+ * Start privacy-sensitive on-device conversion management.
1792
+ * This is iOS-only.
1793
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1794
+ * You need to pass the sha256-hashed of phone number in E.164 format. See [this link](https://firebase.google.com/docs/tutorials/ads-ios-on-device-measurement/step-3#use-hashed-credentials) for more information.
1795
+ *
1796
+ * @platform ios
1797
+ * @param hashedPhoneNumber sha256-hashed of normalized phone number in E.164 format - that is a leading + sign, then up to 15 digits, no dashes or spaces.
1798
+ */
1799
+ initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(
1800
+ hashedPhoneNumber: string,
1801
+ ): Promise<void>;
1802
+
1775
1803
  /**
1776
1804
  * For Consent Mode!
1777
1805
  *
package/lib/index.js CHANGED
@@ -743,6 +743,22 @@ class FirebaseAnalyticsModule extends FirebaseModule {
743
743
  return this.native.initiateOnDeviceConversionMeasurementWithEmailAddress(emailAddress);
744
744
  }
745
745
 
746
+ initiateOnDeviceConversionMeasurementWithHashedEmailAddress(hashedEmailAddress) {
747
+ if (!isString(hashedEmailAddress)) {
748
+ throw new Error(
749
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedEmailAddress(*) 'hashedEmailAddress' expected a string value.",
750
+ );
751
+ }
752
+
753
+ if (!isIOS) {
754
+ return;
755
+ }
756
+
757
+ return this.native.initiateOnDeviceConversionMeasurementWithHashedEmailAddress(
758
+ hashedEmailAddress,
759
+ );
760
+ }
761
+
746
762
  initiateOnDeviceConversionMeasurementWithPhoneNumber(phoneNumber) {
747
763
  if (!isE164PhoneNumber(phoneNumber)) {
748
764
  throw new Error(
@@ -756,6 +772,28 @@ class FirebaseAnalyticsModule extends FirebaseModule {
756
772
 
757
773
  return this.native.initiateOnDeviceConversionMeasurementWithPhoneNumber(phoneNumber);
758
774
  }
775
+
776
+ initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(hashedPhoneNumber) {
777
+ if (isE164PhoneNumber(hashedPhoneNumber)) {
778
+ throw new Error(
779
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(*) 'hashedPhoneNumber' expected a sha256-hashed value of a phone number in E.164 format.",
780
+ );
781
+ }
782
+
783
+ if (!isString(hashedPhoneNumber)) {
784
+ throw new Error(
785
+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(*) 'hashedPhoneNumber' expected a string value.",
786
+ );
787
+ }
788
+
789
+ if (!isIOS) {
790
+ return;
791
+ }
792
+
793
+ return this.native.initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(
794
+ hashedPhoneNumber,
795
+ );
796
+ }
759
797
  }
760
798
 
761
799
  // import { SDK_VERSION } from '@react-native-firebase/analytics';
@@ -1143,6 +1143,7 @@ export function logViewSearchResults(
1143
1143
  * For Web, the values passed persist on the current page and are passed with all
1144
1144
  * subsequent events.
1145
1145
  *
1146
+ * @platform ios
1146
1147
  * @param analytics Analytics instance.
1147
1148
  * @param params Parameters to be added to the map of parameters added to every event.
1148
1149
  */
@@ -1152,10 +1153,11 @@ export function setDefaultEventParameters(
1152
1153
  ): Promise<void>;
1153
1154
 
1154
1155
  /**
1155
- * start privacy-sensitive on-device conversion management.
1156
+ * Start privacy-sensitive on-device conversion management.
1156
1157
  * This is iOS-only.
1157
- * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
1158
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1158
1159
  *
1160
+ * @platform ios
1159
1161
  * @param analytics Analytics instance.
1160
1162
  * @param emailAddress email address, properly formatted complete with domain name e.g, 'user@example.com'
1161
1163
  */
@@ -1165,10 +1167,26 @@ export function initiateOnDeviceConversionMeasurementWithEmailAddress(
1165
1167
  ): Promise<void>;
1166
1168
 
1167
1169
  /**
1168
- * start privacy-sensitive on-device conversion management.
1170
+ * Start privacy-sensitive on-device conversion management.
1169
1171
  * This is iOS-only.
1170
- * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
1172
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1173
+ * You need to pass the sha256-hashed of normalized email address to this function. See [this link](https://firebase.google.com/docs/tutorials/ads-ios-on-device-measurement/step-3#use-hashed-credentials) for more information.
1171
1174
  *
1175
+ * @platform ios
1176
+ * @param analytics Analytics instance.
1177
+ * @param hashedEmailAddress sha256-hashed of normalized email address, properly formatted complete with domain name e.g, 'user@example.com'
1178
+ */
1179
+ export function initiateOnDeviceConversionMeasurementWithHashedEmailAddress(
1180
+ analytics: Analytics,
1181
+ hashedEmailAddress: string,
1182
+ ): Poromise<void>;
1183
+
1184
+ /**
1185
+ * Start privacy-sensitive on-device conversion management.
1186
+ * This is iOS-only.
1187
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1188
+ *
1189
+ * @platform ios
1172
1190
  * @param analytics Analytics instance.
1173
1191
  * @param phoneNumber phone number in E.164 format - that is a leading + sign, then up to 15 digits, no dashes or spaces.
1174
1192
  */
@@ -1177,6 +1195,21 @@ export function initiateOnDeviceConversionMeasurementWithPhoneNumber(
1177
1195
  phoneNumber: string,
1178
1196
  ): Promise<void>;
1179
1197
 
1198
+ /**
1199
+ * Start privacy-sensitive on-device conversion management.
1200
+ * This is iOS-only.
1201
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile.
1202
+ * You need to pass the sha256-hashed of phone number in E.164 format. See [this link](https://firebase.google.com/docs/tutorials/ads-ios-on-device-measurement/step-3#use-hashed-credentials) for more information.
1203
+ *
1204
+ * @platform ios
1205
+ * @param analytics Analytics instance.
1206
+ * @param hashedPhoneNumber sha256-hashed of normalized phone number in E.164 format - that is a leading + sign, then up to 15 digits, no dashes or spaces.
1207
+ */
1208
+ export function initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(
1209
+ analytics: Analytics,
1210
+ hashedPhoneNumber: string,
1211
+ ): Promise<void>;
1212
+
1180
1213
  /**
1181
1214
  * Checks four different things.
1182
1215
  * 1. Checks if it's not a browser extension environment.
@@ -524,6 +524,22 @@ export function initiateOnDeviceConversionMeasurementWithEmailAddress(analytics,
524
524
  return analytics.initiateOnDeviceConversionMeasurementWithEmailAddress(emailAddress);
525
525
  }
526
526
 
527
+ /**
528
+ * start privacy-sensitive on-device conversion management.
529
+ * This is iOS-only.
530
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
531
+ *
532
+ * @param analytics Analytics instance.
533
+ * @param hashedEmailAddress sha256-hashed of normalized email address, properly formatted complete with domain name e.g, 'user@example.com'
534
+ * @link https://firebase.google.com/docs/tutorials/ads-ios-on-device-measurement/step-3#use-hashed-credentials
535
+ */
536
+ export function initiateOnDeviceConversionMeasurementWithHashedEmailAddress(
537
+ analytics,
538
+ hashedEmailAddress,
539
+ ) {
540
+ return analytics.initiateOnDeviceConversionMeasurementWithHashedEmailAddress(hashedEmailAddress);
541
+ }
542
+
527
543
  /**
528
544
  * start privacy-sensitive on-device conversion management.
529
545
  * This is iOS-only.
@@ -535,6 +551,22 @@ export function initiateOnDeviceConversionMeasurementWithPhoneNumber(analytics,
535
551
  return analytics.initiateOnDeviceConversionMeasurementWithPhoneNumber(phoneNumber);
536
552
  }
537
553
 
554
+ /**
555
+ * start privacy-sensitive on-device conversion management.
556
+ * This is iOS-only.
557
+ * This is a no-op if you do not include '$RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
558
+ *
559
+ * @param analytics Analytics instance.
560
+ * @param hashedPhoneNumber sha256-hashed of normalized phone number in E.164 format - that is a leading + sign, then up to 15 digits, no dashes or spaces.
561
+ * @link https://firebase.google.com/docs/tutorials/ads-ios-on-device-measurement/step-3#use-hashed-credentials
562
+ */
563
+ export function initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(
564
+ analytics,
565
+ hashedPhoneNumber,
566
+ ) {
567
+ return analytics.initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(hashedPhoneNumber);
568
+ }
569
+
538
570
  /**
539
571
  * Checks four different things.
540
572
  * 1. Checks if it's not a browser extension environment.
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '20.4.0';
2
+ module.exports = '21.0.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/analytics",
3
- "version": "20.4.0",
3
+ "version": "21.0.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.4.0"
25
+ "@react-native-firebase/app": "21.0.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "3ac3e9623674a8db52c111b4aa0a85a883260116"
30
+ "gitHead": "6965c40db30a832a21c3f9a93f6e5df36f137461"
31
31
  }