@stacksjs/ts-analytics 0.1.6
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/CHANGELOG.md +68 -0
- package/LICENSE.md +21 -0
- package/README.md +361 -0
- package/bin/cli.ts +169 -0
- package/dist/Analytics.d.ts +558 -0
- package/dist/api.d.ts +109 -0
- package/dist/batching.d.ts +93 -0
- package/dist/chunk-2mx7fq49.js +4 -0
- package/dist/chunk-3z29508k.js +204 -0
- package/dist/chunk-deephkz6.js +56 -0
- package/dist/chunk-j261vgyp.js +305 -0
- package/dist/chunk-xga17tz7.js +207 -0
- package/dist/config.d.ts +132 -0
- package/dist/dashboard/components/index.d.ts +80 -0
- package/dist/dashboard/composables/useAnalytics.d.ts +99 -0
- package/dist/dashboard/index.d.ts +110 -0
- package/dist/dashboard/types/index.d.ts +144 -0
- package/dist/dashboard/utils/index.d.ts +81 -0
- package/dist/dynamodb.d.ts +86 -0
- package/dist/funnels.d.ts +104 -0
- package/dist/geolocation.d.ts +96 -0
- package/dist/index.d.ts +371 -0
- package/dist/index.js +10211 -0
- package/dist/infrastructure/cdk.d.ts +60 -0
- package/dist/infrastructure/cloudformation.d.ts +44 -0
- package/dist/infrastructure/index.d.ts +45 -0
- package/dist/infrastructure/setup.d.ts +133 -0
- package/dist/integrations/cloudflare.d.ts +76 -0
- package/dist/integrations/hono.d.ts +60 -0
- package/dist/integrations/index.d.ts +24 -0
- package/dist/integrations/nuxt.d.ts +7 -0
- package/dist/integrations/nuxt.js +42 -0
- package/dist/integrations/runtime/use-ts-analytics.d.ts +18 -0
- package/dist/integrations/runtime/use-ts-analytics.js +17 -0
- package/dist/integrations/stx.d.ts +88 -0
- package/dist/integrations/stx.js +18 -0
- package/dist/lib/crypto-random.d.ts +4 -0
- package/dist/lib/salt.d.ts +16 -0
- package/dist/local.d.ts +56 -0
- package/dist/model-connector.d.ts +145 -0
- package/dist/models/AggregatedStats.d.ts +9 -0
- package/dist/models/CampaignStats.d.ts +9 -0
- package/dist/models/Conversion.d.ts +11 -0
- package/dist/models/CustomEvent.d.ts +11 -0
- package/dist/models/DeviceStats.d.ts +9 -0
- package/dist/models/EventStats.d.ts +9 -0
- package/dist/models/GeoStats.d.ts +9 -0
- package/dist/models/Goal.d.ts +9 -0
- package/dist/models/GoalStats.d.ts +9 -0
- package/dist/models/PageStats.d.ts +11 -0
- package/dist/models/PageView.d.ts +13 -0
- package/dist/models/RealtimeStats.d.ts +9 -0
- package/dist/models/ReferrerStats.d.ts +9 -0
- package/dist/models/Session.d.ts +11 -0
- package/dist/models/Site.d.ts +11 -0
- package/dist/models/index.d.ts +28 -0
- package/dist/models/types.d.ts +60 -0
- package/dist/sqs-buffering.d.ts +243 -0
- package/dist/stacks-integration.d.ts +159 -0
- package/dist/tracking-script.d.ts +71 -0
- package/dist/tracking.d.ts +17 -0
- package/dist/tracking.js +26 -0
- package/dist/types.d.ts +595 -0
- package/dist/utils/geolocation.d.ts +111 -0
- package/dist/utils/user-agent.d.ts +17 -0
- package/dist/version.d.ts +7 -0
- package/package.json +119 -0
- package/src/Analytics.ts +3349 -0
- package/src/api.ts +1286 -0
- package/src/assets/crosswind.css +2220 -0
- package/src/batching.ts +452 -0
- package/src/components/dashboard/index.ts +18 -0
- package/src/config.ts +456 -0
- package/src/dashboard/Dashboard.stx +1517 -0
- package/src/dashboard/components/AlertCard.stx +177 -0
- package/src/dashboard/components/AnalyticsDashboard.stx +354 -0
- package/src/dashboard/components/AnimatedNumber.stx +86 -0
- package/src/dashboard/components/BarChart.stx +220 -0
- package/src/dashboard/components/BrowserBreakdown.stx +98 -0
- package/src/dashboard/components/BrowsersTable.stx +125 -0
- package/src/dashboard/components/CampaignBreakdown.stx +163 -0
- package/src/dashboard/components/CampaignTable.stx +238 -0
- package/src/dashboard/components/CountryList.stx +101 -0
- package/src/dashboard/components/DataTable.stx +226 -0
- package/src/dashboard/components/DateRangePicker.stx +77 -0
- package/src/dashboard/components/DeviceBreakdown.stx +94 -0
- package/src/dashboard/components/DevicesTable.stx +163 -0
- package/src/dashboard/components/DonutChart.stories.ts +55 -0
- package/src/dashboard/components/DonutChart.stx +157 -0
- package/src/dashboard/components/EmptyState.stx +90 -0
- package/src/dashboard/components/EngagementMetrics.stx +183 -0
- package/src/dashboard/components/EventsSection.stx +192 -0
- package/src/dashboard/components/FilterBar.stx +104 -0
- package/src/dashboard/components/FullAnalyticsDashboard.stx +455 -0
- package/src/dashboard/components/FunnelChart.stx +142 -0
- package/src/dashboard/components/GeoTable.stx +337 -0
- package/src/dashboard/components/GoalsPanel.stx +109 -0
- package/src/dashboard/components/Header.stx +39 -0
- package/src/dashboard/components/HeatmapChart.stx +140 -0
- package/src/dashboard/components/LiveActivityFeed.stx +172 -0
- package/src/dashboard/components/MetricComparison.stx +106 -0
- package/src/dashboard/components/MiniStats.stx +96 -0
- package/src/dashboard/components/OSBreakdown.stx +124 -0
- package/src/dashboard/components/PageDetailCard.stx +102 -0
- package/src/dashboard/components/PagesTable.stx +127 -0
- package/src/dashboard/components/ProgressRing.stx +89 -0
- package/src/dashboard/components/RealtimeCounter.stories.ts +45 -0
- package/src/dashboard/components/RealtimeCounter.stx +46 -0
- package/src/dashboard/components/ReferrersTable.stx +180 -0
- package/src/dashboard/components/SparklineChart.stx +160 -0
- package/src/dashboard/components/StatCard.stories.ts +58 -0
- package/src/dashboard/components/StatCard.stx +90 -0
- package/src/dashboard/components/SummaryStats.stx +81 -0
- package/src/dashboard/components/TabNav.stx +66 -0
- package/src/dashboard/components/ThemeSwitcher.stx +124 -0
- package/src/dashboard/components/TimeSeriesChart.stx +106 -0
- package/src/dashboard/components/TopList.stories.ts +58 -0
- package/src/dashboard/components/TopList.stx +74 -0
- package/src/dashboard/components/TrendIndicator.stx +84 -0
- package/src/dashboard/components/heatmap/ClickHeatmap.stx +264 -0
- package/src/dashboard/components/heatmap/ElementClickList.stx +125 -0
- package/src/dashboard/components/heatmap/HeatmapControls.stx +125 -0
- package/src/dashboard/components/heatmap/HeatmapLegend.stx +69 -0
- package/src/dashboard/components/heatmap/PageHeatmap.stx +264 -0
- package/src/dashboard/components/heatmap/ScrollHeatmap.stx +127 -0
- package/src/dashboard/components/heatmap/index.ts +12 -0
- package/src/dashboard/components/index.ts +86 -0
- package/src/dashboard/composables/useAnalytics.ts +465 -0
- package/src/dashboard/demo/DemoApp.stx +370 -0
- package/src/dashboard/demo/index.ts +8 -0
- package/src/dashboard/demo/mockData.ts +234 -0
- package/src/dashboard/index.ts +117 -0
- package/src/dashboard/stx-shim.d.ts +4 -0
- package/src/dashboard/types/index.ts +203 -0
- package/src/dashboard/utils/index.ts +426 -0
- package/src/dynamodb.ts +344 -0
- package/src/funnels.ts +534 -0
- package/src/geolocation.ts +515 -0
- package/src/handlers/alerts.ts +328 -0
- package/src/handlers/annotations.ts +128 -0
- package/src/handlers/api-keys.ts +240 -0
- package/src/handlers/auth.ts +1020 -0
- package/src/handlers/authz.ts +137 -0
- package/src/handlers/collect.ts +724 -0
- package/src/handlers/data.ts +625 -0
- package/src/handlers/experiments.ts +138 -0
- package/src/handlers/funnels.ts +216 -0
- package/src/handlers/goals.ts +218 -0
- package/src/handlers/heatmaps.ts +272 -0
- package/src/handlers/index.ts +56 -0
- package/src/handlers/lib/read-cache.ts +63 -0
- package/src/handlers/misc.ts +486 -0
- package/src/handlers/oauth.ts +233 -0
- package/src/handlers/performance.ts +388 -0
- package/src/handlers/sessions.ts +413 -0
- package/src/handlers/sharing.ts +198 -0
- package/src/handlers/stats.ts +1368 -0
- package/src/handlers/team.ts +161 -0
- package/src/handlers/uptime.ts +283 -0
- package/src/handlers/views.ts +390 -0
- package/src/handlers/webhooks.ts +226 -0
- package/src/heatmap/index.ts +32 -0
- package/src/heatmap/tracking-script.ts +452 -0
- package/src/heatmap/types.ts +79 -0
- package/src/index.ts +387 -0
- package/src/infrastructure/cdk.ts +496 -0
- package/src/infrastructure/cloudformation.ts +595 -0
- package/src/infrastructure/index.ts +48 -0
- package/src/infrastructure/setup.ts +611 -0
- package/src/integrations/cloudflare.ts +732 -0
- package/src/integrations/hono.ts +589 -0
- package/src/integrations/index.ts +27 -0
- package/src/integrations/nuxt.ts +78 -0
- package/src/integrations/runtime/use-ts-analytics.ts +32 -0
- package/src/integrations/stx.ts +138 -0
- package/src/jobs/index.ts +127 -0
- package/src/lib/crypto-random.ts +41 -0
- package/src/lib/ddb-errors.ts +20 -0
- package/src/lib/dynamodb.ts +216 -0
- package/src/lib/email.ts +38 -0
- package/src/lib/ga-import.ts +471 -0
- package/src/lib/ga4-api.ts +244 -0
- package/src/lib/goals.ts +205 -0
- package/src/lib/index.ts +6 -0
- package/src/lib/ingest-counters.ts +123 -0
- package/src/lib/log.ts +36 -0
- package/src/lib/membership.ts +98 -0
- package/src/lib/plans.ts +90 -0
- package/src/lib/quota.ts +46 -0
- package/src/lib/rate-limit.ts +27 -0
- package/src/lib/rollups.ts +472 -0
- package/src/lib/salt.ts +97 -0
- package/src/lib/scheduler.ts +97 -0
- package/src/lib/significance.ts +66 -0
- package/src/lib/site-retention.ts +56 -0
- package/src/local.ts +360 -0
- package/src/model-connector.ts +616 -0
- package/src/models/AggregatedStats.ts +162 -0
- package/src/models/CampaignStats.ts +141 -0
- package/src/models/Conversion.ts +135 -0
- package/src/models/CustomEvent.ts +123 -0
- package/src/models/DeviceStats.ts +105 -0
- package/src/models/EventStats.ts +108 -0
- package/src/models/GeoStats.ts +112 -0
- package/src/models/Goal.ts +105 -0
- package/src/models/GoalStats.ts +106 -0
- package/src/models/PageStats.ts +152 -0
- package/src/models/PageView.ts +277 -0
- package/src/models/RealtimeStats.ts +96 -0
- package/src/models/ReferrerStats.ts +115 -0
- package/src/models/Session.ts +235 -0
- package/src/models/Site.ts +115 -0
- package/src/models/index.ts +50 -0
- package/src/models/orm/index.ts +2043 -0
- package/src/models/types.ts +71 -0
- package/src/router.ts +521 -0
- package/src/sqs-buffering.ts +806 -0
- package/src/stacks-integration.ts +527 -0
- package/src/tracking-script.ts +944 -0
- package/src/tracking.ts +27 -0
- package/src/types/analytics.ts +219 -0
- package/src/types/api.ts +75 -0
- package/src/types/bun-router.d.ts +15 -0
- package/src/types/dashboard.ts +62 -0
- package/src/types/index.ts +66 -0
- package/src/types/stx.d.ts +27 -0
- package/src/types/window.d.ts +101 -0
- package/src/types.ts +911 -0
- package/src/utils/cache.ts +148 -0
- package/src/utils/date.ts +118 -0
- package/src/utils/filters.ts +71 -0
- package/src/utils/geolocation.ts +323 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/response.ts +180 -0
- package/src/utils/timezone-country.ts +242 -0
- package/src/utils/user-agent.ts +110 -0
- package/src/version.ts +7 -0
package/src/tracking.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stacksjs/ts-analytics/tracking`
|
|
3
|
+
*
|
|
4
|
+
* A dependency-free entry point exposing the backend-agnostic tracking +
|
|
5
|
+
* privacy primitives, split out from the main barrel so consumers (e.g. the
|
|
6
|
+
* ghostanalytics app) can use them WITHOUT pulling in the DynamoDB/router/
|
|
7
|
+
* aggregation graph that the root `@stacksjs/ts-analytics` export carries.
|
|
8
|
+
*
|
|
9
|
+
* Everything re-exported here comes from `src/utils/*`, which have no imports.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
getBrowserFamily,
|
|
14
|
+
isBot,
|
|
15
|
+
type ParsedUserAgent,
|
|
16
|
+
parseUserAgent,
|
|
17
|
+
} from './utils/user-agent'
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
anonymizeIp,
|
|
21
|
+
countryCodeOf,
|
|
22
|
+
countryFlagEmoji,
|
|
23
|
+
getCountryFromHeaders,
|
|
24
|
+
getRegionFromHeaders,
|
|
25
|
+
isSpamReferrer,
|
|
26
|
+
parseReferrerSource,
|
|
27
|
+
} from './utils/geolocation'
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Core analytics types - extracted from component inline definitions
|
|
2
|
+
|
|
3
|
+
export interface Goal {
|
|
4
|
+
id: string
|
|
5
|
+
name: string
|
|
6
|
+
type: string
|
|
7
|
+
pattern?: string
|
|
8
|
+
matchType?: string
|
|
9
|
+
durationMinutes?: number
|
|
10
|
+
value?: number
|
|
11
|
+
isActive: boolean
|
|
12
|
+
conversions?: number
|
|
13
|
+
conversionRate?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GoalFormData {
|
|
17
|
+
name: string
|
|
18
|
+
type: string
|
|
19
|
+
pattern: string
|
|
20
|
+
matchType: string
|
|
21
|
+
durationMinutes?: number
|
|
22
|
+
value?: number
|
|
23
|
+
isActive: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface AnalyticsEvent {
|
|
27
|
+
name: string
|
|
28
|
+
count?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Session {
|
|
32
|
+
id: string
|
|
33
|
+
sessionId: string
|
|
34
|
+
entryPage: string
|
|
35
|
+
entryPath: string
|
|
36
|
+
startTime: string
|
|
37
|
+
startedAt: string
|
|
38
|
+
pageViews: number
|
|
39
|
+
pageViewCount: number
|
|
40
|
+
duration: number
|
|
41
|
+
bounced: boolean
|
|
42
|
+
isBounce: boolean
|
|
43
|
+
browser: string
|
|
44
|
+
country: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface PageView {
|
|
48
|
+
path: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SessionEvent {
|
|
52
|
+
type: string
|
|
53
|
+
name: string
|
|
54
|
+
path: string
|
|
55
|
+
message: string
|
|
56
|
+
timestamp: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SessionDetail {
|
|
60
|
+
pageViewCount: number
|
|
61
|
+
pageViews: PageView[]
|
|
62
|
+
duration: number
|
|
63
|
+
browser: string
|
|
64
|
+
country: string
|
|
65
|
+
events: SessionEvent[]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface Funnel {
|
|
69
|
+
id: string
|
|
70
|
+
name: string
|
|
71
|
+
steps: string[]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface FunnelAnalysisStep {
|
|
75
|
+
path: string
|
|
76
|
+
visitors: number
|
|
77
|
+
rate: number
|
|
78
|
+
dropoff: number
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface FunnelAnalysis {
|
|
82
|
+
name: string
|
|
83
|
+
totalVisitors: number
|
|
84
|
+
conversionRate: number
|
|
85
|
+
steps: FunnelAnalysisStep[]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface Vital {
|
|
89
|
+
metric: string
|
|
90
|
+
p75: number
|
|
91
|
+
samples: number
|
|
92
|
+
good: number
|
|
93
|
+
needsImprovement: number
|
|
94
|
+
poor: number
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface BudgetViolation {
|
|
98
|
+
metric: string
|
|
99
|
+
currentValue: number
|
|
100
|
+
threshold: number
|
|
101
|
+
exceededBy: number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface FlowPage {
|
|
105
|
+
path: string
|
|
106
|
+
count: number
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface FlowLink {
|
|
110
|
+
source: string
|
|
111
|
+
target: string
|
|
112
|
+
count: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface FlowData {
|
|
116
|
+
entryPages: FlowPage[]
|
|
117
|
+
flows: FlowLink[]
|
|
118
|
+
mostVisited: FlowPage[]
|
|
119
|
+
totalSessions: number
|
|
120
|
+
uniquePaths: number
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface LiveActivity {
|
|
124
|
+
path: string
|
|
125
|
+
country: string
|
|
126
|
+
device: string
|
|
127
|
+
browser: string
|
|
128
|
+
timestamp: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface Insight {
|
|
132
|
+
title: string
|
|
133
|
+
description: string
|
|
134
|
+
type: string
|
|
135
|
+
severity: string
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ComparisonPeriodStats {
|
|
139
|
+
visitors: number
|
|
140
|
+
views: number
|
|
141
|
+
sessions: number
|
|
142
|
+
bounceRate: number
|
|
143
|
+
avgDuration: number
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Shape returned by GET /comparison: the selected range vs the period before. */
|
|
147
|
+
export interface ComparisonStats {
|
|
148
|
+
current: ComparisonPeriodStats
|
|
149
|
+
previous: ComparisonPeriodStats
|
|
150
|
+
/** Percentage change (current vs previous) per metric. */
|
|
151
|
+
changes: ComparisonPeriodStats
|
|
152
|
+
periods?: {
|
|
153
|
+
current: { start: string, end: string }
|
|
154
|
+
previous: { start: string, end: string }
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface Referrer {
|
|
159
|
+
name: string
|
|
160
|
+
source?: string
|
|
161
|
+
visitors: number
|
|
162
|
+
views?: number
|
|
163
|
+
favicon?: string
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Settings types
|
|
167
|
+
export interface ApiKey {
|
|
168
|
+
name: string
|
|
169
|
+
key: string
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface Alert {
|
|
173
|
+
id: string
|
|
174
|
+
metric: string
|
|
175
|
+
threshold: number
|
|
176
|
+
email: string
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface EmailReport {
|
|
180
|
+
id: string
|
|
181
|
+
email: string
|
|
182
|
+
frequency: string
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface UptimeMonitor {
|
|
186
|
+
id: string
|
|
187
|
+
url: string
|
|
188
|
+
interval: number
|
|
189
|
+
status: string
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface TeamMember {
|
|
193
|
+
id: string
|
|
194
|
+
email: string
|
|
195
|
+
role: string
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface Webhook {
|
|
199
|
+
id: string
|
|
200
|
+
url: string
|
|
201
|
+
events: string[]
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface PerfBudget {
|
|
205
|
+
id: string
|
|
206
|
+
metric: string
|
|
207
|
+
threshold: number
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface SiteSettings {
|
|
211
|
+
apiKey: ApiKey | null
|
|
212
|
+
alerts: Alert[]
|
|
213
|
+
emailReports: EmailReport[]
|
|
214
|
+
uptimeMonitors: UptimeMonitor[]
|
|
215
|
+
teamMembers: TeamMember[]
|
|
216
|
+
webhooks: Webhook[]
|
|
217
|
+
perfBudgets: PerfBudget[]
|
|
218
|
+
retentionDays: number
|
|
219
|
+
}
|
package/src/types/api.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// API response types - inferred from dashboard fetch calls
|
|
2
|
+
|
|
3
|
+
import type { Goal, AnalyticsEvent, Session, Funnel, Vital, BudgetViolation, FlowData, LiveActivity, Insight, ComparisonStats, Referrer, ApiKey, Alert, EmailReport, UptimeMonitor, TeamMember, Webhook, PerfBudget } from './analytics'
|
|
4
|
+
|
|
5
|
+
export interface GoalsResponse {
|
|
6
|
+
goals?: Goal[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface EventsResponse {
|
|
10
|
+
events?: AnalyticsEvent[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SessionsResponse {
|
|
14
|
+
sessions?: Session[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface FunnelsResponse {
|
|
18
|
+
funnels?: Funnel[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface VitalsResponse {
|
|
22
|
+
vitals?: Vital[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BudgetViolationsResponse {
|
|
26
|
+
violations?: BudgetViolation[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface FlowResponse extends FlowData {}
|
|
30
|
+
|
|
31
|
+
export interface LiveResponse {
|
|
32
|
+
activities?: LiveActivity[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface InsightsResponse {
|
|
36
|
+
insights?: Insight[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ComparisonResponse extends ComparisonStats {}
|
|
40
|
+
|
|
41
|
+
export interface ReferrersResponse {
|
|
42
|
+
referrers?: Referrer[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ApiKeysResponse {
|
|
46
|
+
apiKey?: ApiKey
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AlertsResponse {
|
|
50
|
+
alerts?: Alert[]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface EmailReportsResponse {
|
|
54
|
+
reports?: EmailReport[]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface UptimeResponse {
|
|
58
|
+
monitors?: UptimeMonitor[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface TeamResponse {
|
|
62
|
+
members?: TeamMember[]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface WebhooksResponse {
|
|
66
|
+
webhooks?: Webhook[]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface PerfBudgetsResponse {
|
|
70
|
+
budgets?: PerfBudget[]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface RetentionResponse {
|
|
74
|
+
days?: number
|
|
75
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module '@stacksjs/bun-router' {
|
|
2
|
+
export class Router {
|
|
3
|
+
constructor(_options?: any)
|
|
4
|
+
get(_path: string, _handler: any): Promise<any>
|
|
5
|
+
post(_path: string, _handler: any): Promise<any>
|
|
6
|
+
put(_path: string, _handler: any): Promise<any>
|
|
7
|
+
delete(_path: string, _handler: any): Promise<any>
|
|
8
|
+
patch(_path: string, _handler: any): Promise<any>
|
|
9
|
+
start(_options?: any): Promise<any>
|
|
10
|
+
handleRequest(_request: Request): Promise<Response>
|
|
11
|
+
[key: string]: any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function injectQueryPreservationScript(_html: string, _config: any): string
|
|
15
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Dashboard UI types - extracted from component inline definitions
|
|
2
|
+
|
|
3
|
+
export interface ModalOptions {
|
|
4
|
+
title?: string
|
|
5
|
+
content?: string
|
|
6
|
+
size?: string
|
|
7
|
+
className?: string
|
|
8
|
+
showFooter?: boolean
|
|
9
|
+
submitText?: string
|
|
10
|
+
cancelText?: string
|
|
11
|
+
onSubmit?: (() => Promise<void>) | null
|
|
12
|
+
onCancel?: (() => void) | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ModalAPI {
|
|
16
|
+
open: (options?: ModalOptions) => void
|
|
17
|
+
close: () => void
|
|
18
|
+
handleSubmit: () => Promise<void>
|
|
19
|
+
getFormData: () => Record<string, string | boolean>
|
|
20
|
+
confirm: (message: string, onConfirm: () => Promise<void>) => void
|
|
21
|
+
alert: (title: string, message: string) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GoalModalAPI {
|
|
25
|
+
openCreate: () => void
|
|
26
|
+
openEdit: (goal: any) => void
|
|
27
|
+
close: () => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NavTab {
|
|
31
|
+
id: string
|
|
32
|
+
label: string
|
|
33
|
+
href: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface DashboardHeaderAPI {
|
|
37
|
+
toggleTheme: () => void
|
|
38
|
+
goBack: () => void
|
|
39
|
+
isDarkTheme: () => boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface DateRange {
|
|
43
|
+
id: string
|
|
44
|
+
label: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ControlsBarAPI {
|
|
48
|
+
activeRange: () => string
|
|
49
|
+
showComparison: () => boolean
|
|
50
|
+
realtimeCount: () => number
|
|
51
|
+
lastUpdated: () => string
|
|
52
|
+
isRefreshing: () => boolean
|
|
53
|
+
setRange: (range: string) => void
|
|
54
|
+
toggleComparison: () => void
|
|
55
|
+
refresh: () => Promise<void>
|
|
56
|
+
exportData: (format: string) => void
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ReferrersTableProps {
|
|
60
|
+
referrers?: import('./analytics').Referrer[]
|
|
61
|
+
loading?: boolean
|
|
62
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Barrel export for all shared types
|
|
2
|
+
export type {
|
|
3
|
+
// Analytics types
|
|
4
|
+
Goal,
|
|
5
|
+
GoalFormData,
|
|
6
|
+
AnalyticsEvent,
|
|
7
|
+
Session,
|
|
8
|
+
PageView,
|
|
9
|
+
SessionEvent,
|
|
10
|
+
SessionDetail,
|
|
11
|
+
Funnel,
|
|
12
|
+
FunnelAnalysisStep,
|
|
13
|
+
FunnelAnalysis,
|
|
14
|
+
Vital,
|
|
15
|
+
BudgetViolation,
|
|
16
|
+
FlowPage,
|
|
17
|
+
FlowLink,
|
|
18
|
+
FlowData,
|
|
19
|
+
LiveActivity,
|
|
20
|
+
Insight,
|
|
21
|
+
ComparisonStats,
|
|
22
|
+
Referrer,
|
|
23
|
+
ApiKey,
|
|
24
|
+
Alert,
|
|
25
|
+
EmailReport,
|
|
26
|
+
UptimeMonitor,
|
|
27
|
+
TeamMember,
|
|
28
|
+
Webhook,
|
|
29
|
+
PerfBudget,
|
|
30
|
+
SiteSettings,
|
|
31
|
+
} from './analytics'
|
|
32
|
+
|
|
33
|
+
export type {
|
|
34
|
+
// Dashboard UI types
|
|
35
|
+
ModalOptions,
|
|
36
|
+
ModalAPI,
|
|
37
|
+
GoalModalAPI,
|
|
38
|
+
NavTab,
|
|
39
|
+
DashboardHeaderAPI,
|
|
40
|
+
DateRange,
|
|
41
|
+
ControlsBarAPI,
|
|
42
|
+
ReferrersTableProps,
|
|
43
|
+
} from './dashboard'
|
|
44
|
+
|
|
45
|
+
export type {
|
|
46
|
+
// API response types
|
|
47
|
+
GoalsResponse,
|
|
48
|
+
EventsResponse,
|
|
49
|
+
SessionsResponse,
|
|
50
|
+
FunnelsResponse,
|
|
51
|
+
VitalsResponse,
|
|
52
|
+
BudgetViolationsResponse,
|
|
53
|
+
FlowResponse,
|
|
54
|
+
LiveResponse,
|
|
55
|
+
InsightsResponse,
|
|
56
|
+
ComparisonResponse,
|
|
57
|
+
ReferrersResponse,
|
|
58
|
+
ApiKeysResponse,
|
|
59
|
+
AlertsResponse,
|
|
60
|
+
EmailReportsResponse,
|
|
61
|
+
UptimeResponse,
|
|
62
|
+
TeamResponse,
|
|
63
|
+
WebhooksResponse,
|
|
64
|
+
PerfBudgetsResponse,
|
|
65
|
+
RetentionResponse,
|
|
66
|
+
} from './api'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare module '@stacksjs/stx' {
|
|
2
|
+
export function processDirectives(
|
|
3
|
+
_template: string,
|
|
4
|
+
_context: Record<string, unknown>,
|
|
5
|
+
_templatePath: string,
|
|
6
|
+
_config: any,
|
|
7
|
+
_seen: Set<string>,
|
|
8
|
+
): Promise<string>
|
|
9
|
+
|
|
10
|
+
export function extractVariables(
|
|
11
|
+
_script: string,
|
|
12
|
+
_context: Record<string, unknown>,
|
|
13
|
+
_templatePath: string,
|
|
14
|
+
): Promise<void>
|
|
15
|
+
|
|
16
|
+
export function buildViews(_options?: any): Promise<void>
|
|
17
|
+
|
|
18
|
+
export const defaultConfig: Record<string, any>
|
|
19
|
+
|
|
20
|
+
export function createRoute(
|
|
21
|
+
_handler: (request: Request) => Response | Promise<Response>,
|
|
22
|
+
): (request: Request) => Response | Promise<Response>
|
|
23
|
+
|
|
24
|
+
export function createMiddleware(_options?: any): any
|
|
25
|
+
|
|
26
|
+
export function readMarkdownFile(_path: string): any
|
|
27
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Window interface augmentation - eliminates (window as any) casts
|
|
2
|
+
|
|
3
|
+
import type { ModalAPI, GoalModalAPI, DashboardHeaderAPI, ControlsBarAPI } from './dashboard'
|
|
4
|
+
|
|
5
|
+
export {}
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
// Site configuration (set by dashboard.ts / layout scripts)
|
|
10
|
+
siteId: string | undefined
|
|
11
|
+
API_ENDPOINT: string
|
|
12
|
+
ANALYTICS_API: string
|
|
13
|
+
ANALYTICS_API_ENDPOINT: string
|
|
14
|
+
ANALYTICS_SITE_ID: string
|
|
15
|
+
ANALYTICS_STEALTH_MODE: boolean
|
|
16
|
+
USE_STEALTH: boolean
|
|
17
|
+
|
|
18
|
+
// API helpers (set by dashboard.ts)
|
|
19
|
+
apiPath: (url: string) => string
|
|
20
|
+
getDateRangeParams: () => string
|
|
21
|
+
|
|
22
|
+
// Dashboard controller functions (set by dashboard.ts)
|
|
23
|
+
fetchDashboardData: (() => Promise<void>) | undefined
|
|
24
|
+
refreshAllPanels: (() => void) | undefined
|
|
25
|
+
setDateRange: ((_range: string) => void) | undefined
|
|
26
|
+
toggleComparison: (() => void) | undefined
|
|
27
|
+
exportData: ((_format: string) => void) | undefined
|
|
28
|
+
dateRange: string | undefined
|
|
29
|
+
navigateTo: ((_tab: string) => void) | undefined
|
|
30
|
+
applyFilter: ((_type: string, _value: string) => void) | undefined
|
|
31
|
+
|
|
32
|
+
// Panel refresh functions (set by individual panels)
|
|
33
|
+
refreshGoalsPanel: (() => void) | undefined
|
|
34
|
+
refreshEventsPanel: (() => void) | undefined
|
|
35
|
+
refreshPagesPanel: (() => void) | undefined
|
|
36
|
+
refreshReferrersPanel: (() => void) | undefined
|
|
37
|
+
refreshCountriesPanel: (() => void) | undefined
|
|
38
|
+
refreshBrowsersPanel: (() => void) | undefined
|
|
39
|
+
refreshDevicesPanel: (() => void) | undefined
|
|
40
|
+
refreshCampaignsPanel: (() => void) | undefined
|
|
41
|
+
|
|
42
|
+
// Component APIs (set via provide/inject and window exposure)
|
|
43
|
+
goalModal: GoalModalAPI | undefined
|
|
44
|
+
Modal: ModalAPI | undefined
|
|
45
|
+
dashboardHeader: DashboardHeaderAPI | undefined
|
|
46
|
+
controlsBar: ControlsBarAPI | undefined
|
|
47
|
+
|
|
48
|
+
// Header bridge functions
|
|
49
|
+
headerSetSiteName: ((_name: string) => void) | undefined
|
|
50
|
+
toggleTheme: (() => void) | undefined
|
|
51
|
+
goBack: (() => void) | undefined
|
|
52
|
+
|
|
53
|
+
// Controls bar bridge functions
|
|
54
|
+
updateRealtimeCount: ((_count: number) => void) | undefined
|
|
55
|
+
updateLastUpdated: ((_time: string) => void) | undefined
|
|
56
|
+
controlsSetDateRange: ((_range: string) => void) | undefined
|
|
57
|
+
|
|
58
|
+
// Filter bar functions
|
|
59
|
+
setFilterCountries: ((_countries: string[]) => void) | undefined
|
|
60
|
+
setFilterBrowsers: ((_browsers: string[]) => void) | undefined
|
|
61
|
+
getFilterParams: (() => string) | undefined
|
|
62
|
+
resetFilters: (() => void) | undefined
|
|
63
|
+
|
|
64
|
+
// FunnelsTab window globals (for modal innerHTML onclick)
|
|
65
|
+
__addFunnelStep: (() => void) | undefined
|
|
66
|
+
__removeFunnelStep: ((_index: number) => void) | undefined
|
|
67
|
+
|
|
68
|
+
// Legacy goal modal functions (dashboard.ts)
|
|
69
|
+
showEditGoalModal: ((_goalId: string) => void) | undefined
|
|
70
|
+
confirmDeleteGoal: ((_goalId: string) => void) | undefined
|
|
71
|
+
|
|
72
|
+
// Annotation
|
|
73
|
+
addAnnotation: (() => void) | undefined
|
|
74
|
+
|
|
75
|
+
// Modal close (SessionModal)
|
|
76
|
+
closeModal: (() => void) | undefined
|
|
77
|
+
|
|
78
|
+
// STX runtime
|
|
79
|
+
stx: {
|
|
80
|
+
state: <T>(initial: T) => { (): T; set: (v: T) => void; update: (fn: (v: T) => T) => void }
|
|
81
|
+
derived: <T>(fn: () => T) => () => T
|
|
82
|
+
effect: (fn: () => void | (() => void)) => void
|
|
83
|
+
mount: (el: Element, fn: () => void) => void
|
|
84
|
+
[key: string]: any
|
|
85
|
+
}
|
|
86
|
+
stxRouter: { navigate: (url: string) => void; clearCache: () => void }
|
|
87
|
+
stxLoading: { start: () => void; finish: () => void; show: () => void; hide: () => void }
|
|
88
|
+
STX_ROUTER_OPTIONS: Record<string, any>
|
|
89
|
+
|
|
90
|
+
// Composables registry
|
|
91
|
+
__composables: {
|
|
92
|
+
useSiteApi: () => any
|
|
93
|
+
useFetchData: (initialValue?: any) => any
|
|
94
|
+
useFetchMultiple: () => any
|
|
95
|
+
useModal: () => any
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Tracking script
|
|
99
|
+
sa: ((..._args: any[]) => void) & { q?: any[][] }
|
|
100
|
+
}
|
|
101
|
+
}
|