posthog-js
Advanced tools
Comparing version 1.145.1 to 1.146.0
@@ -14,5 +14,7 @@ import RageClick from './extensions/rageclick'; | ||
private buffer; | ||
private _flushInterval; | ||
constructor(instance: PostHog); | ||
get flushIntervalMilliseconds(): number; | ||
get isEnabled(): boolean; | ||
startIfEnabled(): void; | ||
get isEnabled(): boolean; | ||
afterDecideResponse(response: DecideResponse): void; | ||
@@ -25,3 +27,4 @@ getAndClearBuffer(): HeatmapEventBuffer; | ||
private _capture; | ||
private flush; | ||
} | ||
export {}; |
@@ -143,3 +143,3 @@ import { PostHogFeatureFlags } from './posthog-featureflags'; | ||
_addCaptureHook(callback: (eventName: string, eventPayload?: CaptureResult) => void): void; | ||
_calculate_event_properties(event_name: string, event_properties: Properties, options?: CaptureOptions): Properties; | ||
_calculate_event_properties(event_name: string, event_properties: Properties): Properties; | ||
_calculate_set_once_properties(dataSetOnce?: Properties): Properties | undefined; | ||
@@ -146,0 +146,0 @@ /** |
@@ -75,2 +75,5 @@ import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'; | ||
} | ||
export interface HeatmapConfig { | ||
flush_interval_milliseconds: number; | ||
} | ||
export interface PostHogConfig { | ||
@@ -157,2 +160,3 @@ api_host: string; | ||
enable_heatmaps?: boolean; | ||
capture_heatmaps?: boolean | HeatmapConfig; | ||
disable_scroll_properties?: boolean; | ||
@@ -253,4 +257,2 @@ scroll_root_selector?: string | string[]; | ||
_url?: string; /** Used to override the desired endpoint for the captured event */ | ||
/** Some events are sent as passengers inside other events - e.g. heatmaps and web vitals, not all ingestion routes can process passengers */ | ||
_noHeatmaps?: boolean; | ||
_batchKey?: string; /** key of queue, e.g. 'sessionRecording' vs 'event' */ | ||
@@ -257,0 +259,0 @@ _noTruncate?: boolean; /** if set, overrides and disables config.properties_string_max_length */ |
{ | ||
"name": "posthog-js", | ||
"version": "1.145.1", | ||
"version": "1.146.0", | ||
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/PostHog/posthog-js", |
@@ -126,3 +126,2 @@ import { window } from '../../utils/globals'; | ||
_batchKey: 'exceptionEvent', | ||
_noHeatmaps: true, | ||
_url: this.endpoint, | ||
@@ -129,0 +128,0 @@ }); |
@@ -843,3 +843,2 @@ var __assign = (this && this.__assign) || function () { | ||
_batchKey: SESSION_RECORDING_BATCH_KEY, | ||
_noHeatmaps: true, | ||
}); | ||
@@ -846,0 +845,0 @@ }; |
@@ -14,5 +14,7 @@ import RageClick from './extensions/rageclick'; | ||
private buffer; | ||
private _flushInterval; | ||
constructor(instance: PostHog); | ||
get flushIntervalMilliseconds(): number; | ||
get isEnabled(): boolean; | ||
startIfEnabled(): void; | ||
get isEnabled(): boolean; | ||
afterDecideResponse(response: DecideResponse): void; | ||
@@ -25,3 +27,4 @@ getAndClearBuffer(): HeatmapEventBuffer; | ||
private _capture; | ||
private flush; | ||
} | ||
export {}; |
@@ -17,4 +17,7 @@ var __assign = (this && this.__assign) || function () { | ||
import { HEATMAPS_ENABLED_SERVER_SIDE, TOOLBAR_ID } from './constants'; | ||
import { isUndefined } from './utils/type-utils'; | ||
import { isEmptyObject, isObject, isUndefined } from './utils/type-utils'; | ||
import { logger } from './utils/logger'; | ||
var DEFAULT_FLUSH_INTERVAL = 5000; | ||
var HEATMAPS = 'heatmaps'; | ||
var LOGGER_PREFIX = '[' + HEATMAPS + ']'; | ||
function elementOrParentPositionMatches(el, matches, breakOnElement) { | ||
@@ -40,2 +43,3 @@ var curEl = el; | ||
function Heatmaps(instance) { | ||
var _this = this; | ||
var _a; | ||
@@ -45,16 +49,30 @@ this.rageclicks = new RageClick(); | ||
this._initialized = false; | ||
this._flushInterval = null; | ||
this.instance = instance; | ||
this._enabledServerSide = !!((_a = this.instance.persistence) === null || _a === void 0 ? void 0 : _a.props[HEATMAPS_ENABLED_SERVER_SIDE]); | ||
window === null || window === void 0 ? void 0 : window.addEventListener('beforeunload', function () { | ||
_this.flush(); | ||
}); | ||
} | ||
Heatmaps.prototype.startIfEnabled = function () { | ||
if (this.isEnabled && !this._initialized) { | ||
logger.info('[heatmaps] Heatmaps enabled, starting...'); | ||
this._setupListeners(); | ||
} | ||
}; | ||
Object.defineProperty(Heatmaps.prototype, "flushIntervalMilliseconds", { | ||
get: function () { | ||
var flushInterval = DEFAULT_FLUSH_INTERVAL; | ||
if (isObject(this.instance.config.capture_heatmaps) && | ||
this.instance.config.capture_heatmaps.flush_interval_milliseconds) { | ||
flushInterval = this.instance.config.capture_heatmaps.flush_interval_milliseconds; | ||
} | ||
return flushInterval; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Heatmaps.prototype, "isEnabled", { | ||
get: function () { | ||
return !isUndefined(this.instance.config.enable_heatmaps) | ||
? this.instance.config.enable_heatmaps | ||
: this._enabledServerSide; | ||
if (!isUndefined(this.instance.config.capture_heatmaps)) { | ||
return this.instance.config.capture_heatmaps !== false; | ||
} | ||
if (!isUndefined(this.instance.config.enable_heatmaps)) { | ||
return this.instance.config.enable_heatmaps; | ||
} | ||
return this._enabledServerSide; | ||
}, | ||
@@ -64,2 +82,20 @@ enumerable: false, | ||
}); | ||
Heatmaps.prototype.startIfEnabled = function () { | ||
var _a; | ||
if (this.isEnabled) { | ||
// nested if here since we only want to run the else | ||
// if this.enabled === false | ||
// not if this method is called more than once | ||
if (this._initialized) { | ||
return; | ||
} | ||
logger.info(LOGGER_PREFIX + ' starting...'); | ||
this._setupListeners(); | ||
this._flushInterval = setInterval(this.flush.bind(this), this.flushIntervalMilliseconds); | ||
} | ||
else { | ||
clearInterval((_a = this._flushInterval) !== null && _a !== void 0 ? _a : undefined); | ||
this.getAndClearBuffer(); | ||
} | ||
}; | ||
Heatmaps.prototype.afterDecideResponse = function (response) { | ||
@@ -140,2 +176,10 @@ var _a; | ||
}; | ||
Heatmaps.prototype.flush = function () { | ||
if (!this.buffer || isEmptyObject(this.buffer)) { | ||
return; | ||
} | ||
this.instance.capture('$$heatmap', { | ||
$heatmap_data: this.getAndClearBuffer(), | ||
}); | ||
}; | ||
return Heatmaps; | ||
@@ -142,0 +186,0 @@ }()); |
@@ -143,3 +143,3 @@ import { PostHogFeatureFlags } from './posthog-featureflags'; | ||
_addCaptureHook(callback: (eventName: string, eventPayload?: CaptureResult) => void): void; | ||
_calculate_event_properties(event_name: string, event_properties: Properties, options?: CaptureOptions): Properties; | ||
_calculate_event_properties(event_name: string, event_properties: Properties): Properties; | ||
_calculate_set_once_properties(dataSetOnce?: Properties): Properties | undefined; | ||
@@ -146,0 +146,0 @@ /** |
@@ -75,2 +75,5 @@ import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'; | ||
} | ||
export interface HeatmapConfig { | ||
flush_interval_milliseconds: number; | ||
} | ||
export interface PostHogConfig { | ||
@@ -157,2 +160,3 @@ api_host: string; | ||
enable_heatmaps?: boolean; | ||
capture_heatmaps?: boolean | HeatmapConfig; | ||
disable_scroll_properties?: boolean; | ||
@@ -253,4 +257,2 @@ scroll_root_selector?: string | string[]; | ||
_url?: string; /** Used to override the desired endpoint for the captured event */ | ||
/** Some events are sent as passengers inside other events - e.g. heatmaps and web vitals, not all ingestion routes can process passengers */ | ||
_noHeatmaps?: boolean; | ||
_batchKey?: string; /** key of queue, e.g. 'sessionRecording' vs 'event' */ | ||
@@ -257,0 +259,0 @@ _noTruncate?: boolean; /** if set, overrides and disables config.properties_string_max_length */ |
{ | ||
"name": "posthog-js", | ||
"version": "1.145.1", | ||
"version": "1.146.0", | ||
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/PostHog/posthog-js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7646050
24313