@contractspec/example.analytics-dashboard 3.9.8 → 3.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/dashboard/dashboard.enum.js +1 -34
- package/dist/browser/dashboard/dashboard.operation.js +1 -289
- package/dist/browser/dashboard/dashboard.presentation.js +1 -200
- package/dist/browser/dashboard/dashboard.schema.js +1 -126
- package/dist/browser/dashboard/dashboard.test-spec.js +1 -213
- package/dist/browser/dashboard/index.js +1 -299
- package/dist/browser/dashboard.feature.js +1 -683
- package/dist/browser/datasource/posthog-datasource.js +4 -289
- package/dist/browser/docs/analytics-dashboard.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/events.js +1 -81
- package/dist/browser/example.js +1 -42
- package/dist/browser/handlers/analytics.handlers.js +4 -278
- package/dist/browser/handlers/index.js +7 -571
- package/dist/browser/handlers/query.handlers.js +4 -294
- package/dist/browser/index.js +12 -2317
- package/dist/browser/query/index.js +1 -159
- package/dist/browser/query/query.enum.js +1 -11
- package/dist/browser/query/query.operation.js +1 -154
- package/dist/browser/query/query.presentation.js +1 -122
- package/dist/browser/query/query.schema.js +1 -70
- package/dist/browser/query/query.test-spec.js +1 -113
- package/dist/browser/query-engine/index.js +4 -491
- package/dist/browser/seeders/index.js +2 -20
- package/dist/browser/ui/AnalyticsDashboard.js +1 -1115
- package/dist/browser/ui/AnalyticsDashboard.widgets.js +1 -94
- package/dist/browser/ui/AnalyticsQueriesTable.js +1 -188
- package/dist/browser/ui/hooks/index.js +1 -660
- package/dist/browser/ui/hooks/useAnalyticsData.js +1 -657
- package/dist/browser/ui/index.js +5 -1283
- package/dist/browser/ui/renderers/analytics.markdown.js +5 -756
- package/dist/browser/ui/renderers/index.js +5 -756
- package/dist/browser/visualizations/catalog.js +1 -457
- package/dist/browser/visualizations/index.js +1 -611
- package/dist/browser/visualizations/specs.breakdown.js +1 -140
- package/dist/browser/visualizations/specs.performance.js +1 -198
- package/dist/browser/visualizations/widgets.js +1 -595
- package/dist/dashboard/dashboard.enum.js +1 -34
- package/dist/dashboard/dashboard.operation.js +1 -289
- package/dist/dashboard/dashboard.presentation.js +1 -200
- package/dist/dashboard/dashboard.schema.js +1 -126
- package/dist/dashboard/dashboard.test-spec.js +1 -213
- package/dist/dashboard/index.js +1 -299
- package/dist/dashboard.feature.js +1 -683
- package/dist/datasource/posthog-datasource.js +4 -289
- package/dist/docs/analytics-dashboard.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/events.js +1 -81
- package/dist/example.js +1 -42
- package/dist/handlers/analytics.handlers.js +4 -278
- package/dist/handlers/index.js +7 -571
- package/dist/handlers/query.handlers.js +4 -294
- package/dist/index.js +12 -2317
- package/dist/node/dashboard/dashboard.enum.js +1 -34
- package/dist/node/dashboard/dashboard.operation.js +1 -289
- package/dist/node/dashboard/dashboard.presentation.js +1 -200
- package/dist/node/dashboard/dashboard.schema.js +1 -126
- package/dist/node/dashboard/dashboard.test-spec.js +1 -213
- package/dist/node/dashboard/index.js +1 -299
- package/dist/node/dashboard.feature.js +1 -683
- package/dist/node/datasource/posthog-datasource.js +4 -289
- package/dist/node/docs/analytics-dashboard.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/events.js +1 -81
- package/dist/node/example.js +1 -42
- package/dist/node/handlers/analytics.handlers.js +4 -278
- package/dist/node/handlers/index.js +7 -571
- package/dist/node/handlers/query.handlers.js +4 -294
- package/dist/node/index.js +12 -2317
- package/dist/node/query/index.js +1 -159
- package/dist/node/query/query.enum.js +1 -11
- package/dist/node/query/query.operation.js +1 -154
- package/dist/node/query/query.presentation.js +1 -122
- package/dist/node/query/query.schema.js +1 -70
- package/dist/node/query/query.test-spec.js +1 -113
- package/dist/node/query-engine/index.js +4 -491
- package/dist/node/seeders/index.js +2 -20
- package/dist/node/ui/AnalyticsDashboard.js +1 -1115
- package/dist/node/ui/AnalyticsDashboard.widgets.js +1 -94
- package/dist/node/ui/AnalyticsQueriesTable.js +1 -188
- package/dist/node/ui/hooks/index.js +1 -660
- package/dist/node/ui/hooks/useAnalyticsData.js +1 -657
- package/dist/node/ui/index.js +5 -1283
- package/dist/node/ui/renderers/analytics.markdown.js +5 -756
- package/dist/node/ui/renderers/index.js +5 -756
- package/dist/node/visualizations/catalog.js +1 -457
- package/dist/node/visualizations/index.js +1 -611
- package/dist/node/visualizations/specs.breakdown.js +1 -140
- package/dist/node/visualizations/specs.performance.js +1 -198
- package/dist/node/visualizations/widgets.js +1 -595
- package/dist/query/index.js +1 -159
- package/dist/query/query.enum.js +1 -11
- package/dist/query/query.operation.js +1 -154
- package/dist/query/query.presentation.js +1 -122
- package/dist/query/query.schema.js +1 -70
- package/dist/query/query.test-spec.js +1 -113
- package/dist/query-engine/index.js +4 -491
- package/dist/seeders/index.js +2 -20
- package/dist/ui/AnalyticsDashboard.js +1 -1115
- package/dist/ui/AnalyticsDashboard.widgets.js +1 -94
- package/dist/ui/AnalyticsQueriesTable.js +1 -188
- package/dist/ui/hooks/index.js +1 -660
- package/dist/ui/hooks/useAnalyticsData.js +1 -657
- package/dist/ui/index.js +5 -1283
- package/dist/ui/renderers/analytics.markdown.js +5 -756
- package/dist/ui/renderers/index.js +5 -756
- package/dist/visualizations/catalog.js +1 -457
- package/dist/visualizations/index.js +1 -611
- package/dist/visualizations/specs.breakdown.js +1 -140
- package/dist/visualizations/specs.performance.js +1 -198
- package/dist/visualizations/widgets.js +1 -595
- package/package.json +13 -13
|
@@ -1,757 +1,6 @@
|
|
|
1
|
-
// src/visualizations/specs.breakdown.ts
|
|
2
|
-
import { defineVisualization } from "@contractspec/lib.contracts-spec/visualizations";
|
|
3
|
-
var QUERY_REF = { key: "analytics.query.execute", version: "1.0.0" };
|
|
4
|
-
var META = {
|
|
5
|
-
version: "1.0.0",
|
|
6
|
-
domain: "analytics",
|
|
7
|
-
stability: "experimental",
|
|
8
|
-
owners: ["@example.analytics-dashboard"],
|
|
9
|
-
tags: ["analytics", "dashboard", "visualization"]
|
|
10
|
-
};
|
|
11
|
-
var ChannelMixVisualization = defineVisualization({
|
|
12
|
-
meta: {
|
|
13
|
-
...META,
|
|
14
|
-
key: "analytics.visualization.channel-mix",
|
|
15
|
-
title: "Channel Mix",
|
|
16
|
-
description: "Session distribution across acquisition channels.",
|
|
17
|
-
goal: "Explain which channels currently drive the largest share of traffic.",
|
|
18
|
-
context: "Marketing attribution dashboard."
|
|
19
|
-
},
|
|
20
|
-
source: { primary: QUERY_REF, resultPath: "data" },
|
|
21
|
-
visualization: {
|
|
22
|
-
kind: "pie",
|
|
23
|
-
nameDimension: "channel",
|
|
24
|
-
valueMeasure: "sessions",
|
|
25
|
-
dimensions: [
|
|
26
|
-
{
|
|
27
|
-
key: "channel",
|
|
28
|
-
label: "Channel",
|
|
29
|
-
dataPath: "channel",
|
|
30
|
-
type: "category"
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
measures: [{ key: "sessions", label: "Sessions", dataPath: "sessions" }],
|
|
34
|
-
table: { caption: "Sessions by acquisition channel." }
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
var EngagementHeatmapVisualization = defineVisualization({
|
|
38
|
-
meta: {
|
|
39
|
-
...META,
|
|
40
|
-
key: "analytics.visualization.engagement-heatmap",
|
|
41
|
-
title: "Engagement Heatmap",
|
|
42
|
-
description: "Average engagement score by weekday and time band.",
|
|
43
|
-
goal: "Reveal the highest-engagement time windows for product activity.",
|
|
44
|
-
context: "Usage analytics dashboard."
|
|
45
|
-
},
|
|
46
|
-
source: { primary: QUERY_REF, resultPath: "data" },
|
|
47
|
-
visualization: {
|
|
48
|
-
kind: "heatmap",
|
|
49
|
-
xDimension: "timeBand",
|
|
50
|
-
yDimension: "weekday",
|
|
51
|
-
valueMeasure: "engagementScore",
|
|
52
|
-
dimensions: [
|
|
53
|
-
{
|
|
54
|
-
key: "timeBand",
|
|
55
|
-
label: "Time Band",
|
|
56
|
-
dataPath: "timeBand",
|
|
57
|
-
type: "category"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
key: "weekday",
|
|
61
|
-
label: "Weekday",
|
|
62
|
-
dataPath: "weekday",
|
|
63
|
-
type: "category"
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
measures: [
|
|
67
|
-
{
|
|
68
|
-
key: "engagementScore",
|
|
69
|
-
label: "Engagement",
|
|
70
|
-
dataPath: "engagementScore"
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
table: { caption: "Engagement score by weekday and time band." }
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
var ConversionFunnelVisualization = defineVisualization({
|
|
77
|
-
meta: {
|
|
78
|
-
...META,
|
|
79
|
-
key: "analytics.visualization.conversion-funnel",
|
|
80
|
-
title: "Conversion Funnel",
|
|
81
|
-
description: "Progression through the main acquisition funnel.",
|
|
82
|
-
goal: "Show where the product is losing the largest share of prospects.",
|
|
83
|
-
context: "Growth dashboard."
|
|
84
|
-
},
|
|
85
|
-
source: { primary: QUERY_REF, resultPath: "data" },
|
|
86
|
-
visualization: {
|
|
87
|
-
kind: "funnel",
|
|
88
|
-
nameDimension: "stage",
|
|
89
|
-
valueMeasure: "users",
|
|
90
|
-
sort: "descending",
|
|
91
|
-
dimensions: [
|
|
92
|
-
{ key: "stage", label: "Stage", dataPath: "stage", type: "category" }
|
|
93
|
-
],
|
|
94
|
-
measures: [{ key: "users", label: "Users", dataPath: "users" }],
|
|
95
|
-
table: { caption: "Users per conversion stage." }
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
var AccountCoverageGeoVisualization = defineVisualization({
|
|
99
|
-
meta: {
|
|
100
|
-
...META,
|
|
101
|
-
key: "analytics.visualization.account-coverage-geo",
|
|
102
|
-
title: "Account Coverage",
|
|
103
|
-
description: "High-value accounts plotted on a slippy-map surface.",
|
|
104
|
-
goal: "Locate where active commercial concentration is strongest.",
|
|
105
|
-
context: "Territory coverage dashboard."
|
|
106
|
-
},
|
|
107
|
-
source: { primary: QUERY_REF, resultPath: "data" },
|
|
108
|
-
visualization: {
|
|
109
|
-
kind: "geo",
|
|
110
|
-
mode: "slippy-map",
|
|
111
|
-
variant: "scatter",
|
|
112
|
-
nameDimension: "city",
|
|
113
|
-
latitudeDimension: "latitude",
|
|
114
|
-
longitudeDimension: "longitude",
|
|
115
|
-
valueMeasure: "accounts",
|
|
116
|
-
dimensions: [
|
|
117
|
-
{ key: "city", label: "City", dataPath: "city", type: "category" },
|
|
118
|
-
{
|
|
119
|
-
key: "latitude",
|
|
120
|
-
label: "Latitude",
|
|
121
|
-
dataPath: "latitude",
|
|
122
|
-
type: "latitude"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
key: "longitude",
|
|
126
|
-
label: "Longitude",
|
|
127
|
-
dataPath: "longitude",
|
|
128
|
-
type: "longitude"
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
measures: [{ key: "accounts", label: "Accounts", dataPath: "accounts" }],
|
|
132
|
-
table: { caption: "Account concentration by city." }
|
|
133
|
-
}
|
|
134
|
-
});
|
|
1
|
+
import{defineVisualization as G}from"@contractspec/lib.contracts-spec/visualizations";var W={key:"analytics.query.execute",version:"1.0.0"},j={version:"1.0.0",domain:"analytics",stability:"experimental",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","visualization"]},k=G({meta:{...j,key:"analytics.visualization.channel-mix",title:"Channel Mix",description:"Session distribution across acquisition channels.",goal:"Explain which channels currently drive the largest share of traffic.",context:"Marketing attribution dashboard."},source:{primary:W,resultPath:"data"},visualization:{kind:"pie",nameDimension:"channel",valueMeasure:"sessions",dimensions:[{key:"channel",label:"Channel",dataPath:"channel",type:"category"}],measures:[{key:"sessions",label:"Sessions",dataPath:"sessions"}],table:{caption:"Sessions by acquisition channel."}}}),x=G({meta:{...j,key:"analytics.visualization.engagement-heatmap",title:"Engagement Heatmap",description:"Average engagement score by weekday and time band.",goal:"Reveal the highest-engagement time windows for product activity.",context:"Usage analytics dashboard."},source:{primary:W,resultPath:"data"},visualization:{kind:"heatmap",xDimension:"timeBand",yDimension:"weekday",valueMeasure:"engagementScore",dimensions:[{key:"timeBand",label:"Time Band",dataPath:"timeBand",type:"category"},{key:"weekday",label:"Weekday",dataPath:"weekday",type:"category"}],measures:[{key:"engagementScore",label:"Engagement",dataPath:"engagementScore"}],table:{caption:"Engagement score by weekday and time band."}}}),w=G({meta:{...j,key:"analytics.visualization.conversion-funnel",title:"Conversion Funnel",description:"Progression through the main acquisition funnel.",goal:"Show where the product is losing the largest share of prospects.",context:"Growth dashboard."},source:{primary:W,resultPath:"data"},visualization:{kind:"funnel",nameDimension:"stage",valueMeasure:"users",sort:"descending",dimensions:[{key:"stage",label:"Stage",dataPath:"stage",type:"category"}],measures:[{key:"users",label:"Users",dataPath:"users"}],table:{caption:"Users per conversion stage."}}}),S=G({meta:{...j,key:"analytics.visualization.account-coverage-geo",title:"Account Coverage",description:"High-value accounts plotted on a slippy-map surface.",goal:"Locate where active commercial concentration is strongest.",context:"Territory coverage dashboard."},source:{primary:W,resultPath:"data"},visualization:{kind:"geo",mode:"slippy-map",variant:"scatter",nameDimension:"city",latitudeDimension:"latitude",longitudeDimension:"longitude",valueMeasure:"accounts",dimensions:[{key:"city",label:"City",dataPath:"city",type:"category"},{key:"latitude",label:"Latitude",dataPath:"latitude",type:"latitude"},{key:"longitude",label:"Longitude",dataPath:"longitude",type:"longitude"}],measures:[{key:"accounts",label:"Accounts",dataPath:"accounts"}],table:{caption:"Account concentration by city."}}});import{defineVisualization as n}from"@contractspec/lib.contracts-spec/visualizations";var P={key:"analytics.query.execute",version:"1.0.0"},N={version:"1.0.0",domain:"analytics",stability:"experimental",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","visualization"]},B=n({meta:{...N,key:"analytics.visualization.revenue-metric",title:"Revenue Snapshot",description:"Current recurring revenue with prior-period comparison.",goal:"Highlight the headline commercial metric for the dashboard.",context:"Executive revenue overview."},source:{primary:P,resultPath:"data"},visualization:{kind:"metric",measure:"totalRevenue",comparisonMeasure:"priorRevenue",dimensions:[{key:"period",label:"Period",dataPath:"period",type:"time"}],measures:[{key:"totalRevenue",label:"Revenue",dataPath:"totalRevenue",format:"currency"},{key:"priorRevenue",label:"Prior Revenue",dataPath:"priorRevenue",format:"currency"}],sparkline:{dimension:"period",measure:"totalRevenue"},table:{caption:"Revenue trend and prior period values."}}}),$=n({meta:{...N,key:"analytics.visualization.revenue-trend",title:"Revenue Trend",description:"Monthly revenue progression for the current quarter.",goal:"Track whether revenue growth is accelerating or stalling.",context:"Quarterly commercial dashboard."},source:{primary:P,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"date",yMeasures:["revenue"],dimensions:[{key:"date",label:"Month",dataPath:"date",type:"time"}],measures:[{key:"revenue",label:"Revenue",dataPath:"revenue",format:"currency",color:"#0f766e"}],thresholds:[{key:"target",value:140000,label:"Target",color:"#dc2626"}],table:{caption:"Monthly revenue values."}}}),D=n({meta:{...N,key:"analytics.visualization.regional-revenue",title:"Regional Revenue",description:"Revenue split by sales territory.",goal:"Compare the strongest and weakest performing territories.",context:"Territory planning and commercial comparison."},source:{primary:P,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"region",yMeasures:["revenue"],dimensions:[{key:"region",label:"Region",dataPath:"region",type:"category"}],measures:[{key:"revenue",label:"Revenue",dataPath:"revenue",format:"currency",color:"#1d4ed8"}],table:{caption:"Revenue by region."}}}),c=n({meta:{...N,key:"analytics.visualization.retention-area",title:"Retention Curve",description:"Weekly retention progression across the active cohort.",goal:"Show whether user retention remains above the desired floor.",context:"Product health dashboard."},source:{primary:P,resultPath:"data"},visualization:{kind:"cartesian",variant:"area",xDimension:"week",yMeasures:["retentionRate"],dimensions:[{key:"week",label:"Week",dataPath:"week",type:"category"}],measures:[{key:"retentionRate",label:"Retention",dataPath:"retentionRate",format:"percentage",color:"#16a34a"}],thresholds:[{key:"floor",value:0.5,label:"Floor",color:"#f59e0b"}],table:{caption:"Weekly retention rate."}}}),L=n({meta:{...N,key:"analytics.visualization.pipeline-scatter",title:"Pipeline Velocity",description:"Deal-cycle length against win rate for active accounts.",goal:"Spot outliers where the sales cycle is long but conversion remains weak.",context:"Commercial operations dashboard."},source:{primary:P,resultPath:"data"},visualization:{kind:"cartesian",variant:"scatter",xDimension:"cycleDays",yMeasures:["winRate"],dimensions:[{key:"cycleDays",label:"Cycle Days",dataPath:"cycleDays",type:"number"}],measures:[{key:"winRate",label:"Win Rate",dataPath:"winRate",format:"percentage",color:"#7c3aed"},{key:"arr",label:"ARR",dataPath:"arr",format:"currency"}],series:[{key:"pipeline",label:"Accounts",measure:"winRate",type:"scatter",color:"#7c3aed"}],table:{caption:"Sales cycle and win rate per account."}}});import{VisualizationRegistry as M}from"@contractspec/lib.contracts-spec/visualizations";var C=[B,$,D,c,L,k,x,w,S],O=new M([...C]),_=C.map((r)=>h(r)),T=new Map(C.map((r)=>[s(r.meta),r])),H={[s(B.meta)]:{data:[{period:"2025-11-01",totalRevenue:112000,priorRevenue:103000},{period:"2025-12-01",totalRevenue:119000,priorRevenue:110000},{period:"2026-01-01",totalRevenue:126500,priorRevenue:116000},{period:"2026-02-01",totalRevenue:133000,priorRevenue:124000},{period:"2026-03-01",totalRevenue:145500,priorRevenue:133000}]},[s($.meta)]:{data:[{date:"2025-11-01",revenue:112000},{date:"2025-12-01",revenue:119000},{date:"2026-01-01",revenue:126500},{date:"2026-02-01",revenue:133000},{date:"2026-03-01",revenue:145500}]},[s(D.meta)]:{data:[{region:"North America",revenue:210000},{region:"EMEA",revenue:174000},{region:"APAC",revenue:132000},{region:"LATAM",revenue:88000}]},[s(c.meta)]:{data:[{week:"Week 1",retentionRate:0.71},{week:"Week 2",retentionRate:0.66},{week:"Week 3",retentionRate:0.62},{week:"Week 4",retentionRate:0.58},{week:"Week 5",retentionRate:0.55},{week:"Week 6",retentionRate:0.53}]},[s(L.meta)]:{data:[{cycleDays:18,winRate:0.31,arr:82000},{cycleDays:26,winRate:0.44,arr:65000},{cycleDays:33,winRate:0.27,arr:91000},{cycleDays:14,winRate:0.56,arr:47000},{cycleDays:21,winRate:0.48,arr:59000},{cycleDays:39,winRate:0.22,arr:114000}]},[s(k.meta)]:{data:[{channel:"Direct",sessions:4200},{channel:"Organic Search",sessions:3600},{channel:"Paid Search",sessions:2100},{channel:"Partner",sessions:1400},{channel:"Referral",sessions:900}]},[s(x.meta)]:{data:[{weekday:"Mon",timeBand:"09:00",engagementScore:74},{weekday:"Mon",timeBand:"13:00",engagementScore:82},{weekday:"Tue",timeBand:"09:00",engagementScore:69},{weekday:"Tue",timeBand:"13:00",engagementScore:88},{weekday:"Wed",timeBand:"09:00",engagementScore:77},{weekday:"Wed",timeBand:"13:00",engagementScore:91},{weekday:"Thu",timeBand:"09:00",engagementScore:72},{weekday:"Thu",timeBand:"13:00",engagementScore:86},{weekday:"Fri",timeBand:"09:00",engagementScore:65},{weekday:"Fri",timeBand:"13:00",engagementScore:79}]},[s(w.meta)]:{data:[{stage:"Visited Site",users:12000},{stage:"Started Trial",users:4200},{stage:"Activated Workspace",users:2400},{stage:"Requested Demo",users:980},{stage:"Closed Won",users:310}]},[s(S.meta)]:{data:[{city:"Paris",latitude:48.8566,longitude:2.3522,accounts:48},{city:"London",latitude:51.5072,longitude:-0.1276,accounts:62},{city:"New York",latitude:40.7128,longitude:-74.006,accounts:71},{city:"Toronto",latitude:43.6532,longitude:-79.3832,accounts:36},{city:"Singapore",latitude:1.3521,longitude:103.8198,accounts:29}]}};function h(r){return{key:r.meta.key,version:r.meta.version}}function s(r){return`${r.key}.v${r.version}`}var Y={METRIC:h(B),LINE_CHART:h($),BAR_CHART:h(D),AREA_CHART:h(c),SCATTER_PLOT:h(L),PIE_CHART:h(k),HEATMAP:h(x),FUNNEL:h(w),MAP:h(S)};function A(r){return[u(r,"widget_revenue_metric","Revenue Snapshot","METRIC",0,0,4,2,{layout:"single",bindings:[p(B,200)]}),u(r,"widget_revenue_trend","Revenue Trend","LINE_CHART",4,0,8,4,{layout:"single",bindings:[p($)]}),u(r,"widget_regional_revenue","Regional Revenue","BAR_CHART",0,2,6,4,{layout:"single",bindings:[p(D)]}),u(r,"widget_channel_mix","Channel Mix","PIE_CHART",6,2,6,4,{layout:"single",bindings:[p(k)]}),u(r,"widget_retention","Retention Curve","AREA_CHART",0,6,6,4,{layout:"single",bindings:[p(c)]}),u(r,"widget_pipeline","Pipeline Velocity","SCATTER_PLOT",6,6,6,4,{layout:"single",bindings:[p(L)]}),u(r,"widget_heatmap","Engagement Heatmap","HEATMAP",0,10,8,4,{layout:"single",bindings:[p(x)]}),u(r,"widget_funnel","Conversion Funnel","FUNNEL",8,10,4,4,{layout:"single",bindings:[p(w)]}),u(r,"widget_geo","Account Coverage","MAP",0,14,12,5,{layout:"single",bindings:[p(S,360)]}),u(r,"widget_comparison","Commercial Comparison","EMBED",0,19,12,6,{layout:"comparison",description:"Compare regional distribution, channel balance, and funnel shape.",bindings:[p(D,240),p(k,240),p(w,240)]}),u(r,"widget_timeline","Growth Timeline","EMBED",0,25,12,6,{layout:"timeline",description:"Track revenue and retention over the same reporting cadence.",bindings:[p($,220),p(c,220)]})]}function Q(r){let t=l(r),o=t.bindings.map((m)=>{let e=T.get(s(m.ref));if(!e)return null;return{key:`${r.id}:${s(m.ref)}`,spec:e,data:m.data,title:m.title??e.meta.title,description:m.description??e.meta.description,height:m.height}}).filter((m)=>Boolean(m));if(!o.length)return null;return{id:r.id,name:r.name,description:t.description,layout:t.layout,gridX:r.gridX,gridY:r.gridY,gridWidth:r.gridWidth,gridHeight:r.gridHeight,bindings:o}}function l(r){if(F(r.config))return r.config;let t=Y[r.type];return t?{layout:"single",bindings:[{ref:t,data:H[s(t)]}]}:{layout:"single",bindings:[]}}function p(r,t=280){return{ref:h(r),data:H[s(r.meta)],height:t}}function u(r,t,o,m,e,y,q,J,K){let X=new Date;return{id:t,dashboardId:r,name:o,type:m,gridX:e,gridY:y,gridWidth:q,gridHeight:J,config:K,createdAt:X,updatedAt:X}}function F(r){if(!r||typeof r!=="object")return!1;let t=r;return(t.layout==="single"||t.layout==="comparison"||t.layout==="timeline")&&Array.isArray(t.bindings)}var Z=[{id:"dash-1",name:"Sales Overview",slug:"sales-overview",status:"PUBLISHED",widgetCount:11,viewCount:1250,lastViewedAt:"2026-03-18T12:00:00Z"},{id:"dash-2",name:"User Engagement",slug:"user-engagement",status:"PUBLISHED",widgetCount:8,viewCount:890,lastViewedAt:"2026-03-18T10:00:00Z"}],U=[{id:"q-1",name:"Monthly Revenue",type:"AGGREGATION",isShared:!0,executionCount:1500},{id:"q-2",name:"User Growth",type:"METRIC",isShared:!0,executionCount:890},{id:"q-3",name:"Product Sales",type:"SQL",isShared:!1,executionCount:340},{id:"q-4",name:"Conversion Funnel",type:"AGGREGATION",isShared:!0,executionCount:450}];function v(r){return A(r).map((t)=>Q(t)).filter((t)=>Boolean(t))}var pr={target:"markdown",render:async(r)=>{if(r.source.type!=="component"||r.source.componentKey!=="AnalyticsDashboard")throw Error("analyticsDashboardMarkdownRenderer: not AnalyticsDashboard");let t=Z[0];if(!t)return{mimeType:"text/markdown",body:`# No Dashboards
|
|
135
2
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
version: "1.0.0",
|
|
141
|
-
domain: "analytics",
|
|
142
|
-
stability: "experimental",
|
|
143
|
-
owners: ["@example.analytics-dashboard"],
|
|
144
|
-
tags: ["analytics", "dashboard", "visualization"]
|
|
145
|
-
};
|
|
146
|
-
var RevenueMetricVisualization = defineVisualization2({
|
|
147
|
-
meta: {
|
|
148
|
-
...META2,
|
|
149
|
-
key: "analytics.visualization.revenue-metric",
|
|
150
|
-
title: "Revenue Snapshot",
|
|
151
|
-
description: "Current recurring revenue with prior-period comparison.",
|
|
152
|
-
goal: "Highlight the headline commercial metric for the dashboard.",
|
|
153
|
-
context: "Executive revenue overview."
|
|
154
|
-
},
|
|
155
|
-
source: { primary: QUERY_REF2, resultPath: "data" },
|
|
156
|
-
visualization: {
|
|
157
|
-
kind: "metric",
|
|
158
|
-
measure: "totalRevenue",
|
|
159
|
-
comparisonMeasure: "priorRevenue",
|
|
160
|
-
dimensions: [
|
|
161
|
-
{ key: "period", label: "Period", dataPath: "period", type: "time" }
|
|
162
|
-
],
|
|
163
|
-
measures: [
|
|
164
|
-
{
|
|
165
|
-
key: "totalRevenue",
|
|
166
|
-
label: "Revenue",
|
|
167
|
-
dataPath: "totalRevenue",
|
|
168
|
-
format: "currency"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
key: "priorRevenue",
|
|
172
|
-
label: "Prior Revenue",
|
|
173
|
-
dataPath: "priorRevenue",
|
|
174
|
-
format: "currency"
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
sparkline: { dimension: "period", measure: "totalRevenue" },
|
|
178
|
-
table: { caption: "Revenue trend and prior period values." }
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
var RevenueTrendVisualization = defineVisualization2({
|
|
182
|
-
meta: {
|
|
183
|
-
...META2,
|
|
184
|
-
key: "analytics.visualization.revenue-trend",
|
|
185
|
-
title: "Revenue Trend",
|
|
186
|
-
description: "Monthly revenue progression for the current quarter.",
|
|
187
|
-
goal: "Track whether revenue growth is accelerating or stalling.",
|
|
188
|
-
context: "Quarterly commercial dashboard."
|
|
189
|
-
},
|
|
190
|
-
source: { primary: QUERY_REF2, resultPath: "data" },
|
|
191
|
-
visualization: {
|
|
192
|
-
kind: "cartesian",
|
|
193
|
-
variant: "line",
|
|
194
|
-
xDimension: "date",
|
|
195
|
-
yMeasures: ["revenue"],
|
|
196
|
-
dimensions: [
|
|
197
|
-
{ key: "date", label: "Month", dataPath: "date", type: "time" }
|
|
198
|
-
],
|
|
199
|
-
measures: [
|
|
200
|
-
{
|
|
201
|
-
key: "revenue",
|
|
202
|
-
label: "Revenue",
|
|
203
|
-
dataPath: "revenue",
|
|
204
|
-
format: "currency",
|
|
205
|
-
color: "#0f766e"
|
|
206
|
-
}
|
|
207
|
-
],
|
|
208
|
-
thresholds: [
|
|
209
|
-
{ key: "target", value: 140000, label: "Target", color: "#dc2626" }
|
|
210
|
-
],
|
|
211
|
-
table: { caption: "Monthly revenue values." }
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
var RegionalRevenueVisualization = defineVisualization2({
|
|
215
|
-
meta: {
|
|
216
|
-
...META2,
|
|
217
|
-
key: "analytics.visualization.regional-revenue",
|
|
218
|
-
title: "Regional Revenue",
|
|
219
|
-
description: "Revenue split by sales territory.",
|
|
220
|
-
goal: "Compare the strongest and weakest performing territories.",
|
|
221
|
-
context: "Territory planning and commercial comparison."
|
|
222
|
-
},
|
|
223
|
-
source: { primary: QUERY_REF2, resultPath: "data" },
|
|
224
|
-
visualization: {
|
|
225
|
-
kind: "cartesian",
|
|
226
|
-
variant: "bar",
|
|
227
|
-
xDimension: "region",
|
|
228
|
-
yMeasures: ["revenue"],
|
|
229
|
-
dimensions: [
|
|
230
|
-
{ key: "region", label: "Region", dataPath: "region", type: "category" }
|
|
231
|
-
],
|
|
232
|
-
measures: [
|
|
233
|
-
{
|
|
234
|
-
key: "revenue",
|
|
235
|
-
label: "Revenue",
|
|
236
|
-
dataPath: "revenue",
|
|
237
|
-
format: "currency",
|
|
238
|
-
color: "#1d4ed8"
|
|
239
|
-
}
|
|
240
|
-
],
|
|
241
|
-
table: { caption: "Revenue by region." }
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
var RetentionAreaVisualization = defineVisualization2({
|
|
245
|
-
meta: {
|
|
246
|
-
...META2,
|
|
247
|
-
key: "analytics.visualization.retention-area",
|
|
248
|
-
title: "Retention Curve",
|
|
249
|
-
description: "Weekly retention progression across the active cohort.",
|
|
250
|
-
goal: "Show whether user retention remains above the desired floor.",
|
|
251
|
-
context: "Product health dashboard."
|
|
252
|
-
},
|
|
253
|
-
source: { primary: QUERY_REF2, resultPath: "data" },
|
|
254
|
-
visualization: {
|
|
255
|
-
kind: "cartesian",
|
|
256
|
-
variant: "area",
|
|
257
|
-
xDimension: "week",
|
|
258
|
-
yMeasures: ["retentionRate"],
|
|
259
|
-
dimensions: [
|
|
260
|
-
{ key: "week", label: "Week", dataPath: "week", type: "category" }
|
|
261
|
-
],
|
|
262
|
-
measures: [
|
|
263
|
-
{
|
|
264
|
-
key: "retentionRate",
|
|
265
|
-
label: "Retention",
|
|
266
|
-
dataPath: "retentionRate",
|
|
267
|
-
format: "percentage",
|
|
268
|
-
color: "#16a34a"
|
|
269
|
-
}
|
|
270
|
-
],
|
|
271
|
-
thresholds: [
|
|
272
|
-
{ key: "floor", value: 0.5, label: "Floor", color: "#f59e0b" }
|
|
273
|
-
],
|
|
274
|
-
table: { caption: "Weekly retention rate." }
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
var PipelineScatterVisualization = defineVisualization2({
|
|
278
|
-
meta: {
|
|
279
|
-
...META2,
|
|
280
|
-
key: "analytics.visualization.pipeline-scatter",
|
|
281
|
-
title: "Pipeline Velocity",
|
|
282
|
-
description: "Deal-cycle length against win rate for active accounts.",
|
|
283
|
-
goal: "Spot outliers where the sales cycle is long but conversion remains weak.",
|
|
284
|
-
context: "Commercial operations dashboard."
|
|
285
|
-
},
|
|
286
|
-
source: { primary: QUERY_REF2, resultPath: "data" },
|
|
287
|
-
visualization: {
|
|
288
|
-
kind: "cartesian",
|
|
289
|
-
variant: "scatter",
|
|
290
|
-
xDimension: "cycleDays",
|
|
291
|
-
yMeasures: ["winRate"],
|
|
292
|
-
dimensions: [
|
|
293
|
-
{
|
|
294
|
-
key: "cycleDays",
|
|
295
|
-
label: "Cycle Days",
|
|
296
|
-
dataPath: "cycleDays",
|
|
297
|
-
type: "number"
|
|
298
|
-
}
|
|
299
|
-
],
|
|
300
|
-
measures: [
|
|
301
|
-
{
|
|
302
|
-
key: "winRate",
|
|
303
|
-
label: "Win Rate",
|
|
304
|
-
dataPath: "winRate",
|
|
305
|
-
format: "percentage",
|
|
306
|
-
color: "#7c3aed"
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
key: "arr",
|
|
310
|
-
label: "ARR",
|
|
311
|
-
dataPath: "arr",
|
|
312
|
-
format: "currency"
|
|
313
|
-
}
|
|
314
|
-
],
|
|
315
|
-
series: [
|
|
316
|
-
{
|
|
317
|
-
key: "pipeline",
|
|
318
|
-
label: "Accounts",
|
|
319
|
-
measure: "winRate",
|
|
320
|
-
type: "scatter",
|
|
321
|
-
color: "#7c3aed"
|
|
322
|
-
}
|
|
323
|
-
],
|
|
324
|
-
table: { caption: "Sales cycle and win rate per account." }
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// src/visualizations/catalog.ts
|
|
329
|
-
import { VisualizationRegistry } from "@contractspec/lib.contracts-spec/visualizations";
|
|
330
|
-
var AnalyticsVisualizationSpecs = [
|
|
331
|
-
RevenueMetricVisualization,
|
|
332
|
-
RevenueTrendVisualization,
|
|
333
|
-
RegionalRevenueVisualization,
|
|
334
|
-
RetentionAreaVisualization,
|
|
335
|
-
PipelineScatterVisualization,
|
|
336
|
-
ChannelMixVisualization,
|
|
337
|
-
EngagementHeatmapVisualization,
|
|
338
|
-
ConversionFunnelVisualization,
|
|
339
|
-
AccountCoverageGeoVisualization
|
|
340
|
-
];
|
|
341
|
-
var AnalyticsVisualizationRegistry = new VisualizationRegistry([
|
|
342
|
-
...AnalyticsVisualizationSpecs
|
|
343
|
-
]);
|
|
344
|
-
var AnalyticsVisualizationRefs = AnalyticsVisualizationSpecs.map((spec) => refOf(spec));
|
|
345
|
-
var AnalyticsVisualizationSpecMap = new Map(AnalyticsVisualizationSpecs.map((spec) => [
|
|
346
|
-
visualizationRefKey(spec.meta),
|
|
347
|
-
spec
|
|
348
|
-
]));
|
|
349
|
-
var AnalyticsVisualizationSampleData = {
|
|
350
|
-
[visualizationRefKey(RevenueMetricVisualization.meta)]: {
|
|
351
|
-
data: [
|
|
352
|
-
{ period: "2025-11-01", totalRevenue: 112000, priorRevenue: 103000 },
|
|
353
|
-
{ period: "2025-12-01", totalRevenue: 119000, priorRevenue: 110000 },
|
|
354
|
-
{ period: "2026-01-01", totalRevenue: 126500, priorRevenue: 116000 },
|
|
355
|
-
{ period: "2026-02-01", totalRevenue: 133000, priorRevenue: 124000 },
|
|
356
|
-
{ period: "2026-03-01", totalRevenue: 145500, priorRevenue: 133000 }
|
|
357
|
-
]
|
|
358
|
-
},
|
|
359
|
-
[visualizationRefKey(RevenueTrendVisualization.meta)]: {
|
|
360
|
-
data: [
|
|
361
|
-
{ date: "2025-11-01", revenue: 112000 },
|
|
362
|
-
{ date: "2025-12-01", revenue: 119000 },
|
|
363
|
-
{ date: "2026-01-01", revenue: 126500 },
|
|
364
|
-
{ date: "2026-02-01", revenue: 133000 },
|
|
365
|
-
{ date: "2026-03-01", revenue: 145500 }
|
|
366
|
-
]
|
|
367
|
-
},
|
|
368
|
-
[visualizationRefKey(RegionalRevenueVisualization.meta)]: {
|
|
369
|
-
data: [
|
|
370
|
-
{ region: "North America", revenue: 210000 },
|
|
371
|
-
{ region: "EMEA", revenue: 174000 },
|
|
372
|
-
{ region: "APAC", revenue: 132000 },
|
|
373
|
-
{ region: "LATAM", revenue: 88000 }
|
|
374
|
-
]
|
|
375
|
-
},
|
|
376
|
-
[visualizationRefKey(RetentionAreaVisualization.meta)]: {
|
|
377
|
-
data: [
|
|
378
|
-
{ week: "Week 1", retentionRate: 0.71 },
|
|
379
|
-
{ week: "Week 2", retentionRate: 0.66 },
|
|
380
|
-
{ week: "Week 3", retentionRate: 0.62 },
|
|
381
|
-
{ week: "Week 4", retentionRate: 0.58 },
|
|
382
|
-
{ week: "Week 5", retentionRate: 0.55 },
|
|
383
|
-
{ week: "Week 6", retentionRate: 0.53 }
|
|
384
|
-
]
|
|
385
|
-
},
|
|
386
|
-
[visualizationRefKey(PipelineScatterVisualization.meta)]: {
|
|
387
|
-
data: [
|
|
388
|
-
{ cycleDays: 18, winRate: 0.31, arr: 82000 },
|
|
389
|
-
{ cycleDays: 26, winRate: 0.44, arr: 65000 },
|
|
390
|
-
{ cycleDays: 33, winRate: 0.27, arr: 91000 },
|
|
391
|
-
{ cycleDays: 14, winRate: 0.56, arr: 47000 },
|
|
392
|
-
{ cycleDays: 21, winRate: 0.48, arr: 59000 },
|
|
393
|
-
{ cycleDays: 39, winRate: 0.22, arr: 114000 }
|
|
394
|
-
]
|
|
395
|
-
},
|
|
396
|
-
[visualizationRefKey(ChannelMixVisualization.meta)]: {
|
|
397
|
-
data: [
|
|
398
|
-
{ channel: "Direct", sessions: 4200 },
|
|
399
|
-
{ channel: "Organic Search", sessions: 3600 },
|
|
400
|
-
{ channel: "Paid Search", sessions: 2100 },
|
|
401
|
-
{ channel: "Partner", sessions: 1400 },
|
|
402
|
-
{ channel: "Referral", sessions: 900 }
|
|
403
|
-
]
|
|
404
|
-
},
|
|
405
|
-
[visualizationRefKey(EngagementHeatmapVisualization.meta)]: {
|
|
406
|
-
data: [
|
|
407
|
-
{ weekday: "Mon", timeBand: "09:00", engagementScore: 74 },
|
|
408
|
-
{ weekday: "Mon", timeBand: "13:00", engagementScore: 82 },
|
|
409
|
-
{ weekday: "Tue", timeBand: "09:00", engagementScore: 69 },
|
|
410
|
-
{ weekday: "Tue", timeBand: "13:00", engagementScore: 88 },
|
|
411
|
-
{ weekday: "Wed", timeBand: "09:00", engagementScore: 77 },
|
|
412
|
-
{ weekday: "Wed", timeBand: "13:00", engagementScore: 91 },
|
|
413
|
-
{ weekday: "Thu", timeBand: "09:00", engagementScore: 72 },
|
|
414
|
-
{ weekday: "Thu", timeBand: "13:00", engagementScore: 86 },
|
|
415
|
-
{ weekday: "Fri", timeBand: "09:00", engagementScore: 65 },
|
|
416
|
-
{ weekday: "Fri", timeBand: "13:00", engagementScore: 79 }
|
|
417
|
-
]
|
|
418
|
-
},
|
|
419
|
-
[visualizationRefKey(ConversionFunnelVisualization.meta)]: {
|
|
420
|
-
data: [
|
|
421
|
-
{ stage: "Visited Site", users: 12000 },
|
|
422
|
-
{ stage: "Started Trial", users: 4200 },
|
|
423
|
-
{ stage: "Activated Workspace", users: 2400 },
|
|
424
|
-
{ stage: "Requested Demo", users: 980 },
|
|
425
|
-
{ stage: "Closed Won", users: 310 }
|
|
426
|
-
]
|
|
427
|
-
},
|
|
428
|
-
[visualizationRefKey(AccountCoverageGeoVisualization.meta)]: {
|
|
429
|
-
data: [
|
|
430
|
-
{ city: "Paris", latitude: 48.8566, longitude: 2.3522, accounts: 48 },
|
|
431
|
-
{ city: "London", latitude: 51.5072, longitude: -0.1276, accounts: 62 },
|
|
432
|
-
{ city: "New York", latitude: 40.7128, longitude: -74.006, accounts: 71 },
|
|
433
|
-
{ city: "Toronto", latitude: 43.6532, longitude: -79.3832, accounts: 36 },
|
|
434
|
-
{
|
|
435
|
-
city: "Singapore",
|
|
436
|
-
latitude: 1.3521,
|
|
437
|
-
longitude: 103.8198,
|
|
438
|
-
accounts: 29
|
|
439
|
-
}
|
|
440
|
-
]
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
function refOf(spec) {
|
|
444
|
-
return { key: spec.meta.key, version: spec.meta.version };
|
|
445
|
-
}
|
|
446
|
-
function visualizationRefKey(ref) {
|
|
447
|
-
return `${ref.key}.v${ref.version}`;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// src/visualizations/widgets.ts
|
|
451
|
-
var LEGACY_VISUALIZATION_REFS = {
|
|
452
|
-
METRIC: refOf(RevenueMetricVisualization),
|
|
453
|
-
LINE_CHART: refOf(RevenueTrendVisualization),
|
|
454
|
-
BAR_CHART: refOf(RegionalRevenueVisualization),
|
|
455
|
-
AREA_CHART: refOf(RetentionAreaVisualization),
|
|
456
|
-
SCATTER_PLOT: refOf(PipelineScatterVisualization),
|
|
457
|
-
PIE_CHART: refOf(ChannelMixVisualization),
|
|
458
|
-
HEATMAP: refOf(EngagementHeatmapVisualization),
|
|
459
|
-
FUNNEL: refOf(ConversionFunnelVisualization),
|
|
460
|
-
MAP: refOf(AccountCoverageGeoVisualization)
|
|
461
|
-
};
|
|
462
|
-
function createExampleWidgets(dashboardId) {
|
|
463
|
-
return [
|
|
464
|
-
widget(dashboardId, "widget_revenue_metric", "Revenue Snapshot", "METRIC", 0, 0, 4, 2, {
|
|
465
|
-
layout: "single",
|
|
466
|
-
bindings: [binding(RevenueMetricVisualization, 200)]
|
|
467
|
-
}),
|
|
468
|
-
widget(dashboardId, "widget_revenue_trend", "Revenue Trend", "LINE_CHART", 4, 0, 8, 4, {
|
|
469
|
-
layout: "single",
|
|
470
|
-
bindings: [binding(RevenueTrendVisualization)]
|
|
471
|
-
}),
|
|
472
|
-
widget(dashboardId, "widget_regional_revenue", "Regional Revenue", "BAR_CHART", 0, 2, 6, 4, {
|
|
473
|
-
layout: "single",
|
|
474
|
-
bindings: [binding(RegionalRevenueVisualization)]
|
|
475
|
-
}),
|
|
476
|
-
widget(dashboardId, "widget_channel_mix", "Channel Mix", "PIE_CHART", 6, 2, 6, 4, {
|
|
477
|
-
layout: "single",
|
|
478
|
-
bindings: [binding(ChannelMixVisualization)]
|
|
479
|
-
}),
|
|
480
|
-
widget(dashboardId, "widget_retention", "Retention Curve", "AREA_CHART", 0, 6, 6, 4, {
|
|
481
|
-
layout: "single",
|
|
482
|
-
bindings: [binding(RetentionAreaVisualization)]
|
|
483
|
-
}),
|
|
484
|
-
widget(dashboardId, "widget_pipeline", "Pipeline Velocity", "SCATTER_PLOT", 6, 6, 6, 4, {
|
|
485
|
-
layout: "single",
|
|
486
|
-
bindings: [binding(PipelineScatterVisualization)]
|
|
487
|
-
}),
|
|
488
|
-
widget(dashboardId, "widget_heatmap", "Engagement Heatmap", "HEATMAP", 0, 10, 8, 4, {
|
|
489
|
-
layout: "single",
|
|
490
|
-
bindings: [binding(EngagementHeatmapVisualization)]
|
|
491
|
-
}),
|
|
492
|
-
widget(dashboardId, "widget_funnel", "Conversion Funnel", "FUNNEL", 8, 10, 4, 4, {
|
|
493
|
-
layout: "single",
|
|
494
|
-
bindings: [binding(ConversionFunnelVisualization)]
|
|
495
|
-
}),
|
|
496
|
-
widget(dashboardId, "widget_geo", "Account Coverage", "MAP", 0, 14, 12, 5, {
|
|
497
|
-
layout: "single",
|
|
498
|
-
bindings: [binding(AccountCoverageGeoVisualization, 360)]
|
|
499
|
-
}),
|
|
500
|
-
widget(dashboardId, "widget_comparison", "Commercial Comparison", "EMBED", 0, 19, 12, 6, {
|
|
501
|
-
layout: "comparison",
|
|
502
|
-
description: "Compare regional distribution, channel balance, and funnel shape.",
|
|
503
|
-
bindings: [
|
|
504
|
-
binding(RegionalRevenueVisualization, 240),
|
|
505
|
-
binding(ChannelMixVisualization, 240),
|
|
506
|
-
binding(ConversionFunnelVisualization, 240)
|
|
507
|
-
]
|
|
508
|
-
}),
|
|
509
|
-
widget(dashboardId, "widget_timeline", "Growth Timeline", "EMBED", 0, 25, 12, 6, {
|
|
510
|
-
layout: "timeline",
|
|
511
|
-
description: "Track revenue and retention over the same reporting cadence.",
|
|
512
|
-
bindings: [
|
|
513
|
-
binding(RevenueTrendVisualization, 220),
|
|
514
|
-
binding(RetentionAreaVisualization, 220)
|
|
515
|
-
]
|
|
516
|
-
})
|
|
517
|
-
];
|
|
518
|
-
}
|
|
519
|
-
function resolveAnalyticsWidget(widget) {
|
|
520
|
-
const config = parseWidgetConfig(widget);
|
|
521
|
-
const bindings = config.bindings.map((binding) => {
|
|
522
|
-
const spec = AnalyticsVisualizationSpecMap.get(visualizationRefKey(binding.ref));
|
|
523
|
-
if (!spec)
|
|
524
|
-
return null;
|
|
525
|
-
return {
|
|
526
|
-
key: `${widget.id}:${visualizationRefKey(binding.ref)}`,
|
|
527
|
-
spec,
|
|
528
|
-
data: binding.data,
|
|
529
|
-
title: binding.title ?? spec.meta.title,
|
|
530
|
-
description: binding.description ?? spec.meta.description,
|
|
531
|
-
height: binding.height
|
|
532
|
-
};
|
|
533
|
-
}).filter((binding) => Boolean(binding));
|
|
534
|
-
if (!bindings.length)
|
|
535
|
-
return null;
|
|
536
|
-
return {
|
|
537
|
-
id: widget.id,
|
|
538
|
-
name: widget.name,
|
|
539
|
-
description: config.description,
|
|
540
|
-
layout: config.layout,
|
|
541
|
-
gridX: widget.gridX,
|
|
542
|
-
gridY: widget.gridY,
|
|
543
|
-
gridWidth: widget.gridWidth,
|
|
544
|
-
gridHeight: widget.gridHeight,
|
|
545
|
-
bindings
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
function parseWidgetConfig(widget) {
|
|
549
|
-
if (isAnalyticsWidgetConfig(widget.config)) {
|
|
550
|
-
return widget.config;
|
|
551
|
-
}
|
|
552
|
-
const legacyRef = LEGACY_VISUALIZATION_REFS[widget.type];
|
|
553
|
-
return legacyRef ? {
|
|
554
|
-
layout: "single",
|
|
555
|
-
bindings: [
|
|
556
|
-
{
|
|
557
|
-
ref: legacyRef,
|
|
558
|
-
data: AnalyticsVisualizationSampleData[visualizationRefKey(legacyRef)]
|
|
559
|
-
}
|
|
560
|
-
]
|
|
561
|
-
} : { layout: "single", bindings: [] };
|
|
562
|
-
}
|
|
563
|
-
function binding(spec, height = 280) {
|
|
564
|
-
return {
|
|
565
|
-
ref: refOf(spec),
|
|
566
|
-
data: AnalyticsVisualizationSampleData[visualizationRefKey(spec.meta)],
|
|
567
|
-
height
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
function widget(dashboardId, id, name, type, gridX, gridY, gridWidth, gridHeight, config) {
|
|
571
|
-
const now = new Date;
|
|
572
|
-
return {
|
|
573
|
-
id,
|
|
574
|
-
dashboardId,
|
|
575
|
-
name,
|
|
576
|
-
type,
|
|
577
|
-
gridX,
|
|
578
|
-
gridY,
|
|
579
|
-
gridWidth,
|
|
580
|
-
gridHeight,
|
|
581
|
-
config,
|
|
582
|
-
createdAt: now,
|
|
583
|
-
updatedAt: now
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
function isAnalyticsWidgetConfig(value) {
|
|
587
|
-
if (!value || typeof value !== "object")
|
|
588
|
-
return false;
|
|
589
|
-
const candidate = value;
|
|
590
|
-
return (candidate.layout === "single" || candidate.layout === "comparison" || candidate.layout === "timeline") && Array.isArray(candidate.bindings);
|
|
591
|
-
}
|
|
592
|
-
// src/ui/renderers/analytics.markdown.ts
|
|
593
|
-
var mockDashboards = [
|
|
594
|
-
{
|
|
595
|
-
id: "dash-1",
|
|
596
|
-
name: "Sales Overview",
|
|
597
|
-
slug: "sales-overview",
|
|
598
|
-
status: "PUBLISHED",
|
|
599
|
-
widgetCount: 11,
|
|
600
|
-
viewCount: 1250,
|
|
601
|
-
lastViewedAt: "2026-03-18T12:00:00Z"
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
id: "dash-2",
|
|
605
|
-
name: "User Engagement",
|
|
606
|
-
slug: "user-engagement",
|
|
607
|
-
status: "PUBLISHED",
|
|
608
|
-
widgetCount: 8,
|
|
609
|
-
viewCount: 890,
|
|
610
|
-
lastViewedAt: "2026-03-18T10:00:00Z"
|
|
611
|
-
}
|
|
612
|
-
];
|
|
613
|
-
var mockQueries = [
|
|
614
|
-
{
|
|
615
|
-
id: "q-1",
|
|
616
|
-
name: "Monthly Revenue",
|
|
617
|
-
type: "AGGREGATION",
|
|
618
|
-
isShared: true,
|
|
619
|
-
executionCount: 1500
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
id: "q-2",
|
|
623
|
-
name: "User Growth",
|
|
624
|
-
type: "METRIC",
|
|
625
|
-
isShared: true,
|
|
626
|
-
executionCount: 890
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
id: "q-3",
|
|
630
|
-
name: "Product Sales",
|
|
631
|
-
type: "SQL",
|
|
632
|
-
isShared: false,
|
|
633
|
-
executionCount: 340
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
id: "q-4",
|
|
637
|
-
name: "Conversion Funnel",
|
|
638
|
-
type: "AGGREGATION",
|
|
639
|
-
isShared: true,
|
|
640
|
-
executionCount: 450
|
|
641
|
-
}
|
|
642
|
-
];
|
|
643
|
-
function dashboardWidgets(dashboardId) {
|
|
644
|
-
return createExampleWidgets(dashboardId).map((widget2) => resolveAnalyticsWidget(widget2)).filter((widget2) => Boolean(widget2));
|
|
645
|
-
}
|
|
646
|
-
var analyticsDashboardMarkdownRenderer = {
|
|
647
|
-
target: "markdown",
|
|
648
|
-
render: async (desc) => {
|
|
649
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "AnalyticsDashboard") {
|
|
650
|
-
throw new Error("analyticsDashboardMarkdownRenderer: not AnalyticsDashboard");
|
|
651
|
-
}
|
|
652
|
-
const dashboard = mockDashboards[0];
|
|
653
|
-
if (!dashboard) {
|
|
654
|
-
return {
|
|
655
|
-
mimeType: "text/markdown",
|
|
656
|
-
body: `# No Dashboards
|
|
657
|
-
|
|
658
|
-
No dashboards available.`
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
const widgets = dashboardWidgets(dashboard.id);
|
|
662
|
-
const metricWidgets = widgets.filter((widget2) => widget2.bindings[0]?.spec.visualization.kind === "metric");
|
|
663
|
-
const lines = [
|
|
664
|
-
`# ${dashboard.name}`,
|
|
665
|
-
"",
|
|
666
|
-
"> Contract-backed analytics dashboard overview.",
|
|
667
|
-
"",
|
|
668
|
-
"## Key Metrics",
|
|
669
|
-
""
|
|
670
|
-
];
|
|
671
|
-
for (const widget2 of metricWidgets) {
|
|
672
|
-
const binding2 = widget2.bindings[0];
|
|
673
|
-
if (!binding2)
|
|
674
|
-
continue;
|
|
675
|
-
lines.push(`- **${widget2.name}** via \`${binding2.spec.meta.key}\``);
|
|
676
|
-
}
|
|
677
|
-
lines.push("");
|
|
678
|
-
lines.push("## Visual Blocks");
|
|
679
|
-
lines.push("");
|
|
680
|
-
for (const widget2 of widgets) {
|
|
681
|
-
const kinds = widget2.bindings.map((binding2) => binding2.spec.visualization.kind).join(", ");
|
|
682
|
-
lines.push(`- **${widget2.name}** (${widget2.layout}) → ${kinds}`);
|
|
683
|
-
}
|
|
684
|
-
lines.push("");
|
|
685
|
-
lines.push("## Dashboard Stats");
|
|
686
|
-
lines.push("");
|
|
687
|
-
lines.push("| Metric | Value |");
|
|
688
|
-
lines.push("|--------|-------|");
|
|
689
|
-
lines.push(`| Total Dashboards | ${mockDashboards.length} |`);
|
|
690
|
-
lines.push(`| Published | ${mockDashboards.filter((item) => item.status === "PUBLISHED").length} |`);
|
|
691
|
-
lines.push(`| Shared Queries | ${mockQueries.filter((query) => query.isShared).length} |`);
|
|
692
|
-
return {
|
|
693
|
-
mimeType: "text/markdown",
|
|
694
|
-
body: lines.join(`
|
|
695
|
-
`)
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
var dashboardListMarkdownRenderer = {
|
|
700
|
-
target: "markdown",
|
|
701
|
-
render: async (desc) => {
|
|
702
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "DashboardList") {
|
|
703
|
-
throw new Error("dashboardListMarkdownRenderer: not DashboardList");
|
|
704
|
-
}
|
|
705
|
-
const lines = [
|
|
706
|
-
"# Dashboards",
|
|
707
|
-
"",
|
|
708
|
-
"> Browse and manage analytics dashboards",
|
|
709
|
-
"",
|
|
710
|
-
"| Dashboard | Widgets | Views | Status | Last Viewed |",
|
|
711
|
-
"|-----------|---------|-------|--------|-------------|"
|
|
712
|
-
];
|
|
713
|
-
for (const dashboard of mockDashboards) {
|
|
714
|
-
const lastViewed = dashboard.lastViewedAt ? new Date(dashboard.lastViewedAt).toLocaleDateString() : "Never";
|
|
715
|
-
const statusIcon = dashboard.status === "PUBLISHED" ? "\uD83D\uDFE2" : "⚫";
|
|
716
|
-
lines.push(`| [${dashboard.name}](/dashboards/${dashboard.slug}) | ${dashboard.widgetCount} | ${dashboard.viewCount.toLocaleString()} | ${statusIcon} ${dashboard.status} | ${lastViewed} |`);
|
|
717
|
-
}
|
|
718
|
-
return {
|
|
719
|
-
mimeType: "text/markdown",
|
|
720
|
-
body: lines.join(`
|
|
721
|
-
`)
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
var queryBuilderMarkdownRenderer = {
|
|
726
|
-
target: "markdown",
|
|
727
|
-
render: async (desc) => {
|
|
728
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "QueryBuilder") {
|
|
729
|
-
throw new Error("queryBuilderMarkdownRenderer: not QueryBuilder");
|
|
730
|
-
}
|
|
731
|
-
const lines = [
|
|
732
|
-
"# Query Builder",
|
|
733
|
-
"",
|
|
734
|
-
"> Create and manage reusable data queries.",
|
|
735
|
-
"",
|
|
736
|
-
"| Query | Type | Shared | Executions |",
|
|
737
|
-
"|-------|------|--------|------------|"
|
|
738
|
-
];
|
|
739
|
-
for (const query of mockQueries) {
|
|
740
|
-
lines.push(`| ${query.name} | ${query.type} | ${query.isShared ? "\uD83C\uDF10" : "\uD83D\uDD12"} | ${query.executionCount.toLocaleString()} |`);
|
|
741
|
-
}
|
|
742
|
-
lines.push("");
|
|
743
|
-
lines.push("## Visualization Contracts");
|
|
744
|
-
lines.push("");
|
|
745
|
-
lines.push("Widgets reference `VisualizationSpec` contracts instead of rendering ad-hoc widget types.");
|
|
746
|
-
return {
|
|
747
|
-
mimeType: "text/markdown",
|
|
748
|
-
body: lines.join(`
|
|
749
|
-
`)
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
export {
|
|
754
|
-
queryBuilderMarkdownRenderer,
|
|
755
|
-
dashboardListMarkdownRenderer,
|
|
756
|
-
analyticsDashboardMarkdownRenderer
|
|
757
|
-
};
|
|
3
|
+
No dashboards available.`};let o=v(t.id),m=o.filter((y)=>y.bindings[0]?.spec.visualization.kind==="metric"),e=[`# ${t.name}`,"","> Contract-backed analytics dashboard overview.","","## Key Metrics",""];for(let y of m){let q=y.bindings[0];if(!q)continue;e.push(`- **${y.name}** via \`${q.spec.meta.key}\``)}e.push(""),e.push("## Visual Blocks"),e.push("");for(let y of o){let q=y.bindings.map((J)=>J.spec.visualization.kind).join(", ");e.push(`- **${y.name}** (${y.layout}) → ${q}`)}return e.push(""),e.push("## Dashboard Stats"),e.push(""),e.push("| Metric | Value |"),e.push("|--------|-------|"),e.push(`| Total Dashboards | ${Z.length} |`),e.push(`| Published | ${Z.filter((y)=>y.status==="PUBLISHED").length} |`),e.push(`| Shared Queries | ${U.filter((y)=>y.isShared).length} |`),{mimeType:"text/markdown",body:e.join(`
|
|
4
|
+
`)}}},hr={target:"markdown",render:async(r)=>{if(r.source.type!=="component"||r.source.componentKey!=="DashboardList")throw Error("dashboardListMarkdownRenderer: not DashboardList");let t=["# Dashboards","","> Browse and manage analytics dashboards","","| Dashboard | Widgets | Views | Status | Last Viewed |","|-----------|---------|-------|--------|-------------|"];for(let o of Z){let m=o.lastViewedAt?new Date(o.lastViewedAt).toLocaleDateString():"Never",e=o.status==="PUBLISHED"?"\uD83D\uDFE2":"⚫";t.push(`| [${o.name}](/dashboards/${o.slug}) | ${o.widgetCount} | ${o.viewCount.toLocaleString()} | ${e} ${o.status} | ${m} |`)}return{mimeType:"text/markdown",body:t.join(`
|
|
5
|
+
`)}}},ur={target:"markdown",render:async(r)=>{if(r.source.type!=="component"||r.source.componentKey!=="QueryBuilder")throw Error("queryBuilderMarkdownRenderer: not QueryBuilder");let t=["# Query Builder","","> Create and manage reusable data queries.","","| Query | Type | Shared | Executions |","|-------|------|--------|------------|"];for(let o of U)t.push(`| ${o.name} | ${o.type} | ${o.isShared?"\uD83C\uDF10":"\uD83D\uDD12"} | ${o.executionCount.toLocaleString()} |`);return t.push(""),t.push("## Visualization Contracts"),t.push(""),t.push("Widgets reference `VisualizationSpec` contracts instead of rendering ad-hoc widget types."),{mimeType:"text/markdown",body:t.join(`
|
|
6
|
+
`)}}};export{ur as queryBuilderMarkdownRenderer,hr as dashboardListMarkdownRenderer,pr as analyticsDashboardMarkdownRenderer};
|