Skip to content

feat: make analytics_opt_out the single switch for error reporting - #3538

Open
vpetersson-bot wants to merge 1 commit into
masterfrom
feat/single-analytics-opt-out
Open

vpetersson-bot wants to merge 1 commit into
masterfrom
feat/single-analytics-opt-out

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

What

analytics_opt_out in ~/.anthias/anthias.conf becomes the one switch for everything that reports home: Google Analytics, Anthias's own Sentry, and Sentry in anthias-wifi-connect.

Why

Today the opt-out turns off GA and strips PII from Sentry events, but crash reports still go out. The Wi-Fi setup service (wifi-connect, which now reports to Sentry upstream) ignores it entirely. To really opt out, an operator had to set SENTRY_DSN as well and add WIFI_CONNECT_NO_SENTRY=true to docker-compose.yml by hand. upgrade_containers.sh regenerates that file from its template on every run, so the hand edit was lost on each upgrade.

How

  • django_project/settings.py: the default Sentry DSN is empty when analytics_opt_out is on. An explicit SENTRY_DSN still wins, so an operator who points Anthias at their own Sentry keeps that.
  • bin/analytics_opt_out.sh (new): prints true/false for the key, using the same rules as configparser's getboolean (case-insensitive key, = or :, 1/yes/true/on). A missing file, missing key or unexpected value gives false, which is also the server's default. It always prints exactly one word because wifi-connect rejects values it can't parse, and a rejected value would stop the portal starting.
  • bin/upgrade_containers.sh exports the answer before envsubst, and docker-compose.yml.tmpl passes it to the wifi-connect service as WIFI_CONNECT_NO_SENTRY. The existing up -d --no-start anthias-wifi-connect recreates the container when its definition changes, so the setting takes effect on the next upgrade and stays in place after that.
  • Balena: an OTA compose file can't read a device's anthias.conf, and wifi-connect is an upstream FROM scratch image that only reads environment variables. On balena the docs therefore say to set the device variable WIFI_CONNECT_NO_SENTRY=true as well. The balena templates are unchanged.
  • Docs: a new FAQ entry ("How do I turn off analytics and error reporting?"), an "Error reporting" section on the Wi-Fi setup page, and the comment in the shipped anthias.conf.

Testing

  • tests/test_analytics_opt_out_script.py (new): runs the helper against true, false and malformed values, on/off as written by AnthiasSettings.save(), CRLF line endings, commented-out keys, the wrong section and a missing file, and checks that its answer matches configparser. It also checks that the template uses the variable and that the upgrade script exports it before rendering.
  • tests/test_sentry.py: the DSN-default helper and the pinned source expression now cover the opt-out.
  • pytest on the sentry, telemetry, settings, wifi-connect, upgrade-script, core-dump and balena-compose suites: 264 passed. ruff check and ruff format --check pass, and shellcheck is clean on the new script.
  • Rendered the template with envsubst and confirmed WIFI_CONNECT_NO_SENTRY=true ends up in the wifi-connect service.
  • Not tested on a device yet.

🤖 Generated with Claude Code

analytics_opt_out in anthias.conf used to turn off GA telemetry and
strip PII from Sentry, but crash reports still went out, and the
anthias-wifi-connect container kept reporting regardless. Opting out
meant also setting SENTRY_DSN and adding WIFI_CONNECT_NO_SENTRY to
docker-compose.yml by hand, which every upgrade then threw away.

- settings.py: the default Sentry DSN is empty when the operator opted
  out. An explicit SENTRY_DSN still wins.
- bin/analytics_opt_out.sh reads the key the way configparser does;
  upgrade_containers.sh renders its answer into the wifi-connect
  service as WIFI_CONNECT_NO_SENTRY on every run, so the opt-out
  survives upgrades.
- Docs: FAQ entry, a section on the WiFi setup page, and the comment in
  the shipped anthias.conf. Balena can't propagate a file setting into
  another service, so it is documented as a device variable there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
@vpetersson-bot
vpetersson-bot requested a review from a team as a code owner November 30, 2026 17:33
Copilot AI lite review requested due to automatic review settings November 30, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants