Skip to content

Feature/xapi tracking#76

Open
sei-awelle wants to merge 13 commits intomainfrom
feature/xapi-tracking
Open

Feature/xapi tracking#76
sei-awelle wants to merge 13 commits intomainfrom
feature/xapi-tracking

Conversation

@sei-awelle
Copy link
Copy Markdown
Contributor

Add comprehensive xAPI tracking for Player views, applications, and team switching

Implements xAPI statement tracking for Player user activities with team context:

  • View tracking: Dedicated POST endpoint for view entry (not on every GET)
  • Application switching: Tracks app navigation with "accessed" verb
  • Team switching: Tracks team changes with "switched" verb
  • Team context: All statements include team extension for filtering/analysis
  • Queue system: Uses background service for reliable statement delivery

Technical changes:

  • Add POST /api/xapi/viewed/view/{viewId} endpoint
  • Add POST /api/xapi/switched/view/{viewId}/team/{teamId} endpoint
  • Remove auto-emit from GET /api/views/{id} to prevent unwanted logs
  • URL-encode application names in activity IDs for IRI compliance
  • Add team context extension (https://crucible.sei.cmu.edu/xapi/extensions/team) to all statements

Verbs used:

  • http://id.tincanapi.com/verb/viewed - View entry
  • http://activitystrea.ms/schema/1.0/access - Application access
  • https://w3id.org/xapi/verbs/switched - Team switching

sei-awelle added 7 commits May 5, 2026 01:28
- Add xAPI queue database table and Entity Framework migration
- Implement XApiService for statement generation (ViewViewed, TeamJoined)
- Implement XApiQueueService for persistent queue management
- Add XApiBackgroundService for background statement delivery
- Emit ViewViewed statement when user accesses a view
- Emit TeamJoined statement when user is added to a team
- Add XApiOptions configuration with LRS endpoint settings
- Add XApiController for manual queue inspection/testing
- Add xAPI queue database table and Entity Framework migration
- Implement XApiService for statement generation (ViewViewed, TeamJoined)
- Implement XApiQueueService for persistent queue management
- Add XApiBackgroundService for background statement delivery
- Emit ViewViewed statement when user accesses a view
- Emit TeamJoined statement when user is added to a team
- Add XApiOptions configuration with LRS endpoint settings
- Add XApiController for manual queue inspection/testing
…statements

- Add EmitTeamSwitchedAsync using "switched" verb (https://w3id.org/xapi/verbs/switched)
- Add team context extension (https://crucible.sei.cmu.edu/xapi/extensions/team) to all xAPI statements
- Include user's active teamId in viewed, experienced, terminated, and switched statements
- Add POST /api/xapi/switched/view/{viewId}/team/{teamId} endpoint
- Emit team switched statement from SetPrimary handler
- Add POST /api/xapi/viewed/view/{viewId} endpoint for explicit view tracking
- Remove auto-emit from GET /api/views/{id} to prevent unwanted statements
- View viewed statement now only logs when user actively enters view, not on every GET request
Use 'accessed' verb (http://activitystrea.ms/schema/1.0/access) for application switching instead of 'experienced'. More semantically accurate for navigating to applications and matches Console's VM access pattern.
Fix xAPI validation error when application names contain spaces (e.g., 'MSEL View'). URL-encode application name before using in activity ID to ensure valid IRI format.
@sei-awelle sei-awelle requested a review from a team as a code owner May 6, 2026 15:45
github-actions Bot and others added 6 commits May 6, 2026 15:45
Ensures xAPI statements are eventually delivered to LRS even during extended outages by distinguishing transient errors (retry indefinitely) from permanent errors (fail immediately).

**Transient vs Permanent Error Handling:**
- Transient (retry indefinitely): Timeouts, network errors, HTTP 429/500/502/503/504
- Permanent (fail immediately): HTTP 400/401/403/422 (bad data or auth)
- HTTP 409 (Conflict) treated as success (statement already exists)
- Removed MaxRetryCount limit for transient errors
- Increased retry delay from 5 to 30 seconds (configurable)

**Stuck Processing Record Cleanup:**
- Add ProcessingTimeoutMinutes config (default 10 minutes)
- Add GetStuckProcessingStatementsAsync to detect orphaned records
- Cleanup deletes Processing records where LastAttemptAt > timeout
- Prevents accumulation of records stuck when service crashes during HTTP call

**Configuration Changes:**
- Add ProcessingTimeoutMinutes to XApiOptions (default 10)
- Add ProcessingDelaySeconds to XApiOptions (default 30)
- Both configurable via appsettings.json

**Data Loss Prevention:**
- LRS down 1 hour: statements keep retrying
- LRS down 1 day: statements keep retrying
- LRS down 7+ days: statements deleted per RetentionDays (increase if needed)
- Permanent errors (bad credentials, malformed statements) fail immediately

**Breaking Changes:**
- IXApiQueueService.MarkFailedAsync signature changed: added bool isTransientError parameter
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