Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [firebase_analytics] Custom Parameters Assertions Break Enhanced E-Commerce Events #10629

Closed
muccy opened this issue Mar 21, 2023 · 14 comments 路 Fixed by #11030
Closed

馃悰 [firebase_analytics] Custom Parameters Assertions Break Enhanced E-Commerce Events #10629

muccy opened this issue Mar 21, 2023 · 14 comments 路 Fixed by #11030
Assignees
Labels
plugin: analytics resolution: fixed A fix has been merged or is pending merge from a PR. type: enhancement New feature or request type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API.

Comments

@muccy
Copy link
Contributor

muccy commented Mar 21, 2023

Bug report

Describe the bug
The version 10.1 of firebase_analytics plugin introduced an assertion to filter out lists from custom parameters (see: #9520). This change forces us to use stock methods (e.g.: logPurchase) in order to track e-commerce events but we are not allowed to pass extra (legal) parameters to GA4.

Expected behavior

To circumvent the restrictions of the stock methods I used to call logEvent with the proper event name and parameter keys.

It should be useful to enrich stock log* methods with extra parameters to pass.

@muccy muccy added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Mar 21, 2023
@darshankawar darshankawar added the triage Issue is currently being triaged. label Mar 21, 2023
@darshankawar
Copy link

/cc @russellwheatley for visibility.

@darshankawar darshankawar added plugin: analytics type: enhancement New feature or request type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API. and removed type: bug Something isn't working Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Mar 21, 2023
@tavanarad
Copy link

any update?

@russellwheatley
Copy link
Member

Are you able to prove that a list shows up in the Firebase console? My investigation showed that they do not, and the Firebase documentation is pretty clear on that as noted in the PR.

@russellwheatley russellwheatley added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Apr 25, 2023
@muccy
Copy link
Contributor Author

muccy commented Apr 26, 2023

Yes, I am.
In the current version of the app I'm using firebase_analytics: 10.1.0 and I'm not using the library events in order to track (for instance) purchases. I'm calling something like:

await FirebaseAnalytics.instance.logEvent(
  name: "purchase", 
  parameters: {
    "items": data.products
        .map(
          (product) => {
            "item_id": product.id,
            "item_name": product.name,
            "price": product.price.value,
            "currency": product.price.currency.code,
            "quantity": product.quantity,
          },
        )
        .toList(),
    "value": data.grandTotal.value,
    "currency": data.grandTotal.currency.code,
    "transaction_id": data.transactionId,
    "shipping": data.shippingCost.value,
    if (data.couponCode?.isNotEmpty == true) "coupon": data.couponCode,
    if (data.firstMargin != null) "tnc_first_margin": data.firstMargin?.value,
    if (data.secondMargin != null) "tnc_second_margin": data.secondMargin?.value,
  },
);

I can confirm you I can see data incoming to GA4:
image

I would be more than happy using stock methods (e.g. logPurchase) but, as you can see, I need to pass extra data along with the event (e.g. tnc_first_margin).

On the other hand, it would not be a problem also to keep using logEvent manually if there was a way to circumvent the assertion

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Apr 26, 2023
@sefai
Copy link

sefai commented Jul 8, 2023

Are you able to prove that a list shows up in the Firebase console? My investigation showed that they do not, and the Firebase documentation is pretty clear on that as noted in the PR.

It is also possible to add custom parameters to items, not just events. Interestingly Firebase documentation also has a Dart/Flutter code sample which is not possible with this plugin!

https://firebase.google.com/docs/analytics/measure-ecommerce#item_custom_parameters

@muccy
Copy link
Contributor Author

muccy commented Jul 10, 2023

The linked pull request works pretty well in production. Sadly I'm still searching the time to fill the checklist

@mvolpato
Copy link
Contributor

@muccy do you need help?

@FabricioIC
Copy link

Hello!

My name is Fabricio, I'm part of the technology team at i-Cherry, a Google partner agency and official reseller of Google Analytics, and as an official partner we provide support to customers not only in implementation but in solving problems involving Analytics.

Recently, our customers with flutter applications that use this plugin are having problems logging Ecommerce events with additional custom parameters.
In one of them, a migration from React Native to Flutter is being made, and unfortunately the implementation that is now functional in React Nactive cannot be replicated in Flutter due to the limitation imposed where it is not possible to send the array items (for ecommerce events) in the logEvent and it is also not possible to send additional parameters in preconfigured ecommerce events, this limits some implementations that need additional data which can vary greatly from client to client.

As @muccy mentioned an example of a purchase with additional parameters, this type of situation is very common, of needing to enrich the data with specific information about the customer's business, but with the current limitations placed, it is impossible to apply them in a friendly way.

A very common practice among the clients we serve is the implementation of customized modules (classes) to centralize analytics tools in order to be reused in every application, and normally "logEvent" is used for its freedom to define the event and parameters according to need.

I understand that the limitation has been implemented because arrays are not allowed in custom events, resulting in error 21 in firebase, but even with this error the information is recorded, discarding only the error, but it will not be an error if the event name is an expected standard event according to the official Google documentation (purchase, add_to_cart and others from ecommerce).

Please, I ask you to review, at least the logEvent and leave it free for customization as needed, as I understand that this should be his proposal, removing the limitation that today only the flutter version of the SDK has.

It is worth mentioning that GA4 (the current version of Google Analytics) is constantly evolving, and frequently receives relevant updates on events, and I understand that logEvent with less restrictions will allow the use of new features in the future to be used without the need for an update in the Flutter SDK code, as it is in the Java and Swift SDK.

@muccy
Copy link
Contributor Author

muccy commented Jul 25, 2023

Hey @mvolpato, this morning I finally found the time to complete the PR checklist. Any help or opinion is great anyway. For example I keep having problems with melos + cloud_firestore_odm_generator. In fact I had to ignore it when bootstrapping

@mvolpato
Copy link
Contributor

Hey @mvolpato, this morning I finally found the time to complete the PR checklist. Any help or opinion is great anyway. For example I keep having problems with melos + cloud_firestore_odm_generator. In fact I had to ignore it when bootstrapping

I do not know much about cloud_firestore_odm_generator. I was volunteering for getting the PR to the state that it is now. Thanks for updating it.

@russellwheatley
Copy link
Member

Thanks for the feedback, I'll take a look at this once I get a chance 馃檹

@russellwheatley russellwheatley self-assigned this Jul 25, 2023
@Pavel-Sulimau
Copy link

Hello @russellwheatley, have you had a chance to give the PR a look?

@mvolpato
Copy link
Contributor

Hi @russellwheatley , is there any way we can increase visibility of this issue?

@russellwheatley
Copy link
Member

Sorry for the tardiness on this issue, the PR LGTM.

For future reference, custom parameters can be sent with any event as documented here.

Custom parameters can also be sent with Items as documented here.

Let me raise this with the Firebase team and, should they approve, I will look to get this merged. Thank you for your patience 馃檹

@russellwheatley russellwheatley removed the Needs Attention This issue needs maintainer attention. label Oct 23, 2023
@darshankawar darshankawar added the resolution: fixed A fix has been merged or is pending merge from a PR. label Nov 27, 2023
@firebase firebase locked and limited conversation to collaborators Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: analytics resolution: fixed A fix has been merged or is pending merge from a PR. type: enhancement New feature or request type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API.
Projects
None yet
9 participants