Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(web-analytics): Stamp last web analytics vist time on person properties (#57724)

Jordan Mryyan0e1079b20c9b
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
index e56fb6e332e0..c824c495d850 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
@@ -2479,6 +2479,15 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
return
}
+ // Stamp the last-used timestamp for feature flag targeting (throttled to once per day per browser).
+ const stampKey = `ph_last_web_analytics_stamp_${posthog.get_distinct_id()}`
+ const oneDayMs = 24 * 60 * 60 * 1000
+ const lastStamp = Number(localStorage.getItem(stampKey) || 0)
+ if (Date.now() - lastStamp > oneDayMs) {
+ posthog.setPersonProperties({ last_used_web_analytics_at: new Date().toISOString() })
+ localStorage.setItem(stampKey, Date.now().toString())
+ }
+
const parsedFilters = filters ? (isWebAnalyticsPropertyFilters(filters) ? filters : []) : undefined
if (parsedFilters) {
if (productTab === ProductTab.BOT_ANALYTICS) {