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

[rust] Selenium Manager decrease frequency of statistics reporting #13555

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

bonigarcia
Copy link
Member

Description

This PR makes SM decrease the frequency of statistics reporting, as requested and discussed on #13521.

To decrease this frequency, we rely on the value of TTL, one day by default. This way, when the same stats properties are used (i.e., the properties sent to Plausible: browser, browser_version, os, arch, lang, and selenium_version), the request to Plausible will be done only once. For that, the SM metadata file is used (~/.cache/selenium/sm-metadata.json). For example, when calling SM for the first time:

./selenium-manager --browser chrome --debug

DEBUG   Sending stats to Plausible: Props { browser: "chrome", browser_version: "", os: "windows", arch: "amd64", lang: "", selenium_version: "4.18-nightly" }
DEBUG   chromedriver not found in PATH
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
DEBUG   Output: "\r\r\n\r\r\nVersion=121.0.6167.140\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 121.0.6167.140
DEBUG   Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
DEBUG   Required driver: chromedriver 121.0.6167.85
DEBUG   chromedriver 121.0.6167.85 already in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\121.0.6167.85\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

After that, the metadata file will contain the following:

{
  "browsers": [],
  "drivers": [
    {
      "major_browser_version": "121",
      "driver_name": "chromedriver",
      "driver_version": "121.0.6167.85",
      "driver_ttl": 1707308646
    }
  ],
  "stats": [
    {
      "browser": "chrome",
      "browser_version": "",
      "os": "windows",
      "arch": "amd64",
      "lang": "",
      "selenium_version": "4.18-nightly",
      "stats_ttl": 1707308646
    }
  ]
}

The field stats_ttl is used in the following same calls (in terms of properties) to prevent requesting Plausible again. Only when stats_ttl is stale (i.e., in 1 day), the same properties will be sent to Plausible.

Note that, as discussed on Slack, the path for the new calls to Plausible is /sm-usage. Plausible already has counted my tests:

https://plausible.io/manager.selenium.dev

Motivation and Context

This PR implements #13521.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

LGTM.

@bonigarcia bonigarcia merged commit f38718b into trunk Feb 8, 2024
20 checks passed
@bonigarcia bonigarcia deleted the sm_stats_ttl branch February 8, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants