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(toolbar): remove the sampling control from click maps (#95578)

Paul D'Ambrabc65d510cb6e
diff --git a/frontend/src/toolbar/TELEMETRY.md b/frontend/src/toolbar/TELEMETRY.md
index ba615642d77e..733106d9859f 100644
--- a/frontend/src/toolbar/TELEMETRY.md
+++ b/frontend/src/toolbar/TELEMETRY.md
@@ -330,26 +330,3 @@ Fired after a successful screenshot/media upload.
| `source` | `'toolbar'` | Always `'toolbar'` |
**File:** `screenshot-upload/screenshotUploadLogic.ts`
-
-## Heatmap sampling (page's PostHog instance)
-
-These events use the **page's** `posthog.capture()`, not `toolbarPosthogJS`.
-They are sent to the customer's project, not PostHog's internal project.
-
-### `sampling_enabled_on_heatmap`
-
-Fired when sampling is enabled on the heatmap. No properties.
-
-### `sampling_disabled_on_heatmap`
-
-Fired when sampling is disabled on the heatmap. No properties.
-
-### `sampling_percentage_updated_on_heatmap`
-
-Fired when the sampling percentage is changed.
-
-| Property | Type | Description |
-| ---------------- | -------- | ------------------------------------------ |
-| `samplingFactor` | `number` | New sampling factor (e.g., 0.1, 0.25, 0.5) |
-
-**File:** `stats/HeatmapToolbarMenu.tsx`
diff --git a/frontend/src/toolbar/elements/heatmapToolbarMenuLogic.ts b/frontend/src/toolbar/elements/heatmapToolbarMenuLogic.ts
index 1c1ae47b91b6..e59f891276c2 100644
--- a/frontend/src/toolbar/elements/heatmapToolbarMenuLogic.ts
+++ b/frontend/src/toolbar/elements/heatmapToolbarMenuLogic.ts
@@ -393,7 +393,6 @@ export interface heatmapToolbarMenuLogicValues {
processed: number
total: number
} | null
- samplingFactor: number
scrollDepthPosthogJsError: 'disabled' | 'version' | null
wantedDataAttributes: string[]
windowHeight: number
@@ -567,9 +566,6 @@ export interface heatmapToolbarMenuLogicActions {
processed: number
total: number
}
- setSamplingFactor: (samplingFactor: number) => {
- samplingFactor: number
- }
startAreaSelection: () => {
value: true
}
@@ -690,7 +686,6 @@ export const heatmapToolbarMenuLogic = kea<heatmapToolbarMenuLogicType>([
enableHeatmap: true,
disableHeatmap: true,
toggleClickmapsEnabled: (enabled: boolean) => ({ enabled }),
- setSamplingFactor: (samplingFactor: number) => ({ samplingFactor }),
loadMoreElementStats: true,
setMatchLinksByHref: (matchLinksByHref: boolean) => ({ matchLinksByHref }),
loadAllEnabled: true,
@@ -813,13 +808,6 @@ export const heatmapToolbarMenuLogic = kea<heatmapToolbarMenuLogicType>([
toggleClickmapsEnabled: (_, { enabled }) => enabled,
},
],
- samplingFactor: [
- 1,
- { persist: true },
- {
- setSamplingFactor: (_, { samplingFactor }) => samplingFactor,
- },
- ],
elementMetrics: [
new Map<HTMLElement, { visible: boolean }>(),
{
@@ -902,7 +890,6 @@ export const heatmapToolbarMenuLogic = kea<heatmapToolbarMenuLogicType>([
date_from: values.commonFilters.date_from,
date_to: values.commonFilters.date_to,
paginate_response: true,
- sampling_factor: values.samplingFactor,
limit: limit ?? ELEMENT_STATS_PAGE_LIMIT,
// the matchers only read the configured data attributes from each
// element's attributes map, so let the server drop the rest
@@ -1362,10 +1349,6 @@ export const heatmapToolbarMenuLogic = kea<heatmapToolbarMenuLogicType>([
setCommonFilters: () => {
actions.loadAllEnabled()
},
- setSamplingFactor: () => {
- actions.maybeLoadClickmap()
- },
-
toggleClickmapsEnabled: () => {
if (values.clickmapsEnabled) {
actions.maybeLoadClickmap()
diff --git a/frontend/src/toolbar/stats/HeatmapToolbarMenu.tsx b/frontend/src/toolbar/stats/HeatmapToolbarMenu.tsx
index 301990ca8069..478b102c40fb 100644
--- a/frontend/src/toolbar/stats/HeatmapToolbarMenu.tsx
+++ b/frontend/src/toolbar/stats/HeatmapToolbarMenu.tsx
@@ -1,5 +1,4 @@
import { useActions, useValues } from 'kea'
-import posthog from 'posthog-js'
import React from 'react'
import { IconMagicWand, IconTarget } from '@posthog/icons'
@@ -10,8 +9,6 @@ import { HeatmapsSettings } from 'lib/components/heatmaps/HeatMapsSettings'
import { heatmapDateOptions } from 'lib/components/IframedToolbarBrowser/utils'
import { IconSync } from 'lib/lemon-ui/icons'
import { LemonInput } from 'lib/lemon-ui/LemonInput'
-import { LemonLabel } from 'lib/lemon-ui/LemonLabel'
-import { LemonSegmentedButton } from 'lib/lemon-ui/LemonSegmentedButton'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
@@ -104,7 +101,6 @@ export const HeatmapToolbarMenu = (): JSX.Element => {
clickmapsEnabled,
heatmapFixedPositionMode,
heatmapColorPalette,
- samplingFactor,
elementsLoading,
processingProgress,
areaSelectionActive,
@@ -118,7 +114,6 @@ export const HeatmapToolbarMenu = (): JSX.Element => {
toggleClickmapsEnabled,
setHeatmapFixedPositionMode,
setHeatmapColorPalette,
- setSamplingFactor,
startAreaSelection,
cancelAreaSelection,
selectHeatmapAreaFilter,
@@ -294,46 +289,6 @@ export const HeatmapToolbarMenu = (): JSX.Element => {
Tip: Hold <kbd className="border rounded px-1 py-0.5 bg-surface-tertiary">shift</kbd> to
interact with the page beneath the clickmap.
</p>
- <div className="flex items-center justify-between pb-2">
- <div className="flex items-center gap-1">
- <LemonLabel
- info="Sampling computes the result on a proportion of data of the users in the dataset, making click maps load significantly faster."
- infoLink="https://posthog.com/docs/toolbar/heatmaps"
- >
- Sampling
- </LemonLabel>
- <LemonSwitch
- className="m-2"
- onChange={(checked) => {
- if (checked) {
- setSamplingFactor(0.1)
- posthog.capture('sampling_enabled_on_heatmap')
- return
- }
- setSamplingFactor(1)
- posthog.capture('sampling_disabled_on_heatmap')
- }}
- checked={samplingFactor !== 1}
- />
- </div>
- {samplingFactor !== 1 && (
- <div className="flex items-center gap-2">
- <LemonSegmentedButton
- options={[0.1, 1, 10, 25, 50].map((percentage) => ({
- value: percentage / 100,
- label: `${percentage}%`,
- }))}
- value={samplingFactor}
- onChange={(newValue) => {
- setSamplingFactor(newValue)
- posthog.capture('sampling_percentage_updated_on_heatmap', {
- samplingFactor: newValue,
- })
- }}
- />
- </div>
- )}
- </div>
<div className="flex items-center gap-2">
<LemonButton
icon={<IconSync />}