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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(firebase_analytics): support complex data structures like list and map on Android #4394

Conversation

lColinDl
Copy link
Contributor

@lColinDl lColinDl commented Dec 14, 2020

Description

The native Android implementation of the firebase_analytics plugin does not support passing complex data structures (e.g. lists) as parameters into the logEventmethod. This is for example necessary for ecommerce events like "view_item_list".
The native plugin implementation for iOS supports this already.

This PR is based on this already open, but outdated PR (#1458). I don't care which PR gets merged, but as this is blocking the usage of ecommerce events, this is really important for me.

Related Issues

This PR fixes:

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@google-cla
Copy link

google-cla bot commented Dec 14, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Dec 14, 2020
@lColinDl
Copy link
Contributor Author

@googlebot I fixed it.

@google-cla google-cla bot added cla: yes and removed cla: no labels Dec 14, 2020
@muccy
Copy link
Contributor

muccy commented Mar 15, 2021

Sorry for the bump, but this seems critical to me and I was about to make a similar PR

@CameliaTripon
Copy link

When can we expect this to be merged? We really need this fix for our application

@russellwheatley
Copy link
Member

Hey @lColinDl, it would be great if you could have add a test to confirm an array and map type works here for us to consider this. Something like:

await FirebaseAnalytics().logEvent(
      name: 'test_complex_data',
      parameters: <String, dynamic>{
        'items': []// complex types here
      },
    )

I wasn't able to log complex data types using your changes in my own preliminary investigation. It was an invalid type error from the native side.

@rrousselGit
Copy link
Contributor

Agreed with Russell, we'll want tests.

I also believe we'll want iOS and web support too.

@lColinDl
Copy link
Contributor Author

iOS worked out of the box and if I look at the code for web it should also work. It is just Android that was not working. I wrote the test for the change now in the same way as the existing tests. Hope its fine now. I'm not sure why it's not working for you @russellwheatley and what exactly you tested, but the implementation works for me for all enhanced ecommerce events that I had to implement by now. If there is a specific case that is not working, please specify it for me, so I can test and adjust the code.

@@ -30,5 +30,23 @@ void main() {
expect(
FirebaseAnalytics().setCurrentScreen(screenName: 'testing'), completes);
expect(FirebaseAnalytics().logEvent(name: 'testing'), completes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test for maps inside maps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff so far, @lColinDl 🎉 . I agree with @rrousselGit, we should probably test a nested map as well 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted the tests. Now there is an Array containing a Map containing a Map. Hope that is enough :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Could you also add a test for the throw IllegalArgumentException?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Salakar
Copy link
Member

Salakar commented Apr 1, 2021

Just waiting on the below if possible then I think we're good to merge:

image

@Salakar Salakar changed the title fix(firebase_analytics): Support complex data structures like list and map on Android fix(firebase_analytics): support complex data structures like list and map on Android Apr 1, 2021
@Salakar Salakar added plugin: analytics platform: android Issues / PRs which are specifically for Android. blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Apr 1, 2021
rrousselGit
rrousselGit previously approved these changes Apr 1, 2021
@Salakar
Copy link
Member

Salakar commented Apr 6, 2021

Looks like there's a failing Web test, could you take a look please? Thanks?

@rrousselGit rrousselGit dismissed their stale review April 6, 2021 14:01

failing test

Copy link
Member

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@russellwheatley russellwheatley merged commit 84d6024 into firebase:master Apr 7, 2021
@firebase firebase locked and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. cla: yes platform: android Issues / PRs which are specifically for Android. plugin: analytics
Projects
None yet
6 participants