flowgrid-sdk 1.0.0
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/LICENSE +21 -0
- package/dist/browser.d.ts +119 -0
- package/dist/flowgrid.min.js +2 -0
- package/dist/flowgrid.min.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client/enterprise-ftrpc.d.ts +51 -0
- package/dist/lib/client/ftrpc.d.ts +43 -0
- package/dist/lib/client/modules.d.ts +104 -0
- package/dist/lib/features/analytics/attribution.d.ts +257 -0
- package/dist/lib/features/analytics/events.d.ts +304 -0
- package/dist/lib/features/analytics/funnels.d.ts +291 -0
- package/dist/lib/features/analytics/heatmaps.d.ts +247 -0
- package/dist/lib/features/analytics/identify.d.ts +273 -0
- package/dist/lib/features/analytics/index.d.ts +22 -0
- package/dist/lib/features/analytics/page-views.d.ts +250 -0
- package/dist/lib/features/analytics/performance.d.ts +281 -0
- package/dist/lib/features/analytics/retention.d.ts +294 -0
- package/dist/lib/features/analytics/sessions.d.ts +277 -0
- package/dist/lib/features/core/activation.d.ts +239 -0
- package/dist/lib/features/core/experiment.d.ts +286 -0
- package/dist/lib/features/core/feature-flag.d.ts +264 -0
- package/dist/lib/features/core/index.d.ts +14 -0
- package/dist/lib/features/core/track-feature.d.ts +220 -0
- package/dist/lib/features/core/track-prompt.d.ts +247 -0
- package/dist/lib/features/ecommerce/cart.d.ts +298 -0
- package/dist/lib/features/ecommerce/checkout.d.ts +324 -0
- package/dist/lib/features/ecommerce/index.d.ts +26 -0
- package/dist/lib/features/ecommerce/inventory.d.ts +221 -0
- package/dist/lib/features/ecommerce/ltv.d.ts +258 -0
- package/dist/lib/features/ecommerce/products.d.ts +268 -0
- package/dist/lib/features/ecommerce/promotions.d.ts +266 -0
- package/dist/lib/features/ecommerce/purchases.d.ts +287 -0
- package/dist/lib/features/ecommerce/refunds.d.ts +232 -0
- package/dist/lib/features/ecommerce/search.d.ts +225 -0
- package/dist/lib/features/ecommerce/subscriptions.d.ts +281 -0
- package/dist/lib/features/ecommerce/wishlist.d.ts +236 -0
- package/dist/lib/features/enterprise/acquisition.d.ts +373 -0
- package/dist/lib/features/enterprise/alerts.d.ts +348 -0
- package/dist/lib/features/enterprise/churn.d.ts +288 -0
- package/dist/lib/features/enterprise/cohorts.d.ts +270 -0
- package/dist/lib/features/enterprise/engagement.d.ts +233 -0
- package/dist/lib/features/enterprise/forecasting.d.ts +351 -0
- package/dist/lib/features/enterprise/index.d.ts +20 -0
- package/dist/lib/features/enterprise/monetization.d.ts +356 -0
- package/dist/lib/features/enterprise/multi-path-funnels.d.ts +327 -0
- package/dist/lib/features/enterprise/paths.d.ts +332 -0
- package/dist/lib/features/enterprise/security.d.ts +387 -0
- package/dist/lib/features/enterprise/support.d.ts +329 -0
- package/dist/lib/frameworks/index.d.ts +9 -0
- package/dist/lib/frameworks/nextjs/client.d.ts +208 -0
- package/dist/lib/frameworks/nextjs/index.d.ts +29 -0
- package/dist/lib/frameworks/nextjs/server.d.ts +201 -0
- package/dist/lib/frameworks/node/index.d.ts +265 -0
- package/dist/lib/frameworks/nuxt/index.d.ts +190 -0
- package/dist/lib/frameworks/react/index.d.ts +245 -0
- package/dist/lib/frameworks/vue/index.d.ts +275 -0
- package/dist/lib/types/analytics.d.ts +365 -0
- package/dist/lib/types/common.d.ts +230 -0
- package/dist/lib/types/ecommerce.d.ts +309 -0
- package/dist/lib/types/index.d.ts +7 -0
- package/dist/lib/utils/functions.d.ts +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - Page View Tracking
|
|
3
|
+
* @module features/analytics/page-views
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track page views with rich context including scroll depth, time on page,
|
|
7
|
+
* referrer information, and user engagement signals.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Track which pages users visit most frequently
|
|
11
|
+
* - Measure time spent on content pages
|
|
12
|
+
* - Identify high bounce rate pages
|
|
13
|
+
* - Analyze user navigation patterns
|
|
14
|
+
* - Monitor landing page performance
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Total page views
|
|
18
|
+
* - Unique page views
|
|
19
|
+
* - Average time on page
|
|
20
|
+
* - Bounce rate by page
|
|
21
|
+
* - Scroll depth distribution
|
|
22
|
+
* - Entry/exit page analysis
|
|
23
|
+
*
|
|
24
|
+
* @chartData
|
|
25
|
+
* - Line chart: Page views over time
|
|
26
|
+
* - Bar chart: Top pages by views
|
|
27
|
+
* - Heatmap: Scroll depth by page
|
|
28
|
+
* - Funnel: Page flow analysis
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const pageViews = new PageViews(webId, endpoint, apiKey);
|
|
33
|
+
*
|
|
34
|
+
* // Track a page view
|
|
35
|
+
* await pageViews.track({
|
|
36
|
+
* url: window.location.href,
|
|
37
|
+
* path: window.location.pathname,
|
|
38
|
+
* title: document.title,
|
|
39
|
+
* referrer: document.referrer
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Track with scroll depth
|
|
43
|
+
* await pageViews.trackScrollDepth({
|
|
44
|
+
* path: '/blog/article-1',
|
|
45
|
+
* scrollDepth: 75
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
50
|
+
import { TimeSeriesData, DateRangeFilter, PaginationParams } from "../../types";
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for tracking a page view.
|
|
53
|
+
*/
|
|
54
|
+
export interface PageViewConfig {
|
|
55
|
+
/** Full page URL */
|
|
56
|
+
url: string;
|
|
57
|
+
/** Page path (without domain) */
|
|
58
|
+
path: string;
|
|
59
|
+
/** Page title */
|
|
60
|
+
title?: string;
|
|
61
|
+
/** Referrer URL */
|
|
62
|
+
referrer?: string;
|
|
63
|
+
/** User ID (if authenticated) */
|
|
64
|
+
userId?: string;
|
|
65
|
+
/** Session ID */
|
|
66
|
+
sessionId?: string;
|
|
67
|
+
/** Custom properties */
|
|
68
|
+
properties?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for tracking scroll depth.
|
|
72
|
+
*/
|
|
73
|
+
export interface ScrollDepthConfig {
|
|
74
|
+
/** Page path */
|
|
75
|
+
path: string;
|
|
76
|
+
/** Scroll depth percentage (0-100) */
|
|
77
|
+
scrollDepth: number;
|
|
78
|
+
/** Time at this depth (seconds) */
|
|
79
|
+
timeAtDepth?: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Configuration for tracking time on page.
|
|
83
|
+
*/
|
|
84
|
+
export interface TimeOnPageConfig {
|
|
85
|
+
/** Page path */
|
|
86
|
+
path: string;
|
|
87
|
+
/** Time spent in seconds */
|
|
88
|
+
duration: number;
|
|
89
|
+
/** Whether user engaged (scrolled, clicked, etc.) */
|
|
90
|
+
engaged?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Page view response from API.
|
|
94
|
+
*/
|
|
95
|
+
export interface PageViewResponse {
|
|
96
|
+
eventName: string;
|
|
97
|
+
properties: Record<string, unknown>;
|
|
98
|
+
response: {
|
|
99
|
+
pageViewId: string;
|
|
100
|
+
tracked: boolean;
|
|
101
|
+
};
|
|
102
|
+
timestamp: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Page analytics data for charts.
|
|
106
|
+
*/
|
|
107
|
+
export interface PageAnalyticsData {
|
|
108
|
+
/** Top pages */
|
|
109
|
+
topPages: Array<{
|
|
110
|
+
path: string;
|
|
111
|
+
title: string;
|
|
112
|
+
views: number;
|
|
113
|
+
uniqueViews: number;
|
|
114
|
+
avgTimeOnPage: number;
|
|
115
|
+
bounceRate: number;
|
|
116
|
+
}>;
|
|
117
|
+
/** Page views time series */
|
|
118
|
+
timeSeries: TimeSeriesData;
|
|
119
|
+
/** Summary metrics */
|
|
120
|
+
summary: {
|
|
121
|
+
totalPageViews: number;
|
|
122
|
+
uniquePageViews: number;
|
|
123
|
+
avgTimeOnPage: number;
|
|
124
|
+
avgScrollDepth: number;
|
|
125
|
+
bounceRate: number;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* PageViews - Track and analyze page view events.
|
|
130
|
+
*
|
|
131
|
+
* @extends FTRPC
|
|
132
|
+
*
|
|
133
|
+
* @description
|
|
134
|
+
* Provides comprehensive page view tracking with support for:
|
|
135
|
+
* - Basic page view events
|
|
136
|
+
* - Scroll depth tracking
|
|
137
|
+
* - Time on page measurement
|
|
138
|
+
* - Exit intent detection
|
|
139
|
+
* - Page engagement scoring
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const pageViews = new PageViews(webId, endpoint, apiKey);
|
|
144
|
+
*
|
|
145
|
+
* // Basic page view
|
|
146
|
+
* await pageViews.track({
|
|
147
|
+
* url: 'https://example.com/products',
|
|
148
|
+
* path: '/products',
|
|
149
|
+
* title: 'Our Products'
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* // Pull analytics data for charts
|
|
153
|
+
* const analytics = await pageViews.getAnalytics({
|
|
154
|
+
* range: 'last30days'
|
|
155
|
+
* });
|
|
156
|
+
*
|
|
157
|
+
* // Data ready for charting
|
|
158
|
+
* const chartData = analytics.timeSeries.data.map(d => ({
|
|
159
|
+
* x: d.label,
|
|
160
|
+
* y: d.value
|
|
161
|
+
* }));
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare class PageViews extends FTRPC {
|
|
165
|
+
/**
|
|
166
|
+
* Tracks a page view event.
|
|
167
|
+
*
|
|
168
|
+
* @param config - Page view configuration
|
|
169
|
+
* @returns Promise resolving to the API response
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* await pageViews.track({
|
|
174
|
+
* url: window.location.href,
|
|
175
|
+
* path: window.location.pathname,
|
|
176
|
+
* title: document.title
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
track(config: PageViewConfig): Promise<PageViewResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Tracks scroll depth on a page.
|
|
183
|
+
*
|
|
184
|
+
* @param config - Scroll depth configuration
|
|
185
|
+
* @returns Promise resolving to the API response
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Track when user scrolls to 50%
|
|
190
|
+
* await pageViews.trackScrollDepth({
|
|
191
|
+
* path: '/article/how-to-guide',
|
|
192
|
+
* scrollDepth: 50
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
trackScrollDepth(config: ScrollDepthConfig): Promise<PageViewResponse>;
|
|
197
|
+
/**
|
|
198
|
+
* Tracks time spent on a page.
|
|
199
|
+
*
|
|
200
|
+
* @param config - Time on page configuration
|
|
201
|
+
* @returns Promise resolving to the API response
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* // Track on page unload
|
|
206
|
+
* window.addEventListener('beforeunload', () => {
|
|
207
|
+
* pageViews.trackTimeOnPage({
|
|
208
|
+
* path: '/pricing',
|
|
209
|
+
* duration: 45,
|
|
210
|
+
* engaged: true
|
|
211
|
+
* });
|
|
212
|
+
* });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
trackTimeOnPage(config: TimeOnPageConfig): Promise<PageViewResponse>;
|
|
216
|
+
/**
|
|
217
|
+
* Tracks a page exit event.
|
|
218
|
+
*
|
|
219
|
+
* @param path - Page path being exited
|
|
220
|
+
* @param duration - Time spent on page
|
|
221
|
+
* @param scrollDepth - Final scroll depth
|
|
222
|
+
* @returns Promise resolving to the API response
|
|
223
|
+
*/
|
|
224
|
+
trackExit(path: string, duration: number, scrollDepth: number): Promise<PageViewResponse>;
|
|
225
|
+
/**
|
|
226
|
+
* Retrieves page analytics data for dashboards and charts.
|
|
227
|
+
*
|
|
228
|
+
* @param filter - Date range filter
|
|
229
|
+
* @param pagination - Pagination options
|
|
230
|
+
* @returns Promise resolving to analytics data
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const analytics = await pageViews.getAnalytics({
|
|
235
|
+
* range: 'last7days'
|
|
236
|
+
* });
|
|
237
|
+
*
|
|
238
|
+
* // Use for line chart
|
|
239
|
+
* const lineData = analytics.timeSeries.data;
|
|
240
|
+
*
|
|
241
|
+
* // Use for bar chart
|
|
242
|
+
* const barData = analytics.topPages.map(p => ({
|
|
243
|
+
* label: p.path,
|
|
244
|
+
* value: p.views
|
|
245
|
+
* }));
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
getAnalytics(filter?: DateRangeFilter, pagination?: PaginationParams): Promise<PageAnalyticsData>;
|
|
249
|
+
}
|
|
250
|
+
export default PageViews;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - Performance Monitoring
|
|
3
|
+
* @module features/analytics/performance
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track web performance metrics including Core Web Vitals,
|
|
7
|
+
* page load times, and resource performance.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Monitor Core Web Vitals (LCP, FID, CLS)
|
|
11
|
+
* - Track page load performance
|
|
12
|
+
* - Identify slow pages and resources
|
|
13
|
+
* - Correlate performance with conversions
|
|
14
|
+
* - Monitor API response times
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Largest Contentful Paint (LCP)
|
|
18
|
+
* - First Input Delay (FID)
|
|
19
|
+
* - Cumulative Layout Shift (CLS)
|
|
20
|
+
* - Time to First Byte (TTFB)
|
|
21
|
+
* - First Contentful Paint (FCP)
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Line chart: Core Web Vitals over time
|
|
25
|
+
* - Bar chart: Slowest pages
|
|
26
|
+
* - Histogram: Load time distribution
|
|
27
|
+
* - Gauge: Performance score
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const performance = new Performance(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Track Core Web Vitals
|
|
34
|
+
* await performance.trackWebVitals({
|
|
35
|
+
* lcp: 2500,
|
|
36
|
+
* fid: 100,
|
|
37
|
+
* cls: 0.1,
|
|
38
|
+
* pageUrl: '/products'
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
43
|
+
import { DateRangeFilter, TimeSeriesData } from "../../types";
|
|
44
|
+
/**
|
|
45
|
+
* Core Web Vitals data.
|
|
46
|
+
*/
|
|
47
|
+
export interface WebVitalsData {
|
|
48
|
+
/** Largest Contentful Paint (ms) */
|
|
49
|
+
lcp?: number;
|
|
50
|
+
/** First Input Delay (ms) */
|
|
51
|
+
fid?: number;
|
|
52
|
+
/** Cumulative Layout Shift (score) */
|
|
53
|
+
cls?: number;
|
|
54
|
+
/** First Contentful Paint (ms) */
|
|
55
|
+
fcp?: number;
|
|
56
|
+
/** Time to First Byte (ms) */
|
|
57
|
+
ttfb?: number;
|
|
58
|
+
/** Interaction to Next Paint (ms) */
|
|
59
|
+
inp?: number;
|
|
60
|
+
/** Page URL */
|
|
61
|
+
pageUrl: string;
|
|
62
|
+
/** User ID */
|
|
63
|
+
userId?: string;
|
|
64
|
+
/** Connection type */
|
|
65
|
+
connectionType?: 'slow-2g' | '2g' | '3g' | '4g' | 'wifi' | 'unknown';
|
|
66
|
+
/** Device type */
|
|
67
|
+
deviceType?: 'mobile' | 'tablet' | 'desktop';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Page load timing data.
|
|
71
|
+
*/
|
|
72
|
+
export interface PageLoadData {
|
|
73
|
+
/** Page URL */
|
|
74
|
+
pageUrl: string;
|
|
75
|
+
/** DNS lookup time (ms) */
|
|
76
|
+
dnsTime?: number;
|
|
77
|
+
/** TCP connection time (ms) */
|
|
78
|
+
tcpTime?: number;
|
|
79
|
+
/** Time to first byte (ms) */
|
|
80
|
+
ttfb?: number;
|
|
81
|
+
/** DOM content loaded time (ms) */
|
|
82
|
+
domContentLoaded?: number;
|
|
83
|
+
/** Full page load time (ms) */
|
|
84
|
+
loadTime?: number;
|
|
85
|
+
/** DOM interactive time (ms) */
|
|
86
|
+
domInteractive?: number;
|
|
87
|
+
/** Number of resources */
|
|
88
|
+
resourceCount?: number;
|
|
89
|
+
/** Total transfer size (bytes) */
|
|
90
|
+
transferSize?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resource timing data.
|
|
94
|
+
*/
|
|
95
|
+
export interface ResourceData {
|
|
96
|
+
/** Resource URL */
|
|
97
|
+
resourceUrl: string;
|
|
98
|
+
/** Resource type */
|
|
99
|
+
resourceType: 'script' | 'stylesheet' | 'image' | 'font' | 'fetch' | 'xhr' | 'other';
|
|
100
|
+
/** Duration (ms) */
|
|
101
|
+
duration: number;
|
|
102
|
+
/** Transfer size (bytes) */
|
|
103
|
+
transferSize?: number;
|
|
104
|
+
/** Page URL where resource was loaded */
|
|
105
|
+
pageUrl: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Performance response from API.
|
|
109
|
+
*/
|
|
110
|
+
export interface PerformanceResponse {
|
|
111
|
+
eventName: string;
|
|
112
|
+
properties: Record<string, unknown>;
|
|
113
|
+
response: {
|
|
114
|
+
recorded: boolean;
|
|
115
|
+
performanceScore?: number;
|
|
116
|
+
};
|
|
117
|
+
timestamp: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Performance analytics data.
|
|
121
|
+
*/
|
|
122
|
+
export interface PerformanceAnalyticsData {
|
|
123
|
+
/** Core Web Vitals summary */
|
|
124
|
+
webVitals: {
|
|
125
|
+
lcp: {
|
|
126
|
+
p50: number;
|
|
127
|
+
p75: number;
|
|
128
|
+
p95: number;
|
|
129
|
+
good: number;
|
|
130
|
+
needsImprovement: number;
|
|
131
|
+
poor: number;
|
|
132
|
+
};
|
|
133
|
+
fid: {
|
|
134
|
+
p50: number;
|
|
135
|
+
p75: number;
|
|
136
|
+
p95: number;
|
|
137
|
+
good: number;
|
|
138
|
+
needsImprovement: number;
|
|
139
|
+
poor: number;
|
|
140
|
+
};
|
|
141
|
+
cls: {
|
|
142
|
+
p50: number;
|
|
143
|
+
p75: number;
|
|
144
|
+
p95: number;
|
|
145
|
+
good: number;
|
|
146
|
+
needsImprovement: number;
|
|
147
|
+
poor: number;
|
|
148
|
+
};
|
|
149
|
+
inp: {
|
|
150
|
+
p50: number;
|
|
151
|
+
p75: number;
|
|
152
|
+
p95: number;
|
|
153
|
+
good: number;
|
|
154
|
+
needsImprovement: number;
|
|
155
|
+
poor: number;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/** Performance by page */
|
|
159
|
+
byPage: Array<{
|
|
160
|
+
pageUrl: string;
|
|
161
|
+
avgLoadTime: number;
|
|
162
|
+
avgLCP: number;
|
|
163
|
+
avgFID: number;
|
|
164
|
+
avgCLS: number;
|
|
165
|
+
sampleSize: number;
|
|
166
|
+
}>;
|
|
167
|
+
/** Performance by device */
|
|
168
|
+
byDevice: Array<{
|
|
169
|
+
device: string;
|
|
170
|
+
avgLoadTime: number;
|
|
171
|
+
avgLCP: number;
|
|
172
|
+
sampleSize: number;
|
|
173
|
+
}>;
|
|
174
|
+
/** Slowest resources */
|
|
175
|
+
slowResources: Array<{
|
|
176
|
+
resourceUrl: string;
|
|
177
|
+
resourceType: string;
|
|
178
|
+
avgDuration: number;
|
|
179
|
+
occurrences: number;
|
|
180
|
+
}>;
|
|
181
|
+
/** Performance trends */
|
|
182
|
+
trends: {
|
|
183
|
+
lcp: TimeSeriesData;
|
|
184
|
+
fid: TimeSeriesData;
|
|
185
|
+
cls: TimeSeriesData;
|
|
186
|
+
};
|
|
187
|
+
/** Overall score (0-100) */
|
|
188
|
+
performanceScore: number;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Performance - Track web performance metrics.
|
|
192
|
+
*
|
|
193
|
+
* @extends FTRPC
|
|
194
|
+
*
|
|
195
|
+
* @description
|
|
196
|
+
* Provides performance monitoring including:
|
|
197
|
+
* - Core Web Vitals tracking
|
|
198
|
+
* - Page load timing
|
|
199
|
+
* - Resource performance
|
|
200
|
+
* - API response times
|
|
201
|
+
* - Performance scoring
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const performance = new Performance(webId, endpoint, apiKey);
|
|
206
|
+
*
|
|
207
|
+
* // Track Web Vitals (use web-vitals library)
|
|
208
|
+
* import { onLCP, onFID, onCLS } from 'web-vitals';
|
|
209
|
+
*
|
|
210
|
+
* onLCP((metric) => {
|
|
211
|
+
* performance.trackWebVitals({
|
|
212
|
+
* lcp: metric.value,
|
|
213
|
+
* pageUrl: window.location.pathname
|
|
214
|
+
* });
|
|
215
|
+
* });
|
|
216
|
+
*
|
|
217
|
+
* // Get performance report
|
|
218
|
+
* const report = await performance.getAnalytics({ range: 'last7days' });
|
|
219
|
+
* console.log(`Performance Score: ${report.performanceScore}`);
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export declare class PerformanceTracking extends FTRPC {
|
|
223
|
+
/**
|
|
224
|
+
* Tracks Core Web Vitals.
|
|
225
|
+
*
|
|
226
|
+
* @param data - Web Vitals data
|
|
227
|
+
* @returns Promise resolving to performance response
|
|
228
|
+
*/
|
|
229
|
+
trackWebVitals(data: WebVitalsData): Promise<PerformanceResponse>;
|
|
230
|
+
/**
|
|
231
|
+
* Tracks page load timing.
|
|
232
|
+
*
|
|
233
|
+
* @param data - Page load data
|
|
234
|
+
* @returns Promise resolving to performance response
|
|
235
|
+
*/
|
|
236
|
+
trackPageLoad(data: PageLoadData): Promise<PerformanceResponse>;
|
|
237
|
+
/**
|
|
238
|
+
* Tracks resource performance.
|
|
239
|
+
*
|
|
240
|
+
* @param data - Resource data
|
|
241
|
+
* @returns Promise resolving to performance response
|
|
242
|
+
*/
|
|
243
|
+
trackResource(data: ResourceData): Promise<PerformanceResponse>;
|
|
244
|
+
/**
|
|
245
|
+
* Tracks API call performance.
|
|
246
|
+
*
|
|
247
|
+
* @param endpoint - API endpoint
|
|
248
|
+
* @param duration - Response time (ms)
|
|
249
|
+
* @param success - Whether call succeeded
|
|
250
|
+
* @param statusCode - HTTP status code
|
|
251
|
+
* @returns Promise resolving to performance response
|
|
252
|
+
*/
|
|
253
|
+
trackApiCall(endpoint: string, duration: number, success: boolean, statusCode?: number): Promise<PerformanceResponse>;
|
|
254
|
+
/**
|
|
255
|
+
* Gets performance analytics for dashboards.
|
|
256
|
+
*
|
|
257
|
+
* @param filter - Date range filter
|
|
258
|
+
* @returns Promise resolving to performance analytics
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const analytics = await performance.getAnalytics({
|
|
263
|
+
* range: 'last7days'
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* // Gauge - performance score
|
|
267
|
+
* const score = analytics.performanceScore;
|
|
268
|
+
*
|
|
269
|
+
* // Line chart - LCP trend
|
|
270
|
+
* const lcpTrend = analytics.trends.lcp.data;
|
|
271
|
+
*
|
|
272
|
+
* // Table - slowest pages
|
|
273
|
+
* const slowPages = analytics.byPage.sort((a, b) =>
|
|
274
|
+
* b.avgLoadTime - a.avgLoadTime
|
|
275
|
+
* );
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
getAnalytics(filter?: DateRangeFilter): Promise<PerformanceAnalyticsData>;
|
|
279
|
+
}
|
|
280
|
+
export { PerformanceTracking as Performance };
|
|
281
|
+
export default PerformanceTracking;
|