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

feat(firebase_analytics): retrieves appInstanceId property on native platforms if available #8689

Merged
merged 2 commits into from Jul 22, 2022

Conversation

willbryant
Copy link
Contributor

Add an appInstanceId property on FirebaseAnalytics, exporting the API from the underlying native Firebase library implementations.

Description

This value is needed to send server-side events through the Measurement Protocol as a part of the same session, and also useful for debugging to pair up with the data visible in DebugView and BigQuery.

Related Issues

Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR. Note that you'll have to prefix the issue numbers with flutter/flutter#.

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 (melos run 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.
  • No, this is not a breaking change.

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.

Hey @willbryant, nice work! Couple of things I'd like to see, please:

  1. Could you add another mock test for the platform interface here?
  2. Do you mind updating the java implementation to use the TaskCompletionSource like
    the example linked?

Thanks! 😄

@willbryant
Copy link
Contributor Author

Thanks for the code review @russellwheatley!

I'll wait till your PR is merged and rebase, so I don't create a merge conflict.

Just to understand the second point, do we still need to use a TaskCompletionSource when we already have a Task? I think I'd need to Tasks.await to get the value out of that Task to pass to taskCompletionSource.setResult?

@russellwheatley
Copy link
Member

Thanks for the code review @russellwheatley!

I'll wait till your PR is merged and rebase, so I don't create a merge conflict.

Just to understand the second point, do we still need to use a TaskCompletionSource when we already have a Task? I think I'd need to Tasks.await to get the value out of that Task to pass to taskCompletionSource.setResult?

@willbryant, yes, for consistency and to use the cachedThreadPool . You can do the following:

taskCompletionSource.setResult(Tasks.await(analytics.getAppInstanceId()));

@willbryant
Copy link
Contributor Author

Cool, that's basically what I did.

I added a try/finally for consistency with the others.

@willbryant willbryant force-pushed the analytics_app_instance_id branch 2 times, most recently from 8a26bb0 to 320ddbd Compare May 19, 2022 11:21
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.

Hey @willbryant, do you mind also updating analytics web so that it throws this exception, please?

@willbryant
Copy link
Contributor Author

Done, and squashed.

@russellwheatley
Copy link
Member

Hey @willbryant, do you mind also adding an e2e test to analytics if possible? 😄

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. plugin: analytics platform: android Issues / PRs which are specifically for Android. blocked: do-not-merge PR blocked externally and removed blocked: do-not-merge PR blocked externally labels Jul 11, 2022
@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Jul 12, 2022
@google-oss-bot
Copy link

Hey @willbryant. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@russellwheatley russellwheatley removed the Stale Issue with no recent activity label Jul 12, 2022
@willbryant willbryant force-pushed the analytics_app_instance_id branch 2 times, most recently from aced8b2 to 2a0226c Compare July 15, 2022 03:18
@willbryant
Copy link
Contributor Author

@russellwheatley I can't get e2e tests to run for the life of me, but I've pushed a draft, if you wouldn't mind approving a CI run.

@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 Jul 15, 2022
@willbryant
Copy link
Contributor Author

Struggling a bit without CI access, can't get the main e2e test directory to run locally. But, I discovered there's a sort of second copy under example/ in the plugin itself, which showed the same issue, so using that I made a bit more progress.

Hopefully the next run works better.

@russellwheatley
Copy link
Member

russellwheatley commented Jul 21, 2022

@willbryant run melos run format and all should be well. Tip for future: comment out all e2e tests here and run melos run test:e2e for testing analytics e2e (provided you've installed melos).

Some of the e2e's need the emulators running to work (e.g. firebase_database) so maybe that was your problem.

I'm also presuming you've ran melos bootstrap in the project directory 😄

@russellwheatley
Copy link
Member

ahh, you'll have to run flutter format .in tests/ directory. Melos doesn't pick that up at the moment 😞

This value is needed to send server-side events through the Measurement Protocol as a part of the same session, and also useful for debugging to pair up with the data visible in DebugView and BigQuery.
@willbryant
Copy link
Contributor Author

willbryant commented Jul 21, 2022

Hopefully that's it, thanks for your help :).

@russellwheatley russellwheatley changed the title feat(firebase_analytics): add appInstanceId property feat(firebase_analytics): retrieves appInstanceId property on native platforms if available Jul 22, 2022
@Lyokone Lyokone merged commit 7132d77 into firebase:master Jul 22, 2022
@firebase firebase locked and limited conversation to collaborators Aug 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. plugin: analytics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants