3.3 KiB
Simple Glitchtip Plugin for Concrete5
A lightweight plugin for Concrete5 that reports errors and exceptions to GlitchTip or Sentry. This package is designed to provide seamless error tracking by integrating with GlitchTip via environment variables.
Installation
To install or update the Simple Glitchtip plugin, run the following command from your server's root directory:
curl -sSL https://git.nixc.us/nixius/simple-glitchtip-c5/raw/branch/main/install.sh | bash
This script automates the installation process and sets up the required files for the plugin.
Enabling the Plugin
After running the installation script, enable the plugin via the Concrete5 dashboard:
- Log in to your Concrete5 admin panel.
- Navigate to System & Settings > Extend Concrete5 > Add Functionality.
- Find Simple Glitchtip in the list of available packages and click Install.
Once installed, the plugin will automatically capture and report errors.
What the install.sh
Script Does
The install.sh
script performs the following actions:
-
Creates the Plugin Directory:
- Ensures the
packages/simple_glitchtip
directory exists under your Concrete5 root.
- Ensures the
-
Downloads the Required Files:
- Fetches the
controller.php
file containing the plugin logic. - Installs the necessary dependencies, such as the Sentry PHP SDK, if not already present.
- Fetches the
-
Sets Permissions:
- Ensures the files have appropriate permissions for execution by the Concrete5 application.
-
Prints a Success Message:
- Confirms the plugin has been installed or updated successfully.
Configuration
Environment Variables
This plugin uses environment variables to configure the integration with GlitchTip/Sentry:
GLITCHTIP_DSN
: The DSN URL provided by your GlitchTip/Sentry project.APP_ENV
: The application environment (e.g.,production
,staging
,development
). Defaults toproduction
.APP_VERSION
: The current version of your application for release tracking. Defaults to1.0.0
.
Setting Environment Variables
You can set these variables in your server configuration or in a .env
file, depending on your environment. For example:
export GLITCHTIP_DSN=https://your-glitchtip-dsn-url
export APP_ENV=production
export APP_VERSION=1.2.3
How It Works
-
Error and Exception Handling:
- The plugin hooks into Concrete5's lifecycle to capture uncaught exceptions and PHP errors.
- Errors are reported to GlitchTip/Sentry using the DSN configured in
GLITCHTIP_DSN
.
-
Event IDs:
- Each error is assigned a unique event ID for tracking in GlitchTip/Sentry.
- Event IDs are also logged to Concrete5's internal log system for cross-referencing.
-
Fail-Safe Operation:
- If the
GLITCHTIP_DSN
environment variable is not set, the plugin gracefully disables error reporting and logs a warning.
- If the
Testing the Plugin
To test the integration, you can trigger a test error:
Example 1: Uncaught Exception
throw new \Exception('Test Exception from Simple Glitchtip');
Example 2: PHP Error
trigger_error('Test Warning from Simple Glitchtip', E_USER_WARNING);
Check your GlitchTip/Sentry dashboard for the reported errors, and Concrete5 logs for the corresponding event IDs.