diff --git a/app/share/[id]/page.tsx b/app/share/[id]/page.tsx
index 38666ad..952a36a 100644
--- a/app/share/[id]/page.tsx
+++ b/app/share/[id]/page.tsx
@@ -271,8 +271,8 @@ export default function PublicDashboardPage() {
/>
- {/* Performance Stats */}
- {performance && (
+ {/* Performance Stats - Only show if enabled */}
+ {performance && data.site?.enable_performance_insights && (
diff --git a/app/sites/[id]/page.tsx b/app/sites/[id]/page.tsx
index a0a8cd1..53108dd 100644
--- a/app/sites/[id]/page.tsx
+++ b/app/sites/[id]/page.tsx
@@ -228,10 +228,12 @@ export default function SiteDashboardPage() {
/>
- {/* Performance Stats */}
-
+ {/* Performance Stats - Only show if enabled */}
+ {site.enable_performance_insights && (
+
+ )}
+ {/* Performance Insights Toggle */}
+
+
Performance Insights
+
+
+
+
Performance Insights (Add-on)
+
+ Track Core Web Vitals (LCP, CLS, INP) to monitor site performance
+
+
+
+
+
+
+
{/* Excluded Paths */}
Path Filtering
diff --git a/lib/api/sites.ts b/lib/api/sites.ts
index a127695..1893027 100644
--- a/lib/api/sites.ts
+++ b/lib/api/sites.ts
@@ -18,6 +18,8 @@ export interface Site {
collect_device_info?: boolean
collect_geo_data?: GeoDataLevel
collect_screen_resolution?: boolean
+ // Performance insights setting
+ enable_performance_insights?: boolean
// Session replay settings
replay_mode?: ReplayMode
replay_sampling_rate?: number
@@ -46,6 +48,8 @@ export interface UpdateSiteRequest {
collect_device_info?: boolean
collect_geo_data?: GeoDataLevel
collect_screen_resolution?: boolean
+ // Performance insights setting
+ enable_performance_insights?: boolean
// Session replay settings
replay_mode?: ReplayMode
replay_sampling_rate?: number
diff --git a/public/script.js b/public/script.js
index f346bbd..e885f1a 100644
--- a/public/script.js
+++ b/public/script.js
@@ -24,6 +24,7 @@
// * Performance Monitoring (Core Web Vitals) State
let currentEventId = null;
let metrics = { lcp: 0, cls: 0, inp: 0 };
+ let performanceInsightsEnabled = false;
// * Session Replay State
let replayEnabled = false;
@@ -74,7 +75,8 @@
}
function sendMetrics() {
- if (!currentEventId || (metrics.lcp === 0 && metrics.cls === 0 && metrics.inp === 0)) return;
+ // * Only send metrics if performance insights are enabled
+ if (!performanceInsightsEnabled || !currentEventId || (metrics.lcp === 0 && metrics.cls === 0 && metrics.inp === 0)) return;
// * Use sendBeacon if available for reliability on unload
const data = JSON.stringify({
@@ -96,7 +98,8 @@
}
}
- // * Start observing immediately
+ // * Start observing metrics immediately (buffered observers will capture early metrics)
+ // * Metrics will only be sent if performance insights are enabled (checked in sendMetrics)
observeMetrics();
// * Send metrics when user leaves or hides the page
@@ -214,6 +217,9 @@
if (res.ok) {
replaySettings = await res.json();
replayMode = replaySettings.replay_mode;
+
+ // * Set performance insights enabled flag
+ performanceInsightsEnabled = replaySettings.enable_performance_insights === true;
// Check sampling rate
if (replayMode !== 'disabled') {