From 012869f97166ce613783c565d7a4c4fa14de5e57 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Wed, 3 Aug 2022 14:44:34 -0400 Subject: [PATCH] Fleet Premium: de-anonymize usage stats (#7013) --- changes/issue-6384-deanonymize-usage-stats | 2 ++ cmd/fleet/serve_test.go | 3 +- cmd/fleetctl/preview.go | 6 ++-- cmd/fleetctl/setup.go | 2 +- docs/Using-Fleet/Usage-statistics.md | 5 ++-- .../ConfirmationPage/ConfirmationPage.tsx | 6 ++-- .../cards/Statistics/Statistics.tsx | 2 +- .../admin/AppSettingsPage/cards/constants.ts | 1 + server/datastore/mysql/statistics.go | 4 +++ server/datastore/mysql/statistics_test.go | 29 +++++++++++++++---- server/fleet/statistics.go | 1 + .../webhooks/receive-usage-analytics.js | 1 + website/api/models/HistoricalUsageSnapshot.js | 1 + website/assets/js/cloud.setup.js | 2 +- 14 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 changes/issue-6384-deanonymize-usage-stats diff --git a/changes/issue-6384-deanonymize-usage-stats b/changes/issue-6384-deanonymize-usage-stats new file mode 100644 index 0000000000..1ea819746e --- /dev/null +++ b/changes/issue-6384-deanonymize-usage-stats @@ -0,0 +1,2 @@ +* Fleet Premium: De-anonymize usage statistics by adding an `organization` property to the usage statistics payload. For Fleet Free instances, organization is reported as "unknown". To turn off usage statistics in the Fleet UI, head to **Settings > Organization settings > Usage statistics**, de-select the "Enable usage statistics" checkbox, and select **Save**. + diff --git a/cmd/fleet/serve_test.go b/cmd/fleet/serve_test.go index d478e97eaa..f4b36504d1 100644 --- a/cmd/fleet/serve_test.go +++ b/cmd/fleet/serve_test.go @@ -62,6 +62,7 @@ func TestMaybeSendStatistics(t *testing.T) { }, }, StoredErrors: []byte(`[]`), + Organization: "Fleet", }, true, nil } recorded := false @@ -73,7 +74,7 @@ func TestMaybeSendStatistics(t *testing.T) { err := trySendStatistics(context.Background(), ds, fleet.StatisticsFrequency, ts.URL, fleetConfig, &fleet.LicenseInfo{Tier: "premium"}) require.NoError(t, err) assert.True(t, recorded) - assert.Equal(t, `{"anonymousIdentifier":"ident","fleetVersion":"1.2.3","licenseTier":"premium","numHostsEnrolled":999,"numUsers":99,"numTeams":9,"numPolicies":0,"numLabels":3,"softwareInventoryEnabled":true,"vulnDetectionEnabled":true,"systemUsersEnabled":true,"hostsStatusWebHookEnabled":true,"numWeeklyActiveUsers":111,"hostsEnrolledByOperatingSystem":{"linux":[{"version":"1.2.3","numEnrolled":22}]},"storedErrors":[],"numHostsNotResponding":0}`, requestBody) + assert.Equal(t, `{"anonymousIdentifier":"ident","fleetVersion":"1.2.3","licenseTier":"premium","organization":"Fleet","numHostsEnrolled":999,"numUsers":99,"numTeams":9,"numPolicies":0,"numLabels":3,"softwareInventoryEnabled":true,"vulnDetectionEnabled":true,"systemUsersEnabled":true,"hostsStatusWebHookEnabled":true,"numWeeklyActiveUsers":111,"hostsEnrolledByOperatingSystem":{"linux":[{"version":"1.2.3","numEnrolled":22}]},"storedErrors":[],"numHostsNotResponding":0}`, requestBody) } func TestMaybeSendStatisticsSkipsSendingIfNotNeeded(t *testing.T) { diff --git a/cmd/fleetctl/preview.go b/cmd/fleetctl/preview.go index 657247c32a..61304c795d 100644 --- a/cmd/fleetctl/preview.go +++ b/cmd/fleetctl/preview.go @@ -302,7 +302,7 @@ Use the stop and reset subcommands to manage the server and dependencies once st return err } - // disable anonymous analytics collection and enable software inventory for preview + // disable analytics collection and enable software inventory for preview if err := client.ApplyAppConfig(map[string]map[string]bool{ "host_settings": {"enable_software_inventory": true}, "server_settings": {"enable_analytics": false}, @@ -319,12 +319,12 @@ Use the stop and reset subcommands to manage the server and dependencies once st return errors.New("Expected 1 active enroll secret") } - // disable anonymous analytics collection for preview + // disable analytics collection for preview if err := client.ApplyAppConfig(map[string]map[string]bool{ "server_settings": {"enable_analytics": false}, }, ); err != nil { - return fmt.Errorf("Error disabling anonymous analytics collection in app config: %w", err) + return fmt.Errorf("Error disabling analytics collection in app config: %w", err) } fmt.Println("Fleet will now log you into the UI automatically.") diff --git a/cmd/fleetctl/setup.go b/cmd/fleetctl/setup.go index 71913b7e73..5adac9cf90 100644 --- a/cmd/fleetctl/setup.go +++ b/cmd/fleetctl/setup.go @@ -105,7 +105,7 @@ func setupCommand() *cli.Command { return fmt.Errorf("error setting token for the current context: %w", err) } - fmt.Println("Fleet Device Management Inc. periodically collects anonymous information about your instance.\nSending usage statistics from your Fleet instance is optional and can be disabled in settings.") + fmt.Println("Fleet Device Management Inc. periodically collects information about your instance.\nSending usage statistics from your Fleet instance is optional and can be disabled in settings.") fmt.Println("[+] Fleet setup successful and context configured!") return nil diff --git a/docs/Using-Fleet/Usage-statistics.md b/docs/Using-Fleet/Usage-statistics.md index d242243d4c..06c009ce3d 100644 --- a/docs/Using-Fleet/Usage-statistics.md +++ b/docs/Using-Fleet/Usage-statistics.md @@ -4,7 +4,7 @@ ℹ️ In Fleet 4.0, Usage statistics were introduced. ``` -Fleet Device Management Inc. periodically collects anonymous information about your instance. +Fleet Device Management Inc. periodically collects information about your instance. ## What is included in usage statistics in Fleet? @@ -15,6 +15,7 @@ Fleet Device Management Inc. periodically collects anonymous information about y "anonymousIdentifier": "9pnzNmrES3mQG66UQtd29cYTiX2+fZ4CYxDvh495720=", "fleetVersion": "x.x.x", "licenseTier": "free", + "organization": "Fleet", "numHostsEnrolled": 999, "numUsers": 999, "numTeams": 999, @@ -89,7 +90,7 @@ Fleet Device Management Inc. periodically collects anonymous information about y } ``` -- All statistics are anonymous and contain no personal information about any particular device, organization, or person. +- Statistics contain no personal information about any particular device or person. - Sending Usage statistics from your Fleet instance is optional and can be disabled. diff --git a/frontend/components/forms/RegistrationForm/ConfirmationPage/ConfirmationPage.tsx b/frontend/components/forms/RegistrationForm/ConfirmationPage/ConfirmationPage.tsx index ff2ae7c6b5..34553a314c 100644 --- a/frontend/components/forms/RegistrationForm/ConfirmationPage/ConfirmationPage.tsx +++ b/frontend/components/forms/RegistrationForm/ConfirmationPage/ConfirmationPage.tsx @@ -98,9 +98,9 @@ const ConfirmationPage = ({ {importOsqueryConfig()}

- Fleet Device Management Inc. periodically collects anonymous information - about your instance. Sending usage statistics from your Fleet instance - is optional and can be disabled in settings. + Fleet Device Management Inc. periodically collects information about + your instance. Sending usage statistics from your Fleet instance is + optional and can be disabled in settings.