humanbehavior-js 0.4.9 → 0.4.11
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/clean-console-demo.html +39 -0
- package/dist/cjs/angular/index.cjs +55 -17
- package/dist/cjs/angular/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +55 -17
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/react/index.cjs +55 -17
- package/dist/cjs/react/index.cjs.map +1 -1
- package/dist/cjs/remix/index.cjs +55 -17
- package/dist/cjs/remix/index.cjs.map +1 -1
- package/dist/cjs/svelte/index.cjs +55 -17
- package/dist/cjs/svelte/index.cjs.map +1 -1
- package/dist/cjs/vue/index.cjs +55 -17
- package/dist/cjs/vue/index.cjs.map +1 -1
- package/dist/cli/ai-auto-install.js +0 -0
- package/dist/esm/angular/index.js +55 -17
- package/dist/esm/angular/index.js.map +1 -1
- package/dist/esm/index.js +55 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +55 -17
- package/dist/esm/react/index.js.map +1 -1
- package/dist/esm/remix/index.js +55 -17
- package/dist/esm/remix/index.js.map +1 -1
- package/dist/esm/svelte/index.js +55 -17
- package/dist/esm/svelte/index.js.map +1 -1
- package/dist/esm/vue/index.js +55 -17
- 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 +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/react/index.d.ts +1 -0
- package/dist/types/remix/index.d.ts +1 -0
- package/dist/types/svelte/index.d.ts +1 -0
- package/package.json +1 -1
- package/readme.md +26 -2
- package/src/api.ts +2 -2
- package/src/tracker.ts +63 -17
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>HumanBehavior Clean Console Demo</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<h1>HumanBehavior Clean Console Demo</h1>
|
|
10
|
+
<p>This demo shows how to suppress common rrweb errors for a clean console.</p>
|
|
11
|
+
|
|
12
|
+
<!-- External images that would normally cause CORS errors -->
|
|
13
|
+
<img src="https://img.lumas.com/showimg_rwt01_search.jpg" alt="External image 1" style="width: 100px; height: 100px;">
|
|
14
|
+
<img src="https://media.lumas.de/homepage/2024/magazine-kachel-300x400.webp" alt="External image 2" style="width: 100px; height: 100px;">
|
|
15
|
+
|
|
16
|
+
<button>Click me to test recording</button>
|
|
17
|
+
<input type="text" placeholder="Type something">
|
|
18
|
+
<input type="password" placeholder="Password (will be redacted)">
|
|
19
|
+
|
|
20
|
+
<script src="./dist/index.min.js"></script>
|
|
21
|
+
<script>
|
|
22
|
+
// Initialize the tracker with error suppression enabled (default)
|
|
23
|
+
const tracker = HumanBehaviorTracker.init('13c3e029-ca45-4a3c-a33b-f5dcb297e31c', {
|
|
24
|
+
redactFields: ['input[type="password"]'],
|
|
25
|
+
suppressConsoleErrors: true, // Enable error suppression (default)
|
|
26
|
+
logLevel: 'warn' // Only show warnings and errors
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log('✅ HumanBehavior tracker initialized with clean console mode');
|
|
30
|
+
console.log('✅ Canvas security errors and CORS issues will be suppressed');
|
|
31
|
+
|
|
32
|
+
// Test that core functionality still works
|
|
33
|
+
tracker.customEvent('demo_started', {
|
|
34
|
+
feature: 'clean_console',
|
|
35
|
+
timestamp: Date.now()
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
@@ -12582,7 +12582,7 @@ class HumanBehaviorAPI {
|
|
|
12582
12582
|
sessionId: sessionId,
|
|
12583
12583
|
posthogName: userData.email || userData.name || null // Update user name with email
|
|
12584
12584
|
};
|
|
12585
|
-
|
|
12585
|
+
logDebug('Sending user data to server:', payload);
|
|
12586
12586
|
const response = yield fetch(`${this.baseUrl}/api/ingestion/user`, {
|
|
12587
12587
|
method: 'POST',
|
|
12588
12588
|
headers: {
|
|
@@ -12595,7 +12595,7 @@ class HumanBehaviorAPI {
|
|
|
12595
12595
|
throw new Error(`Failed to send user data: ${response.statusText} with API key: ${this.apiKey}`);
|
|
12596
12596
|
}
|
|
12597
12597
|
const result = yield response.json();
|
|
12598
|
-
|
|
12598
|
+
logDebug('Server response:', result);
|
|
12599
12599
|
return result;
|
|
12600
12600
|
}
|
|
12601
12601
|
catch (error) {
|
|
@@ -13171,6 +13171,53 @@ class HumanBehaviorTracker {
|
|
|
13171
13171
|
* This is the main entry point - call this once per page
|
|
13172
13172
|
*/
|
|
13173
13173
|
static init(apiKey, options) {
|
|
13174
|
+
// ✅ SUPPRESS COMMON RRWEB ERRORS FOR CLEAN CONSOLE
|
|
13175
|
+
if (isBrowser && (options === null || options === void 0 ? void 0 : options.suppressConsoleErrors) !== false) {
|
|
13176
|
+
// Suppress canvas security errors
|
|
13177
|
+
const originalConsoleError = console.error;
|
|
13178
|
+
console.error = (...args) => {
|
|
13179
|
+
const message = args.join(' ');
|
|
13180
|
+
if (message.includes('SecurityError: Failed to execute \'toDataURL\'') ||
|
|
13181
|
+
message.includes('Tainted canvases may not be exported') ||
|
|
13182
|
+
message.includes('Cannot inline img src=') ||
|
|
13183
|
+
message.includes('Cross-Origin') ||
|
|
13184
|
+
message.includes('CORS') ||
|
|
13185
|
+
message.includes('Access-Control-Allow-Origin') ||
|
|
13186
|
+
message.includes('Failed to load resource') ||
|
|
13187
|
+
message.includes('net::ERR_BLOCKED_BY_CLIENT')) {
|
|
13188
|
+
// Silently suppress these common rrweb errors
|
|
13189
|
+
return;
|
|
13190
|
+
}
|
|
13191
|
+
originalConsoleError.apply(console, args);
|
|
13192
|
+
};
|
|
13193
|
+
// Suppress console.warn for similar issues
|
|
13194
|
+
const originalConsoleWarn = console.warn;
|
|
13195
|
+
console.warn = (...args) => {
|
|
13196
|
+
const message = args.join(' ');
|
|
13197
|
+
if (message.includes('Cannot inline img src=') ||
|
|
13198
|
+
message.includes('Cross-Origin') ||
|
|
13199
|
+
message.includes('CORS') ||
|
|
13200
|
+
message.includes('Access-Control-Allow-Origin') ||
|
|
13201
|
+
message.includes('Failed to load resource') ||
|
|
13202
|
+
message.includes('net::ERR_BLOCKED_BY_CLIENT')) {
|
|
13203
|
+
// Silently suppress these common rrweb warnings
|
|
13204
|
+
return;
|
|
13205
|
+
}
|
|
13206
|
+
originalConsoleWarn.apply(console, args);
|
|
13207
|
+
};
|
|
13208
|
+
// Add global error handler for any remaining rrweb errors
|
|
13209
|
+
window.addEventListener('error', (event) => {
|
|
13210
|
+
const message = event.message || '';
|
|
13211
|
+
if (message.includes('SecurityError') ||
|
|
13212
|
+
message.includes('Tainted canvases') ||
|
|
13213
|
+
message.includes('toDataURL') ||
|
|
13214
|
+
message.includes('Cross-Origin') ||
|
|
13215
|
+
message.includes('CORS')) {
|
|
13216
|
+
event.preventDefault();
|
|
13217
|
+
return false;
|
|
13218
|
+
}
|
|
13219
|
+
});
|
|
13220
|
+
}
|
|
13174
13221
|
// Return existing instance if already initialized
|
|
13175
13222
|
if (isBrowser && window.__humanBehaviorGlobalTracker) {
|
|
13176
13223
|
logDebug('Tracker already initialized, returning existing instance');
|
|
@@ -13192,16 +13239,6 @@ class HumanBehaviorTracker {
|
|
|
13192
13239
|
if ((options === null || options === void 0 ? void 0 : options.enableAutomaticTracking) !== false) {
|
|
13193
13240
|
tracker.setupAutomaticTracking(options === null || options === void 0 ? void 0 : options.automaticTrackingOptions);
|
|
13194
13241
|
}
|
|
13195
|
-
// Test connection (non-blocking)
|
|
13196
|
-
if (isBrowser) {
|
|
13197
|
-
const testUrl = tracker.api['baseUrl'] + '/api/health';
|
|
13198
|
-
fetch(testUrl, { method: 'HEAD' })
|
|
13199
|
-
.then(() => logDebug('Connection test successful'))
|
|
13200
|
-
.catch((error) => {
|
|
13201
|
-
logWarn('Connection test failed - ad blocker may be active:', error.message);
|
|
13202
|
-
tracker._connectionBlocked = true;
|
|
13203
|
-
});
|
|
13204
|
-
}
|
|
13205
13242
|
// Start tracking
|
|
13206
13243
|
tracker.start();
|
|
13207
13244
|
return tracker;
|
|
@@ -13764,6 +13801,7 @@ class HumanBehaviorTracker {
|
|
|
13764
13801
|
const originalEndUserId = this.endUserId;
|
|
13765
13802
|
// Store user properties
|
|
13766
13803
|
this.userProperties = userProperties;
|
|
13804
|
+
logDebug('Identifying user:', { userProperties, originalEndUserId, sessionId: this.sessionId });
|
|
13767
13805
|
// Send user data with the original endUserId
|
|
13768
13806
|
yield this.api.sendUserData(originalEndUserId, userProperties, this.sessionId);
|
|
13769
13807
|
// Don't update endUserId - keep it as the original UUID
|
|
@@ -13809,11 +13847,11 @@ class HumanBehaviorTracker {
|
|
|
13809
13847
|
maskInputOptions: { password: true }, // HumanBehavior default
|
|
13810
13848
|
maskInputFn: undefined,
|
|
13811
13849
|
slimDOMOptions: {},
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
recordCanvas: false, // Disabled to prevent large data URIs
|
|
13850
|
+
// ✅ ERROR SUPPRESSION SETTINGS - Disabled to prevent console noise
|
|
13851
|
+
collectFonts: false, // Disable font collection to reduce errors
|
|
13852
|
+
inlineStylesheet: false, // Disable inline stylesheet to reduce errors
|
|
13853
|
+
recordCrossOriginIframes: false, // Prevent cross-origin iframe errors
|
|
13854
|
+
recordCanvas: false, // Disabled to prevent large data URIs and canvas errors
|
|
13817
13855
|
// ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
|
|
13818
13856
|
// Rely on initial FullSnapshot + navigation-triggered ones only
|
|
13819
13857
|
});
|