Ir para o conteúdo

Lição 25 · Projects and Reference

Project: A KPI Dashboard

Design and prototype a support-team KPI dashboard: brief, KPI cards, status rules, a working HTML and JavaScript preview, stale data warnings and a user test.

This project turns the dashboard lessons into a working prototype for an invented support team. It uses plain HTML and JavaScript so that you can see every rule. A business intelligence tool would replace the code, but the decisions would be the same.

Step 1: The brief

TEXT
Readers:   Support team lead (daily), department head (weekly)
Decision:  Where to move people, and which problems to escalate
Questions: Are customers getting a first reply fast enough?
           Is quality holding? Which queue is struggling?
Freshness: Hourly; show a warning if data is older than 2 hours

Step 2: Define the KPIs

KPI Definition Target Direction
First reply within 4 h Tickets with first reply within 4 hours, divided by tickets whose 4 hours have passed or that got a reply in time 90% Higher
Reopen rate Closed tickets reopened within 7 days, divided by closed tickets at least 7 days old 5% Lower
Open backlog Tickets not closed at the data time 120 Lower

The first definition avoids a common trap. A new ticket that has no reply but is only one hour old has not failed yet, so it is left out. A ticket older than 4 hours without a reply counts as a miss.

Step 3: Test the definition in code

Python The first-reply KPI with edge cases

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The result is 60% (3 of 5). If your team counts business hours only, this simple age calculation is not enough, and you need a working-hours calendar. Write that rule in the definition.

Notice one effect of this definition: a fast reply counts at once, while a possible miss counts only after 4 hours. For the very newest tickets, the rate can therefore look a little high. If that matters, judge only tickets older than 4 hours and show the data window.

Step 4: Sketch

TEXT
+---------------------------------------------------------+
| Support overview        data through HH:MM     owner    |
| [warning banner if stale]                               |
+------------------+------------------+-------------------+
| First reply KPI  | Reopen rate      | Open backlog      |
+------------------+------------------+-------------------+
| Queue table, worst first: queue, KPI, backlog, status   |
+---------------------------------------------------------+

Step 5: Prototype

The preview below holds sample data in a script. Status rules live in one function, so cards and table agree. Text is added with textContent, which does not interpret data as HTML.

A support KPI dashboard prototype

The total reply rate is 300 of 330, about 90.9%, so it is on target. Yet Billing is at 84%. This is why the table sits under the cards: a good overall figure can hide a struggling queue. The backlog is 111, within the limit of 120, and the data is almost 3 hours old, so the warning appears.

Step 6: Break it on purpose

Try these changes and check the behavior:

  • Set a queue's judged to 0. The rate becomes invalid. Add a rule that shows "n/a" and no status.
  • Change dataTime to 08:30. The warning should disappear.
  • Rename a queue to <b>Billing</b>. It should appear as plain text.

Step 7: Test with a reader

Give a colleague the preview and ask: "What needs attention?" and "Would you act on these numbers right now?" A reader who misses the stale-data warning shows you that it must be more prominent. Record what you change.

What a real version needs

A production dashboard also needs a data connection, access control, tested definitions, history for trends, monitoring and an owner. Do not put database passwords or private rows in browser code, because anyone who receives the page can read it.

Decide what happens on bad days

A prototype usually shows a normal day. Before building the real version, write down how it behaves when things are not normal.

Situation Expected behavior
No tickets judged yet today Show "n/a" with the counts, and no status
Source feed stopped Show a stale warning; do not show a fresh status
A new queue appears Include it, and flag it for the owner to confirm
A ticket moves between queues Follow the written rule, for example the current queue
A sudden flood of tickets Keep the list readable, with the oldest first

Each row is a decision for the support lead, not only for the developer. The queue rule is a good example: counting a moved ticket in its first queue or in its current one changes which team appears slow. Put the chosen rule in the KPI definition.

Also plan the history. The prototype shows only the present. To see whether replies are getting faster, store a daily snapshot of each KPI with its numerator, denominator and definition version. Then you can draw a trend with correct weekly totals instead of averaging daily percentages.

Plan the rollout

Run the new dashboard beside the current way of working for a short period. Each day, compare a few figures with the ticket system and investigate any difference. Ask the lead to note each time the dashboard changed a decision, and each time it raised a question it could not answer. These notes tell you what to keep, what to add and what to remove before more teams start relying on it.

Finally, name who may change a target. If anyone can edit the limit in the code, a red card can turn green without any change in service. Keep targets in one reviewed place, show them on the cards and record when each one changed. Review the targets with the support lead on an agreed schedule, using the stored history.

A card that shows "On target" with stale data can give false comfort. Consider hiding statuses, or marking them as unknown, when the data is too old.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Why is a one-hour-old unanswered ticket left out of the 4-hour KPI?

    Judging it early would make the rate wrong.
  2. 2. The total is on target but one queue is far below. What should the dashboard do?

    Totals can hide problems in parts.
  3. 3. Why use textContent when adding queue names to the page?

    Treating data as text avoids injected markup.

Summary

  • Begin with readers, decisions and precise KPI definitions.
  • Test definitions with edge cases such as pending tickets and exact limits.
  • Keep status rules in one place and show breakdowns under totals.
  • Warn about stale data and handle zero denominators.
  • Try to break the prototype and test it with a real reader.

Next: Glossary and Cheat Sheet

Seu progresso fica salvo neste navegador. Não precisa de conta.