Skip to content

fix(telemetry): keep analytics errors out of the app console - #421

Open
dhivadhiva wants to merge 1 commit into
base:masterfrom
dhivadhiva:fix/silence-analytics-console-errors
Open

dhivadhiva wants to merge 1 commit into
base:masterfrom
dhivadhiva:fix/silence-analytics-console-errors

Conversation

@dhivadhiva

@dhivadhiva dhivadhiva commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

The vendored analytics script sends every internal and request failure to its onError option. The default handler is console.error. When an ad blocker drops the cca-lite.coinbase.com requests, every app that loads the SDK gets this in its console:

Analytics SDK: TypeError: Failed to fetch {context: 'AnalyticsSDKApiError'}

App developers can't do anything about that line. The SDK already passes showDebugLogging: false, so telemetry is meant to stay quiet.

Changes:

  • initCCA.ts passes a no-op onError to ClientAnalytics.init, so telemetry failures stay inside the SDK.
  • ca.d.ts declares the onError option, which init() already accepts: it merges its options over the defaults.

This is the same fix as coinbase/coinbase-wallet-sdk#1938. The error was reported in coinbase/coinbase-wallet-sdk#1804. initCCA.ts, its test, ca.d.ts and the vendored ca.js are identical in both repos.

The browser's own Failed to load resource: net::ERR_BLOCKED_BY_CLIENT lines for the blocked requests remain, because page scripts can't suppress them.

How did you test your changes?

  • Added a unit test that calls the onError given to init with the error an ad blocker produces and asserts nothing reaches console.error. It fails on master and passes with this change. I also updated the existing exact-params assertion.
  • yarn typecheck and Biome lint and format checks are clean. The telemetry tests pass.
  • Ran an end-to-end check in headless Chrome with the built UMD bundle (dist/base-account.min.js). The page called createBaseAccountSDK() and made a few getProvider().request() calls. Every cca-lite.coinbase.com request was aborted with blockedbyclient, the same way an ad blocker does it.

Console before (master 1c310570):

[error] Failed to load resource: net::ERR_BLOCKED_BY_CLIENT   (x3, from the browser)
[error] Analytics SDK: TypeError: Failed to fetch {"context":"AnalyticsSDKApiError"}

Console after:

[error] Failed to load resource: net::ERR_BLOCKED_BY_CLIENT   (x3, from the browser)

The vendored analytics script reports every failure through its onError
option, which defaults to console.error. When an ad blocker drops the
cca-lite.coinbase.com requests, every app using the SDK logs
"Analytics SDK: TypeError: Failed to fetch".

Pass a no-op onError so telemetry failures stay inside the SDK, and
declare the option in the vendor typings.
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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.

2 participants