Skip to content

add google analytics to flutter_tools#3523

Merged
devoncarew merged 8 commits intoflutter:masterfrom
devoncarew:add_analytics
Apr 26, 2016
Merged

add google analytics to flutter_tools#3523
devoncarew merged 8 commits intoflutter:masterfrom
devoncarew:add_analytics

Conversation

@devoncarew
Copy link
Contributor

This adds support for sending anonymous usage data for flutter_tools to google analytics. It:

  • prints a message on first run, telling the user how to disable the analytics, and displaying the privacy policy
  • adds a new flutter config command, where analytics can be enabled and disabled
  • sends command usage, command timing, and crash data

We'll want to iterate on it to properly track the host OS and command parameters.

fix #1065

@sethladd
Copy link
Contributor

sethladd commented Apr 25, 2016

and command parameters

Do you mean "multi-arg commands" like flutter build apk ?

Also, thanks!! This is great :)

printStatus(
'The Flutter tool anonymously reports feature usage statistics and basic crash reports to improve\n'
'the tool over time; use "flutter config" to control this behavior. See our privacy policy:\n'
'https://www.google.com/intl/en/policies/privacy/.\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

remove trailing .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's there to complete the sentence :)

@Hixie
Copy link
Contributor

Hixie commented Apr 25, 2016

I think it is critical that we add a test that verifies that if you turn off analytics, we don't send any analytics.

_ga.sendException(message);
}

Future<Null> waitForLastPing() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this name is confusing. I know it's just the same as the underlying API's, but I think we should name it something clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ensureAnalyticsSent()?

@Hixie
Copy link
Contributor

Hixie commented Apr 25, 2016

LGTM if, and only if, we have a test that verifies that once you opt-out, we don't send analytics. Ideally this would test the following scenarios:

  • flutter create in two different directories, opt-out while in one, are you opted out of the other?
  • opt out then flutter upgrade (not sure how you simulate this usefully), are you still opted out?
  • opt out then change channel (alpha -> master, say), are you still opted out?

@Hixie
Copy link
Contributor

Hixie commented Apr 25, 2016

Also, please update our docs so that when they introduce the flutter tool, they mention how to opt-out.

// Check if this is the first run. If so, enable analytics. We show opt-out
// methods (flutter config) the first time the tool is run.
if (!_ga.hasSetOptIn) {
_isFirstRun = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we avoid sending analytics on the run where we give the opt-out information?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup; I'll update to not track the config command.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant on the first run. The one where we say how to opt-out. But yeah, not tracking the config command seems like an excellent idea also!

@devoncarew
Copy link
Contributor Author

Do you mean "multi-arg commands" like flutter build apk?

No, I meant things like --foo - flags and options to commands. flutter build apk would come in as apk. For the nested commands, we could manually override to something like build_apk.

@devoncarew
Copy link
Contributor Author

I'll add some tests and update the PR. We store the opt-out data in ~/.flutter, so it would work independent of the current project, or something like running flutter upgrade.

@devoncarew
Copy link
Contributor Author

(I'm going to rev. the usage package to make this easier to test.)

@devoncarew
Copy link
Contributor Author

devoncarew commented Apr 26, 2016

@Hixie, this PR has been updated quite a bit since the first review. It doesn't send any analytics at first; it doesn't send any analytics for the config command (in case the user is in the process of disabling analytics); we print the analytics state in the help for config now; we rev'd to 2.2.0 of usage to capture some changes that make testing easier; and there are two tests to verify that we don't send data when we shouldn't.

printStatus(
'The Flutter tool anonymously reports feature usage statistics and basic crash reports to Google to\n'
'help Google contribute improvements to Flutter over time. Use "flutter config" to control this\n'
'behavior. See Google\'s privacy policy: https://www.google.com/intl/en/policies/privacy/.\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

remove trailing "." in url

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

@Hixie
Copy link
Contributor

Hixie commented Apr 26, 2016

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter command should have analytics

3 participants