import * as Sentry from "@sentry/browser"
import { Integrations } from "@sentry/tracing"

export const init = (dsn, tracingOrigins, environment) => {
    if (typeof window !== "undefined") {
        Sentry.init({
            dsn: dsn,
            integrations: [
                new Integrations.BrowserTracing({
                    tracingOrigins: tracingOrigins,
                    traceFetch: false,
                    traceXHR: false,
                }),
            ],
            environment: environment,
            tracesSampleRate: 1.0,
            debug: false,
        })
        console.log("Sentry initialized")
    }
}

export const currentTransaction = () =>
    Sentry.getCurrentHub().getScope().getTransaction()
