Key Pick few enough to remember. Quality beats quantity. Focus on perceived utility, not execution speed or error rate. Choose simple metrics. KPIs are summaries, not the whole story. Performance Indicators Define Success
Who Cares? Snapshot of company health and progress. Help customers follow best practices. Identify failing accounts. Prioritize projects and benchmark success. Drive design. Board CS Product
Desiderata Support per-org queries with on- the-fly aggregation. Aggregate over days, weeks, months, quarters, and years. HTML tables in debug plus flat file downloads. Sharding Periods UI
# In fanmgmt. kpi s. constants. your_pi llar_name from . base i mport Kpi Enum, Kpi EnumValue class ExampleKpi (Kpi Enum) : WIDGETS = Kpi EnumValue(1, ' wi dgets' , _(' Wi dgets Produced' ) ) PERCENT_GNOME = Kpi EnumValue( 2, ' percent_gnome' , _(' % Made by Gnomes' ) , explanati on=' Gnomes are small humanoi ds' ) First Define your KPIs.
Second Add your pillar. # In fanmgmt. kpi s. constants. pi llar from . your_pi llar_name i mport ExampleKpi class Pi llar(OrderedRi chEnum) : . . . EXAMPLE = _Pi llar(4, ' example' , _(' Example' ) , ExampleKpi )
# In your app' s tasks module # Schedule through debug, send to KPI queue from fanmgmt i mport kpi @kpi . task(kpi . Pi llar. EXAMPLE) def count_wi dgets(organi zati on, start, end, track) : # Type si gnature i s i mportant! wi dgets = Wi dget. obj ects. fi lter(**params) . count() gnome = Wi dget. obj ects. fi lter(**other_params) . count() track. count(ExampleKpi . WIDGETS, wi dgets) ) track. fracti on(ExampleKpi . PERCENT_GNOME, gnome, wi dgets) Last Write some tasks.
var toggleWi dget = functi on() { // HearsayEvents i s already i n the global scope. var kpi = new HearsayEvents. Tracker("myPi llar") ; // Start si mple. kpi . track("myEvent") ; // More complex. . . i f you must. kpi . track("complexEvent", "subtype1", 100) ; }; First Track your events.
var toggleWi dget = functi on() { // HearsayEvents i s already i n the global scope. var kpi = new HearsayEvents. Tracker("myPi llar") ; // Start si mple. kpi . track("myEvent") ; // More complex. . . i f you must. kpi . track("complexEvent", "subtype1", 100) ; }; First Track your events.
Optional Subclass the tracker. var myTracker = functi on() { // Easy to take an obj ect and do some di spatch logi c thi s. trackComplex = functi on(j sObj ect) { thi s. track("cli cked_" + j sObj ect. name) ; thi s. track("num_" + j sObj ect. name, "", j sObj ect. length) ; }; }; myTracker. prototype = new HearsayEvents. Tracker("myPi llar") ;