: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
import type { ConnectivityClient } from "@posthog/ui/features/connectivity/connectivityClient";
// Real web connectivity, backed by navigator.onLine and the browser's
// online/offline events. Desktop resolves this over the main-process
// connectivity service (which probes reachability); the browser's own network
// state is the equivalent signal here.
export const webConnectivityClient: ConnectivityClient = {
getStatus: () => Promise.resolve({ isOnline: navigator.onLine }),
checkNow: () => Promise.resolve({ isOnline: navigator.onLine }),
onStatusChange: (sub) => {
const emit = () => sub.onData({ isOnline: navigator.onLine });
window.addEventListener("online", emit);
window.addEventListener("offline", emit);
return {
unsubscribe: () => {
window.removeEventListener("online", emit);
window.removeEventListener("offline", emit);
},
};
},
};