Skip to content
On this page

Analytics

Query TrainHeroic coach analytics from the SDK, including team readiness, compliance, training volume, one-rep-max history, and lift progress.

Analytics helpers are read-only. TrainHeroic happens to use POST for these report queries, but the calls do not mutate account data.

import { analyticsMetricCatalog, queryAnalytics } from "@trainheroic-unofficial/js";

const readiness = await queryAnalytics(client, {
  metric: "readiness-team",
  teamId: 42,
  date: "2026-08-10",
});

console.log(readiness);
console.log(analyticsMetricCatalog());

Metrics

Metric Scope Required inputs
readiness-team Team date
compliance-team Team dateStart, dateEnd
lift-progress-team Team exerciseId, dateStart, dateEnd
readiness-athlete Athlete dateStart, dateEnd
training-summary-athlete Athlete dateStart, dateEnd
lift-1rm-history Athlete exerciseId, dateStart, dateEnd
working-max-history Athlete exerciseId

queryAnalytics throws a readable error that names any required input you left out.

Query inputs

PropType
metricAnalyticsMetric

One of the metric names in the metrics table.

TypeAnalyticsMetric
teamId?number

The team to report on. Required for team metrics.

Typenumber
userIds?number[]

One or more athlete ids. Required for athlete metrics; the report returns one row per athlete.

Typenumber[]
date?string

A single day as YYYY-MM-DD, for readiness-team.

Typestring
dateStart?string

The first day of a range, as YYYY-MM-DD.

Typestring
dateEnd?string

The last day of a range, as YYYY-MM-DD.

Typestring
exerciseId?number

The lift to report on, for the lift metrics.

Typenumber
useMetric?boolean

Report weights in kilograms, for lift-1rm-history and working-max-history.

Typeboolean

Team volume

There is no raw team-volume metric. Pass every athlete id to training-summary-athlete, or use teamVolume() to group the per-athlete rows into one rollup.