Migration: Analytics v2 to TimescaleDB
Migration Guide: Analytics v2 to TimescaleDB
This guide helps you migrate from the deprecated Orleans grain-based analytics endpoints (v2) to the new TimescaleDB-backed analytics endpoints (v3).
Overview
The platform is transitioning SMS analytics from an in-memory Orleans grain architecture to a persistent TimescaleDB time-series database. This change provides:
- Improved accuracy: Persistent storage with guaranteed consistency vs. eventual consistency from grain state
- Better performance: TimescaleDB hypertables and continuous aggregates optimized for time-series queries
- Simplified data model: Cleaner response structure focused on SMS metrics (no cost fields)
- Extended history: 12 months of queryable analytics history per tenant
Deprecation Timeline
| Phase | Date | Action |
|---|---|---|
| Deprecation Notice | 2026-01-07 | v2 endpoints return Deprecation: true header |
| Soft Deadline | 2026-03-07 | Recommended migration completion |
| Hard Deadline | 2026-04-07 | v2 endpoints removed |
Endpoint Mapping
Daily Analytics
Old (v2):
Code
New (v3):
Code
Period Analytics (Weekly/Monthly/Quarterly/Yearly)
Old (v2):
Code
New (v3):
Code
Request/Response Changes
Daily Analytics Response
Old (v2) Response:
Code
New (v3) Response:
Code
Key Differences
| Field | v2 | v3 | Notes |
|---|---|---|---|
| Cost metrics | totalCostLast30Days | ❌ Removed | Delegated to external billing API |
| Time scope | Fixed (24h, 30d) | Flexible date range | Use startDate and endDate query params |
| Granularity | Per-request | Daily base + period rollups | Use /daily for day-by-day, /period for aggregates |
| Direction | Not supported | direction field | Defaults to outbound; inbound reserved for future |
| Latency | Not available | avgSendToFinalStatusSeconds | New metric for delivery performance |
| Unique recipients | Not available | uniqueRecipientCount | New metric for reach analysis |
Authentication
Both v2 and v3 endpoints use the same Zitadel-based authentication. No changes required.
Code
The tenant ID is extracted from the JWT claims (org_id). Cross-tenant queries are not permitted except for internal/operator roles.
Migration Code Examples
JavaScript/TypeScript
Before (v2):
Code
After (v3):
Code
C# / .NET
Before (v2):
Code
After (v3):
Code
Billing/Cost Data
Cost analytics have been removed from the SMS Analytics API and are now provided by a separate billing service. If your application requires cost data, please contact support for the billing API documentation.
FAQ
Q: Why are cost fields removed?
A: Billing is now handled by an external service that provides more accurate cost tracking, including discounts, credits, and multi-currency support. This separation improves the maintainability of both systems.
Q: What happens to my historical data?
A: Analytics data is retained for 12 months in TimescaleDB. Data older than 12 months may be archived. Historical data from the old grain-based system is not automatically migrated; the new system accumulates data as new SMS events occur.
Q: Can I query inbound SMS analytics?
A: Not yet. The direction field is included in the response for future compatibility, but currently only outbound analytics are available. Inbound analytics will be added in a future release.
Q: Are the rates computed differently?
A: Rates are computed from the aggregated counts at query time:
deliveryRatePercent = (deliveredCount / processedCount) * 100failureRatePercent = (failedCount / processedCount) * 100
Q: How do I handle the deprecation header?
A: Look for the Deprecation: true response header from v2 endpoints. Log a warning and plan your migration before the Sunset date specified in the response headers.
Code
Support
If you encounter issues during migration, please:
- Check the SMS Analytics API documentation
- Review the API changelog
- Contact support at support@tech231.com
Last updated: 2026-01-07