@atlassian/sentry-transport-forge

Custom transport for Sentry. Use it to send captured errors and messages from Forge runtime.

Usage no npm install needed!

<script type="module">
  import atlassianSentryTransportForge from 'https://cdn.skypack.dev/@atlassian/sentry-transport-forge';
</script>

README

Forge transport for Sentry

Custom transport for Sentry. Use it to send captured errors and messages from Forge runtime.

Usage

import { ForgeRuntimeTransport, ForgeRuntimeTransportOptions } from '@atlassian/sentry-transport-forge';
import { fetch } from '@forge/api';
import * as Sentry from '@sentry/node';

const DISABLE_INTEGRATIONS = [
    Sentry.Integrations.Http,
    Sentry.Integrations.OnUncaughtException,
    Sentry.Integrations.OnUnhandledRejection,
];
Sentry.init({
    dsn: process.env.SENTRY_DSN,
    // version 6.9.0 enables `autoSessionTracking` by default
    // `autoSessionTracking` uses `process.on('beforeExit')` which is not available in Forge runtime
    transport: ForgeRuntimeTransport,
    transportOptions: {
        dsn: process.env.SENTRY_DSN,
        fetch,
        logError: console.error,
    } as ForgeRuntimeTransportOptions,
    autoSessionTracking: false,
    // some integrations don't work well in Forge runtime
    // as they rely on Node.JS environment
    integrations: integrations => {
        return integrations.filter(integration => {
            return DISABLE_INTEGRATIONS.every(DisableIntegrationConstructor => {
                return !(integration instanceof DisableIntegrationConstructor);
            });
        });
    },
    ...restOptions,
});

Support

See Get help for how to get help and provide feedback.