Skip to main content
← All Guides
intermediate 15 min 250 XP

Build an Analytics Dashboard

Use the analytics and CSAT endpoints to build a team performance dashboard showing ticket metrics, agent stats, and customer satisfaction.

Prerequisites

  • A cStar account with a secret API key
  • Some resolved tickets for data
1

Fetch the analytics overview

Get ticket counts, response times and CSAT for any time period.

js
import { CStarClient } from '@cstar.help/js';

const cstar = new CStarClient({
  apiKey: process.env.CSTAR_SECRET_KEY,
  teamId: process.env.CSTAR_TEAM_ID,
});

// Get this week's metrics (bare resource, Plan 03 / 0.13.0)
const overview = await cstar.analytics.overview({ period: 'week' });

console.log('Tickets this week:', overview.tickets.total);
console.log('Open:', overview.tickets.open);
console.log('Closed:', overview.tickets.closed);
console.log('Avg first response (s):', overview.responseTime.avgSeconds);

// CSAT has its own rollup
const csat = await cstar.analytics.csatStats({ period: 'week' });
console.log('CSAT:', csat);

2

Get per-agent performance

See how each agent is performing.

js
// One row per agent: { agentId, ticketsClosed, avgResponseSeconds, goldTier, missedSla }
const { agents } = await cstar.analytics.performance({ period: 'week' });

for (const agent of agents) {
  console.log(`${agent.agentId}: ${agent.ticketsClosed} closed, ${agent.missedSla} missed SLA`);
}

3

Add the game leaderboard

Show the gamification leaderboard alongside traditional metrics.

js
// Game leaderboard, unique to cStar.
// Plan 03 returns the unwrapped envelope directly:
// {entries, totalParticipants?, period?}
const { entries } = await cstar.game.leaderboard({ period: 'weekly' });

for (const entry of entries) {
  console.log(`#${entry.rank} ${entry.name} (Level ${entry.level}, Score: ${entry.score})`);
}

// Boss status: bare resource
const boss = await cstar.game.boss.current();
if (boss.active) {
  console.log(`Active boss: ${boss.name} (${boss.healthPercent}% HP)`);
}

What's Next?