Skip to content

Commit

Permalink
fix: record heatmap as dropped only when there is heatmap data (#22311)
Browse files Browse the repository at this point in the history
* fix: record heatmap as dropped only when there is heatmap data

* Update plugin-server/src/worker/ingestion/event-pipeline/extractHeatmapDataStep.ts
  • Loading branch information
pauldambra committed May 16, 2024
1 parent 1b0f5d8 commit 0b4e000
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ function extractScrollDepthHeatmapData(event: PreIngestionEvent): RawClickhouseH

let heatmapData = $heatmap_data as HeatmapData | null

if (!isValidString(distinctId) || isDistinctIdIllegal(distinctId)) {
return drop('invalid_distinct_id')
}

if (!isValidNumber($viewport_height) || !isValidNumber($viewport_width)) {
status.warn('馃憖', '[extract-heatmap-data] dropping because invalid viewport dimensions', {
$viewport_height,
$viewport_width,
})
return drop('invalid_viewport_dimensions')
}

if ($prev_pageview_pathname && $current_url) {
// We are going to add the scroll depth info derived from the previous pageview to the current pageview's heatmap data
if (!heatmapData) {
Expand All @@ -122,10 +110,25 @@ function extractScrollDepthHeatmapData(event: PreIngestionEvent): RawClickhouseH

let heatmapEvents: RawClickhouseHeatmapEvent[] = []

if (!heatmapData) {
if (!heatmapData || Object.entries(heatmapData).length === 0) {
return []
}

if (!isValidString(distinctId) || isDistinctIdIllegal(distinctId)) {
return drop('invalid_distinct_id')
}

if (!isValidNumber($viewport_height) || !isValidNumber($viewport_width)) {
status.warn('馃憖', '[extract-heatmap-data] dropping because invalid viewport dimensions', {
parent: event.event,
teamId: teamId,
eventTimestamp: timestamp,
$viewport_height,
$viewport_width,
})
return drop('invalid_viewport_dimensions')
}

Object.entries(heatmapData).forEach(([url, items]) => {
if (!isValidString(url)) {
return
Expand Down

0 comments on commit 0b4e000

Please sign in to comment.