Metadata-Version: 2.4
Name: sentry-mattermost-plugin
Version: 0.1.1
Summary: Plugin for Sentry which allows sending notifications to a self-hosted Mattermost instance.
Home-page: https://github.com/masstek/sentry-mattermost-plugin
Author: Albert Fakhriev
Author-email: masstek.project@gmail.com
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Bug Tracking
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# sentry-mattermost-plugin

A Sentry plugin that sends issue notifications to a self-hosted [Mattermost](https://mattermost.com/) instance via the Mattermost Bot API.

[Official Repo](https://github.com/NDrive/sentry-mattermost) seems to be outdated. So here's alternative.

Inspired by [sentry-telegram](https://github.com/butorov/sentry-telegram).

## Requirements

- Sentry (self-hosted)
- Python 3.8+
- A Mattermost Bot account with a token

## Installation

Install the package into Sentry's Python environment:

```bash
pip install sentry-mattermost-plugin
```

Or in development mode from source:

```bash
git clone https://github.com/masstek/sentry-mattermost-plugin
cd sentry-mattermost
pip install -e .
```

Restart Sentry after installation so the entry point is picked up.

## Configuration

1. In Sentry, go to **Project Settings → Legacy Integrations**.
2. Find **Mattermost Notifications** and click **Configure plugin**.
3. Fill in the fields:

| Field | Description |
|---|---|
| **Mattermost Host** | Base URL of your Mattermost instance, e.g. `https://mattermost.company.com` |
| **Bot Token** | Access token for the Mattermost Bot account |
| **Channel IDs** | One channel ID per line. Find IDs via Mattermost → channel name → **View Info** |
| **Message Template** | Optional. Supports `{project_name}`, `{url}`, `{title}`, `{message}`, `{tag[key]}` |
| **Verify SSL Certificate** | Uncheck if your instance uses a self-signed certificate |

4. Click **Save changes**.
5. Click **Test Plugin** to send a test notification to all configured channels.

## Creating a Mattermost Bot

1. In Mattermost go to **Main Menu → Integrations → Bot Accounts**.
2. Click **Add Bot Account**, give it a name, and save.
3. Copy the generated token — this is the **Bot Token** for the plugin.
4. Add the bot to the channels it needs to post in.

## Message Template

The default template is:

```
*[Sentry]* {project_name} | {title}
{url}
{message}
```

Available variables:

| Variable | Description |
|---|---|
| `{project_name}` | Sentry project name |
| `{url}` | Link to the Sentry issue |
| `{title}` | Error title (truncated to 500 characters) |
| `{message}` | Error message |
| `{tag[key]}` | Value of a Sentry tag by key, e.g. `{tag[environment]}`. Returns `[NA]` if absent. |

Mattermost Markdown is supported in the template.

## Running Tests

```bash
pip install pytest pytest-cov requests django
pytest tests/ --cov=sentry_mattermost_plugin --cov-report=term-missing
```

No Sentry installation is required to run the tests.

## License

MIT
