PHPackages                             fof/sentry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. fof/sentry

ActiveFlarum-extension

fof/sentry
==========

Flarum integration for Sentry

1.5.0(5mo ago)515.7k—3.1%4[1 issues](https://github.com/FriendsOfFlarum/sentry/issues)MITPHPCI passing

Since Dec 18Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/FriendsOfFlarum/sentry)[ Packagist](https://packagist.org/packages/fof/sentry)[ Docs](https://friendsofflarum.org)[ Fund](https://opencollective.com/fof/donate)[ RSS](/packages/fof-sentry/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (48)Used By (0)

Sentry by FriendsOfFlarum
=========================

[](#sentry-by-friendsofflarum)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) [![Latest Stable Version](https://camo.githubusercontent.com/6ef6b02f0072e5dd368bb2f03280492bd01246a620a9c860ed1a78f421bc9342/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f662f73656e7472792e737667)](https://packagist.org/packages/fof/sentry) [![OpenCollective](https://camo.githubusercontent.com/1903c197bb0307e60d6328653532b8a6b9890b898fbc92e314ab39d699491e74/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e636f6c6c6563746976652d666f662d626c75652e737667)](https://opencollective.com/fof/donate) [![Donate](https://camo.githubusercontent.com/6c7b26396e320eb8dd60d767a4500684b60bb7d37f7cacbaf6b2eae6f2d30010/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d6461746974697365762d696d706f7274616e742e737667)](https://datitisev.me/donate)

A [Flarum](http://flarum.org) extension. Flarum integration for [Sentry](https://sentry.io).

[![screenshot](https://camo.githubusercontent.com/3523e622674a8fd32332d59fdea7e3f0da986547941f48a61e5e5bd7b70f0320/68747470733a2f2f692e696d6775722e636f6d2f71447a483036612e706e67)](https://camo.githubusercontent.com/3523e622674a8fd32332d59fdea7e3f0da986547941f48a61e5e5bd7b70f0320/68747470733a2f2f692e696d6775722e636f6d2f71447a483036612e706e67)

Features
--------

[](#features)

- **Error Tracking**: Automatically capture and report PHP and JavaScript errors to Sentry
- **Performance Monitoring**: Track backend and frontend performance with configurable sample rates
- **Database Query Monitoring**: Advanced database performance tracking with N+1 detection
- **User Context**: Automatically include user information (ID, username, email, groups) with error reports
- **User Feedback**: Allow users to submit feedback when errors occur
- **Session Replay**: Record user sessions to reproduce bugs (frontend only)
- **Profiling**: PHP profiling support via Excimer extension

Sentry SDK Versions
-------------------

[](#sentry-sdk-versions)

- **Backend (PHP)**: Sentry PHP SDK v4.x
- **Frontend (JavaScript)**: Sentry Browser SDK v10.0.0

Installation
------------

[](#installation)

Install with composer:

```
composer require fof/sentry:"*"
```

### Updating

[](#updating)

```
composer update fof/sentry:"*"
```

### Optional: PHP Profiling Support

[](#optional-php-profiling-support)

For backend profiling support, install the Excimer PHP extension (Linux only):

```
pecl install excimer
```

Configuration
-------------

[](#configuration)

Configure the extension in the admin panel. You'll need to provide your Sentry DSN to get started.

### General Settings

[](#general-settings)

#### Sentry DSN

[](#sentry-dsn)

**Setting**: `fof-sentry.dsn` (required)

Your primary Sentry DSN. This is used for both frontend and backend error reporting.

**Note**: If you use a Relay DSN as the primary one, do not enable "User Feedback" as it will not work with Relay DSNs.

#### Sentry DSN (Backend Only)

[](#sentry-dsn-backend-only)

**Setting**: `fof-sentry.dsn_backend` (optional)

An optional separate DSN for backend errors only. This is useful if you want to:

- Use a different Sentry project for backend errors
- Route backend errors through a Relay for improved performance
- Separate backend and frontend error tracking

If not set, the primary DSN will be used for both frontend and backend.

#### Environment

[](#environment)

**Setting**: `fof-sentry.environment` (optional)

Set the environment name for all Sentry events (e.g., "production", "staging", "development"). This helps you filter and organize errors in Sentry.

### User Context Settings

[](#user-context-settings)

#### User Feedback

[](#user-feedback)

**Setting**: `fof-sentry.user_feedback`**Default**: `false`

When enabled, users will see a feedback dialog when an error occurs, allowing them to provide additional context about what happened. The dialog pre-fills with their username, email (if enabled), and group membership.

**Important**: This feature requires a direct Sentry DSN (not a Relay DSN).

#### Send User Email Addresses with Sentry Reports

[](#send-user-email-addresses-with-sentry-reports)

**Setting**: `fof-sentry.send_emails_with_sentry_reports`**Default**: `false`

When enabled, user email addresses are included in error reports and user feedback dialogs. This can help with user support but consider your privacy policy before enabling.

User context always includes:

- User ID
- Username
- User groups (e.g., "Admin", "Moderator")

### Backend Performance Monitoring

[](#backend-performance-monitoring)

#### Back-end Performance Monitoring Rate

[](#back-end-performance-monitoring-rate)

**Setting**: `fof-sentry.monitor_performance`**Default**: `0` (disabled) **Range**: 0-100

Percentage of backend requests to trace for performance monitoring. Set to:

- `0` to disable performance monitoring
- `100` to trace all requests
- Lower values (e.g., `10`) to sample 10% of requests

Performance monitoring tracks:

- Request/response times
- Database queries (when enabled)
- Extension loading times
- Custom spans

#### Back-end Profiling Rate

[](#back-end-profiling-rate)

**Setting**: `fof-sentry.profile_rate`**Default**: `0` (disabled) **Range**: 0-100

Percentage of traced transactions to profile. This is **relative to the performance monitoring rate**.

**Requirements**:

- Performance monitoring must be enabled (`monitor_performance > 0`)
- Excimer PHP extension must be installed (Linux only)

**Example**: If `monitor_performance = 10` and `profile_rate = 50`, then:

- 10% of requests are traced
- 50% of those traced requests are profiled
- Result: 5% of all requests are profiled

**⚠️ Warning**: Profiling adds overhead and affects response time. See [Sentry documentation](https://docs.sentry.io/platforms/php/profiling/#improve-response-time) for optimization tips.

### Frontend (JavaScript) Monitoring

[](#frontend-javascript-monitoring)

#### Report JavaScript Errors

[](#report-javascript-errors)

**Setting**: `fof-sentry.javascript`**Default**: `true`

Enable JavaScript error reporting to Sentry. Disable this if you only want backend error tracking.

#### Capture JavaScript Console

[](#capture-javascript-console)

**Setting**: `fof-sentry.javascript.console`**Default**: `false`

Capture console messages (log, info, warn, error) as breadcrumbs in error reports. Useful for debugging but increases data volume.

#### Front-end Performance Monitoring Rate

[](#front-end-performance-monitoring-rate)

**Setting**: `fof-sentry.javascript.trace_sample_rate`**Default**: `0` (disabled) **Range**: 0-100

Percentage of frontend page loads to trace for performance monitoring.

**⚠️ Note**: Enabling this increases bundle size by ~30 KB.

#### Front-end Session Replays Rate

[](#front-end-session-replays-rate)

**Setting**: `fof-sentry.javascript.replays_session_sample_rate`**Default**: `0` (disabled) **Range**: 0-100

Percentage of user sessions to record from the beginning. Session replays capture user interactions, allowing you to see exactly what the user did before encountering an error.

**⚠️ Note**: Enabling any replay feature increases bundle size by ~150 KB.

#### Front-end Error Replays Rate

[](#front-end-error-replays-rate)

**Setting**: `fof-sentry.javascript.replays_error_sample_rate`**Default**: `0` (disabled) **Range**: 0-100

Percentage of sessions to record only when an error occurs. Captures up to 1 minute before the error and continues until the session ends.

**⚠️ Note**: Enabling any replay feature increases bundle size by ~150 KB.

### Database Query Performance Monitoring

[](#database-query-performance-monitoring)

These settings control advanced database query tracking and performance monitoring. Database monitoring is only active when backend performance monitoring is enabled (`monitor_performance > 0`).

#### Slow Query Threshold

[](#slow-query-threshold)

**Setting**: `fof-sentry.db.slow_query_threshold`**Default**: `1000` (1 second) **Range**: 100-10000 milliseconds

Queries taking longer than this threshold are flagged as slow queries and tagged with severity levels:

- **Medium**: 1× to 2× threshold
- **High**: 2× to 5× threshold
- **Critical**: 5× threshold or more

Slow queries are **always tracked** regardless of the query sample rate.

#### Enable N+1 Query Detection

[](#enable-n1-query-detection)

**Setting**: `fof-sentry.db.n_plus_one_detection`**Default**: `true`

Automatically detect potential N+1 query problems by tracking repeated query patterns. When the same query pattern executes multiple times (with different parameters), it's flagged as a potential N+1 issue.

#### N+1 Detection Threshold

[](#n1-detection-threshold)

**Setting**: `fof-sentry.db.n_plus_one_threshold`**Default**: `10`**Range**: 5-100

Number of times a query pattern must repeat to be flagged as a potential N+1 issue. Lower values are more sensitive but may produce false positives.

Common patterns:

- `5-10`: Aggressive detection (may catch smaller loops)
- `10-20`: Balanced (recommended)
- `20+`: Conservative (only flags severe N+1 issues)

#### Track Query Parameter Bindings

[](#track-query-parameter-bindings)

**Setting**: `fof-sentry.db.track_bindings`**Default**: `false`

Include query parameter values in Sentry reports. This helps with debugging but may expose sensitive data.

**⚠️ Warning**: Use with caution. While passwords and hashes are automatically sanitized, other sensitive data in query parameters may be exposed. Review your privacy and security requirements before enabling.

Automatic sanitization:

- Strings longer than 100 characters are truncated
- Hexadecimal strings (32+ chars) are masked as `[HASH]`

#### Query Sampling Rate

[](#query-sampling-rate)

**Setting**: `fof-sentry.db.query_sample_rate`**Default**: `100` (track all queries) **Range**: 0-100

Percentage of database queries to track in performance monitoring.

- `100`: Track all queries (full visibility, higher overhead)
- `50`: Track 50% of queries (balanced)
- `10`: Track 10% of queries (lower overhead)
- `0`: Only track slow queries (minimum overhead)

**Note**: Slow queries (above threshold) are **always tracked** regardless of this setting.

Set lower values on high-traffic sites to reduce performance impact and data volume.

### Database Monitoring Features

[](#database-monitoring-features)

When database query monitoring is enabled, you'll get:

1. **Individual Query Tracking**

    - Query execution time
    - Query type (SELECT, INSERT, UPDATE, DELETE, DDL)
    - Tables involved
    - Query bindings (if enabled)
    - Slow query detection with severity levels
    - N+1 query detection
2. **Aggregate Statistics** (per request)

    - Total number of queries
    - Total query time
    - Average query time
    - Number of duplicate query patterns
    - Top duplicate query count
3. **Query Tags** (for filtering in Sentry)

    - `query_type`: select, insert, update, delete, ddl, other
    - `table`: Primary table name
    - `slow_query`: true (if slow)
    - `n_plus_one_candidate`: true (if potential N+1)
    - `severity`: critical, high, medium, warning

Recommended Configurations
--------------------------

[](#recommended-configurations)

### Production Site (High Traffic)

[](#production-site-high-traffic)

For production sites with high traffic, use conservative settings to minimize overhead:

```
Performance Monitoring: 10-25%
Profiling: 0% (disabled)
Database Query Sample Rate: 10-25%
Slow Query Threshold: 1000ms
N+1 Detection: Enabled
Track Bindings: Disabled (for privacy)
JavaScript Errors: Enabled
JavaScript Performance: 10%
Session Replays: 1-5% (error replays only)

```

### Staging/Development

[](#stagingdevelopment)

For staging or development environments, use aggressive settings for full visibility:

```
Performance Monitoring: 100%
Profiling: 50-100% (if Excimer is installed)
Database Query Sample Rate: 100%
Slow Query Threshold: 500ms
N+1 Detection: Enabled (threshold: 5)
Track Bindings: Enabled
JavaScript Errors: Enabled
JavaScript Performance: 100%
Session Replays: 100% (both session and error)

```

### Troubleshooting Performance Issues

[](#troubleshooting-performance-issues)

When investigating performance problems, temporarily increase monitoring:

```
Performance Monitoring: 100%
Database Query Sample Rate: 100%
Slow Query Threshold: 500ms (or lower)
N+1 Detection: Enabled (threshold: 5)
Track Bindings: Enabled

```

Remember to reduce these settings after troubleshooting to minimize overhead and costs.

Privacy Considerations
----------------------

[](#privacy-considerations)

This extension can collect user data. Review these privacy implications:

1. **User Email Addresses**: Only sent when `send_emails_with_sentry_reports` is enabled
2. **User Groups**: Always included in user context (can reveal user roles)
3. **Query Bindings**: May contain user-generated content when `track_bindings` is enabled
4. **Session Replays**: Capture all user interactions, including form inputs (with automatic PII masking)

Ensure your privacy policy covers data sent to Sentry.

Security Notes
--------------

[](#security-notes)

### Automatic Sanitization

[](#automatic-sanitization)

The extension automatically sanitizes sensitive data:

1. **Query Bindings**:

    - Passwords and hashes (32+ hex chars) are masked as `[HASH]`
    - Long strings (100+ chars) are truncated
2. **User Feedback Dialog**:

    - All data is properly JSON-encoded to prevent XSS attacks
    - User input is sanitized through Sentry's SDK

### Best Practices

[](#best-practices)

- **Don't track bindings in production** unless necessary
- **Use separate DSNs** for frontend and backend to isolate data
- **Set appropriate sample rates** to limit data collection
- **Review Sentry's privacy settings** to auto-scrub PII

Customizing Sentry for Developers
---------------------------------

[](#customizing-sentry-for-developers)

This extension provides an extender that allows other extensions to customize Sentry configuration. You can use this to set custom release versions, add tags, and more. All settings are applied to both the PHP backend and JavaScript frontend.

### Basic Usage

[](#basic-usage)

In your extension's `extend.php` file:

```
use FoF\Sentry\Extend\Sentry;

return [
    // Other extenders

    (new Sentry())
        ->setRelease('my-app-v1.2.3')
        ->setEnvironment('production')
        ->addTag('app_name', 'My Awesome App'),
];
```

### Available Methods

[](#available-methods)

#### `setRelease(string $release)`

[](#setreleasestring-release)

Set a custom release version for Sentry events (applied to both backend and frontend):

```
(new Sentry())->setRelease('v2.0.0-beta.1');
```

#### `setEnvironment(string $environment)`

[](#setenvironmentstring-environment)

Set a custom environment name (applied to both backend and frontend):

```
(new Sentry())->setEnvironment('staging');
```

#### `addTag(string $key, string $value)`

[](#addtagstring-key-string-value)

Add a custom tag to all Sentry events (applied to both backend and frontend):

```
(new Sentry())
    ->addTag('server_type', 'dedicated')
    ->addTag('php_version', PHP_VERSION);
```

### Example: Setting Environment Variables

[](#example-setting-environment-variables)

You can use environment variables to configure Sentry:

```
(new Sentry())
    ->setRelease(env('APP_VERSION', 'development'))
    ->setEnvironment(env('APP_ENV', 'production'))
    ->addTag('server_id', env('SERVER_ID', 'unknown'));
```

### Links

[](#links)

[![OpenCollective](https://camo.githubusercontent.com/8ea53c451470d1a72789d650c77e2b22eee915f7fbf2cbeeeeaa25f47301efe2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d667269656e64736f66666c6172756d2d3434414545353f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e2d636f6c6c656374697665)](https://opencollective.com/fof/donate) [![GitHub](https://camo.githubusercontent.com/19562cc0996a556a7abda08327f57924e288bbbc3c5312b096c62175a2841ae4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d6461746974697365762d6561346161613f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562)](https://datitisev.me/donate/github)

- [Packagist](https://packagist.org/packages/fof/sentry)
- [GitHub](https://github.com/FriendsOfFlarum/sentry)

An extension by [FriendsOfFlarum](https://github.com/FriendsOfFlarum), commissioned by [webdeveloper.com](https://webdeveloper.com).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance75

Regular maintenance activity

Popularity32

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~66 days

Recently: every ~24 days

Total

41

Last Release

54d ago

Major Versions

0.8.0 → 1.0.02021-06-28

1.5.0 → 2.0.0-beta.12025-12-16

1.x-dev → 2.0.0-beta.32026-02-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16573496?v=4)[IanM](/maintainers/imorland)[@imorland](https://github.com/imorland)

![](https://avatars.githubusercontent.com/u/1630413?v=4)[Gregor Hammerschmidt](/maintainers/GreXXL)[@GreXXL](https://github.com/GreXXL)

![](https://www.gravatar.com/avatar/0538135c1debcef5602dce7ece027909cc832b7a6284ab9189a19aa8de98d60d?d=identicon)[clarkwinkelmann](/maintainers/clarkwinkelmann)

![](https://www.gravatar.com/avatar/1298cdc0b2402a1aa34fb75a254947d655e090d62bd0531311331d369cac934e?d=identicon)[datitisev](/maintainers/datitisev)

---

Top Contributors

[![dsevillamartin](https://avatars.githubusercontent.com/u/6401250?v=4)](https://github.com/dsevillamartin "dsevillamartin (61 commits)")[![imorland](https://avatars.githubusercontent.com/u/16573496?v=4)](https://github.com/imorland "imorland (26 commits)")[![flarum-bot](https://avatars.githubusercontent.com/u/39334649?v=4)](https://github.com/flarum-bot "flarum-bot (18 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![luceos](https://avatars.githubusercontent.com/u/504687?v=4)](https://github.com/luceos "luceos (7 commits)")[![davwheat](https://avatars.githubusercontent.com/u/7406822?v=4)](https://github.com/davwheat "davwheat (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![francescomasala](https://avatars.githubusercontent.com/u/25754886?v=4)](https://github.com/francescomasala "francescomasala (1 commits)")[![PatrickRoethlisberger](https://avatars.githubusercontent.com/u/9606082?v=4)](https://github.com/PatrickRoethlisberger "PatrickRoethlisberger (1 commits)")

---

Tags

flarumfriendsofflarumhacktoberfestsentryflarum

### Embed Badge

![Health badge](/badges/fof-sentry/health.svg)

```
[![Health](https://phpackages.com/badges/fof-sentry/health.svg)](https://phpackages.com/packages/fof-sentry)
```

###  Alternatives

[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

188171.7k15](/packages/fof-upload)[fof/byobu

Well integrated, advanced private discussions.

61105.8k9](/packages/fof-byobu)[fof/gamification

Upvotes and downvotes for your Flarum community

4157.1k6](/packages/fof-gamification)[fof/user-bio

Add a user bio to user profiles

2196.5k9](/packages/fof-user-bio)[flarum-lang/russian

Russian language pack for Flarum.

13126.1k](/packages/flarum-lang-russian)[fof/drafts

Allow users to create post and discussion drafts

1771.1k5](/packages/fof-drafts)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
