Skip to content

feat(#10438): add telemetry for visible task count on recalculation#10755

Merged
dianabarsan merged 3 commits intomedic:masterfrom
megha1807:feat/10438-visible-task-telemetry
Mar 27, 2026
Merged

feat(#10438): add telemetry for visible task count on recalculation#10755
dianabarsan merged 3 commits intomedic:masterfrom
megha1807:feat/10438-visible-task-telemetry

Conversation

@megha1807
Copy link
Copy Markdown
Contributor

@megha1807 megha1807 commented Mar 25, 2026

Description

Fixes #10438
Docs PR:medic/cht-docs#2171

Each time tasks are recalculated in tasks.component.ts, there was no way to know how many tasks are visible to a
user without querying the server directly.

This PR adds a telemetry entry tasks:visible-count that records the number of visible tasks each time refreshTasks()
is called — covering both initial load and subsequent recalculations triggered by changes or rules engine updates.

Changes Made

  • Injected TelemetryService into TasksComponent
  • Added telemetryService.record('tasks:visible-count', tasksWithLineage.length) after tasks are recalculated
  • Added unit test to verify telemetry is recorded with
    the correct key and count

Code review checklist

  • Readable: Concise, well named, follows the style guide
  • Tested: Unit tests added
  • AI disclosure: Used AI assistance for guidance on
    implementation approach and test structure

Copy link
Copy Markdown
Member

@dianabarsan dianabarsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! One small comment about naming.

...this.getTaskLineage(subjects, task)
}));
this.tasksActions.setTasksList(tasksWithLineage);
this.telemetryService.record('tasks:visible-count', tasksWithLineage.length);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using visible is too bespoke here. Please just use tasks:all-tasks, because it matches with other telemetry entries that we have: https://docs.communityhealthtoolkit.org/technical-overview/data/performance/telemetry/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dianabarsan, thank you for the feedback!
I have updated the telemetry key from tasks:visible-count to tasks:all-tasks to match the existing naming conventions.

@dianabarsan dianabarsan self-requested a review March 25, 2026 14:50
Copy link
Copy Markdown
Member

@dianabarsan dianabarsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!

I will have to ask for a followup PR to cht-docs telemetry to document the new entry.

@megha1807
Copy link
Copy Markdown
Contributor Author

Thanks @dianabarsan!

I’ll create a follow-up PR in cht-docs to document the new telemetry entry.

@megha1807
Copy link
Copy Markdown
Contributor Author

Hello @dianabarsan
I have made a PR to PR in cht-docs to document the new telemetry entry.
medic/cht-docs#2171

@dianabarsan dianabarsan merged commit 4048e3c into medic:master Mar 27, 2026
28 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.

Add telemetry for how many tasks the users see

2 participants