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.

feat(llma): widen AI observability onboarding lookback window (#63092)

Radu Raicea864068e4f831
diff --git a/frontend/src/lib/utils/aiEventsUtils.test.ts b/frontend/src/lib/utils/aiEventsUtils.test.ts
index 5681f323c834..ba7e2528e1a6 100644
--- a/frontend/src/lib/utils/aiEventsUtils.test.ts
+++ b/frontend/src/lib/utils/aiEventsUtils.test.ts
@@ -69,7 +69,7 @@ describe('aiEventsUtils', () => {
})
it('falls back to ClickHouse when EventDefinition is stale', async () => {
- const staleDate = dayjs().subtract(60, 'day').toISOString()
+ const staleDate = dayjs().subtract(120, 'day').toISOString()
useMocks({
get: {
diff --git a/frontend/src/lib/utils/aiEventsUtils.ts b/frontend/src/lib/utils/aiEventsUtils.ts
index 8af7c8245d5b..981944fc999a 100644
--- a/frontend/src/lib/utils/aiEventsUtils.ts
+++ b/frontend/src/lib/utils/aiEventsUtils.ts
@@ -8,6 +8,12 @@ import { isDefinitionStale } from './definitions'
export const AI_EVENT_NAMES = ['$ai_generation', '$ai_trace', '$ai_span', '$ai_embedding']
+// Use a longer staleness window than the global default so orgs that ingested AI events
+// in the past, paused, and have since resumed still land on the dashboard rather than the
+// onboarding screen.
+const AI_STALE_EVENT_DAYS = 90
+const AI_STALE_EVENT_SECONDS = AI_STALE_EVENT_DAYS * 24 * 60 * 60
+
/**
* Checks if the team has sent any AI events.
*
@@ -23,7 +29,7 @@ export async function hasRecentAIEvents(): Promise<boolean> {
})
const validDefinition = aiEventDefinitions.results.find(
- (r) => AI_EVENT_NAMES.includes(r.name) && !isDefinitionStale(r)
+ (r) => AI_EVENT_NAMES.includes(r.name) && !isDefinitionStale(r, AI_STALE_EVENT_SECONDS)
)
if (validDefinition) {
@@ -34,7 +40,7 @@ export async function hasRecentAIEvents(): Promise<boolean> {
const response = await api.query<HogQLQuery>(
{
kind: NodeKind.HogQLQuery,
- query: hogql`SELECT 1 FROM events WHERE event IN ${[...AI_EVENT_NAMES]} AND timestamp > now() - INTERVAL 3 HOUR LIMIT 1`,
+ query: hogql`SELECT 1 FROM events WHERE event IN ${[...AI_EVENT_NAMES]} AND timestamp > now() - INTERVAL 12 HOUR LIMIT 1`,
tags: { productKey: ProductKey.AI_OBSERVABILITY },
},
{ refresh: 'force_blocking' }
diff --git a/frontend/src/lib/utils/definitions.ts b/frontend/src/lib/utils/definitions.ts
index de141e6afb88..57719ef87a12 100644
--- a/frontend/src/lib/utils/definitions.ts
+++ b/frontend/src/lib/utils/definitions.ts
@@ -3,7 +3,10 @@ import { dayjs } from 'lib/dayjs'
import { EventDefinition, PropertyDefinition } from '~/types'
-export const isDefinitionStale = (definition?: EventDefinition | PropertyDefinition): boolean => {
+export const isDefinitionStale = (
+ definition?: EventDefinition | PropertyDefinition,
+ staleSeconds: number = STALE_EVENT_SECONDS
+): boolean => {
const parsedLastSeen = definition?.last_seen_at ? dayjs(definition.last_seen_at) : null
- return !!parsedLastSeen && dayjs().diff(parsedLastSeen, 'seconds') > STALE_EVENT_SECONDS
+ return !!parsedLastSeen && dayjs().diff(parsedLastSeen, 'seconds') > staleSeconds
}