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

(CAT-1807) Remove analytics from the PDK #1339

Merged
merged 6 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions docs/pdk_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,65 +296,3 @@ $env:http_proxy="http://user:[email protected]:port"

$env:https_proxy="http://user:[email protected]:port"
```

## Analytics

### PDK data collection

PDK collects usage data to help us understand how it's being used and how we can
improve it. You can opt out of data collection at any time; see the section
below about opting out.

We collect these values for every analytics event:

- A random non-identifying user ID. This ID is shared with Puppet Bolt® analytics, if
you've installed Bolt and enabled analytics.
- PDK installation method (`package` or `gem`).
- Version of PDK.
- Operating system and version.

For every successful command line invocation of PDK, we collect:

- The PDK command executed, such as `pdk new module` or ``pdk validate``.
- Anonymised command options and arguments.
- The version of Ruby used to execute the command.
- The output formats for the command.
- `PDK_*` environment variables and their values, if set.
- Whether a template repository, if used, is `default` or `custom` — we do not
record the path to the template repo itself.
- If the default template repo is used, we collect events for each file
rendered, recording whether the file is `unmanaged`, `deleted`,
`customized`, or `default`. For customized files, we do not record what
changed, only that it was changed in the `.sync.yml` file.

> **Note:** All arguments and non-Boolean option values, except `--puppet-version` are redacted in our collected data

Invalid commands are submitted as a distinct analytics events with the arguments
and option values redacted.

To see the data PDK collects, add the `--debug` option to any `pdk` command. We
test the analytics calls strictly to ensure that no unexpected data is
accidentally passed in.

### Opting out of PDK data collection

The first time you run PDK, it asks you if you want to opt out of data
collection. To opt out of data collection after that, edit the `analytics.yml`
file, setting the `disabled` key to `true`.

```
disabled: true
```

The location of this configuration file depends on your operating system and
configuration:

- For most \*nix systems, where the `$XDG_CONFIG_HOME` variable is set:
`${XDG_CONFIG_HOME}/puppet/analytics.yml`.
- For most macOS systems, where the `$XDG_CONFIG_HOME` variable is not set:
`~/.config/puppet/analytics.yml`.
- For Windows: `%LOCALAPPDATA%/puppet/analytics.yml`.

You can also opt out of analytics by setting the environment variable
`PDK_DISABLE_ANALYTICS=true`. This is useful if you are using PDK in your CI
system.
10 changes: 5 additions & 5 deletions docs/pdk_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Usage:
pdk get config <key>
```

For example: `pdk config get user.analytics.disabled`
For example: `pdk config get user.module_defaults.author`

|Argument|Description|Value|Default|
|--------|-----------|-----|-------|
|`<key>`|The name, or name prefix, of the setting key to retrieve. Raises an error if the setting does not exist.|The full name of the setting, such as `user.analytics.disabled`. Alternatively, the beginning of the setting name, which retrieves all settings that match. For example, `user.analytics` returns all settings that start with user.analytics`user.analytics`.|If no `<key>` is passed, the command returns all configuration keys that it finds.|
|`<key>`|The name, or name prefix, of the setting key to retrieve. Raises an error if the setting does not exist.|The full name of the setting, such as `user.module_defaults.author`. Alternatively, the beginning of the setting name, which retrieves all settings that match. For example, `user.module_defaults` returns all settings that start with `user.module_defaults`.|If no `<key>` is passed, the command returns all configuration keys that it finds.|

## `pdk remove config` command

Expand All @@ -64,7 +64,7 @@ pdk remove config [--all] <key>

|Argument|Description|Value|Default|
|--------|-----------|-----|-------|
|`<key>`|Required. The configuration key to delete values for.|The full name of the setting, such as `user.analytics.disabled`. Alternatively, the beginning of the setting name, which retrieves all settings that match. For example, `user.analytics` returns all settings that start with user.analytics`user.analytics`.|No default. The `<key>` is required.|
|`<key>`|Required. The configuration key to delete values for.|The full name of the setting, such as `user.module_defaults.author`. Alternatively, the beginning of the setting name, which retrieves all settings that match. For example, `user.module_defaults` returns all settings that start with `user.module_defaults`.|No default. The `<key>` is required.|
|`<value>`|Required. The value to delete for the specified key. To delete all values, use the `--all` option instead of specifying values.|One or more specified values for the given configuration key.|No default. Either a `<value>` or the `--all` option is required for normal usage.|
|`--all`|Empties all values for the given key.|None.|When this option is passed, empties all values for the specified key.|

Expand All @@ -79,11 +79,11 @@ Usage:
pdk set config [--type|--as <typename>] [--force] <key> [<value>]
```

For example: `pdk set config --type boolean user.analytics.disabled false`
For example: `pdk set config --type boolean user.module_defaults.author john_doe`

|Argument|Description|Value|Default|
|--------|-----------|-----|-------|
|`<key>`|Required. The configuration key to set, change, or add values for.|The full name of the setting, such as `user.analytics.disabled`.|No default. The `<key>` is required.|
|`<key>`|Required. The configuration key to set, change, or add values for.|The full name of the setting, such as `user.module_defaults.author`.|No default. The `<key>` is required.|
|`<value>`|Required. The value to set for the specified key.|One or more valid values for the specified `<key>`.|No default. One or more values are required.|
|`–-add`|Treats a user-defined configuration key as a multi-value key.|None.|This option treats the value as a list of values.|
|`--force`|Runs the command, making literal changes without prompting for confirmation.|None.|By default, prompts are enabled.|
Expand Down
14 changes: 0 additions & 14 deletions lib/pdk.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module PDK
autoload :Analytics, 'pdk/analytics'
autoload :AnswerFile, 'pdk/answer_file'
autoload :Bolt, 'pdk/bolt'
autoload :Config, 'pdk/config'
Expand Down Expand Up @@ -58,17 +57,4 @@ def self.feature_flag?(flagname)

requested_feature_flags.include?(flagname)
end

def self.analytics
@analytics ||= PDK::Analytics.build_client(
logger: PDK.logger,
disabled: PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK.config.get_within_scopes('analytics.disabled', ['user', 'system']),
user_id: PDK.config.get_within_scopes('analytics.user-id', ['user', 'system']),
app_id: "UA-139917834-#{PDK::Util.development_mode? ? '2' : '1'}",
client: :google_analytics,
app_name: 'pdk',
app_version: PDK::VERSION,
app_installer: PDK::Util.package_install? ? 'package' : 'gem'
)
end
end
30 changes: 0 additions & 30 deletions lib/pdk/analytics.rb

This file was deleted.

141 changes: 0 additions & 141 deletions lib/pdk/analytics/client/google_analytics.rb

This file was deleted.

25 changes: 0 additions & 25 deletions lib/pdk/analytics/client/noop.rb

This file was deleted.

18 changes: 0 additions & 18 deletions lib/pdk/analytics/util.rb

This file was deleted.

2 changes: 0 additions & 2 deletions lib/pdk/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Command
class CriExitException
def initialize(is_error:)
@is_error = is_error
PDK.analytics.event('CLI', 'invalid command', label: PDK::CLI.anonymised_args.join(' ')) if error?
end
end
end
Expand Down Expand Up @@ -56,7 +55,6 @@ def self.anonymised_args

def self.run(args)
@args = args
PDK::Config.analytics_config_interview! unless PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK::Config.analytics_config_exist?
@base_cmd.run(args)
rescue PDK::CLI::ExitWithError => e
PDK.logger.send(e.log_level, e.message)
Expand Down
2 changes: 0 additions & 2 deletions lib/pdk/cli/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module CLI
log_level: :info
)

PDK::CLI::Util.analytics_screen_view('build', opts)

module_metadata = PDK::Module::Metadata.from_file('metadata.json')

# TODO: Ensure forge metadata has been set, or call out to interview
Expand Down
2 changes: 0 additions & 2 deletions lib/pdk/cli/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ module CLI
screen_view_name << args[0] if args.size >= 1
screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'

PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))

# Ensure that the correct Ruby is activated before running command.
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
Expand Down
2 changes: 0 additions & 2 deletions lib/pdk/cli/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ module CLI

PDK::CLI::Util.validate_puppet_version_opts(processed_options)

PDK::CLI::Util.analytics_screen_view('console', args)

# TODO: figure out if we need to remove default configs set by puppet
# so it is scoped for the module only
# "--environmentpath"...
Expand Down
2 changes: 0 additions & 2 deletions lib/pdk/cli/convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ module CLI

PDK::CLI::Util.validate_template_opts(opts)

PDK::CLI::Util.analytics_screen_view('convert', opts)

if opts[:'skip-interview'] && opts[:'full-interview']
PDK.logger.info 'Ignoring --full-interview and continuing with --skip-interview.'
opts[:'full-interview'] = false
Expand Down
Loading