Add webhook notification functionality with configuration options

This commit is contained in:
2025-09-21 16:00:45 +02:00
parent 46289d4667
commit b56a950f04
10 changed files with 750 additions and 57 deletions

View File

@@ -66,7 +66,9 @@ You will need these env variables from the application settings:
EVE_SSO_CLIENT_ID=Client ID
EVE_SSO_SECRET=Secret Key
EVE_SSO_CALLBACK_URL=Callback URL (This should be the domain you are hosting at or if run locally it should be http://localhost:3000)
WEBHOOK_URL=Discord webhook URL for notifications (optional)
# Webhook Configuration (optional)
WEBHOOK_URL=Discord webhook URL for notifications
```
## Run locally
@@ -85,11 +87,44 @@ The application supports webhook notifications for various PI events:
- **Launch pad capacity warnings**: Notify when launch pads are about to be full (configurable percentage)
- **Launch pad full**: Notify when launch pads are at 100% capacity
### Webhook Configuration
To enable webhook notifications:
1. Set the `WEBHOOK_URL` environment variable to your Discord webhook URL
2. Enable webhook notifications in the Settings dialog
3. Configure warning thresholds for extractors, storage, and launch pads
1. Set the `WEBHOOK_URL` environment variable to your Discord webhook URL or other webhook endpoint
2. Open the Settings dialog in the application and enable webhook notifications
3. Configure thresholds in the Settings dialog:
- **Extractor Expiry Warning**: How early to warn about extractor expiry (ISO 8601 duration format, default: P12H = 12 hours)
- **Storage Warning Threshold**: Storage fill percentage for warnings (default: 85%)
- **Storage Critical Threshold**: Storage fill percentage for critical alerts (default: 100%)
### Webhook Behavior
- **Automatic checks**: Runs every minute to check extractor expiry and storage levels
- **Data fetch checks**: Also checks when planet data is refreshed
- **Duplicate prevention**: Won't send the same alert repeatedly within cooldown periods
- **State reset**: Extractor alerts reset when extractors are restarted with fresh cycles
### Webhook Payload Format
The webhook sends JSON payloads with this structure:
```json
{
"type": "extractor_expiring|extractor_expired|storage_almost_full|storage_full|launchpad_almost_full|launchpad_full",
"message": "Human readable message",
"characterName": "Character Name",
"planetName": "Planet Name",
"details": {
"extractorType": "Product Type",
"hoursRemaining": 1.5,
"storageUsed": 8500,
"storageCapacity": 10000,
"fillPercentage": 85.0
},
"timestamp": "2024-01-01T12:00:00.000Z"
}
```
The webhook URL is kept secure in environment variables and not stored in the browser.