Skip to content

Gamify: E-P1 cloud session plumbing + offline event queue #797

Description

@fernandotonon

Part of #796 — Gamify: editor half. Pairs with qtmesh-cloud#80.

Goal

Give the editor a reliable, offline-tolerant way to send gamification events to the account and read back stats — built on the existing cloud session, not a parallel stack.

Work

  • Reuse QtMeshCloudSession / QtMeshCloudClient and the existing credential store (CloudCredentialStore) + device-flow auth. No new auth.
  • Add a persistent event queue (GamificationEventQueue): append-only local store (e.g. JSON/SQLite in the app config dir) of pending events, each with a client-generated idempotency id. Survives restarts.
  • Add client methods:
    • postEditorEvents(bearer, events[]) → POST /v1/events/editor (feature usage).
    • postOperationEvents(bearer, ops[]) → POST /v1/events/operations (outcomes; new cloud endpoint).
    • fetchStats(bearer) → GET /v1/me/stats → parsed {level, xp, streak, achievements, featureUsage, recentlyEarned}.
  • Flush policy: batch every N minutes / on app idle / on graceful shutdown; exponential backoff on failure; drop nothing until acked. Cap queue size with FIFO eviction + a logged warning (no silent loss).
  • Return newly-earned achievements from flush so E-P4 can toast them.

Acceptance criteria

  • Events queued while offline/logged-out are held and flushed once authenticated + online.
  • Flush is idempotent (same id never double-sent effect); backoff on 5xx; respects server retry hints.
  • Queue persists across restarts and is bounded (FIFO eviction logged, never silent).
  • fetchStats parses into a typed struct with unit tests.
  • Zero network activity when the user is logged out.

Notes

  • Keep the queue transport-agnostic so E-P2 (usage) and E-P3 (operations) just enqueue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    editorenhancementNew feature or requestgamificationGamification / engagement (epic prefix: Gamify:)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions