-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates analytics error handling to support checking delivery failures on Context #505
Conversation
…integration tests
… before plugin errors to analytics API calls
} from './test-plugins' | ||
|
||
describe('Analytics', () => { | ||
describe('plugin error behavior', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing 🙌
Just realized I missed one scenario - |
🦋 Changeset detectedLatest commit: 62e445e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This PR attempts to standardize how plugin errors impact analytics API calls and provides a straightforward way to check if event delivery failed.
Background
Errors in
enrichment
,destination
, andafter
plugins don't cause analytics calls to throw.before
plugins do, but what they throw depends on if retries are enabled or not. If there are no retries, their errors bubble up to the analytics call. If there are retries, the event'sContext
itself gets thrown.To further complicate things, source middleware (implemented as a
before
plugin) does not bubble errors ifnext
is never called, but does otherwise.Only
before
plugins and source middleware errors can cause event delivery to fail entirely, but the inconsistent behavior makes it difficult to write code that can react to these failures.Changes
The following has been changed:
analytics.track()
)before
plugins now support cancelation: this is a bug fix, existing test missed that this was brokenContext.failedDelivery()
is added, so now the following works:This also has the benefit that callbacks can now be invoked even on failures, so you can do:
Previously callbacks weren't being invoked if the analytics call threw.
Chore
Also updated the vscode launch.json so the actions work in
packages/browser
.