Repository navigation
fix(telemetry): keep analytics errors out of the app console - #421
Open
dhivadhiva wants to merge 1 commit into
Open
dhivadhiva wants to merge 1 commit into
dhivadhiva wants to merge 1 commit into
Conversation
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.
Collaborator
🟡 Heimdall Review Status
|
This branch has not been deployed
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.
Summary
The vendored analytics script sends every internal and request failure to its
onErroroption. The default handler isconsole.error. When an ad blocker drops thecca-lite.coinbase.comrequests, every app that loads the SDK gets this in its console:App developers can't do anything about that line. The SDK already passes
showDebugLogging: false, so telemetry is meant to stay quiet.Changes:
initCCA.tspasses a no-oponErrortoClientAnalytics.init, so telemetry failures stay inside the SDK.ca.d.tsdeclares theonErroroption, whichinit()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.tsand the vendoredca.jsare identical in both repos.The browser's own
Failed to load resource: net::ERR_BLOCKED_BY_CLIENTlines for the blocked requests remain, because page scripts can't suppress them.How did you test your changes?
onErrorgiven toinitwith the error an ad blocker produces and asserts nothing reachesconsole.error. It fails onmasterand passes with this change. I also updated the existing exact-params assertion.yarn typecheckand Biome lint and format checks are clean. The telemetry tests pass.dist/base-account.min.js). The page calledcreateBaseAccountSDK()and made a fewgetProvider().request()calls. Everycca-lite.coinbase.comrequest was aborted withblockedbyclient, the same way an ad blocker does it.Console before (master
1c310570):Console after: