: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore: Migrate Web Analytics Health to the health issues api (#61704)
Jordan Mryyanb00792e9195a
diff --git a/frontend/src/scenes/health/healthSceneLogic.tsx b/frontend/src/scenes/health/healthSceneLogic.tsxindex 2fd762aa4224..cae2d55b91dc 100644--- a/frontend/src/scenes/health/healthSceneLogic.tsx+++ b/frontend/src/scenes/health/healthSceneLogic.tsx@@ -16,7 +16,7 @@ import { Breadcrumb } from '~/types'import { CATEGORY_ORDER, HEALTH_CATEGORY_CONFIG, categoryForKind } from './healthCategories'import type { healthSceneLogicType } from './healthSceneLogicType'import type { CategoryHealthSummary, HealthIssue, HealthIssueSeverity } from './types'-import { SEVERITY_ORDER } from './types'+import { REFRESH_COOLDOWN_MS, REFRESH_POLL_COUNT, REFRESH_POLL_INTERVAL_MS, SEVERITY_ORDER } from './types'export interface HealthIssuesResponse {results: HealthIssue[]@@ -25,10 +25,6 @@ export interface HealthIssuesResponse {previous?: string | null}-const REFRESH_COOLDOWN_MS = 15 * 60 * 1000-const REFRESH_POLL_INTERVAL_MS = 5000-const REFRESH_POLL_COUNT = 12-export const healthSceneLogic = kea<healthSceneLogicType>([path(['scenes', 'health', 'healthSceneLogic']),tabAwareScene(),@@ -39,7 +35,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([setShowDismissed: (show: boolean) => ({ show }),dismissIssue: (id: string) => ({ id }),undismissIssue: (id: string) => ({ id }),- refreshHealthData: true,+ refreshHealthData: (isManual: boolean = true) => ({ isManual }),resetManualRefresh: true,setNextRefreshAvailableAt: (timestamp: number | null) => ({ timestamp }),clearRefreshInFlight: true,@@ -54,7 +50,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([isManualRefresh: [false,{- refreshHealthData: () => true,+ refreshHealthData: (_, { isManual }) => isManual,resetManualRefresh: () => false,},],@@ -68,7 +64,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([isRefreshInFlight: [false,{- refreshHealthData: () => true,+ refreshHealthData: (state, { isManual }) => (isManual ? true : state),clearRefreshInFlight: () => false,},],@@ -153,7 +149,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([],}),listeners(({ actions, values }) => ({- refreshHealthData: async (_, breakpoint) => {+ refreshHealthData: async ({ isManual }, breakpoint) => {const url = `api/environments/${values.currentTeamIdStrict}/health_issues/refresh/`try {const response = await api.create<{@@ -168,11 +164,15 @@ export const healthSceneLogic = kea<healthSceneLogicType>([if ((response?.scheduled_kinds ?? []).length === 0) {actions.clearRefreshInFlight()actions.resetManualRefresh()- lemonToast.info('No health checks are registered for this project.')+ if (isManual) {+ lemonToast.info('No health checks are registered for this project.')+ }return}- lemonToast.success('Refreshing health checks...', { autoClose: 2000 })+ if (isManual) {+ lemonToast.success('Refreshing health checks...', { autoClose: 2000 })+ }for (let i = 0; i < REFRESH_POLL_COUNT; i++) {await breakpoint(REFRESH_POLL_INTERVAL_MS)@@ -187,8 +187,10 @@ export const healthSceneLogic = kea<healthSceneLogicType>([if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {actions.setNextRefreshAvailableAt(Date.now() + retryAfterSeconds * 1000)}- lemonToast.warning(`Refresh available again ${error.formattedRetryAfter ?? 'in a few minutes'}`)- } else {+ if (isManual) {+ lemonToast.warning(`Refresh available again ${error.formattedRetryAfter ?? 'in a few minutes'}`)+ }+ } else if (isManual) {lemonToast.error('Failed to refresh health checks')}}@@ -240,6 +242,11 @@ export const healthSceneLogic = kea<healthSceneLogicType>([afterMount(({ actions, values }) => {if (values.unifiedHealthPageEnabled) {actions.loadHealthIssues()++ const { nextRefreshAvailableAt } = values+ if (nextRefreshAvailableAt === null || nextRefreshAvailableAt <= Date.now()) {+ actions.refreshHealthData(false)+ }}if (values.nextRefreshAvailableAt !== null) {diff --git a/frontend/src/scenes/health/types.ts b/frontend/src/scenes/health/types.tsindex 79b64d63cf39..84c2b52d3963 100644--- a/frontend/src/scenes/health/types.ts+++ b/frontend/src/scenes/health/types.ts@@ -2,6 +2,10 @@ export type HealthIssueSeverity = 'critical' | 'warning' | 'info'export type HealthIssueStatus = 'active' | 'resolved'export const SEVERITY_ORDER: HealthIssueSeverity[] = ['critical', 'warning', 'info']+export const REFRESH_COOLDOWN_MS = 5 * 60 * 1000+export const REFRESH_POLL_INTERVAL_MS = 5000+export const REFRESH_POLL_COUNT = 12+export interface HealthIssue {id: stringkind: stringdiff --git a/frontend/src/scenes/web-analytics/health/HealthStatusTab.tsx b/frontend/src/scenes/web-analytics/health/HealthStatusTab.tsxindex fe51e16de267..953743023b90 100644--- a/frontend/src/scenes/web-analytics/health/HealthStatusTab.tsx+++ b/frontend/src/scenes/web-analytics/health/HealthStatusTab.tsx@@ -8,8 +8,7 @@ import { HealthCheck } from './healthCheckTypes'import { webAnalyticsHealthLogic } from './webAnalyticsHealthLogic'export function HealthStatusTab(): JSX.Element {- const { overallHealthStatus, checksByCategory, webAnalyticsHealthStatusLoading } =- useValues(webAnalyticsHealthLogic)+ const { overallHealthStatus, checksByCategory, healthIssuesLoading } = useValues(webAnalyticsHealthLogic)const { refreshHealthChecks, trackSectionToggled } = useActions(webAnalyticsHealthLogic)return (@@ -20,7 +19,7 @@ export function HealthStatusTab(): JSX.Element {passedCount={overallHealthStatus.passedCount}totalCount={overallHealthStatus.totalCount}onRefresh={refreshHealthChecks}- loading={webAnalyticsHealthStatusLoading}+ loading={healthIssuesLoading}/><div className="space-y-3">@@ -86,7 +85,13 @@ function OverallHealthBanner({{passedCount} of {totalCount} checks passed</div></div>- <LemonButton type="secondary" size="small" icon={<IconRefresh />} onClick={onRefresh} loading={loading}>+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconRefresh />}+ onClick={() => onRefresh()}+ loading={loading}+ >Refresh</LemonButton></div>diff --git a/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts b/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.tsindex a5e103d63686..608c0d929e38 100644--- a/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts+++ b/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts@@ -1,14 +1,20 @@-import { actions, afterMount, connect, kea, listeners, path, selectors } from 'kea'+import { actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'-import api from 'lib/api'-import { reverseProxyCheckerLogic } from 'lib/components/ReverseProxyChecker/reverseProxyCheckerLogic'-import { isDefinitionStale } from 'lib/utils/definitions'+import api, { ApiError } from 'lib/api'+import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { eventUsageLogic } from 'lib/utils/eventUsageLogic'+import type { HealthIssuesResponse } from 'scenes/health/healthSceneLogic'+import {+ REFRESH_COOLDOWN_MS,+ REFRESH_POLL_COUNT,+ REFRESH_POLL_INTERVAL_MS,+ type HealthIssue,+} from 'scenes/health/types'import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'-import { EventDefinitionType, TeamType } from '~/types'+import { TeamType } from '~/types'import {HealthCheck,@@ -26,16 +32,30 @@ export interface WebAnalyticsHealthStatus {isSendingPageLeavesScroll: boolean}+const KIND_FOR_CHECK: Record<HealthCheckId, string> = {+ [HealthCheckId.PAGEVIEW_EVENTS]: 'no_live_events',+ [HealthCheckId.PAGELEAVE_EVENTS]: 'no_pageleave_events',+ [HealthCheckId.SCROLL_DEPTH]: 'scroll_depth',+ [HealthCheckId.AUTHORIZED_URLS]: 'authorized_urls',+ [HealthCheckId.REVERSE_PROXY]: 'reverse_proxy',+ [HealthCheckId.WEB_VITALS]: 'web_vitals',+}++function severityToStatus(severity: HealthIssue['severity']): HealthCheckStatus {+ return severity === 'critical' ? 'error' : 'warning'+}++function statusForCheck(checkId: HealthCheckId, issuesByKind: Record<string, HealthIssue>): HealthCheckStatus {+ const issue = issuesByKind[KIND_FOR_CHECK[checkId]]+ return issue ? severityToStatus(issue.severity) : 'success'+}+export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([path(['scenes', 'web-analytics', 'health', 'webAnalyticsHealthLogic']),connect(() => ({- values: [teamLogic, ['currentTeam'], reverseProxyCheckerLogic, ['hasReverseProxy', 'hasReverseProxyLoading']],+ values: [teamLogic, ['currentTeam', 'currentTeamIdStrict']],actions: [- teamLogic,- ['updateCurrentTeam'],- reverseProxyCheckerLogic,- ['loadHasReverseProxy'],eventUsageLogic,['reportWebAnalyticsHealthStatus',@@ -48,7 +68,7 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([})),actions({- refreshHealthChecks: true,+ refreshHealthChecks: (isManual: boolean = true) => ({ isManual }),trackTabViewed: true,trackSectionToggled: (category: HealthCheckCategory, isExpanded: boolean) => ({ category, isExpanded }),trackActionClicked: (@@ -62,68 +82,68 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([status,isUrgent,}),+ setNextRefreshAvailableAt: (timestamp: number | null) => ({ timestamp }),}),- loaders(({}) => ({- webAnalyticsHealthStatus: {- __default: null as WebAnalyticsHealthStatus | null,- loadWebAnalyticsHealthStatus: async (): Promise<WebAnalyticsHealthStatus> => {- const [webVitalsResult, pageviewResult, pageleaveResult, pageleaveScroll] = await Promise.allSettled([- api.eventDefinitions.list({- event_type: EventDefinitionType.Event,- search: '$web_vitals',- }),- api.eventDefinitions.list({- event_type: EventDefinitionType.Event,- search: '$pageview',- }),- api.eventDefinitions.list({- event_type: EventDefinitionType.Event,- search: '$pageleave',- }),- api.propertyDefinitions.list({- event_names: ['$pageleave'],- properties: ['$prev_pageview_max_content_percentage'],- }),- ])-- // no need to worry about pagination here, event names beginning with $ are reserved, and we're not- // going to add enough reserved event names that match this search term to cause problems- const webVitalsEntry =- webVitalsResult.status === 'fulfilled'- ? webVitalsResult.value.results.find((r) => r.name === '$web_vitals')- : undefined-- const pageviewEntry =- pageviewResult.status === 'fulfilled'- ? pageviewResult.value.results.find((r) => r.name === '$pageview')- : undefined-- const pageleaveEntry =- pageleaveResult.status === 'fulfilled'- ? pageleaveResult.value.results.find((r) => r.name === '$pageleave')- : undefined-- const pageleaveScrollEntry =- pageleaveScroll.status === 'fulfilled'- ? pageleaveScroll.value.results.find((r) => r.name === '$prev_pageview_max_content_percentage')- : undefined+ reducers({+ nextRefreshAvailableAt: [+ null as number | null,+ { persist: true },+ {+ setNextRefreshAvailableAt: (_, { timestamp }) => timestamp,+ },+ ],+ }),- return {- isSendingWebVitals: !!webVitalsEntry && !isDefinitionStale(webVitalsEntry),- isSendingPageViews: !!pageviewEntry && !isDefinitionStale(pageviewEntry),- isSendingPageLeaves: !!pageleaveEntry && !isDefinitionStale(pageleaveEntry),- isSendingPageLeavesScroll: !!pageleaveScrollEntry && !isDefinitionStale(pageleaveScrollEntry),- }+ loaders(({ values }) => ({+ healthIssues: {+ __default: null as HealthIssuesResponse | null,+ loadHealthIssues: async (): Promise<HealthIssuesResponse | null> => {+ const url = `api/projects/${values.currentTeamIdStrict}/health_issues/?status=active&dismissed=false`+ return await api.get(url)},},})),selectors({+ issuesByKind: [+ (s) => [s.healthIssues],+ (healthIssues: HealthIssuesResponse | null): Record<string, HealthIssue> => {+ const byKind: Record<string, HealthIssue> = {}+ for (const issue of healthIssues?.results ?? []) {+ byKind[issue.kind] ??= issue+ }+ return byKind+ },+ ],++ webAnalyticsHealthStatus: [+ (s) => [s.healthIssues, s.issuesByKind],+ (+ healthIssues: HealthIssuesResponse | null,+ issuesByKind: Record<string, HealthIssue>+ ): WebAnalyticsHealthStatus | null => {+ if (healthIssues === null) {+ return null+ }+ return {+ isSendingWebVitals: !issuesByKind.web_vitals,+ isSendingPageViews: !issuesByKind.no_live_events,+ isSendingPageLeaves: !issuesByKind.no_pageleave_events,+ isSendingPageLeavesScroll: !issuesByKind.scroll_depth,+ }+ },+ ],++ isInitialLoad: [+ (s) => [s.healthIssues, s.healthIssuesLoading],+ (healthIssues: HealthIssuesResponse | null, loading: boolean): boolean => loading && healthIssues === null,+ ],+eventChecks: [- (s) => [s.webAnalyticsHealthStatus, s.webAnalyticsHealthStatusLoading],- (webAnalyticsHealthStatus: WebAnalyticsHealthStatus | null, loading: boolean): HealthCheck[] => {- if (loading || !webAnalyticsHealthStatus) {+ (s) => [s.issuesByKind, s.isInitialLoad],+ (issuesByKind: Record<string, HealthIssue>, isInitialLoad: boolean): HealthCheck[] => {+ if (isInitialLoad) {return [createLoadingCheck(HealthCheckId.PAGEVIEW_EVENTS, 'events', 'PageView events'),createLoadingCheck(HealthCheckId.PAGELEAVE_EVENTS, 'events', 'PageLeave events'),@@ -131,16 +151,20 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([]}+ const pageviewOk = statusForCheck(HealthCheckId.PAGEVIEW_EVENTS, issuesByKind) === 'success'+ const pageleaveOk = statusForCheck(HealthCheckId.PAGELEAVE_EVENTS, issuesByKind) === 'success'+ const scrollOk = statusForCheck(HealthCheckId.SCROLL_DEPTH, issuesByKind) === 'success'+return [{id: HealthCheckId.PAGEVIEW_EVENTS,category: 'events',title: '$pageview',- description: webAnalyticsHealthStatus.isSendingPageViews+ description: pageviewOk? 'Events are flowing in as expected. Head over to the Web Analytics tab to start reviewing your analytics!': 'Complete the PostHog installation to start seeing events in your dashboard.',- status: webAnalyticsHealthStatus.isSendingPageViews ? 'success' : 'error',- action: webAnalyticsHealthStatus.isSendingPageViews+ status: statusForCheck(HealthCheckId.PAGEVIEW_EVENTS, issuesByKind),+ action: pageviewOk? undefined: {label: 'View installation guide',@@ -153,11 +177,11 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([id: HealthCheckId.PAGELEAVE_EVENTS,category: 'events',title: '$pageleave',- description: webAnalyticsHealthStatus.isSendingPageLeaves+ description: pageleaveOk? 'Bounce rate and session duration are accurate!': 'Without $pageleave events, bounce rate and session duration might be inaccurate.',- status: webAnalyticsHealthStatus.isSendingPageLeaves ? 'success' : 'warning',- action: webAnalyticsHealthStatus.isSendingPageLeaves+ status: statusForCheck(HealthCheckId.PAGELEAVE_EVENTS, issuesByKind),+ action: pageleaveOk? undefined: {label: 'View installation guide',@@ -169,11 +193,11 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([id: HealthCheckId.SCROLL_DEPTH,category: 'events',title: 'Scroll depth',- description: webAnalyticsHealthStatus.isSendingPageLeavesScroll+ description: scrollOk? 'Scroll tracking is enabled! Tracking how far users scroll on each page.': 'Enable scroll depth to see how far users read your content before leaving.',- status: webAnalyticsHealthStatus.isSendingPageLeavesScroll ? 'success' : 'warning',- action: webAnalyticsHealthStatus.isSendingPageLeavesScroll+ status: statusForCheck(HealthCheckId.SCROLL_DEPTH, issuesByKind),+ action: scrollOk? undefined: {label: 'View installation guide',@@ -186,14 +210,15 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([],configurationChecks: [- (s) => [s.currentTeam, s.hasReverseProxy, s.hasReverseProxyLoading, s.hasAuthorizedUrls],+ (s) => [s.currentTeam, s.issuesByKind, s.isInitialLoad, s.hasAuthorizedUrls],(currentTeam: TeamType | null,- hasReverseProxy: boolean | null,- hasReverseProxyLoading: boolean,+ issuesByKind: Record<string, HealthIssue>,+ isInitialLoad: boolean,hasAuthorizedUrls: boolean): HealthCheck[] => {- const reverseProxyCheck: HealthCheck = hasReverseProxyLoading+ const hasReverseProxy = statusForCheck(HealthCheckId.REVERSE_PROXY, issuesByKind) === 'success'+ const reverseProxyCheck: HealthCheck = isInitialLoad? createLoadingCheck(HealthCheckId.REVERSE_PROXY, 'configuration', 'Reverse proxy'): {id: HealthCheckId.REVERSE_PROXY,@@ -202,7 +227,7 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([description: hasReverseProxy? 'Reverse proxy is configured! Your tracking requests are routed through your own domain.': 'A reverse proxy routes PostHog requests through your own domain and helps prevent ad blockers from blocking tracking. Some metrics may not be accurate until this is configured.',- status: hasReverseProxy ? 'success' : 'warning',+ status: statusForCheck(HealthCheckId.REVERSE_PROXY, issuesByKind),action: hasReverseProxy? undefined: {@@ -213,35 +238,37 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([urgent: true,}- return [- {- id: HealthCheckId.AUTHORIZED_URLS,- category: 'configuration',- title: 'Authorized URLs',- description: hasAuthorizedUrls- ? `${currentTeam?.app_urls?.length} domain${(currentTeam?.app_urls?.length ?? 0) > 1 ? 's' : ''} configured. Your analytics are filtered to only include traffic from your domains.`- : "No authorized URLs configured. Some filters won't work correctly until you let us know what domains you are sending events from.",- status: hasAuthorizedUrls ? 'success' : 'warning',- action: hasAuthorizedUrls- ? { label: 'Manage domains', to: urls.settings('environment-web-analytics') }- : { label: 'Add domains', to: urls.settings('environment-web-analytics') },- },- reverseProxyCheck,- ]+ const authorizedUrlsCheck: HealthCheck = isInitialLoad+ ? createLoadingCheck(HealthCheckId.AUTHORIZED_URLS, 'configuration', 'Authorized URLs')+ : {+ id: HealthCheckId.AUTHORIZED_URLS,+ category: 'configuration',+ title: 'Authorized URLs',+ description: hasAuthorizedUrls+ ? `${currentTeam?.app_urls?.length} domain${(currentTeam?.app_urls?.length ?? 0) > 1 ? 's' : ''} configured. Your analytics are filtered to only include traffic from your domains.`+ : "No authorized URLs configured. Some filters won't work correctly until you let us know what domains you are sending events from.",+ status: statusForCheck(HealthCheckId.AUTHORIZED_URLS, issuesByKind),+ action: hasAuthorizedUrls+ ? { label: 'Manage domains', to: urls.settings('environment-web-analytics') }+ : { label: 'Add domains', to: urls.settings('environment-web-analytics') },+ }++ return [authorizedUrlsCheck, reverseProxyCheck]},],performanceChecks: [- (s) => [s.webAnalyticsHealthStatus, s.webAnalyticsHealthStatusLoading, s.currentTeam],+ (s) => [s.issuesByKind, s.isInitialLoad, s.currentTeam],(- webAnalyticsHealthStatus: WebAnalyticsHealthStatus | null,- loading: boolean,+ issuesByKind: Record<string, HealthIssue>,+ isInitialLoad: boolean,currentTeam: TeamType | null): HealthCheck[] => {- if (loading || !webAnalyticsHealthStatus) {+ if (isInitialLoad) {return [createLoadingCheck(HealthCheckId.WEB_VITALS, 'performance', 'Web vitals')]}+ const isSendingWebVitals = statusForCheck(HealthCheckId.WEB_VITALS, issuesByKind) === 'success'const webVitalsEnabled = currentTeam?.autocapture_web_vitals_opt_in ?? falsereturn [@@ -249,14 +276,14 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([id: HealthCheckId.WEB_VITALS,category: 'performance',title: '$web_vitals',- description: webAnalyticsHealthStatus.isSendingWebVitals+ description: isSendingWebVitals? 'LCP, INP, and CLS are being tracked. You can monitor your real user experience!': webVitalsEnabled? 'Enabled but no data yet. Core Web Vitals (LCP, INP, CLS) measure real user experience.': 'Core Web Vitals (LCP, INP, CLS) measure real user experience. Google uses these metrics for search ranking.',- status: webAnalyticsHealthStatus.isSendingWebVitals ? 'success' : 'warning',+ status: statusForCheck(HealthCheckId.WEB_VITALS, issuesByKind),action:- webAnalyticsHealthStatus.isSendingWebVitals || webVitalsEnabled+ isSendingWebVitals || webVitalsEnabled? { label: 'View Web Vitals', to: '/web/web-vitals' }: {label: 'Enable Web Vitals',@@ -347,25 +374,57 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([],hasAuthorizedUrls: [- (s) => [s.currentTeam],- (currentTeam: TeamType | null): boolean => {- return !!currentTeam?.app_urls && currentTeam.app_urls.length > 0- },+ (s) => [s.issuesByKind],+ (issuesByKind: Record<string, HealthIssue>): boolean => !issuesByKind.authorized_urls,],}),listeners(({ actions, values }) => ({- refreshHealthChecks: () => {+ refreshHealthChecks: async ({ isManual }, breakpoint) => {const { overallHealthStatus } = valuesactions.reportWebAnalyticsHealthRefreshed({overall_status: overallHealthStatus.status,passed_count: overallHealthStatus.passedCount,})- actions.loadWebAnalyticsHealthStatus()- actions.loadHasReverseProxy()++ const url = `api/projects/${values.currentTeamIdStrict}/health_issues/refresh/`+ try {+ const response = await api.create<{+ scheduled_kinds: string[]+ kinds_failed: string[]+ team_id: number+ }>(url)+ breakpoint()++ actions.setNextRefreshAvailableAt(Date.now() + REFRESH_COOLDOWN_MS)++ if ((response?.scheduled_kinds ?? []).length === 0) {+ if (isManual) {+ lemonToast.info('No health checks are registered for this project.')+ }+ return+ }++ for (let i = 0; i < REFRESH_POLL_COUNT; i++) {+ await breakpoint(REFRESH_POLL_INTERVAL_MS)+ actions.loadHealthIssues()+ }+ } catch (error: unknown) {+ if (error instanceof ApiError && error.status === 429) {+ const retryAfterSeconds = Number(error.headers?.get('Retry-After'))+ if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {+ actions.setNextRefreshAvailableAt(Date.now() + retryAfterSeconds * 1000)+ }+ if (isManual) {+ lemonToast.warning(`Refresh available again ${error.formattedRetryAfter ?? 'in a few minutes'}`)+ }+ } else if (isManual) {+ lemonToast.error('Failed to refresh health checks')+ }+ }},- loadWebAnalyticsHealthStatusSuccess: () => {- const { webAnalyticsHealthStatus, hasAuthorizedUrls, hasReverseProxy, overallHealthStatus } = values+ loadHealthIssuesSuccess: () => {+ const { webAnalyticsHealthStatus, hasAuthorizedUrls, overallHealthStatus, issuesByKind } = valuesif (webAnalyticsHealthStatus && overallHealthStatus.status !== 'loading') {actions.reportWebAnalyticsHealthStatus({has_pageviews: webAnalyticsHealthStatus.isSendingPageViews,@@ -373,7 +432,7 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([has_scroll_depth: webAnalyticsHealthStatus.isSendingPageLeavesScroll,has_web_vitals: webAnalyticsHealthStatus.isSendingWebVitals,has_authorized_urls: hasAuthorizedUrls,- has_reverse_proxy: hasReverseProxy ?? false,+ has_reverse_proxy: !issuesByKind.reverse_proxy,overall_status: overallHealthStatus.status,})}@@ -403,8 +462,13 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([},})),- afterMount(({ actions }) => {- actions.loadWebAnalyticsHealthStatus()+ afterMount(({ actions, values }) => {+ actions.loadHealthIssues()++ const { nextRefreshAvailableAt } = values+ if (nextRefreshAvailableAt === null || nextRefreshAvailableAt <= Date.now()) {+ actions.refreshHealthChecks(false)+ }}),])diff --git a/posthog/rate_limit.py b/posthog/rate_limit.pyindex 338cc5c20fae..8959d2663d60 100644--- a/posthog/rate_limit.py+++ b/posthog/rate_limit.py@@ -1013,7 +1013,7 @@ class GitHubRepositoryRefreshThrottle(PersonalApiKeyOrUserRateThrottle):class HealthIssueRefreshThrottle(PersonalApiKeyOrUserRateThrottle):scope = "health_issue_refresh"- rate = "1/15minutes"+ rate = "1/5minutes"def parse_rate(self, rate):if rate is None:diff --git a/products/web_analytics/backend/temporal/health_checks/reverse_proxy.py b/products/web_analytics/backend/temporal/health_checks/reverse_proxy.pyindex 6f66ecedc6cd..7c5b25b117e5 100644--- a/products/web_analytics/backend/temporal/health_checks/reverse_proxy.py+++ b/products/web_analytics/backend/temporal/health_checks/reverse_proxy.py@@ -13,7 +13,7 @@ WHERE team_id IN %(team_ids)sAND event IN ('$pageview', '$screen')AND timestamp >= now() - INTERVAL %(lookback_days)s DAYGROUP BY team_id-HAVING countIf(position(properties, '"$lib_custom_api_host"') > 0) = 0+HAVING countIf(JSONHas(properties, '$lib_custom_api_host')) = 0"""diff --git a/products/web_analytics/backend/temporal/health_checks/scroll_depth.py b/products/web_analytics/backend/temporal/health_checks/scroll_depth.pyindex bb7b4dbc1094..e4283cf94d49 100644--- a/products/web_analytics/backend/temporal/health_checks/scroll_depth.py+++ b/products/web_analytics/backend/temporal/health_checks/scroll_depth.py@@ -13,7 +13,7 @@ WHERE team_id IN %(team_ids)sAND event = '$pageleave'AND timestamp >= now() - INTERVAL %(lookback_days)s DAYGROUP BY team_id-HAVING countIf(position(properties, '"$prev_pageview_max_content_percentage"') > 0) = 0+HAVING countIf(JSONHas(properties, '$prev_pageview_max_content_percentage')) = 0"""