[PULSE-58] Data retention settings in Site Settings #33

Merged
uz1mani merged 6 commits from staging into main 2026-02-21 19:03:25 +00:00
6 changed files with 149 additions and 5 deletions
Showing only changes of commit d1d82f5b3c - Show all commits

View File

@@ -109,7 +109,7 @@ export default function SiteSettingsPage() {
}
}
// * Clamp data_retention_months when subscription loads: if current value exceeds plan max, sync to max
// * Snap data_retention_months to nearest valid option when subscription loads
useEffect(() => {
if (!subscription) return
const opts = getRetentionOptionsForPlan(subscription.plan_id)
@@ -117,7 +117,8 @@ export default function SiteSettingsPage() {
const maxVal = Math.max(...values)
setFormData(prev => {
if (values.includes(prev.data_retention_months)) return prev
return { ...prev, data_retention_months: Math.min(prev.data_retention_months, maxVal) }
const bestFit = values.filter(v => v <= prev.data_retention_months).pop() ?? maxVal
return { ...prev, data_retention_months: Math.min(bestFit, maxVal) }
})
}, [subscription])

View File

@@ -23,7 +23,7 @@ export function generatePrivacySnippet(site: Site): string {
const screen = site.collect_screen_resolution ?? true
greptile-apps[bot] commented 2026-02-21 18:58:09 +00:00 (Migrated from github.com)
Review

Mismatched default retention value

The fallback here is ?? 12 (12 months), but the settings page (page.tsx:146) defaults to ?? 6 (6 months). For existing sites that haven't saved a data_retention_months value yet, the privacy snippet will claim "Raw event data is automatically deleted after 1 year" while the settings page displays and saves "6 months."

These should use the same default to avoid misleading the user's privacy policy text.

  const retentionMonths = site.data_retention_months ?? 6
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/utils/privacySnippet.ts
Line: 26

Comment:
**Mismatched default retention value**

The fallback here is `?? 12` (12 months), but the settings page (`page.tsx:146`) defaults to `?? 6` (6 months). For existing sites that haven't saved a `data_retention_months` value yet, the privacy snippet will claim "Raw event data is automatically deleted after 1 year" while the settings page displays and saves "6 months."

These should use the same default to avoid misleading the user's privacy policy text.

```suggestion
  const retentionMonths = site.data_retention_months ?? 6
```

How can I resolve this? If you propose a fix, please make it concise.
**Mismatched default retention value** The fallback here is `?? 12` (12 months), but the settings page (`page.tsx:146`) defaults to `?? 6` (6 months). For existing sites that haven't saved a `data_retention_months` value yet, the privacy snippet will claim "Raw event data is automatically deleted after 1 year" while the settings page displays and saves "6 months." These should use the same default to avoid misleading the user's privacy policy text. ```suggestion const retentionMonths = site.data_retention_months ?? 6 ``` <details><summary>Prompt To Fix With AI</summary> `````markdown This is a comment left during a code review. Path: lib/utils/privacySnippet.ts Line: 26 Comment: **Mismatched default retention value** The fallback here is `?? 12` (12 months), but the settings page (`page.tsx:146`) defaults to `?? 6` (6 months). For existing sites that haven't saved a `data_retention_months` value yet, the privacy snippet will claim "Raw event data is automatically deleted after 1 year" while the settings page displays and saves "6 months." These should use the same default to avoid misleading the user's privacy policy text. ```suggestion const retentionMonths = site.data_retention_months ?? 6 ``` How can I resolve this? If you propose a fix, please make it concise. ````` </details>
uz1mani commented 2026-02-21 18:59:05 +00:00 (Migrated from github.com)
Review

Issue: The privacy snippet defaulted to 12 months while the settings page defaults to 6, so unsaved sites could show "1 year" in the snippet but "6 months" in the UI.
Fix: Use ?? 6 to match the settings page default.
Why: Keeps defaults aligned so the generated privacy text matches what the user sees in settings.

Issue: The privacy snippet defaulted to 12 months while the settings page defaults to 6, so unsaved sites could show "1 year" in the snippet but "6 months" in the UI. Fix: Use `?? 6` to match the settings page default. Why: Keeps defaults aligned so the generated privacy text matches what the user sees in settings.
const perf = site.enable_performance_insights ?? false
const filterBots = site.filter_bots ?? true
const retentionMonths = site.data_retention_months ?? 12
const retentionMonths = site.data_retention_months ?? 6
const parts: string[] = []
if (paths) parts.push('which pages are viewed')