Files
moreminimore-chat/.hermes/plans/chatwoot-private/06-remove-amplitude.md
2026-08-16 00:12:29 +07:00

3.5 KiB

Runbook 06 — Remove Amplitude and Product Analytics

Goal: dashboard emits no user/account/page/event data to Amplitude or another analytics provider. Existing callers may keep a stable no-op adapter to reduce upstream conflicts.

SM-06.01 — Convert analytics specs to a no-egress contract

Modify: app/javascript/dashboard/helper/AnalyticsHelper/specs/helper.spec.js

Replace provider-behavior assertions with:

  • importing helper does not import/initialize Amplitude;
  • init, identify, track, and page return without network/provider calls;
  • methods accept existing signatures so callsites need no bulk rewrite;
  • passing a token cannot enable analytics.

Do not delete all tests. The no-op contract is the regression guard.

RED:

pnpm test app/javascript/dashboard/helper/AnalyticsHelper/specs/helper.spec.js

SM-06.02 — Make AnalyticsHelper provider-free no-op

Modify: app/javascript/dashboard/helper/AnalyticsHelper/index.js

Rules:

  • remove @amplitude/analytics-browser import;
  • retain exported class and default object for compatibility;
  • no dynamic import, fetch, beacon, image pixel, local queue, user/email/account serialization;
  • each public method is an explicit no-op.

GREEN:

pnpm test app/javascript/dashboard/helper/AnalyticsHelper/specs/helper.spec.js
pnpm eslint app/javascript/dashboard/helper/AnalyticsHelper/index.js app/javascript/dashboard/helper/AnalyticsHelper/specs/helper.spec.js

SM-06.03 — Remove dashboard token delivery

Modify:

  • app/controllers/dashboard_controller.rb
  • app/views/layouts/vueapp.html.erb
  • spec/controllers/dashboard_controller_spec.rb

Remove CLOUD_ANALYTICS_TOKEN from GLOBAL_CONFIG_KEYS and remove window.analyticsConfig serialization. Add response assertion that the rendered dashboard contains neither analyticsConfig nor configured test token.

Do not alter other global config keys.

Run:

bundle exec rspec spec/controllers/dashboard_controller_spec.rb
bundle exec rubocop app/controllers/dashboard_controller.rb spec/controllers/dashboard_controller_spec.rb

SM-06.04 — Remove SDK and installation config

Modify:

  • package.json
  • pnpm-lock.yaml via pnpm remove @amplitude/analytics-browser
  • config/installation_config.yml

Remove the CLOUD_ANALYTICS_TOKEN entry. Do not hand-edit unrelated lockfile entries.

GREEN:

pnpm install --frozen-lockfile
pnpm test app/javascript/dashboard/helper/AnalyticsHelper/specs/helper.spec.js
rg -n '@amplitude/analytics-browser|CLOUD_ANALYTICS_TOKEN|analyticsConfig' app config package.json pnpm-lock.yaml --glob '!enterprise/**'
git diff --check

Expected runtime/config matches: zero; compatibility helper filenames may remain.

Verified checkpoint status — 2026-08-16

  • a96b977 removed the Amplitude SDK, analytics token delivery, and window.analyticsConfig, but its controller regression exposed that an unrelated CLOUD_ANALYTICS_TOKEN returned by a config stub/source could still be serialized through window.globalConfig.
  • ced77af fixes the root cause by applying .slice(*GLOBAL_CONFIG_KEYS) before merging explicit app_config values.
  • Fresh pre-commit review deleg_f9644984 and exact post-commit review deleg_9b0a2f63 both passed with security_concerns=[] and logic_errors=[].
  • Ruby syntax, git diff --check, and the added-line security scan passed. Rails RSpec/RuboCop are blocked until the pinned Ruby 3.4.4/Bundler 2.5.16 toolchain is available.

Checkpoint commit: privacy: disable product analytics by construction