segment-integrations / analytics-ios-integration-firebase

Segment's bundled integration for Firebase on iOS
MIT License
13 stars 91 forks source link

fix: incorrect "quantity" properties type for Firebase ecommerce event #86

Closed tien closed 1 year ago

tien commented 2 years ago

For quantity property, any type that is not an integer will appear as 0 in the Firebase console

tien commented 2 years ago

For reference some other library that interacted with Firebase also experienced the same issue: https://stackoverflow.com/questions/64574410/react-native-firebase-analytics-purchase-event-item-quantity-always-set-to-0-t

knowledgebreak commented 2 years ago

let configuration = AnalyticsConfiguration(writeKey: "brs0ETC4WjwcE43xia8DaB7NkMGanEix") configuration.trackApplicationLifecycleEvents = true // Enable this to record certain application events automatically! configuration.recordScreenViews = true // Enable this to record screen views automatically! Analytics.setup(with: configuration)

// Enable this to record certain application events automatically! configuration.trackApplicationLifecycleEvents = YES;

// Enable this to record screen views automatically! configuration.recordScreenViews = YES;

[SEGAnalytics setupWithConfiguration:configuration];

import Segment

bsneed commented 1 year ago

@tien We can't single out specific values like that unfortunately. Given Firebases parameters are ever changing, it's best for implementors to verify the data they're passing in is correctly formatted.

Thanks for the irrelevant code @knowledgebreak .. ??

tien commented 1 year ago

@bsneed this library is used by segment React Native library though. And any number passed through the bridge will be first converted to a NSNumber (so this will always break for React Native).

Moreover, the idea of segment library is that one track call will work for all analytics backend, right? So a developer who has used NSNumber before (almost everyone who used objective-c) who now want to use Firebase integration, will need to first debug why their code doesn't work. Then change their track call to use Long instead.

And if they use another integration with issue similar to Firebase and that one required for example Double instead of Long then they can't have one track call for both that integration and Firebase. Defeating the whole purpose of using Segment.

bsneed commented 1 year ago

@tien It's not used by react-native. See the React-Native code here: https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-firebase