107 Commits

Author SHA1 Message Date
Patrick Linnane
d04430d1a5
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-26 14:09:13 -08:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
なつき
2e2db25496 Use spawn to replace fork + exec 2024-08-09 14:16:36 -07:00
なつき
5442a7e34f Honor homebrew curlrc config for analytics 2024-08-09 14:16:36 -07:00
Carlo Cabrera
ab4f14b359
utils/analytics: improve accuracy of GitHub Packages download counts
`millions_match.captures.first` will typically be a decimal (since it's
matched using `\d+\.\d+`), except we lose accuracy in the `#to_i`
conversion.

Before:
```
❯ brew info --analytics --github-packages-downloads sqlite
==> Analytics
==> install (30 days)
[snip]
==> GitHub Packages Downloads
1,009,898 (30 days)
```

After:

```
❯ brew info --analytics --github-packages-downloads sqlite
==> Analytics
==> install (30 days)
[snip]
==> GitHub Packages Downloads
1,199,898 (30 days)
```

In this case `1.19M` was being rounded down to `1M`.
2024-08-04 05:33:46 +08:00
Bo Anderson
af429d4f1a
utils/analytics: fix handling of newlines 2024-07-16 17:06:38 +01:00
Mike McQuaid
2d345d89eb
utils/analytics: strip out more data.
We've filter this out in `brew formula-analytics` too but let's avoid
sending it here in the first place so we can delete the
formula-analytics filtering later.
2024-07-14 13:15:09 -04:00
Mike McQuaid
b8ff4b3d23
Widen attestation verification rollout
Take 2 of https://github.com/Homebrew/brew/pull/17692 but with:

- provide and document `HOMEBREW_NO_VERIFY_ATTESTATIONS`
- don't try to run unless there's GitHub credentials
- don't try to run unless `gh` is installed
- don't try to run in CI

While we're here:
- split out a `Homebrew::EnvConfig.devcmdrun?` helper method
- add some missing `Homebrew::EnvConfig.github_api_token` presence
  checks
2024-07-14 11:50:57 -04:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
ecd96a2c51
utils/analytics: revert a test-bot analytics change.
https://github.com/Homebrew/brew/pull/17154#discussion_r1581102553 was
ignored by auto-merge, whoops.
2024-04-26 15:24:12 +01:00
Mike McQuaid
414e221990
utils/analytics: cleanup test-bot analytics.
Sort options to ensure consistent ordering and improve readability.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-04-26 14:57:52 +01:00
Mike McQuaid
28c3215dba
analytics: support command and test-bot analytics.
These are used to analyse which commands are used and the
success/failure rate of official taps using `brew test-bot`.
2024-04-25 17:38:04 +01:00
apainintheneck
226239da4c tests: remove unnecessary cache clearing
This PR removes all remaining unnecessary cache clearing in tests
from the codebase since we now clear all cachable classes between
tests making this functionally unnecessary.

Original PR to automatically clear caches:
- https://github.com/Homebrew/brew/pull/16746

I also moved the `Utils::Analytics` module to use cachable so
that we don't have to clear caches specifically in tests anymore.
2024-03-31 18:38:03 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
9259c345cc
utils/analytics: general cleanup.
We have plans to add analytics for commands and `brew test-bot`

This requires a certain amount of refactoring which I've done here.

There was also a bunch of legacy `*_influx_?` usage from when we used
both InfluxDB and Google Analytics that made sense to clean up and
excessive indirection.
2024-03-07 15:19:04 +00:00
Bo Anderson
1f483bfe71
utils/analytics: don't fail on invalid version 2023-11-29 15:56:05 +00:00
Mike McQuaid
dda839c27b
analytics: fix @ in formulae names with --github-packages-downloads 2023-07-26 16:46:23 +01:00
Mike McQuaid
16a36a0910
utils/analytics: new InfluxDB token.
This is created with a different user that's more desirable.
2023-07-18 16:22:23 +01:00
Mike McQuaid
77061817f7
Fix (again) InfluxDB analytics messaging
Address https://github.com/Homebrew/brew/pull/15688#issuecomment-1638725595

Fixes https://github.com/Homebrew/brew/issues/15678
2023-07-18 08:03:57 +01:00
Mike McQuaid
c2ce8e7033
utils/analytics: hide InfluxDB message correctly.
Fixes #15678
2023-07-17 19:26:10 +01:00
Bo Anderson
8adac8a53e
Merge pull request #15659 from SMillerDev/fix/analytics/source
analytics: use new AWS based influxdb
2023-07-10 20:19:29 +01:00
Sean Molenaar
fc48930a59
analytics: use new AWS based influxdb 2023-07-10 20:47:19 +02:00
Mike McQuaid
cd313adbe4
cmd/info: add (undocumented) --github-packages-downloads option.
This screen scrapes GitHub Packages download counts from HTML for a
core formula.

It's useful when figuring out the difference between our analytics
numbers (which people can opt-out of) and our bottle downloads (which
people cannot due to the way GitHub Packages works).
2023-06-16 15:39:49 +01:00
Mike McQuaid
75dd070395
Remove Google Analytics
We are now entirely migrated to InfluxDB so can remove all GA code.
2023-06-16 10:33:15 +01:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Mike McQuaid
4d8445e29d
analytics: improve InfluxDB cardinality
- roll InfluxDB token (we need to report to a new bucket to fix implicit schema)
- adjust various parameters
- separate default tags and fields
- send more fields and fewer tags (tags should have low cardinality)
- use `--data-binary` to match InfluxDB documentation
- document second precision for greater InfluxDB performance
- pass through tap name, formula/cask name, options separately
- pass `devcmdrun` as a tag
- avoid sending very high-cardinality `OS_VERSION` values
2023-03-20 15:26:47 +00:00
Issy Long
8e13a6e1f4
Merge pull request #14944 from issyl0/more-rubocop-naming-method-parameter-name
rubocop: Further trim `Naming/MethodParameterName` allowlist
2023-03-11 22:59:39 +00:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Douglas Eichelberger
02fd0422aa Enable typing in a few more files 2023-03-09 13:42:06 -08:00
Mike McQuaid
792ec7fc85
utils/analytics: tweaks constants.
This enables easier usage in `brew formula-analytics`.
2023-02-21 17:07:01 +00:00
Mike McQuaid
57844530a9
analytics: remove UUID.
We don't use this at all with InfluxDB and don't need it any more for GA
so let's just remove it.
2023-02-20 09:05:15 +00:00
Mike McQuaid
ad1213a7da
utils/analytics: make on_request a proper boolean.
Otherwise when it's `false` it's being turned into a `true` value.
2023-02-16 17:51:42 +00:00
Mike McQuaid
a83fef7b41
utils/analytics: cleanup data.
Based on reviewing InfluxDB buckets.
2023-02-16 13:15:04 +00:00
Mike McQuaid
ef8ad10741
utils/analytics: fix BuildError reporting.
Need to ensure we call the correct methods to avoid duplicates.
2023-02-16 12:59:46 +00:00
Mike McQuaid
e42cae19a5
Merge pull request #14647 from MikeMcQuaid/report_influxdb_default
analytics: report to InfluxDB by default.
2023-02-15 19:19:41 +00:00
Mike McQuaid
dfd4cd9b0c
analytics: update token.
We've deleted the old data and added a new bucket with a new token.
2023-02-15 17:32:34 +00:00
Mike McQuaid
769a8c5001
analytics: report to InfluxDB by default.
Now that this is ready: let's roll it out to everyone in 4.0.0.
2023-02-15 17:27:02 +00:00
Mike McQuaid
c5252817c2
analytics: refactor InfluxDB/Google handling. 2023-02-15 16:34:50 +00:00
Sean Molenaar
50e9247da4
fix: add better keys and fuller values to influxDB analytics 2023-02-15 14:12:05 +01:00
Bo Anderson
7ef0c48362
Fix analytics handling when core/cask taps are untapped 2023-02-15 05:31:08 +00:00
Sean Molenaar
61e5e19bdb
analytics: fix spelling
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2023-02-06 16:56:25 +01:00
Sean Molenaar
10e3c522f7
analytics: stop sending analytics in tests 2023-02-06 16:28:34 +01:00
Francois-Xavier Coudert
2b07d0d5bb analytics: fix URL typo 2023-01-26 21:24:50 +01:00
Sean Molenaar
59ebdab2b7
analytics: switch to InfluxDB for logging 2023-01-19 18:15:27 +01:00
Mike McQuaid
2d5eab2e1c
brew style --fix 2022-06-30 08:56:21 +01:00
Bo Anderson
40bbdc659e
Fix some Style/FetchEnvVar offences 2022-06-17 19:47:57 +01:00
Bo Anderson
a10b16828f
utils/analytics: use curl shim 2022-06-17 19:47:56 +01:00
Kyle Smith
7866a4b586 feat: support user-configured Google Analytics reporting
Allow users to set a custom Google Analytics tracking ID to report user behaviour
via new environment variable: $HOMEBREW_ADDITIONAL_GOOGLE_ANALYTICS_ID.

If provided, this tracking ID will be used _in addition to_ the default tracking
ID used by <https://brew.sh/analytics/>.
2021-10-19 10:49:43 -05:00