Do I need to re-initialize the Sentry instance when using it in other files? (Node/Typescript)

Hi all

I am initializing Sentry at server start with the following code (Node/Typescript):

import * as Sentry from '@sentry/node';

Sentry.init({ dsn: process.env.SENTRY_URL, environment:process.env.ENV });

When I want to use this instance at other places within the server, can I just import it from the package as follows:

import * as Sentry from '@sentry/node';

Sentry.captureException(error);

Or do I need to re-initialize it again?

I was thinking that I could also create the initial Sentry instance as a const and export it so that I can easily import from the startup file at other places.

export const Sentry = require("@sentry/node");

Sentry.init({ dsn: process.env.SENTRY_URL, environment:process.env.ENV });

Thanks a lot!

I don’t think so.
I have one file with customizing captureException and captureMessage. In both, I don’t initialize Sentry. Just import * as Sentry from '@sentry/node';
I initialize Sentry (Sentry.init) only in main file of my app.