Skip to content

Commit e021fa1

Browse files
committed
chore: large update, see changelog
1 parent 90fe2ef commit e021fa1

24 files changed

+2075
-70
lines changed

.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ HYTALE_USE_STAGING=false
3232
# AUTO_SYNC_ENABLED=true
3333
# AUTO_SYNC_INTERVAL=60 # Environment values are in MINUTES (e.g., 60 = 1 hour, 1 = 1 minute)
3434
#
35-
# Note: Database config table stores intervals in SECONDS (e.g., 3600 = 1 hour, 86400 = 24 hours, 60 = 60 seconds)
35+
# Note: Database config table stores intervals in SECONDS (e.g., 3600 = 1 hour, 86400 = 24 hours, 60 = 60 seconds)
36+
37+
# Subuser Sync Settings (optional)
38+
# SYNC_SUBUSERS_ENABLED=true # Enable/disable subuser sync (default: true)
39+
# SYNC_SUBUSERS_BATCH_SIZE=25 # Number of servers to sync per batch (default: 25)

CHANGELOG.md

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Planned
11-
- Partial sync capabilities (sync specific resource types)
12-
- Webhook event filtering and delivery guarantees
13-
- Prometheus metrics export
14-
- gRPC API for internal communication
15-
- Support for additional panel integrations (Game Panel Pro, Wings)
16-
- API documentation for Game Server Providers (GSPs)
17-
- Downloader CLI integration guide
18-
- Customer authentication flow documentation
19-
20-
## [0.2.1] - Unreleased
10+
## [0.2.1] - 2026-01-14
2111

2212
### Added
23-
- **Sentry Error Tracking Integration** - Production error monitoring
24-
- Optional Sentry SDK integration for real-time error tracking
13+
- **Sentry Error Tracking Integration** - Production error monitoring and performance tracking
14+
- Optional Sentry SDK integration for real-time error tracking and transaction monitoring
2515
- Fiber middleware for automatic panic recovery and error reporting
2616
- `SENTRY_DSN` environment variable configuration
2717
- Request context preservation with tags and custom data
2818
- Helper functions for manual error capture (`sentry.CaptureException`, `sentry.CaptureMessage`)
19+
- Transaction tracking with smart sampling (10% default)
20+
- Error classification and context enhancement (`CaptureErrorWithContext`)
2921
- 5-second timeout during graceful shutdown for pending event delivery
30-
- 10% transaction trace sampling for performance monitoring
22+
- **Custom Instrumentation Helpers** for detailed performance monitoring
23+
- `StartSpan()` - Create child spans within transactions
24+
- `GetTransactionFromContext()` - Access active transactions from any context
25+
- `GetSpanFromContext()` - Access active spans from any context
26+
- `CaptureExceptionWithContext()` - Capture errors in background workers without Fiber context
27+
- **Background Worker Transaction Tracking**
28+
- `worker.refresh_oauth_tokens` - OAuth token refresh operations (every 5 minutes)
29+
- `worker.refresh_game_sessions` - Game session refresh checks (every 5 minutes)
30+
- `worker.cleanup_expired_sessions` - Session cleanup operations (daily at 2 AM)
31+
- `worker.full_sync` - Pterodactyl panel synchronization jobs
32+
- `worker.discord_webhook` - Discord webhook dispatch operations
33+
- **Hytale Game Session Enhancements** - Improved session lifecycle management
34+
- Game session refresh interval changed to every 5 minutes
35+
- Sessions are refreshed when 5 minutes before expiry
36+
- Session token refresh returns new `sessionToken` and `identityToken` from Hytale
37+
- Database method to update session tokens after refresh (`UpdateGameSessionTokens`)
38+
- Pterodactyl API integration to push refreshed tokens to panel servers
39+
- New `UpdateServerEnvironment` method for updating environment variables via Pterodactyl client API
40+
- Sentry transaction tracking for all session refresh operations
41+
- **Hytale Audit Logs API** - New endpoint for retrieving Hytale OAuth event logs
42+
- `GET /api/v1/hytale/logs?account_id={id}&limit={limit}` endpoint
43+
- Query parameter validation (max 1000 logs per request)
44+
- Returns audit logs with event types (TOKEN_CREATED, TOKEN_REFRESHED, SESSION_CREATED, etc.)
45+
- Supports filtering by account ID
3146
- **Comprehensive Unit Test Suite** - Core packages tested for reliability
3247
- Config loading and environment variable parsing tests
3348
- Error handling and HTTP status mapping tests
@@ -41,18 +56,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4156
- Multi-workflow setup: test-build, format, docker, dependencies, coverage
4257
- HTML coverage reports uploaded to GitHub artifacts
4358
- Coverage comments on pull requests with metrics
59+
- **Dual API Integration**: Full Pterodactyl Client API support for user-server relationships
60+
- New `server_subusers` table tracking user access to servers with permissions
61+
- `GetClientServers()` method to fetch servers via Client API
62+
- `GetServerSubusers()` method to fetch subusers for specific servers
63+
- `syncServerSubusers()` sync method integrating Client API data into database
64+
- Configurable subuser sync (enabled by default, 25 servers per batch)
65+
- Automatic owner marking in server_subusers table
66+
- Rate limiting with 2-second delays between batches
67+
- New config options: `SYNC_SUBUSERS_ENABLED`, `SYNC_SUBUSERS_BATCH_SIZE`
68+
- Client API types: `ClientServer` and `ClientSubuser` structs
69+
- **Hytale Game Server Log Persistence** - Automatic backup of console logs to database
70+
- Background worker periodically fetches logs from Hytale API (every 5 minutes)
71+
- Persistent storage in PostgreSQL with sync state tracking to prevent duplicates
72+
- Automatic cleanup of logs older than 30 days (runs daily at 4 AM)
73+
- API endpoints for historical log retrieval:
74+
- `GET /api/v1/hytale/server-logs` - Retrieve paginated logs for a game server
75+
- `GET /api/v1/hytale/server-logs/count` - Get total log count for a server
76+
- Sync state tracking to monitor last successful sync and handle API errors gracefully
77+
- Sentry transaction tracking for log persistence operations
4478

4579
### Changed
80+
- **Sentry SDK Configuration** - SDK API compatibility improvements
81+
- TracesSampler now correctly returns `float64` instead of `sentry.Sampled`
82+
- Event tags use `event.Tags` map directly instead of `SetTag()` method
83+
- Span operations properly initialized with `WithOpName` and `WithTransactionSource` options
84+
- Structured logging integration enabled (`EnableLogs: true`) for automatic log capture
4685
- **Workflow Reliability** - Fixed workflow configuration issues
4786
- Updated deprecated artifact actions (v3 → v4)
4887
- Added continue-on-error flags to linting steps to prevent false failures
4988
- Fixed gofmt check to use `gofmt -l` instead of `go fmt ./...` (non-destructive)
5089
- Added PR-conditional GitHub script execution to prevent undefined context errors
5190
- PostgreSQL readiness check added to coverage workflow for test database setup
91+
- Full sync now includes server subusers as Step 7 (non-blocking, continues on failure)
92+
- Progress tracking updated to 85% for subuser sync step
93+
- Config struct extended with `SyncSubusersEnabled` and `SyncSubusersBatchSize` fields
5294

5395
### Fixed
96+
- **Hytale OAuth Handler** - Corrected return value handling
97+
- RefreshGameSession handler now properly captures 2 return values from oauth client (`sessionResp`, `err`)
98+
- New tokens are now persisted to database immediately after refresh
5499
- **Test Compatibility** - Aligned tests with actual implementation
55100
- Fixed OAuth endpoint URL format to match `https://oauth.accounts.{host}` pattern
101+
- **Sentry Background Worker Panic** - Fixed nil pointer dereference in background jobs
102+
- Added `StartBackgroundTransaction()` function for workers without HTTP context
103+
- Updated `StartTransaction()` to handle nil fiber.Ctx gracefully
104+
- Fixed 6 worker functions: `RefreshOAuthTokens`, `RefreshGameSessions`, `CleanupExpiredSessions`, `CleanupOldLogs`, `HandleDiscordWebhook`, `HandleFullSync`
105+
- All background jobs now use proper Sentry transaction tracking with `task` operation type
106+
- **Sync Progress Updates** - Enhanced frontend polling visibility
107+
- Added `lastMessage` field to all sync progress updates for real-time status display
108+
- Standardized status values to `RUNNING` (was inconsistently `in_progress`)
109+
- Progress updates now include user-friendly messages like "Syncing locations...", "Syncing nodes...", etc.
110+
- Added `lastUpdated` timestamp to metadata for frontend polling
111+
- **Config Validation** - Removed duplicate field declarations
112+
- Fixed duplicate `SyncSubusersEnabled` and `SyncSubusersBatchSize` fields in Config struct
56113
- Corrected rate limiter Allow() return types (int vs int64)
57114
- Fixed test expectations for rate limiter cleanup behavior
58115
- Removed tests for private/unexported functions

0 commit comments

Comments
 (0)