# justbetter/magento2-sentry

> Magento 2 Logger for Sentry

`composer require justbetter/magento2-sentry`

Canonical URL: https://packagento.com/justbetter/magento2-sentry

## At a glance

- **Vendor**: justbetter (https://packagento.com/justbetter.md)
- **Latest version**: 4.5.5 — released 2026-01-27
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/justbetter/magento2-sentry and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require justbetter/magento2-sentry:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Magento 2 Logger for Sentry

## README

<a href="https://github.com/justbetter/magento2-sentry" title="JustBetter">
    <img src="./.github/assets/banner.svg" alt="Package banner">
</a>


## Magento 2 Sentry Logger
[![Latest Version on Packagist](https://img.shields.io/packagist/v/justbetter/magento2-sentry.svg?style=flat-square)](https://packagist.org/packages/justbetter/magento2-sentry)
[![Total Downloads](https://img.shields.io/packagist/dt/justbetter/magento2-sentry.svg?style=flat-square)](https://packagist.org/packages/justbetter/magento2-sentry)
![Magento Support](https://img.shields.io/badge/magento-2.4-orange.svg?logo=magento&longCache=true&style=flat-square)
[![PHPStan passing](https://img.shields.io/github/actions/workflow/status/justbetter/magento2-sentry/analyse.yml?label=PHPStan&style=flat-square)](https://github.com/justbetter/magento2-sentry/actions/workflows/analyse.yml)

This Magento 2 module integrates [Sentry](https://github.com/getsentry/sentry-php) into magento 2. 
Depending on the log level configured in the backend of magento 2, notifications and errors can be sent to sentry.

### Features

- Send exceptions and logs to Sentry
- Show detailed context on thrown exceptions (Like Magento user/api consumer id)
- Easily control which events get sent to Sentry
- Backend and frontend error reporting
- Performance sampling ([tracing](https://docs.sentry.io/platforms/php/tracing/) & [profiling](https://docs.sentry.io/platforms/php/profiling/))
    - Database Queries (Detect N+1 queries)
    - Events
    - Template rendering
    - [Cache monitoring](https://docs.sentry.io/platforms/php/tracing/instrumentation/caches-module/)
    - [Queue monitoring](https://docs.sentry.io/platforms/php/tracing/instrumentation/queues-module/)
- Cron Monitoring
- Session replay
- Logrocket support
- Sentry feedback form after an error

### Installation
- `composer require justbetter/magento2-sentry`
- `bin/magento module:enable JustBetter_Sentry`
- `bin/magento setup:upgrade`
- `bin/magento setup:di:compile`
- `bin/magento setup:static-content:deploy`

### Configuration
For configuration with Adobe Cloud, [check below](#configuration-for-adobe-cloud).

This module uses the [Magento Deployment Configuration](https://devdocs.magento.com/guides/v2.3/config-guide/config/config-php.html) for most it's configuration. This means that you need to add this array to your `app/etc/env.php`:

```
'sentry' => [
    'dsn' => 'example.com',
    'logrocket_key' => 'example/example',
    'environment' => null,
    'log_level' => \Monolog\Level::Warning,
    'error_types' => E_ALL,
    'ignore_exceptions' => [],
    'mage_mode_development' => false,
    'js_sdk_version' => \JustBetter\Sentry\Block\SentryScript::CURRENT_VERSION,
    'tracing_enabled' => true,
    'traces_sample_rate' => 0.5,
    'disable_default_integrations' => [
        \Sentry\Integration\ModulesIntegration::class,
    ],
    'performance_tracking_enabled' => true,
    'performance_tracking_excluded_areas' => [\Magento\Framework\App\Area::AREA_ADMINHTML, \Magento\Framework\App\Area::AREA_CRONTAB],
    'profiles_sample_rate' => 0.5,
    'ignore_js_errors' => [],
    'enable_csp_report_url' => true,
]
```

Next to that there are some configuration options under Stores > Configuration > JustBetter > Sentry.

_(README truncated for .md surface. Full README on https://packagento.com/justbetter/magento2-sentry.)_

## Changelog

### [4.5.2] - 2025-11-27
#### Fixed
    * Fixed undefined message properties on queues (https://github.com/justbetter/magento2-sentry/pull/221)
    * Fixed error thrown on new setup:install (https://github.com/justbetter/magento2-sentry/pull/223)
    * Fixed activating sentry with invalid DSN (https://github.com/justbetter/magento2-sentry/pull/222)
### [4.5.1] - 2025-11-11
#### Added
    * Set Magento BP as default prefix
### [4.5.0] - 2025-11-04
#### Added
    * Added Logger support (https://github.com/justbetter/magento2-sentry/pull/201)
    * Added support for manual release defnition (https://github.com/justbetter/magento2-sentry/pull/204)
    * Added custom SDK identifier to module (https://github.com/justbetter/magento2-sentry/pull/208)
    * Added Cache instrumentation (https://github.com/justbetter/magento2-sentry/pull/206)
    * Added Queue instrumentation (https://github.com/justbetter/magento2-sentry/pull/210)
    * add csp report-uri if none is configured (https://github.com/justbetter/magento2-sentry/pull/216) thanks to https://github.com/rommelfreddy 
#### Changed
    * Replaced deprecated \Monolog\Logger::Warning (https://github.com/justbetter/magento2-sentry/pull/214) thanks to https://github.com/GeKVe
    * use configured dsn-hostname for csp connect-src policy (https://github.com/justbetter/magento2-sentry/pull/215) thanks to https://github.com/rommelfreddy 
### [4.4.0] - 2025-07-14
#### Fixed
    * Catch zend db adapter errors when database is missing (https://github.com/justbetter/magento2-sentry/pull/193)
    * Fix logrocket key type
#### Added
    * Add the ability to select job codes using regex (https://github.com/justbetter/magento2-sentry/pull/197)
    * Added support for [spotlight](https://spotlightjs.com/) (https://github.com/justbetter/magento2-sentry/pull/195)
### [4.3.0] - 2025-06-24
#### Fixed
    * Catch The default website isnt defined when getting store (https://github.com/justbetter/magento2-sentry/pull/188)
#### Added
    * Add sentry logger by hooking into monolog setHandlers (https://github.com/justbetter/magento2-sentry/pull/184)
    * Added support for cron check-ins (https://github.com/justbetter/magento2-sentry/pull/182)
### [4.2.0] - 2025-06-11
#### Added
    * Add performance sampling by (https://github.com/justbetter/magento2-sentry/pull/178) thanks to https://github.com/indykoning, https://github.com/barryvdh and https://github.com/rommelfreddy
    * Automatically pass all supported sentry config (https://github.com/justbetter/magento2-sentry/pull/177)
### [4.1.0] - 2025-06-04
#### Added
    * Clean up the Magento stacktrace before sending it to Sentry (https://github.com/justbetter/magento2-sentry/pull/171)
    * Pass config also relevant to sentry (https://github.com/justbetter/magento2-sentry/pull/172)
#### Fixed 
    * Gather ip from Magento instead of server variable (https://github.com/justbetter/magento2-sentry/pull/174)
### [4.0.1] - 2025-05-06
#### Fixed 
    * Load customerSession in SentryLog via proxy (Fixing https://github.com/justbetter/magento2-sentry/issues/160) (https://github.com/justbetter/magento2-sentry/pull/169) thanks to https://github.com/brosenberger
### [4.0.0] - 2025-04-23
#### Added 
    * Moved sentry logging to a monolog handler (https://github.com/justbetter/magento2-sentry/pull/165)
    * Added support for Magento 2.4.8
    * Added support for Monolog V3
#### Changed
    * Dynamically add sentry and logrocket domains to CSP whitelist (https://github.com/justbetter/magento2-sentry/pull/156) thanks to https://github.com/brosenberger
    * Use secureRenderer for including sentry frontend js (https://github.com/justbetter/magento2-sentry/pull/157) thanks to https://github.com/brosenberger
### [3.9.0] - 2025-01-31
#### Added 
    * Raised PHPStan level to 5 (https://github.com/justbetter/magento2-sentry/pull/149)
    * Added user context to logging and errors when possible (https://github.com/justbetter/magento2-sentry/pull/133 & https://github.com/just

_(Changelog truncated for .md surface. Full history on https://packagento.com/justbetter/magento2-sentry.)_

## Recent Versions

| Version | Released |
|---|---|
| 4.5.5 | 2026-01-27 |
| 4.5.4 | 2026-01-26 |
| 4.5.3 | 2026-01-05 |
| 4.5.2 | 2025-11-27 |
| 4.5.1 | 2025-11-11 |
| 4.5.0 | 2025-11-04 |
| 4.4.0 | 2025-07-14 |
| 4.3.0 | 2025-06-24 |
| 4.2.0 | 2025-06-11 |
| 4.1.0 | 2025-06-04 |

Showing 10 of 65 versions. Full release history on https://packagento.com/justbetter/magento2-sentry.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| justbetter/magento2-core | ^1.0 |
| magento/framework | >=103.0.7 |
| magento/module-config | >=101.2 |
| magento/module-csp | * |
| monolog/monolog | >=2.7.0\|^3.0 |
| nyholm/psr7 | ^1.2 |
| php | >=8.1 |
| sentry/sentry | ^4.13 |

### Require (dev)

| Package | Constraint |
|---|---|
| bitexpert/phpstan-magento | ^0.32.0 |
| magento/magento-coding-standard | >=34 |
| rector/rector | >=1.2.5 |

## Quality

Latest release (4.5.5) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | 1 | 1 |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 27 | 27 warnings (ruleset: Magento2) |
| PHPMD | Warning | 31 | 31 rule violations (UnusedFormalParameter:16, IfStatementAssignment:5, MissingImport:3, ErrorControlOperator:2, ExcessivePublicCount:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 4 | valid; 4 advisory notes (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 7 | 7 | – | – |
| 2.4.8 | – | 7 | Unknown | – |
| 2.4.9 | – | – | 5 | 5 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["justbetter/magento2-sentry"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

justbetter is a Magento 2 vendor on Packagento. See https://packagento.com/justbetter.md for their full catalogue.

