Custom Integrations

Learn how you can enable a custom integration.

In addition to the integrations that come with the SDK, you can also write custom integrations.

Custom integration must conform to the Integration interface.

A custom integration can be created and added to the SDK as follows:

Copied
function myAwesomeIntegration() {
  return {
    name: 'MyAwesomeIntegration',
    setupOnce() {
      // Do something when the SDK is initialized
    },
  };
}

Sentry.init({
  // ...
  integrations: [myAwesomeIntegration()],
});

The JavaScript Core Package (@sentry/core) also exports a helper function called defineIntegration to help with type-safety:

Copied
import {defineIntegration} from '@sentry/core';

const myAwesomeIntegration = defineIntegration(() => {
  return {
    name: 'MyAwesomeIntegration',
    setupOnce() {
      // Do something when the SDK is initialized
    },
  };
});

Sentry.init({
  // ...
  integrations: [myAwesomeIntegration()],
});
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").