File tree Expand file tree Collapse file tree 8 files changed +73
-0
lines changed
Expand file tree Collapse file tree 8 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 7575 "jest" : " ^28.1.1" ,
7676 "lerna" : " 5.1.4" ,
7777 "prettier" : " ^2.7.1" ,
78+ "regenerator-transform" : " ^0.15.0" ,
7879 "rimraf" : " ^3.0.2" ,
7980 "shelljs" : " ^0.8.5" ,
8081 "ts-jest" : " ^28.0.5" ,
Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ Pod::Spec.new do |s|
4949 s . dependency 'Firebase/Analytics' , firebase_sdk_version
5050 end
5151
52+ # Special pod for on-device conversion
53+ if defined? ( $RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion) && ( $RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion == true )
54+ Pod ::UI . puts "#{ s . name } : GoogleAppMeasurementOnDeviceConversion pod added"
55+
56+ # Releasing as non-breaking change as it is optional but it raises minimum requirements, validate just in case
57+ if ( Gem ::Version . new ( firebase_sdk_version ) < Gem ::Version . new ( "9.0.0" ) )
58+ raise "GoogleAppMeasurementOnDeviceConversion requires firebase-ios-sdk 9.0.0 or greater."
59+ end
60+
61+ s . dependency 'GoogleAppMeasurementOnDeviceConversion' , firebase_sdk_version
62+ end
63+
5264 if defined? ( $RNFirebaseAsStaticFramework)
5365 Pod ::UI . puts "#{ s . name } : Using overridden static_framework value of '#{ $RNFirebaseAsStaticFramework} '"
5466 s . static_framework = $RNFirebaseAsStaticFramework
Original file line number Diff line number Diff line change @@ -521,4 +521,15 @@ describe('Analytics', function () {
521521 ) ;
522522 } ) ;
523523 } ) ;
524+
525+ describe ( 'initiateOnDeviceConversionMeasurementWithEmailAddress()' , function ( ) {
526+ it ( 'throws if not a string' , function ( ) {
527+ expect ( ( ) =>
528+ // @ts -ignore
529+ firebase . analytics ( ) . initiateOnDeviceConversionMeasurementWithEmailAddress ( true ) ,
530+ ) . toThrowError (
531+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithEmailAddress(*) 'emailAddress' expected a string value." ,
532+ ) ;
533+ } ) ;
534+ } ) ;
524535} ) ;
Original file line number Diff line number Diff line change @@ -425,6 +425,15 @@ describe('analytics()', function () {
425425 } ) ;
426426 } ) ;
427427
428+ // Test this last so it does not stop delivery to DebugView
429+ describe ( 'initiateOnDeviceConversionMeasurementWithEmailAddress()' , function ( ) {
430+ it ( 'calls native API successfully' , async function ( ) {
431+ await firebase
432+ . analytics ( )
433+ . initiateOnDeviceConversionMeasurementWithEmailAddress ( 'conversionTest@example.com' ) ;
434+ } ) ;
435+ } ) ;
436+
428437 // Test this last so it does not stop delivery to DebugView
429438 describe ( 'setAnalyticsCollectionEnabled()' , function ( ) {
430439 it ( 'false' , async function ( ) {
Original file line number Diff line number Diff line change @@ -138,6 +138,19 @@ - (dispatch_queue_t)methodQueue {
138138 return resolve ([NSNull null ]);
139139}
140140
141+ RCT_EXPORT_METHOD (initiateOnDeviceConversionMeasurementWithEmailAddress
142+ : (NSString *)emailAddress resolver
143+ : (RCTPromiseResolveBlock)resolve rejecter
144+ : (RCTPromiseRejectBlock)reject) {
145+ @try {
146+ [FIRAnalytics initiateOnDeviceConversionMeasurementWithEmailAddress: emailAddress];
147+ } @catch (NSException *exception) {
148+ return [RNFBSharedUtils rejectPromiseWithExceptionDict: reject exception: exception];
149+ }
150+
151+ return resolve ([NSNull null ]);
152+ }
153+
141154#pragma mark -
142155#pragma mark Private methods
143156
Original file line number Diff line number Diff line change @@ -1502,6 +1502,15 @@ export namespace FirebaseAnalyticsTypes {
15021502 * will clear all parameters.
15031503 */
15041504 setDefaultEventParameters ( params ?: { [ key : string ] : any } ) : Promise < void > ;
1505+
1506+ /**
1507+ * start privacy-sensitive on-device conversion management.
1508+ * This is iOS-only.
1509+ * This is a no-op if you do not include '#RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true' in your Podfile
1510+ *
1511+ * @param emailAddress email address, properly formatted complete with domain name e.g, 'user@example.com'
1512+ */
1513+ initiateOnDeviceConversionMeasurementWithEmailAddress ( emailAddress : string ) : Promise < void > ;
15051514 }
15061515}
15071516
Original file line number Diff line number Diff line change 1717
1818import {
1919 isAlphaNumericUnderscore ,
20+ isIOS ,
2021 isNull ,
2122 isNumber ,
2223 isObject ,
@@ -676,6 +677,20 @@ class FirebaseAnalyticsModule extends FirebaseModule {
676677
677678 return this . native . setDefaultEventParameters ( params ) ;
678679 }
680+
681+ initiateOnDeviceConversionMeasurementWithEmailAddress ( emailAddress ) {
682+ if ( ! isString ( emailAddress ) ) {
683+ throw new Error (
684+ "firebase.analytics().initiateOnDeviceConversionMeasurementWithEmailAddress(*) 'emailAddress' expected a string value." ,
685+ ) ;
686+ }
687+
688+ if ( ! isIOS ) {
689+ return ;
690+ }
691+
692+ return this . native . initiateOnDeviceConversionMeasurementWithEmailAddress ( emailAddress ) ;
693+ }
679694}
680695
681696// import { SDK_VERSION } from '@react-native-firebase/analytics';
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ $RNFirebaseAsStaticFramework = true # toggle this to true (and set 'use_framewor
1111# See: https://firebase.google.com/support/release-notes/ios#analytics - requires firebase-ios-sdk 7.11.0+
1212#$RNFirebaseAnalyticsWithoutAdIdSupport = true # toggle this to true for the no-ad-tracking Analytics subspec
1313
14+ # Toggle this to true if you want to include support for on device conversion measurement APIs
15+ $RNFirebaseAnalyticsGoogleAppMeasurementOnDeviceConversion = true
16+
1417# Versions used below, for quick reference / outdated+upgrade checks
1518$iOSMinimumDeployVersion = '11.0'
1619
You can’t perform that action at this time.
0 commit comments