chore(analytics): drop unused Amplitude events and sample the rest - #14606
Merged
Merged
Conversation
|
- Web: turn off the SDK's automatic session_start/session_end, page view, form and file download events. Everything left out of defaultTracking defaults to on, and session_start and [Amplitude] Page Viewed are deleted in the project, so they were sent and counted by the proxy but dropped. - Web: send Session Start once per Amplitude session instead of every page load. - Web and mobile: skip identify when the traits have not changed (resent weekly). - Web and embed: no analytics for crawlers and automated browsers. - Embed: drop the per-load Session Start; Embed: Open Player already fires on every load and now carries source. - Mobile: only report Buffering Time for buffers of at least 1s. - Explore: Section View once per section per app session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove Session Start everywhere. The platform it carried is now a `client` user property, set when it changes for a device (web, mobile, embed). - Remove every event that is not core and is not used by an Amplitude chart or dashboard viewed or edited in the last 12 months, with its call sites, enum entry and type. Embed: Open Player and Embed: Player Error go too. - Send non-core events from a fixed 10% of devices, picked by a hash of the Amplitude device id, with a `sampleRate` property. Core events are an explicit allowlist in @audius/common (CORE_ANALYTICS_EVENTS) and are always sent. - Drop the analytics-only `source` props on SearchTag, ExternalLink and UserGeneratedText. Chat Entry Point is still fired from ShareModal and ShareDrawer, which are being changed in a separate PR; the metrics proxy drops it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dylanjeffers
force-pushed
the
chore/trim-analytics-noise
branch
from
September 24, 2026 19:09
20abde5 to
5321bb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Amplitude proxy (gain2.audius.co, metrics-worker) caps us at 1.95M events a month, and it has been hitting that in about 4 days. This PR removes most of the events the clients send: anything that's a duplicate, automatic, from a bot, or not used by any recent chart. What's left, apart from the core events, goes out from 10% of devices.
Volume before (Amplitude stored totals, Aug 31 to Sep 4, 5 days, project 265616)
clientuser propertyWeb plus embed is 314k of that, iOS 66k and Android 64k. Some events are sent but never stored, so they don't show up above:
[Amplitude] Page Viewed,session_start(both deleted in the project) and$identify.What changed
1. SDK automatic events off, and bots skipped
defaultTracking: it now names every option. Any option left out defaults to on (isTrackingEnabledin analytics-client-common), so{ sessions: true }had also been sending page views, form events and file downloads. Attribution stays on.navigator.webdrivertraffic gets no analytics on web or embed. On Aug 1-3, one Singapore "Chrome 145" crawler sent 371k Session Starts from 347k new devices.2. Session Start removed everywhere
The platform it carried (
Android Web,iOS Web,MacOS,Windows,Linux,Desktop Web,iOS App,Android App,Embed) is now aclientuser property. It's set through identify only when it changes for a device. Amplitude already computes sessions from session ids.3. Events removed (call site, enum entry and type)
The rule: an event is removed if it isn't core and isn't referenced by an Amplitude chart, dashboard or cohort that was viewed or edited in the last 12 months.
I listed all 642 charts, dashboards, cohorts and notebooks in project 265616, then read the definitions of the 33 charts and 7 dashboards used since 2025-09-24. None of the 11 cohorts or 3 notebooks had been used in that window.
The analytics-only
sourceprops on SearchTag, ExternalLink and UserGeneratedText (linkSource) are removed too.4. Sampling
CORE_ANALYTICS_EVENTSin@audius/common(models/AnalyticsSampling.ts), plus the mobile share-channel events.sampleRate: 0.1, so counts scale back up by dividing bysampleRate. What's still sampled after step 3 is only chart-backed: Play Queue (all 7), Feed: Change view, Error Page, Account Health: Meter Full, Folder: Delete, the Playlist Library folder moves, Offline Play, and Chat Entry Point.services/analytics/amplitude.tsand mobileservices/analytics.ts. Embed now only sends core events.Why the proxy counts about 5.5x what Amplitude stores
$identifyon every account load. Together that's roughly 50-70k a day.insert_id, so it bills only one copy. AudiusProject/metrics-worker#1 gives back events Amplitude doesn't accept, and now also drops the removed event types that older clients still send.Estimate against the 1.95M cap
Kept even though it's low value
Behavior changes to review
store/ui/modals/sagas.tsnow returns no sagas.trackModalOpened/trackModalClosedstill get dispatched and now do nothing.Tests
tscpasses for common, web and mobile. The local sdk and spl dist were rebuilt, because they were stale.exhaustive-depswarnings in the remix-contest host were already there.services/analytics/amplitude.test.ts: automatic events off, client property set once per device, core events always sent, about 10% of devices kept for non-core events withsampleRate, identify dedupe, and bots skipped.store/upload/selectors.test.ts, which fails the same way on an untouched checkout.🤖 Generated with Claude Code