toucan-js@3.0.0
This is a complete rewrite of toucan-js
. The goal of this update is to reuse more components from @sentry/core, fix long-standing issues with source maps, and provide starters using various bundlers (esbuild, rollup, vite, webpack).
The good news is that toucan-js
now supports pretty much all SDK options and methods provided in official Sentry SDKs for JavaScript that you all are used to and love.
The bad news is that I may fail to document all breaking changes, because toucan-js
now delegates to a lot of code written by someone else. So use this release with caution. :)
- All methods and options available on Hub that previously weren't available or didn't work are now supported. This includes integrations!
- On integrations: some integrations from @sentry/integrations might not work because they use globals, or modify global runtime methods (such as console.log). Refer to README file that documents all supported integrations.
- This monorepo now provides quick starts written in TypeScript, with source maps support and local live reloading experience using open source Cloudflare Workers runtime.
- Total bundle size reduced from
65.3kB
to44.3kB
. This is thanks to replacing stacktrace-js with our own stack parser. Pretty cool given that we added a ton of new features at the same time!
Breaking changes
-
Toucan
now uses Envelopes protocol withPOST /api/<project_id>/envelope/
endpoint, instead of previously usedPOST /api/<project_id>/store/
endpoint. -
Toucan
client is no longer the default export. It is now a named export.Before:
import Toucan from 'toucan-js';
After:
import { Toucan } from 'toucan-js';
-
setFingerprint
is no longer a top level method. This method is now available onScope
. There are many ways to configure scope:
Option 1:
const sentry = new Toucan({
dsn: env.SENTRY_DSN,
context,
request,
initialScope: {
fingerprint: [...]
}
});
Option 2:
const sentry = new Toucan({...});
sentry.configureScope(scope => scope.setFingerprint([...]))
Option 3:
const sentry = new Toucan({...});
sentry.withScope((scope) => scope.setFingerprint([...]));
-
OtherOptions
type has been removed. UseOptions
type instead.Options
type isn't a discriminated union anymore and contains all types. -
event
option has been removed. Usecontext
option instead. -
context.request
is no longer used to track request data. If you want to track request data, use top-levelrequest
option instead. -
allowedCookies
,allowedHeaders
,allowedSearchParams
are no longer top level options, but options on newRequestData
integration that is exported from the SDK. The Toucan client provides a shortcut for these options asrequestDataOptions
top level option. To migrate, either move them torequestDataOptions
, or pass them toRequestData
integration.Before:
import Toucan from 'toucan-js'; const sentry = new Toucan({ dsn: '...', context, allowedCookies: ['myCookie'], allowedHeaders: ['user-agent'], allowedSearchParams: ['utm-source'], });
After (option 1):
import { Toucan } from 'toucan-js'; const sentry = new Toucan({ dsn: '...', context, requestDataOptions: { allowedCookies: ['myCookie'], allowedHeaders: ['user-agent'], allowedSearchParams: ['utm-source'], }, });
After (option 2):
import { Toucan, RequestData } from 'toucan-js'; const sentry = new Toucan({ dsn: '...', context, integrations: [new RequestData({{ allowedCookies: ['myCookie'], allowedHeaders: ['user-agent'], allowedSearchParams: ['utm-source'], }})], });
-
allowed*
options now support boolean values on top of lists and regexes.true
allows everything,false
denies everything. -
tracesSampleRate
andtracesSampler
options no longer affect Sentry events. They only affect transactions. If you want to sample sentry events, usesampleRate
option. Refer to https://docs.sentry.io/platforms/javascript/configuration/sampling/ for more information. -
pkg
option has been removed. -
rewriteFrames
option has been removed. To migrate, useRewriteFrames
integration from @sentry/integrations.Before
import Toucan from 'toucan-js'; const sentry = new Toucan({ dsn: '...', context, rewriteFrames: { root: '/', }, });
After
import { RewriteFrames } from '@sentry/integrations'; import { Toucan } from 'toucan-js'; const sentry = new Toucan({ dsn: '...', context, integrations: [new RewriteFrames({ root: '/' })], });