New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(firebase_analytics, ios): add onDeviceConversionMeasurement #11795
base: master
Are you sure you want to change the base?
feat(firebase_analytics, ios): add onDeviceConversionMeasurement #11795
Conversation
Just dropping by for a moment since I saw my tag here 👋 - wanted to note that there is a phone API as well with firebase-ios-sdk 10.13.0+ invertase/react-native-firebase#7358 Same basic pattern, might make sense to get them both in at once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, but looks really good, thanks for this :)
- (void)setAutomaticDataCollectionEnabledAppName:(nonnull NSString *)appName | ||
enabled:(nonnull NSNumber *)enabled | ||
completion: | ||
(nonnull void (^)(FlutterError *_Nullable))completion { | ||
FIRApp *firebaseApp = [FLTFirebasePlugin firebaseAppNamed:appName]; | ||
if (firebaseApp) { | ||
[firebaseApp setDataCollectionDefaultEnabled:[enabled boolValue]]; | ||
} | ||
|
||
completion(nil); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing where this method is being called. You probably need to add something in the handleMethodCall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lyokone I thought the same at first glance, but actually it's being called inside the FirebaseAnalyticsHostApiSetup
firebase_analytics_messages.g.m
void FirebaseAnalyticsHostApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FirebaseAnalyticsHostApi> *api) {
{
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:
@"dev.flutter.pigeon.firebase_analytics_platform_interface.FirebaseAnalyticsHostApi."
@"initiateOnDeviceConversionMeasurementWithEmailAddress"
binaryMessenger:binaryMessenger
codec:FirebaseAnalyticsHostApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector
(initiateOnDeviceConversionMeasurementWithEmailAddressEmailAddress:
completion:)],
@"FirebaseAnalyticsHostApi api (%@) doesn't respond to "
@"@selector(initiateOnDeviceConversionMeasurementWithEmailAddressEmailAddress:"
@"completion:)",
api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
printf("Inside newMessageHandler");
NSArray *args = message;
NSString *arg_emailAddress = GetNullableObjectAtIndex(args, 0);
[api initiateOnDeviceConversionMeasurementWithEmailAddressEmailAddress:arg_emailAddress
completion:^(
FlutterError
*_Nullable error) {
callback(
wrapResult(nil, error));
}];
}];
} else {
[channel setMessageHandler:nil];
}
}
}
It receives the binary messenger and sets a parallel channel, which then calls to the appropriate function. If you run the example, you'll see that the function is properly executed and (if you add the print I wrote in this example) the print too.
In short, there's no need to call it in handleMethodCall
, Pigeon already does it.
The ideal would be to have all the functions of firebase_analytics migrated into pigeon, then all of them would be called in the same place. But I think this would be overkill for this scenario and it would transform this non-breaking PR into a breaking one.
packages/firebase_analytics/firebase_analytics_platform_interface/pubspec.yaml
Show resolved
Hide resolved
Hi, thanks for the feedback! I'll work on your comments this week 😄 |
@Lyokone All your recommendations were implemented and I left a comment on your concern about its functioning. All things considered we should be good to go, right? P.S: I'll eventually add the equivalent of this implementation for phone numbers in a separate PR but I can't promise it will be soon, so I would rather go only with this one for now. |
Sure - did not mean to imply any sort of pressure, just wanted to mention it since whenever this PR makes it through review, using whatever code looks good, the other API should be doing exactly the same thing, so it's potentially a really really quick hit that re-uses all the kind-of-ephemeral wisdom built up on how to do the PR and review it etc. But no one has endless time of course, I certainly feel that! Cheers |
Ohhh I get what you meant now, thanks!!! |
@Lyokone Just checking back on this one, is there anything missing for it to be ready? 😄 |
Description
This PR adds the onDeviceConversionMeasurement function for ios which is needed for an increased volume and precision of conversion tracking.
I followed as example @mikehardy's implementation of the feature in React Native and @Lyokone's implementation of Pigeon.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
).This will ensure a smooth and quick review process. Updating the
pubspec.yaml
and changelogs is not required.///
).melos run analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?