Skip to content

Commit

Permalink
fix: heatmaps with segment integration (#1218)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Jun 3, 2024
1 parent 6c5d1d4 commit bb8065e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,7 @@ export class PostHog {
let data: CaptureResult = {
uuid: uuidv7(),
event: event_name,
properties: this._calculate_event_properties(event_name, properties || {}),
}

if (!options?._noHeatmaps) {
const heatmapsBuffer = this.heatmaps?.getAndClearBuffer()
if (heatmapsBuffer) {
data.properties['$heatmap_data'] = heatmapsBuffer
}
properties: this._calculate_event_properties(event_name, properties || {}, options),
}

if (clientRateLimitContext) {
Expand Down Expand Up @@ -831,7 +824,11 @@ export class PostHog {
this.on('eventCaptured', (data) => callback(data.event))
}

_calculate_event_properties(event_name: string, event_properties: Properties): Properties {
_calculate_event_properties(
event_name: string,
event_properties: Properties,
options?: CaptureOptions
): Properties {
if (!this.persistence || !this.sessionPersistence) {
return event_properties
}
Expand Down Expand Up @@ -911,6 +908,13 @@ export class PostHog {

properties['$is_identified'] = this._isIdentified()

if (!options?._noHeatmaps) {
const heatmapsBuffer = this.heatmaps?.getAndClearBuffer()
if (heatmapsBuffer) {
properties['$heatmap_data'] = heatmapsBuffer
}
}

if (isArray(this.config.property_denylist)) {
each(this.config.property_denylist, function (denylisted_prop) {
delete properties[denylisted_prop]
Expand Down

0 comments on commit bb8065e

Please sign in to comment.