Skip to content

toucan-js@3.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 06 Dec 07:39
· 81 commits to master since this release
aa70df8

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. :)

Breaking changes

  • Toucan now uses Envelopes protocol with POST /api/<project_id>/envelope/ endpoint, instead of previously used POST /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 on Scope. 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. Use Options type instead. Options type isn't a discriminated union anymore and contains all types.

  • event option has been removed. Use context option instead.

  • context.request is no longer used to track request data. If you want to track request data, use top-level request option instead.

  • allowedCookies, allowedHeaders, allowedSearchParams are no longer top level options, but options on new RequestData integration that is exported from the SDK. The Toucan client provides a shortcut for these options as requestDataOptions top level option. To migrate, either move them to requestDataOptions, or pass them to RequestData 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 and tracesSampler options no longer affect Sentry events. They only affect transactions. If you want to sample sentry events, use sampleRate 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, use RewriteFrames 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: '/' })],
    });