oddbit / flutter_facebook_app_events

Flutter Plugin for Facebook App Events
https://pub.dev/packages/facebook_app_events
Apache License 2.0
126 stars 321 forks source link

Events name platform independent #33

Closed jaumard closed 4 years ago

jaumard commented 4 years ago

Would be nice to have the events name in dart https://developers.facebook.com/docs/app-events/reference

From the doc we can see they are different between iOS and Android, would be nice to have a dart constant that will change it to the right one under the hood.

Example: Android: EVENT_NAME_ACHIEVED_LEVEL iOS: FBSDKAppEventNameAchievedLevel Dart: String get eventAchievedLevel => Platform.isAndroid ? 'EVENT_NAME_ACHIEVED_LEVEL' : 'FBSDKAppEventNameAchievedLevel'

Something like this :) to avoir doing this in our side

diegogarciar commented 4 years ago

hey @jaumard I was thinking the same, and was doing it manually until I realized that the final event names are the same. Platform.isAndroid ? 'EVENT_NAME_ACHIEVED_LEVEL' : 'FBSDKAppEventNameAchievedLevel' here you are using constants, but their value is the same.

// General purpose
const FBSDKAppEventNameCompletedRegistration   = "fb_mobile_complete_registration";
const FBSDKAppEventNameViewedContent           = "fb_mobile_content_view";
const FBSDKAppEventNameSearched                = "fb_mobile_search";
const FBSDKAppEventNameRated                   = "fb_mobile_rate";
const FBSDKAppEventNameCompletedTutorial       = "fb_mobile_tutorial_completion";

const EVENT_NAME_COMPLETED_REGISTRATION   = "fb_mobile_complete_registration";
const EVENT_NAME_VIEWED_CONTENT           = "fb_mobile_content_view";
const EVENT_NAME_SEARCHED                 = "fb_mobile_search";
const EVENT_NAME_RATED                    = "fb_mobile_rate";
const EVENT_NAME_COMPLETED_TUTORIAL       = "fb_mobile_tutorial_completion";

this is what I was doing until I realized they're the same. Anyways it still would be nice to have access to those constants on dart

anyway, here they all are with iOS names

// General purpose
const FBSDKAppEventNameCompletedRegistration   = "fb_mobile_complete_registration";
const FBSDKAppEventNameViewedContent           = "fb_mobile_content_view";
const FBSDKAppEventNameSearched                = "fb_mobile_search";
const FBSDKAppEventNameRated                   = "fb_mobile_rate";
const FBSDKAppEventNameCompletedTutorial       = "fb_mobile_tutorial_completion";
const FBSDKAppEventNameContact                 = "Contact";
const FBSDKAppEventNameSubmitApplication       = "SubmitApplication";

// Ecommerce related
const FBSDKAppEventNameAddedToCart             = "fb_mobile_add_to_cart";
const FBSDKAppEventNameAddedToWishlist         = "fb_mobile_add_to_wishlist";
const FBSDKAppEventNameInitiatedCheckout       = "fb_mobile_initiated_checkout";
const FBSDKAppEventNameAddedPaymentInfo        = "fb_mobile_add_payment_info";
const FBSDKAppEventNameProductCatalogUpdate    = "fb_mobile_catalog_update";
const FBSDKAppEventNamePurchased               = "fb_mobile_purchase";

// Public event parameter names

const FBSDKAppEventParameterNameCurrency               = "fb_currency";
const FBSDKAppEventParameterNameRegistrationMethod     = "fb_registration_method";
const FBSDKAppEventParameterNameContentType            = "fb_content_type";
const FBSDKAppEventParameterNameContent                = "fb_content";
const FBSDKAppEventParameterNameContentID              = "fb_content_id";
const FBSDKAppEventParameterNameSearchString           = "fb_search_string";
const FBSDKAppEventParameterNameSuccess                = "fb_success";
const FBSDKAppEventParameterNameMaxRatingValue         = "fb_max_rating_value";
const FBSDKAppEventParameterNamePaymentInfoAvailable   = "fb_payment_info_available";
const FBSDKAppEventParameterNameNumItems               = "fb_num_items";
const FBSDKAppEventParameterNameLevel                  = "fb_level";
const FBSDKAppEventParameterNameDescription            = "fb_description";
const FBSDKAppEventParameterLaunchSource               = "fb_mobile_launch_source";
const FBSDKAppEventParameterNameAdType                 = "ad_type";
const FBSDKAppEventParameterNameOrderID                = "fb_order_id";
jaumard commented 4 years ago

I realized the same things after trying values from their shitty docs... but yes in the end real values are the same, I forgot to close this after finding out ^^ Thanks !