Bc assignment diagnose asset telemetry

From breatheco-de/apiv2 · View interactive version

Bc assignment diagnose asset telemetry is an AI agent skill from the GitHub repository breatheco-de/apiv2. Use when diagnosing assignment/package telemetry collection for an asset, user, or task and when interpreting telemetry stats usage patterns, and do NOT use for general assignment grading or non-telemetry workflows.

How to use this skill

Skill file

Skill: Diagnose Asset Telemetry Collection

When to Use

Use this skill when you need to confirm if telemetry exists for an asset, user, or task, identify why it is missing, or interpret telemetry stats to understand package/asset usage patterns. Use it for ingestion validation, staff upsert/update validation, per-task telemetry retrieval checks, and aggregate telemetry-stats interpretation. Do NOT use this skill to grade assignments, manage code reviews, or modify non-telemetry task fields.

Concepts

Workflow

  1. Identify the telemetry question first:
  1. Validate request scope and headers before troubleshooting data:
  1. Validate ingestion path if telemetry is "not arriving":
  1. Inspect LearnPack webhook processing state (academy staff):
  1. Validate persistence for a specific user+asset:
  1. Validate retrieval from assignment task:
  1. Check canonical slug implications when telemetry appears split:
  1. Queue recomputation of asset-level telemetry stats (staff):

Endpoints

Ingest LearnPack telemetry

Request example

{
  "event": "batch",
  "user_id": 1234,
  "asset_id": 987,
  "slug": "javascript-arrays-intro",
  "package_id": 555,
  "timestamp": "2026-04-15T10:30:00Z",
  "step": 14
}

Response example

"ok"

List LearnPack webhook logs (academy staff observability)

Request example

GET /v1/assignment/academy/learnpack/webhook?student=123,456&event=batch,open_step&asset_id=10,20&learnpack_package_id=1000,2000&status=PENDING,DONE

Response example

{
  "count": 2,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 9011,
      "is_streaming": true,
      "event": "batch",
      "asset_id": 10,
      "learnpack_package_id": 1000,
      "payload": {
        "event": "batch",
        "user_id": 123,
        "asset_id": 10,
        "package_id": 1000
      },
      "status": "DONE",
      "status_text": "OK",
      "student": {
        "id": 123,
        "first_name": "Ada",
        "last_name": "Lovelace"
      },
      "created_at": "2026-04-15T10:30:00Z",
      "updated_at": "2026-04-15T10:30:03Z"
    },
    {
      "id": 9012,
      "is_streaming": true,
      "event": "open_step",
      "asset_id": 20,
      "learnpack_package_id": 2000,
      "payload": {
        "event": "open_step",
        "user_id": 456,
        "asset_id": 20,
        "package_id": 2000
      },
      "status": "ERROR",
      "status_text": "Learnpack telemetry event `open_step` is not implemented",
      "student": {
        "id": 456,
        "first_name": "Grace",
        "last_name": "Hopper"
      },
      "created_at": "2026-04-15T10:35:00Z",
      "updated_at": "2026-04-15T10:35:01Z"
    }
  ]
}

Delete one LearnPack webhook log (academy staff cleanup)

Valid request example

DELETE /v1/assignment/academy/learnpack/webhook/9012

Invalid request example (row is not ERROR)

DELETE /v1/assignment/academy/learnpack/webhook/9011

Bulk delete LearnPack webhook logs by filters (academy staff cleanup)

Valid request example

DELETE /v1/assignment/academy/learnpack/webhook?status=ERROR&asset_id=20&learnpack_package_id=3000

Invalid request examples

DELETE /v1/assignment/academy/learnpack/webhook
DELETE /v1/assignment/academy/learnpack/webhook?status=DONE

Get / replace LearnPack telemetry webhook ignore rules (academy staff)

Matching behavior:

Request body (PUT) — combination-aware shape (recommended):

{
  "rules": [
    {
      "events": ["batch"],
      "learnpack_package_ids": [13190]
    },
    {
      "user_ids": [123]
    }
  ]
}

Legacy body shape (still valid):

{
  "user_ids": [123],
  "learnpack_package_ids": [456],
  "package_slugs": ["my-pack"],
  "asset_ids": [789],
  "events": ["open_step"]
}

Response (GET / PUT): the same object shape (possibly empty {}).

Upsert telemetry for a user and asset (academy staff)

Request example

{
  "telemetry": {
    "event": "batch",
    "step": 3,
    "interactions": 21
  },
  "engagement_score": 82.5,
  "frustration_score": 14.2,
  "metrics_algo_version": 1.2,
  "metrics": {
    "global": {
      "metrics": {
        "total_time_on_platform": 1800,
        "completion_rate": 67.5
      }
    }
  },
  "total_time": "00:30:00",
  "completion_rate": 67.5
}

Response example

{
  "id": 4512,
  "telemetry": {
    "event": "batch",
    "step": 3,
    "interactions": 21
  },
  "engagement_score": 82.5,
  "frustration_score": 14.2,
  "metrics_algo_version": 1.2,
  "metrics": {
    "global": {
      "metrics": {
        "total_time_on_platform": 1800,
        "completion_rate": 67.5
      }
    }
  },
  "total_time": "00:30:00",
  "completion_rate": 67.5
}

Update telemetry for an existing user+asset record (academy staff)

Request example

{
  "engagement_score": 91.0,
  "completion_rate": 95.0,
  "total_time": "00:45:00"
}

Response example

{
  "id": 4512,
  "telemetry": {
    "event": "batch",
    "step": 8,
    "interactions": 55
  },
  "engagement_score": 91.0,
  "frustration_score": 8.1,
  "metrics_algo_version": 1.2,
  "metrics": {
    "global": {
      "metrics": {
        "total_time_on_platform": 2700,
        "completion_rate": 95.0
      }
    }
  },
  "total_time": "00:45:00",
  "completion_rate": 95.0
}

Queue asset telemetry stats recalculation (registry academy)

Request example

{}

Response example (representative; full asset shape is large)

{
  "id": 301,
  "slug": "javascript-arrays-intro",
  "title": "JavaScript Arrays Intro",
  "asset_type": "EXERCISE",
  "academy": 1,
  "telemetry_stats": {
    "last_sync_at": "2026-04-15T09:00:00.123456+00:00",
    "days": {
      "2026-04-14": {
        "frustration_avg": 12.5,
        "engagement_avg": 78.3,
        "completion_avg": 45.2,
        "total_sessions": 120
      }
    }
  },
  "sync_status": "OK",
  "updated_at": "2026-04-15T10:12:00Z"
}

Retrieve telemetry through a task (per user basis)

Response example

{
  "id": 890699,
  "title": "Arrays Practice",
  "task_status": "PENDING",
  "associated_slug": "javascript-arrays-intro",
  "revision_status": "PENDING",
  "task_type": "EXERCISE",
  "assignment_telemetry": {
    "event": "batch",
    "step": 8,
    "interactions": 55
  },
  "created_at": "2026-04-15T09:20:00Z",
  "updated_at": "2026-04-15T10:35:00Z"
}

Edge Cases

  1. Missing Academy header on staff endpoint

Observation: 403 error about missing academy header/scope.

Action: resend request with Academy: <academy_id>.

  1. Missing capability for telemetry write

Observation: 403 (for crud_telemetry or upload_assignment_telemetry).

Action: use a token with the required capability in the target academy.

  1. User does not exist for staff upsert/update

Observation: 404 with slug user-not-found.

Action: correct user_id before retrying.

  1. PUT used before telemetry exists

Observation: 404 with slug telemetry-not-found.

Action: call POST upsert first, then PUT for subsequent updates.

  1. Telemetry accepted but not immediately retrievable

Observation: ingestion returns ok but task retrieval still shows assignment_telemetry: null.

Action: check webhook list endpoint and inspect status/status_text, then re-check after processing.

  1. Canonical slug mismatch

Observation: telemetry appears missing for translated slug while existing for canonical slug.

Action: validate slug normalization/canonical translation and re-check using canonical asset context.

  1. No cross-user telemetry list endpoint

Observation: no public endpoint returns telemetry for multiple users by asset in one request.

Action: rely on per-user telemetry retrieval and asset-level precomputed stats (Asset.telemetry_stats) for aggregate diagnostics.

  1. Stats sync queued but telemetry_stats unchanged in response

Observation: PUT .../action/sync_telemetry_stats returns 200 but telemetry_stats.last_sync_at or today's days entry is unchanged.

Action: wait for Celery, then GET the asset again from registry; avoid tight retry loops.

  1. Invalid numeric filter token on webhook list

Observation: 400 with slug invalid-filter when sending non-numeric ids in student, asset_id, or learnpack_package_id.

Action: send only comma-separated numeric ids on these filters.

  1. Bulk delete without strict ERROR filter

Observation: 400 with slug missing-status (missing status) or invalid-status (status other than ERROR).

Action: resend bulk delete with status=ERROR and optional narrowing filters.

  1. Old webhook logs disappear without manual API delete

Observation: older LearnPackWebhook rows may be removed by maintenance jobs.

Action: account for periodic cleanup via python manage.py assignments_garbage_collect (deletes old webhook rows by age). In many deployments this is likely scheduled by infrastructure on a coarse cadence (often around monthly / ~30 days), but the exact trigger frequency is environment-dependent.

Checklist

  1. Confirmed which telemetry path applies: ingestion, staff upsert/update, or task retrieval.
  2. Confirmed required headers (Authorization, and Academy for /academy/ endpoints).
  3. Verified write endpoint outcome by expected status (201, 200, 404, 403).
  4. Verified task endpoint returns assignment_telemetry for the expected task_id.
  5. Checked slug consistency between task associated_slug and telemetry asset slug used in writes.
  6. Accounted for async delay before concluding telemetry is missing.
  7. If asset-level trend is needed, confirmed data should be read from Asset.telemetry_stats (precomputed aggregate), not from a multi-user telemetry list endpoint.
  8. If stats are stale or missing, used PUT /v1/registry/academy/asset/{asset_slug}/action/sync_telemetry_stats and re-fetched the asset after the background job had time to complete.
  9. If ingestion accepted but telemetry is missing, checked GET /v1/assignment/academy/learnpack/webhook with filters to confirm webhook status and status_text.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.