@brainfish-ai/web-tracker 0.0.30 → 0.0.32
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/index.d.ts +6 -2
- package/dist/record/recorder.d.ts +1 -1
- package/dist/redact/index.d.ts +1 -1
- package/dist/tracker.cjs.js +1 -1
- package/dist/tracker.cjs.js.gz +0 -0
- package/dist/tracker.cjs.js.map +1 -1
- package/dist/tracker.es.js +50 -16
- package/dist/tracker.es.js.gz +0 -0
- package/dist/tracker.es.js.map +1 -1
- package/dist/tracker.js +1 -1
- package/dist/tracker.js.gz +0 -0
- package/dist/tracker.js.map +1 -1
- package/package.json +2 -2
package/dist/tracker.es.js
CHANGED
|
@@ -3391,7 +3391,7 @@ class HttpClient {
|
|
|
3391
3391
|
responseData = {};
|
|
3392
3392
|
}
|
|
3393
3393
|
return responseData;
|
|
3394
|
-
} catch
|
|
3394
|
+
} catch {
|
|
3395
3395
|
}
|
|
3396
3396
|
}
|
|
3397
3397
|
}
|
|
@@ -3743,14 +3743,14 @@ const _TrackerSdk = class _TrackerSdk {
|
|
|
3743
3743
|
}
|
|
3744
3744
|
/**
|
|
3745
3745
|
* Re-enables privacy-sensitive tracking features (recording, screenshots).
|
|
3746
|
-
*
|
|
3746
|
+
* Takes effect immediately; no page refresh required (web tracker attaches
|
|
3747
|
+
* listeners and starts recording when this is called).
|
|
3747
3748
|
*/
|
|
3748
3749
|
enableTracking() {
|
|
3749
3750
|
this.trackingDisabled = false;
|
|
3750
3751
|
if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
|
|
3751
3752
|
localStorage.removeItem(_TrackerSdk.TRACKING_DISABLED_KEY);
|
|
3752
3753
|
}
|
|
3753
|
-
console.log("Brainfish tracking re-enabled. Refresh page for full effect.");
|
|
3754
3754
|
}
|
|
3755
3755
|
/**
|
|
3756
3756
|
* Returns whether privacy-sensitive tracking is currently disabled.
|
|
@@ -24416,7 +24416,7 @@ class Recorder {
|
|
|
24416
24416
|
};
|
|
24417
24417
|
this.stop = null;
|
|
24418
24418
|
}
|
|
24419
|
-
static mockImplementation(
|
|
24419
|
+
static mockImplementation(_arg0) {
|
|
24420
24420
|
throw new Error("Method not implemented.");
|
|
24421
24421
|
}
|
|
24422
24422
|
start() {
|
|
@@ -24501,7 +24501,7 @@ class RecordingManager {
|
|
|
24501
24501
|
}
|
|
24502
24502
|
}
|
|
24503
24503
|
if (this.isClick(event)) {
|
|
24504
|
-
|
|
24504
|
+
const clickedNode = record.mirror.getNode(event.data.id);
|
|
24505
24505
|
if (clickedNode && this.nodeIsInteresting(clickedNode)) {
|
|
24506
24506
|
event["conversionData"] = {};
|
|
24507
24507
|
event.conversionData.eventType = "click";
|
|
@@ -25005,7 +25005,7 @@ function canDiscover(recordingBlocklist, allowLocalhostRecording) {
|
|
|
25005
25005
|
if (matchFn(currentPath)) {
|
|
25006
25006
|
return false;
|
|
25007
25007
|
}
|
|
25008
|
-
} catch
|
|
25008
|
+
} catch {
|
|
25009
25009
|
if (pattern === currentPath) {
|
|
25010
25010
|
return false;
|
|
25011
25011
|
}
|
|
@@ -25185,7 +25185,7 @@ function toCamelCase(str) {
|
|
|
25185
25185
|
($1) => $1.toUpperCase().replace("-", "").replace("_", "")
|
|
25186
25186
|
);
|
|
25187
25187
|
}
|
|
25188
|
-
const VERSION = "0.0.
|
|
25188
|
+
const VERSION = "0.0.32";
|
|
25189
25189
|
class Tracker extends TrackerSdk {
|
|
25190
25190
|
constructor(options) {
|
|
25191
25191
|
super({
|
|
@@ -25199,7 +25199,10 @@ class Tracker extends TrackerSdk {
|
|
|
25199
25199
|
__publicField(this, "sessionManager", SessionManager.getInstance());
|
|
25200
25200
|
__publicField(this, "recordingBlocklist", []);
|
|
25201
25201
|
__publicField(this, "isRecordingActive", false);
|
|
25202
|
+
__publicField(this, "isRecordingInitializing", false);
|
|
25202
25203
|
__publicField(this, "onFirstScreenViewTracked", null);
|
|
25204
|
+
__publicField(this, "outgoingLinksAttached", false);
|
|
25205
|
+
__publicField(this, "attributesAttached", false);
|
|
25203
25206
|
this.options = options;
|
|
25204
25207
|
this.agent = new Agent();
|
|
25205
25208
|
this.recordingBlocklist = options.recordingOptions?.blocklist ?? options.recordingBlocklist ?? [];
|
|
@@ -25212,9 +25215,7 @@ class Tracker extends TrackerSdk {
|
|
|
25212
25215
|
this.trackOutgoingLinks();
|
|
25213
25216
|
}
|
|
25214
25217
|
if (this.options.enableRecording && !trackingDisabled) {
|
|
25215
|
-
this.
|
|
25216
|
-
this.initializeRecordingWithSessionId();
|
|
25217
|
-
};
|
|
25218
|
+
this.deferRecordingUntilFirstScreenView();
|
|
25218
25219
|
}
|
|
25219
25220
|
if (this.options.trackScreenViews) {
|
|
25220
25221
|
this.trackScreenViews();
|
|
@@ -25232,9 +25233,10 @@ class Tracker extends TrackerSdk {
|
|
|
25232
25233
|
return typeof document === "undefined";
|
|
25233
25234
|
}
|
|
25234
25235
|
trackOutgoingLinks() {
|
|
25235
|
-
if (this.isServer()) {
|
|
25236
|
+
if (this.isServer() || this.outgoingLinksAttached) {
|
|
25236
25237
|
return;
|
|
25237
25238
|
}
|
|
25239
|
+
this.outgoingLinksAttached = true;
|
|
25238
25240
|
document.addEventListener("click", (event) => {
|
|
25239
25241
|
const target = event.target;
|
|
25240
25242
|
const link = target.closest("a");
|
|
@@ -25279,9 +25281,10 @@ class Tracker extends TrackerSdk {
|
|
|
25279
25281
|
}
|
|
25280
25282
|
}
|
|
25281
25283
|
trackAttributes() {
|
|
25282
|
-
if (this.isServer()) {
|
|
25284
|
+
if (this.isServer() || this.attributesAttached) {
|
|
25283
25285
|
return;
|
|
25284
25286
|
}
|
|
25287
|
+
this.attributesAttached = true;
|
|
25285
25288
|
document.addEventListener("click", (event) => {
|
|
25286
25289
|
const target = event.target;
|
|
25287
25290
|
const btn = target.closest("button");
|
|
@@ -25350,6 +25353,10 @@ class Tracker extends TrackerSdk {
|
|
|
25350
25353
|
});
|
|
25351
25354
|
}
|
|
25352
25355
|
async initializeRecordingWithSessionId() {
|
|
25356
|
+
if (this.isRecordingInitializing) {
|
|
25357
|
+
return;
|
|
25358
|
+
}
|
|
25359
|
+
this.isRecordingInitializing = true;
|
|
25353
25360
|
try {
|
|
25354
25361
|
const sessionId = await super.getSessionId();
|
|
25355
25362
|
if (this.isTrackingDisabled()) {
|
|
@@ -25369,6 +25376,8 @@ class Tracker extends TrackerSdk {
|
|
|
25369
25376
|
}
|
|
25370
25377
|
} catch (error) {
|
|
25371
25378
|
console.warn("Error initializing ambient learning:", error);
|
|
25379
|
+
} finally {
|
|
25380
|
+
this.isRecordingInitializing = false;
|
|
25372
25381
|
}
|
|
25373
25382
|
}
|
|
25374
25383
|
sendScreenViewEvent(props) {
|
|
@@ -25379,24 +25388,49 @@ class Tracker extends TrackerSdk {
|
|
|
25379
25388
|
this.onFirstScreenViewTracked = null;
|
|
25380
25389
|
}
|
|
25381
25390
|
}
|
|
25391
|
+
deferRecordingUntilFirstScreenView() {
|
|
25392
|
+
if (this.options.enableRecording) {
|
|
25393
|
+
this.onFirstScreenViewTracked = () => {
|
|
25394
|
+
this.initializeRecordingWithSessionId();
|
|
25395
|
+
};
|
|
25396
|
+
}
|
|
25397
|
+
}
|
|
25382
25398
|
/**
|
|
25383
25399
|
* Disables privacy-sensitive tracking features and stops active recording.
|
|
25384
25400
|
*/
|
|
25385
25401
|
disableTracking() {
|
|
25386
25402
|
super.disableTracking();
|
|
25387
|
-
|
|
25403
|
+
this.onFirstScreenViewTracked = null;
|
|
25404
|
+
console.log("Brainfish tracking has been disabled.");
|
|
25388
25405
|
if (this.isRecordingActive) {
|
|
25389
25406
|
this.agent.stop();
|
|
25390
25407
|
this.isRecordingActive = false;
|
|
25408
|
+
console.log("Brainfish has stopped ambient learning");
|
|
25391
25409
|
}
|
|
25392
25410
|
}
|
|
25393
25411
|
/**
|
|
25394
|
-
* Re-enables privacy-sensitive tracking features.
|
|
25395
|
-
*
|
|
25412
|
+
* Re-enables privacy-sensitive tracking features (outgoing links, attributes, recording).
|
|
25413
|
+
* Takes effect immediately; no page refresh required.
|
|
25396
25414
|
*/
|
|
25397
25415
|
enableTracking() {
|
|
25398
25416
|
super.enableTracking();
|
|
25399
|
-
|
|
25417
|
+
if (this.isServer()) {
|
|
25418
|
+
return;
|
|
25419
|
+
}
|
|
25420
|
+
if (this.options.trackOutgoingLinks && !this.outgoingLinksAttached) {
|
|
25421
|
+
this.trackOutgoingLinks();
|
|
25422
|
+
}
|
|
25423
|
+
if (this.options.trackAttributes && !this.attributesAttached) {
|
|
25424
|
+
this.trackAttributes();
|
|
25425
|
+
}
|
|
25426
|
+
if (this.options.enableRecording && !this.isRecordingActive && !this.isRecordingInitializing) {
|
|
25427
|
+
this.deferRecordingUntilFirstScreenView();
|
|
25428
|
+
if (this.options.trackScreenViews) {
|
|
25429
|
+
this.lastPath = "";
|
|
25430
|
+
this.screenView();
|
|
25431
|
+
}
|
|
25432
|
+
}
|
|
25433
|
+
console.log("Brainfish tracking re-enabled.");
|
|
25400
25434
|
}
|
|
25401
25435
|
}
|
|
25402
25436
|
((window2) => {
|
package/dist/tracker.es.js.gz
CHANGED
|
Binary file
|