Integrations

Default Integrations

These integrations are enabled by default and integrate into the standard library or the interpreter itself. They are documented so you can be both aware of what they do and disable them if they cause issues.

To disable system integrations, set default_integrations => false when calling \Sentry\init().

ExceptionListenerIntegration

This integration catches all global uncaught exceptions and emits events when an error occurs.

To do so, it ensures that Sentry's ErrorHandler is registered, and adds a callback to it as an exception listener.

ErrorListenerIntegration

This integration hooks into the global PHP error_handler and emits events when an error occurs.

To do so, it ensures that Sentry's ErrorHandler is registered, and adds a callback to it as an error listener. By default, the ErrorHandler reserves 10 kilobytes of memory to handle fatal errors.

For some frameworks or projects, specific integrations are provided both officially and by third-party users that automatically register the error handlers. Please refer to their documentation.

By default, the errortypes option defaults to the value returned by the error_reporting() function, which can change at runtime. Alternately, you can set the option to a fixed value by setting its value to a bitmask of the PHP `E*constants in\Sentry\init()`. In this case, Sentry will log only errors of those specific types regardless of the current reporting level.

FatalErrorListenerIntegration

This integration catches all fatal errors and emits the corresponding events.

To do so, it ensures that Sentry's ErrorHandler is registered, and adds a callback to it as a fatal error listener.

RequestIntegration

This integration adds to the event request data:

  • HTTP method
  • URL (including the query string)
  • Body (by default only if the body is 10Kb or less)

If the send_default_pii option is enabled, it will also send the following PII:

  • IP address
  • Cookies
  • Headers

TransactionIntegration

This integration sets the transaction attribute of the event to the value found in the raw event payload or to the value of the PATH_INFO server var if present.

FrameContextifierIntegration

This integration reads excerpts of code around the line that originated an error.

EnvironmentIntegration

This integration fills the event data with PHP runtime and server OS information.

Optional Integrations

You can enable these integrations by passing them to the integrations option when initializing the Sentry SDK.

In this example, the optional ModulesIntegration is added:

Copied
\Sentry\init([
    'dsn' => '...',
    'integrations' => [
        new \Sentry\Integration\ModulesIntegration(),
    ],
]);

IgnoreErrorsIntegration

This integration decides whether an event should not be captured according to a series of options that must match with its data.

ModulesIntegration

This integration logs all the versions of the packages installed with Composer with the event details; the root project is also included.

Custom Integrations

You can customize the list of integration without disabling the default integration using the integrations option. You can pass a callable for advanced needs, though a fixed list of integrations will work in most use cases.

In the example below, all integrations are enabled except the ExceptionListenerIntegration. In addition, the ModulesIntegration is added.

Copied
\Sentry\init([
    'dsn' => '...',
    'integrations' => static function (array $integrations) {
        $integrations = array_filter($integrations, static function (\Sentry\Integration\IntegrationInterface $integration) {
            // Check if the integration if an instance of the exception listener and return false to remove it from the array
            if ($integration instanceof \Sentry\Integration\ExceptionListenerIntegration) {
                return false;
            }

            return true;
        });

        $integrations[] = new \Sentry\Integration\ModulesIntegration();

        return $integrations;
    },
]);
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").