Skip to content

Weekly Analytics Logic

The weekly analytics package produces FreightTiger's TMS leadership report from Pylon data. It is deterministic up to the summary stage: data pull, classification, SLA breach, health, and red flags are computed before any LLM text generation.

Pipeline Stages

StageScriptOutput
Pull Pylonscripts/01_pull_pylon.pyaccounts.json, issues_4w.json, issues_1w.json, manifest.json
Compute metricsscripts/02_compute_metrics.pymetrics.json
Generate summariesscripts/03_generate_summaries.pysummaries.json
Render reportscripts/04_render_report.pyreports/{date}/report.html, reports/{date}/report.md
Publishscripts/05_publish.shStaticrypt-encrypted Cloudflare Pages archive

Pull Logic

The pull step:

  • Loads PYLON_API_KEY from .env or environment.
  • Resolves current Pylon enum slugs for System Issue / Bug and New Feature Request.
  • Pulls all accounts from Pylon.
  • Keeps accounts where business_line_for_customer_account = tms.
  • Keeps tiers: Platinum, Gold, Silver, Bronze.
  • Extracts tier, MRR, active modules, and CSM lead.
  • Pulls issues created in the last 28 days.
  • Joins issues to the kept accounts.

Metric Logic

The metrics step:

  • Classifies each issue as bug, feature request, or other.
  • Resolves severity from tms_severity.
  • Falls back from priority when severity is missing:
    • urgent -> P1
    • high -> P2
    • medium -> P3
    • low -> P3
  • Applies SLA policy from config/sla_policy.yml.
  • Uses native resolution_seconds where available.
  • Falls back to resolution_time or updated_at minus created_at for closed tickets.
  • Uses open-ticket age for unresolved tickets.
  • Marks breach when elapsed hours exceed SLA target hours.

SLA Policy

Bug SLA is tier and severity based. Feature request SLA is tier based and converted from days to hours.

TierOutageP1P2P3Feature request
Platinum4h24h72h168h30d
Gold8h48h120h240h45d
Silver24h120h240h360h60d
Bronze48h240h360h720h90d

Health Score

Health is bug-only and severity-weighted.

SeverityWeight
outage10
P17
P24
P32
text
health = sum(severity_weight * on_time_flag) / sum(severity_weight) * 100

Feature request on-time performance is reported separately and does not affect the health score.

Accounts with no evaluable bugs

Accounts with zero evaluable bugs, or only bugs whose severity cannot be resolved, have health = null and do not contribute to tier averages.

Red Flags

The package computes mechanical red flags:

  • Open outage/P1 bugs with no assignee.
  • Accounts with 100 percent bug breach and at least two evaluable bugs.
  • Modules with bug breach above 60 percent and at least three evaluable bugs.
  • Open bugs aged 20 or more days.

These are the primary grounding inputs for the LLM action synthesis.

Summary Logic

The summary step uses local Ollama:

PropertyValue
Endpointhttp://localhost:11434/api/generate
Modelqwen3:8b
Temperature0.2
Scope outputThree concerns per scope
Final synthesisThree or four actions each for Account Managers, Engineering, and Product

The script writes summaries.json incrementally so interrupted runs can resume.

Render Logic

The renderer:

  • Loads metrics, summaries, Pylon URL templates, module labels, and Jinja templates.
  • Converts module slugs to friendly labels.
  • Linkifies valid Pylon ticket numbers.
  • Linkifies known account names using account ids from the snapshot.
  • Linkifies configured tier views.
  • Removes LLM-invented ticket references when the ticket number is not present in issues_4w.json.

FreightTiger Pylon setup, skills, and automations handoff