Skip to content

feat: enhanced telemetry backend#9

Merged
irfanuddinahmad merged 7 commits intoproductionfrom
feature/enhanced-telemetry-backend
Feb 19, 2026
Merged

feat: enhanced telemetry backend#9
irfanuddinahmad merged 7 commits intoproductionfrom
feature/enhanced-telemetry-backend

Conversation

@irfanuddinahmad
Copy link

@irfanuddinahmad irfanuddinahmad commented Feb 19, 2026

This pull request introduces comprehensive developer telemetry support to DevLake by adding detailed git activity tracking and development pattern analysis. The changes include significant updates to the data model, API, and database migration scripts to support new metrics, as well as a critical bug fix ensuring proper JSON deserialization of nested struct fields. The schema and API now support flexible, extensible storage and retrieval of developer activity metrics.

Key changes:

Data Model & API Enhancements

  • Added new nested structs GitActivity, Repository, and DevelopmentActivity to the telemetry metrics, capturing commit counts, code churn, repository breakdowns, test runs, and build commands. All fields now include both json and mapstructure tags to ensure correct serialization and deserialization. [1] [2]
  • Updated the API handler in report_api.go to marshal and store the new metrics in the database, replacing the old commands field with git_activity and development_activity. [1] [2] [3]

Database Schema & Migration

  • Replaced the initial migration script with a new migration (20260219_init_schema.go) that creates the updated _tool_developer_metrics table, including new JSON fields for git_activity and development_activity, and drops/recreates tables for a clean schema in development. [1] [2] [3]
  • Updated the DeveloperMetrics model to match the new schema, removing the obsolete CommandCounts field and adding GitActivity and DevelopmentActivity as JSON text fields.

Bug Fixes

  • Fixed a critical issue with mapstructure serialization by adding explicit mapstructure tags to all nested struct fields, ensuring accurate decoding of incoming telemetry data. [1] [2]

CRITICAL FIX: Added missing mapstructure tags to GitActivity, Repository,
and DevelopmentActivity structs. The api.Decode function uses mapstructure
for decoding request bodies, which requires explicit tags for all fields
in nested structures.

Without these tags:
- Git line counts were 0 (total_lines_added, total_lines_deleted, files_changed)
- Repository details were partially missing (lines_added, lines_deleted, files_changed)
- branches_worked arrays were null

With this fix:
- All git activity metrics now properly decoded and stored
- Complete repository statistics including line changes
- Branch information correctly preserved

Tested: Full pipeline from collector → API → database verified with correct values.
- Remove old migrations (20240211_add_init_tables, 20260219_add_git_activity_fields)
- Create single migration that drops and recreates tables from scratch
- Cleaner schema with git_activity and development_activity fields
- Removes deprecated command_counts field entirely
- Safe for dev mode - drops existing tables and creates fresh schema
- Remove all references to CommandCounts field from models and API
- Fix AutoMigrate syntax in migration (call separately for each table)
- Clean schema without deprecated fields
@irfanuddinahmad irfanuddinahmad merged commit dd040b4 into production Feb 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant