humanbehavior-js 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/angular/index.cjs +53 -7
- package/dist/cjs/angular/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +53 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/react/index.cjs +53 -7
- package/dist/cjs/react/index.cjs.map +1 -1
- package/dist/cjs/remix/index.cjs +53 -7
- package/dist/cjs/remix/index.cjs.map +1 -1
- package/dist/cjs/svelte/index.cjs +53 -7
- package/dist/cjs/svelte/index.cjs.map +1 -1
- package/dist/cjs/vue/index.cjs +53 -7
- package/dist/cjs/vue/index.cjs.map +1 -1
- package/dist/esm/angular/index.js +53 -7
- package/dist/esm/angular/index.js.map +1 -1
- package/dist/esm/index.js +53 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +53 -7
- package/dist/esm/react/index.js.map +1 -1
- package/dist/esm/remix/index.js +53 -7
- package/dist/esm/remix/index.js.map +1 -1
- package/dist/esm/svelte/index.js +53 -7
- package/dist/esm/svelte/index.js.map +1 -1
- package/dist/esm/vue/index.js +53 -7
- package/dist/esm/vue/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/types/angular/index.d.ts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/react/index.d.ts +7 -0
- package/dist/types/remix/index.d.ts +7 -0
- package/dist/types/svelte/index.d.ts +7 -0
- package/package.json +1 -1
- package/src/tracker.ts +60 -8
package/dist/esm/svelte/index.js
CHANGED
|
@@ -13226,6 +13226,8 @@ class HumanBehaviorTracker {
|
|
|
13226
13226
|
this._connectionBlocked = false;
|
|
13227
13227
|
this.recordInstance = null;
|
|
13228
13228
|
this.sessionStartTime = Date.now();
|
|
13229
|
+
this.rrwebRecord = null;
|
|
13230
|
+
this.fullSnapshotTimeout = null;
|
|
13229
13231
|
if (!apiKey) {
|
|
13230
13232
|
throw new Error('Human Behavior API Key is required');
|
|
13231
13233
|
}
|
|
@@ -13333,6 +13335,8 @@ class HumanBehaviorTracker {
|
|
|
13333
13335
|
this.originalPushState.apply(history, args);
|
|
13334
13336
|
// Track navigation event
|
|
13335
13337
|
this.trackNavigationEvent('pushState', this.previousUrl, this.currentUrl);
|
|
13338
|
+
// Take FullSnapshot on navigation (like PostHog does)
|
|
13339
|
+
this.takeFullSnapshot();
|
|
13336
13340
|
};
|
|
13337
13341
|
// Override replaceState to capture programmatic navigation
|
|
13338
13342
|
history.replaceState = (...args) => {
|
|
@@ -13342,12 +13346,16 @@ class HumanBehaviorTracker {
|
|
|
13342
13346
|
this.originalReplaceState.apply(history, args);
|
|
13343
13347
|
// Track navigation event
|
|
13344
13348
|
this.trackNavigationEvent('replaceState', this.previousUrl, this.currentUrl);
|
|
13349
|
+
// Take FullSnapshot on navigation (like PostHog does)
|
|
13350
|
+
this.takeFullSnapshot();
|
|
13345
13351
|
};
|
|
13346
13352
|
// Listen for popstate events (back/forward navigation)
|
|
13347
13353
|
const popstateListener = () => {
|
|
13348
13354
|
this.previousUrl = this.currentUrl;
|
|
13349
13355
|
this.currentUrl = window.location.href;
|
|
13350
13356
|
this.trackNavigationEvent('popstate', this.previousUrl, this.currentUrl);
|
|
13357
|
+
// Take FullSnapshot on navigation (like PostHog does)
|
|
13358
|
+
this.takeFullSnapshot();
|
|
13351
13359
|
};
|
|
13352
13360
|
window.addEventListener('popstate', popstateListener);
|
|
13353
13361
|
this.navigationListeners.push(() => {
|
|
@@ -13775,13 +13783,14 @@ class HumanBehaviorTracker {
|
|
|
13775
13783
|
this.flushInterval = window.setInterval(() => {
|
|
13776
13784
|
this.flush();
|
|
13777
13785
|
}, this.FLUSH_INTERVAL_MS);
|
|
13778
|
-
//
|
|
13779
|
-
this.enableConsoleTracking();
|
|
13786
|
+
// Disable console tracking to reduce event pollution
|
|
13787
|
+
// this.enableConsoleTracking();
|
|
13780
13788
|
// ✅ DOM READY DETECTION
|
|
13781
13789
|
// Wait for DOM to be ready before starting recording
|
|
13782
13790
|
const startRecording = () => {
|
|
13783
13791
|
logDebug('🎯 DOM ready, starting session recording');
|
|
13784
13792
|
// ✅ HUMANBEHAVIOR RRWEB CONFIGURATION
|
|
13793
|
+
this.rrwebRecord = record;
|
|
13785
13794
|
const recordInstance = record({
|
|
13786
13795
|
emit: (event) => {
|
|
13787
13796
|
// ✅ DIRECT EVENT HANDLING - Let rrweb handle events natively
|
|
@@ -13803,12 +13812,12 @@ class HumanBehaviorTracker {
|
|
|
13803
13812
|
recordCrossOriginIframes: false, // HumanBehavior default
|
|
13804
13813
|
// ✅ CANVAS RECORDING - Disabled to prevent large data URIs
|
|
13805
13814
|
recordCanvas: false, // Disabled to prevent large data URIs
|
|
13806
|
-
// ✅ FULLSNAPSHOT GENERATION -
|
|
13807
|
-
// checkoutEveryNms
|
|
13808
|
-
//
|
|
13815
|
+
// ✅ FULLSNAPSHOT GENERATION - Following PostHog's approach (no periodic snapshots)
|
|
13816
|
+
// PostHog doesn't use checkoutEveryNms or checkoutEveryNth to avoid animation issues
|
|
13817
|
+
// They rely on initial FullSnapshot + navigation-triggered ones only
|
|
13809
13818
|
});
|
|
13810
|
-
// Store the record instance for cleanup
|
|
13811
|
-
this.recordInstance = recordInstance;
|
|
13819
|
+
// Store the record instance for cleanup
|
|
13820
|
+
this.recordInstance = recordInstance || null;
|
|
13812
13821
|
};
|
|
13813
13822
|
// ✅ DOM READY DETECTION
|
|
13814
13823
|
logDebug(`🎯 DOM ready state: ${document.readyState}`);
|
|
@@ -13827,6 +13836,37 @@ class HumanBehaviorTracker {
|
|
|
13827
13836
|
}
|
|
13828
13837
|
});
|
|
13829
13838
|
}
|
|
13839
|
+
/**
|
|
13840
|
+
* Manually trigger a FullSnapshot (for navigation events)
|
|
13841
|
+
* Delays snapshot to avoid capturing mid-animation states
|
|
13842
|
+
*/
|
|
13843
|
+
takeFullSnapshot() {
|
|
13844
|
+
// Clear any existing timeout to avoid multiple snapshots
|
|
13845
|
+
if (this.fullSnapshotTimeout) {
|
|
13846
|
+
clearTimeout(this.fullSnapshotTimeout);
|
|
13847
|
+
}
|
|
13848
|
+
// Delay FullSnapshot to let animations settle
|
|
13849
|
+
this.fullSnapshotTimeout = window.setTimeout(() => {
|
|
13850
|
+
try {
|
|
13851
|
+
// Wait for any pending animations/transitions to complete
|
|
13852
|
+
requestAnimationFrame(() => {
|
|
13853
|
+
requestAnimationFrame(() => {
|
|
13854
|
+
// Access takeFullSnapshot from the rrweb record function
|
|
13855
|
+
if (this.rrwebRecord && typeof this.rrwebRecord.takeFullSnapshot === 'function') {
|
|
13856
|
+
this.rrwebRecord.takeFullSnapshot();
|
|
13857
|
+
logDebug('✅ FullSnapshot taken for navigation (delayed for animations)');
|
|
13858
|
+
}
|
|
13859
|
+
else {
|
|
13860
|
+
logWarn('⚠️ takeFullSnapshot not available on record function');
|
|
13861
|
+
}
|
|
13862
|
+
});
|
|
13863
|
+
});
|
|
13864
|
+
}
|
|
13865
|
+
catch (error) {
|
|
13866
|
+
logError('❌ Failed to take FullSnapshot for navigation:', error);
|
|
13867
|
+
}
|
|
13868
|
+
}, 1000); // Wait 1 second for animations to settle
|
|
13869
|
+
}
|
|
13830
13870
|
stop() {
|
|
13831
13871
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13832
13872
|
yield this.ensureInitialized();
|
|
@@ -13841,6 +13881,12 @@ class HumanBehaviorTracker {
|
|
|
13841
13881
|
this.recordInstance();
|
|
13842
13882
|
this.recordInstance = null;
|
|
13843
13883
|
}
|
|
13884
|
+
// Clear any pending FullSnapshot timeouts
|
|
13885
|
+
if (this.fullSnapshotTimeout) {
|
|
13886
|
+
clearTimeout(this.fullSnapshotTimeout);
|
|
13887
|
+
this.fullSnapshotTimeout = null;
|
|
13888
|
+
}
|
|
13889
|
+
this.rrwebRecord = null;
|
|
13844
13890
|
// Disable console tracking
|
|
13845
13891
|
this.disableConsoleTracking();
|
|
13846
13892
|
// Cleanup navigation tracking
|