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(frontend): remove the deferred init sample that never split sessions (#117775)

Paul D'Ambra7a72468481f1
diff --git a/frontend/src/loadPostHogJS.test.ts b/frontend/src/loadPostHogJS.test.ts
index 4fb3dcaa28aa..15b28057f31d 100644
--- a/frontend/src/loadPostHogJS.test.ts
+++ b/frontend/src/loadPostHogJS.test.ts
@@ -1,9 +1,8 @@
import posthog from 'posthog-js'
-import { sampleOnProperty } from 'posthog-js/lib/src/extensions/sampling'
import { AppContext } from '~/types'
-import { LastSeenFeatureFlags, isInDeferredInitSample, loadPostHogJS, withLastSeenFeatureFlags } from './loadPostHogJS'
+import { LastSeenFeatureFlags, loadPostHogJS, withLastSeenFeatureFlags } from './loadPostHogJS'
describe('loadPostHogJS', () => {
describe('withLastSeenFeatureFlags', () => {
@@ -58,15 +57,6 @@ describe('loadPostHogJS', () => {
})
})
- describe('isInDeferredInitSample', () => {
- it.each(['', 'a', '0198f1e2-9c3b-7a1d-8f4e-2b6c9d0e1f23', 'session-one', 'session-two', 'session-three'])(
- 'keeps the posthog-js sampling verdict for session %p',
- (sessionId) => {
- expect(isInDeferredInitSample(sessionId)).toBe(sampleOnProperty(sessionId, 0.5))
- }
- )
- })
-
describe('without a project key', () => {
it('starts posthog-js with no request to PostHog', () => {
window.JS_POSTHOG_API_KEY = undefined
diff --git a/frontend/src/loadPostHogJS.tsx b/frontend/src/loadPostHogJS.tsx
index dd5911d5f4bf..a8eaca1bf1a7 100644
--- a/frontend/src/loadPostHogJS.tsx
+++ b/frontend/src/loadPostHogJS.tsx
@@ -10,17 +10,6 @@ import { startDetachedElementTracking } from './detachedElementTracker'
export const SDK_DEFAULTS_DATE = '2026-05-30'
-// The same hash as posthog-js's own `sampleOnProperty`, so existing sessions keep their side of the
-// split. Inlined because the deep import of that extension ships a second copy of @posthog/core.
-export function isInDeferredInitSample(sessionId: string): boolean {
- let hash = 0
- for (let i = 0; i < sessionId.length; i++) {
- hash = (hash << 5) - hash + sessionId.charCodeAt(i)
- hash |= 0
- }
- return Math.abs(hash) % 100 < 50
-}
-
const LAST_SEEN_FEATURE_FLAGS_KEY = 'posthog-app-last-seen-feature-flags'
export interface LastSeenFeatureFlags {
@@ -103,7 +92,7 @@ export function loadPostHogJS(): void {
disable_product_tours: true,
capture_webmcp: true,
opt_out_capturing_by_default: window.IMPERSONATED_SESSION,
- __preview_deferred_init_extensions: isInDeferredInitSample(posthog.get_session_id()),
+ __preview_deferred_init_extensions: true,
error_tracking: {
__capturePostHogExceptions: true,
},