humanbehavior-js 0.4.5 → 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/cjs/remix/index.cjs
CHANGED
|
@@ -13230,6 +13230,8 @@ class HumanBehaviorTracker {
|
|
|
13230
13230
|
this._connectionBlocked = false;
|
|
13231
13231
|
this.recordInstance = null;
|
|
13232
13232
|
this.sessionStartTime = Date.now();
|
|
13233
|
+
this.rrwebRecord = null;
|
|
13234
|
+
this.fullSnapshotTimeout = null;
|
|
13233
13235
|
if (!apiKey) {
|
|
13234
13236
|
throw new Error('Human Behavior API Key is required');
|
|
13235
13237
|
}
|
|
@@ -13337,6 +13339,8 @@ class HumanBehaviorTracker {
|
|
|
13337
13339
|
this.originalPushState.apply(history, args);
|
|
13338
13340
|
// Track navigation event
|
|
13339
13341
|
this.trackNavigationEvent('pushState', this.previousUrl, this.currentUrl);
|
|
13342
|
+
// Take FullSnapshot on navigation (like PostHog does)
|
|
13343
|
+
this.takeFullSnapshot();
|
|
13340
13344
|
};
|
|
13341
13345
|
// Override replaceState to capture programmatic navigation
|
|
13342
13346
|
history.replaceState = (...args) => {
|
|
@@ -13346,12 +13350,16 @@ class HumanBehaviorTracker {
|
|
|
13346
13350
|
this.originalReplaceState.apply(history, args);
|
|
13347
13351
|
// Track navigation event
|
|
13348
13352
|
this.trackNavigationEvent('replaceState', this.previousUrl, this.currentUrl);
|
|
13353
|
+
// Take FullSnapshot on navigation (like PostHog does)
|
|
13354
|
+
this.takeFullSnapshot();
|
|
13349
13355
|
};
|
|
13350
13356
|
// Listen for popstate events (back/forward navigation)
|
|
13351
13357
|
const popstateListener = () => {
|
|
13352
13358
|
this.previousUrl = this.currentUrl;
|
|
13353
13359
|
this.currentUrl = window.location.href;
|
|
13354
13360
|
this.trackNavigationEvent('popstate', this.previousUrl, this.currentUrl);
|
|
13361
|
+
// Take FullSnapshot on navigation (like PostHog does)
|
|
13362
|
+
this.takeFullSnapshot();
|
|
13355
13363
|
};
|
|
13356
13364
|
window.addEventListener('popstate', popstateListener);
|
|
13357
13365
|
this.navigationListeners.push(() => {
|
|
@@ -13779,13 +13787,14 @@ class HumanBehaviorTracker {
|
|
|
13779
13787
|
this.flushInterval = window.setInterval(() => {
|
|
13780
13788
|
this.flush();
|
|
13781
13789
|
}, this.FLUSH_INTERVAL_MS);
|
|
13782
|
-
//
|
|
13783
|
-
this.enableConsoleTracking();
|
|
13790
|
+
// Disable console tracking to reduce event pollution
|
|
13791
|
+
// this.enableConsoleTracking();
|
|
13784
13792
|
// ✅ DOM READY DETECTION
|
|
13785
13793
|
// Wait for DOM to be ready before starting recording
|
|
13786
13794
|
const startRecording = () => {
|
|
13787
13795
|
logDebug('🎯 DOM ready, starting session recording');
|
|
13788
13796
|
// ✅ HUMANBEHAVIOR RRWEB CONFIGURATION
|
|
13797
|
+
this.rrwebRecord = record;
|
|
13789
13798
|
const recordInstance = record({
|
|
13790
13799
|
emit: (event) => {
|
|
13791
13800
|
// ✅ DIRECT EVENT HANDLING - Let rrweb handle events natively
|
|
@@ -13807,12 +13816,12 @@ class HumanBehaviorTracker {
|
|
|
13807
13816
|
recordCrossOriginIframes: false, // HumanBehavior default
|
|
13808
13817
|
// ✅ CANVAS RECORDING - Disabled to prevent large data URIs
|
|
13809
13818
|
recordCanvas: false, // Disabled to prevent large data URIs
|
|
13810
|
-
// ✅ FULLSNAPSHOT GENERATION -
|
|
13811
|
-
checkoutEveryNms
|
|
13812
|
-
|
|
13819
|
+
// ✅ FULLSNAPSHOT GENERATION - Following PostHog's approach (no periodic snapshots)
|
|
13820
|
+
// PostHog doesn't use checkoutEveryNms or checkoutEveryNth to avoid animation issues
|
|
13821
|
+
// They rely on initial FullSnapshot + navigation-triggered ones only
|
|
13813
13822
|
});
|
|
13814
|
-
// Store the record instance for cleanup
|
|
13815
|
-
this.recordInstance = recordInstance;
|
|
13823
|
+
// Store the record instance for cleanup
|
|
13824
|
+
this.recordInstance = recordInstance || null;
|
|
13816
13825
|
};
|
|
13817
13826
|
// ✅ DOM READY DETECTION
|
|
13818
13827
|
logDebug(`🎯 DOM ready state: ${document.readyState}`);
|
|
@@ -13831,6 +13840,37 @@ class HumanBehaviorTracker {
|
|
|
13831
13840
|
}
|
|
13832
13841
|
});
|
|
13833
13842
|
}
|
|
13843
|
+
/**
|
|
13844
|
+
* Manually trigger a FullSnapshot (for navigation events)
|
|
13845
|
+
* Delays snapshot to avoid capturing mid-animation states
|
|
13846
|
+
*/
|
|
13847
|
+
takeFullSnapshot() {
|
|
13848
|
+
// Clear any existing timeout to avoid multiple snapshots
|
|
13849
|
+
if (this.fullSnapshotTimeout) {
|
|
13850
|
+
clearTimeout(this.fullSnapshotTimeout);
|
|
13851
|
+
}
|
|
13852
|
+
// Delay FullSnapshot to let animations settle
|
|
13853
|
+
this.fullSnapshotTimeout = window.setTimeout(() => {
|
|
13854
|
+
try {
|
|
13855
|
+
// Wait for any pending animations/transitions to complete
|
|
13856
|
+
requestAnimationFrame(() => {
|
|
13857
|
+
requestAnimationFrame(() => {
|
|
13858
|
+
// Access takeFullSnapshot from the rrweb record function
|
|
13859
|
+
if (this.rrwebRecord && typeof this.rrwebRecord.takeFullSnapshot === 'function') {
|
|
13860
|
+
this.rrwebRecord.takeFullSnapshot();
|
|
13861
|
+
logDebug('✅ FullSnapshot taken for navigation (delayed for animations)');
|
|
13862
|
+
}
|
|
13863
|
+
else {
|
|
13864
|
+
logWarn('⚠️ takeFullSnapshot not available on record function');
|
|
13865
|
+
}
|
|
13866
|
+
});
|
|
13867
|
+
});
|
|
13868
|
+
}
|
|
13869
|
+
catch (error) {
|
|
13870
|
+
logError('❌ Failed to take FullSnapshot for navigation:', error);
|
|
13871
|
+
}
|
|
13872
|
+
}, 1000); // Wait 1 second for animations to settle
|
|
13873
|
+
}
|
|
13834
13874
|
stop() {
|
|
13835
13875
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13836
13876
|
yield this.ensureInitialized();
|
|
@@ -13845,6 +13885,12 @@ class HumanBehaviorTracker {
|
|
|
13845
13885
|
this.recordInstance();
|
|
13846
13886
|
this.recordInstance = null;
|
|
13847
13887
|
}
|
|
13888
|
+
// Clear any pending FullSnapshot timeouts
|
|
13889
|
+
if (this.fullSnapshotTimeout) {
|
|
13890
|
+
clearTimeout(this.fullSnapshotTimeout);
|
|
13891
|
+
this.fullSnapshotTimeout = null;
|
|
13892
|
+
}
|
|
13893
|
+
this.rrwebRecord = null;
|
|
13848
13894
|
// Disable console tracking
|
|
13849
13895
|
this.disableConsoleTracking();
|
|
13850
13896
|
// Cleanup navigation tracking
|