Skip to content

[sentry/nextjs] sentry/tracing adds 30kb, can we opt-out ? #4722

@belgattitude

Description

@belgattitude

Problem Statement

Following the sentry/nextjs recommended approach, it's difficult to opt-out from tracing in the browser.

The sentry/tracing adds more or less 30kb to the browser final bundle which is a hard blocker in some circumstances.

Here's a tree map taken with the recommended approach and tested with @sentry/nextjs 6.18.2

image

Solution Brainstorm

I was able to remove the sentry/tracing from the browser, by importing sentry/react rather than sentry/nextjs

// import { init as sentryInit } from '@sentry/nextjs';
import { init as sentryInit } from '@sentry/react';

sentryInit({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  // tracesSampleRate: 1.0,
});

That reduced the bundle from 103kb to 73kb

image

The setup is belgattitude/nextjs-monorepo-example#1409

Is there any drawbacks or risks to this approach (apart from not sending traces) ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions