@brainfish-ai/web-tracker 0.0.23 → 0.0.24
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 +10 -0
- 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.d.ts +1 -1
- package/dist/tracker.es.js +72 -9
- 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.d.ts
CHANGED
package/dist/tracker.es.js
CHANGED
|
@@ -3468,7 +3468,7 @@ var NudgeCTABlockType;
|
|
|
3468
3468
|
NudgeCTABlockType2["Button"] = "button";
|
|
3469
3469
|
NudgeCTABlockType2["Link"] = "link";
|
|
3470
3470
|
})(NudgeCTABlockType || (NudgeCTABlockType = {}));
|
|
3471
|
-
class
|
|
3471
|
+
const _TrackerSdk = class _TrackerSdk {
|
|
3472
3472
|
constructor(options) {
|
|
3473
3473
|
__publicField(this, "options");
|
|
3474
3474
|
__publicField(this, "client");
|
|
@@ -3480,6 +3480,7 @@ class TrackerSdk {
|
|
|
3480
3480
|
__publicField(this, "eventListeners", {});
|
|
3481
3481
|
// this set is used to prevent showing the same nudge multiple times in a short period
|
|
3482
3482
|
__publicField(this, "recentNudgeIds", new TTLSet(1e3));
|
|
3483
|
+
__publicField(this, "trackingDisabled", false);
|
|
3483
3484
|
this.options = options;
|
|
3484
3485
|
const query = {
|
|
3485
3486
|
sdk_name: options.sdk || "node",
|
|
@@ -3500,6 +3501,9 @@ class TrackerSdk {
|
|
|
3500
3501
|
version: options.sdkVersion || ""
|
|
3501
3502
|
}
|
|
3502
3503
|
});
|
|
3504
|
+
if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
|
|
3505
|
+
this.trackingDisabled = localStorage.getItem(_TrackerSdk.TRACKING_DISABLED_KEY) === "true";
|
|
3506
|
+
}
|
|
3503
3507
|
this.setupIncomingPayloadHandler();
|
|
3504
3508
|
}
|
|
3505
3509
|
// placeholder for future use
|
|
@@ -3552,6 +3556,9 @@ class TrackerSdk {
|
|
|
3552
3556
|
if (this.options.disabled) {
|
|
3553
3557
|
return Promise.resolve();
|
|
3554
3558
|
}
|
|
3559
|
+
if (this.trackingDisabled) {
|
|
3560
|
+
return Promise.resolve();
|
|
3561
|
+
}
|
|
3555
3562
|
if (this.options.filter && !this.options.filter(payload)) {
|
|
3556
3563
|
return Promise.resolve();
|
|
3557
3564
|
}
|
|
@@ -3637,6 +3644,9 @@ class TrackerSdk {
|
|
|
3637
3644
|
if (this.options.disabled) {
|
|
3638
3645
|
return Promise.resolve(null);
|
|
3639
3646
|
}
|
|
3647
|
+
if (this.trackingDisabled) {
|
|
3648
|
+
return Promise.resolve(null);
|
|
3649
|
+
}
|
|
3640
3650
|
const payload = {
|
|
3641
3651
|
type: "event.record",
|
|
3642
3652
|
payload: {
|
|
@@ -3686,7 +3696,37 @@ class TrackerSdk {
|
|
|
3686
3696
|
});
|
|
3687
3697
|
this.queue = [];
|
|
3688
3698
|
}
|
|
3689
|
-
|
|
3699
|
+
/**
|
|
3700
|
+
* Disables privacy-sensitive tracking features (recording, screenshots).
|
|
3701
|
+
* This setting persists across page reloads via localStorage.
|
|
3702
|
+
*/
|
|
3703
|
+
disableTracking() {
|
|
3704
|
+
this.trackingDisabled = true;
|
|
3705
|
+
if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
|
|
3706
|
+
localStorage.setItem(_TrackerSdk.TRACKING_DISABLED_KEY, "true");
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
/**
|
|
3710
|
+
* Re-enables privacy-sensitive tracking features (recording, screenshots).
|
|
3711
|
+
* Note: Full effect requires a page reload to restart recording.
|
|
3712
|
+
*/
|
|
3713
|
+
enableTracking() {
|
|
3714
|
+
this.trackingDisabled = false;
|
|
3715
|
+
if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
|
|
3716
|
+
localStorage.removeItem(_TrackerSdk.TRACKING_DISABLED_KEY);
|
|
3717
|
+
}
|
|
3718
|
+
console.log("Brainfish tracking re-enabled. Refresh page for full effect.");
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* Returns whether privacy-sensitive tracking is currently disabled.
|
|
3722
|
+
* @returns true if tracking is disabled, false otherwise
|
|
3723
|
+
*/
|
|
3724
|
+
isTrackingDisabled() {
|
|
3725
|
+
return this.trackingDisabled;
|
|
3726
|
+
}
|
|
3727
|
+
};
|
|
3728
|
+
__publicField(_TrackerSdk, "TRACKING_DISABLED_KEY", "bf_tracking_disabled");
|
|
3729
|
+
let TrackerSdk = _TrackerSdk;
|
|
3690
3730
|
var cache = {
|
|
3691
3731
|
image: /* @__PURE__ */ new Map(),
|
|
3692
3732
|
background: /* @__PURE__ */ new Map(),
|
|
@@ -38440,9 +38480,8 @@ function toCamelCase(str) {
|
|
|
38440
38480
|
($1) => $1.toUpperCase().replace("-", "").replace("_", "")
|
|
38441
38481
|
);
|
|
38442
38482
|
}
|
|
38443
|
-
const VERSION = "0.0.
|
|
38483
|
+
const VERSION = "0.0.24";
|
|
38444
38484
|
class Tracker extends TrackerSdk {
|
|
38445
|
-
// 750KB
|
|
38446
38485
|
constructor(options) {
|
|
38447
38486
|
super({
|
|
38448
38487
|
sdk: "web",
|
|
@@ -38455,6 +38494,8 @@ class Tracker extends TrackerSdk {
|
|
|
38455
38494
|
__publicField(this, "sessionManager", SessionManager.getInstance());
|
|
38456
38495
|
__publicField(this, "recordingBlocklist", []);
|
|
38457
38496
|
__publicField(this, "MAX_SCREENSHOT_SIZE", 750 * 1024);
|
|
38497
|
+
// 750KB
|
|
38498
|
+
__publicField(this, "isRecordingActive", false);
|
|
38458
38499
|
this.options = options;
|
|
38459
38500
|
this.agent = new Agent();
|
|
38460
38501
|
this.recordingBlocklist = options.recordingBlocklist || [];
|
|
@@ -38462,17 +38503,19 @@ class Tracker extends TrackerSdk {
|
|
|
38462
38503
|
this.setGlobalProperties({
|
|
38463
38504
|
__referrer: document.referrer
|
|
38464
38505
|
});
|
|
38465
|
-
|
|
38506
|
+
const trackingDisabled = this.isTrackingDisabled();
|
|
38507
|
+
if (this.options.trackOutgoingLinks && !trackingDisabled) {
|
|
38466
38508
|
this.trackOutgoingLinks();
|
|
38467
38509
|
}
|
|
38468
38510
|
if (this.options.trackScreenViews) {
|
|
38469
38511
|
this.trackScreenViews();
|
|
38470
38512
|
}
|
|
38471
|
-
if (this.options.trackAttributes) {
|
|
38513
|
+
if (this.options.trackAttributes && !trackingDisabled) {
|
|
38472
38514
|
this.trackAttributes();
|
|
38473
38515
|
}
|
|
38474
|
-
if (this.options.enableRecording && this.options._allowScreenRecording) {
|
|
38516
|
+
if (this.options.enableRecording && this.options._allowScreenRecording && !trackingDisabled) {
|
|
38475
38517
|
this.startRecording();
|
|
38518
|
+
this.isRecordingActive = true;
|
|
38476
38519
|
console.log("Brainfish has started ambient learning");
|
|
38477
38520
|
}
|
|
38478
38521
|
}
|
|
@@ -38587,7 +38630,7 @@ class Tracker extends TrackerSdk {
|
|
|
38587
38630
|
__path: path,
|
|
38588
38631
|
__title: document.title
|
|
38589
38632
|
};
|
|
38590
|
-
if (this.options.enableRecording && canDiscover(
|
|
38633
|
+
if (this.options.enableRecording && !this.isTrackingDisabled() && canDiscover(
|
|
38591
38634
|
this.recordingBlocklist,
|
|
38592
38635
|
this.options._allowLocalhostRecording
|
|
38593
38636
|
)) {
|
|
@@ -38625,6 +38668,26 @@ class Tracker extends TrackerSdk {
|
|
|
38625
38668
|
super.track("screen_view", props);
|
|
38626
38669
|
this.sessionManager.updateLastScreenViewEventTime();
|
|
38627
38670
|
}
|
|
38671
|
+
/**
|
|
38672
|
+
* Disables privacy-sensitive tracking features and stops active recording.
|
|
38673
|
+
*/
|
|
38674
|
+
disableTracking() {
|
|
38675
|
+
super.disableTracking();
|
|
38676
|
+
if (this.isRecordingActive) {
|
|
38677
|
+
if (this.agent.recordingManager.recorder.stop) {
|
|
38678
|
+
this.agent.recordingManager.recorder.stop();
|
|
38679
|
+
}
|
|
38680
|
+
this.isRecordingActive = false;
|
|
38681
|
+
console.log("Brainfish has stopped ambient learning");
|
|
38682
|
+
}
|
|
38683
|
+
}
|
|
38684
|
+
/**
|
|
38685
|
+
* Re-enables privacy-sensitive tracking features.
|
|
38686
|
+
* Note: Full effect requires a page reload to restart recording and event listeners.
|
|
38687
|
+
*/
|
|
38688
|
+
enableTracking() {
|
|
38689
|
+
super.enableTracking();
|
|
38690
|
+
}
|
|
38628
38691
|
}
|
|
38629
38692
|
((window2) => {
|
|
38630
38693
|
if (window2.BrainfishAnalytics && "q" in window2.BrainfishAnalytics) {
|
|
@@ -38644,7 +38707,7 @@ class Tracker extends TrackerSdk {
|
|
|
38644
38707
|
window2.BrainfishAnalytics = (t, ...args) => {
|
|
38645
38708
|
const fn = tracker[t] ? tracker[t].bind(tracker) : void 0;
|
|
38646
38709
|
if (typeof fn === "function") {
|
|
38647
|
-
fn(...args);
|
|
38710
|
+
return fn(...args);
|
|
38648
38711
|
} else {
|
|
38649
38712
|
console.warn(`Method ${t} does not exist on BrainfishAnalytics`);
|
|
38650
38713
|
}
|
package/dist/tracker.es.js.gz
CHANGED
|
Binary file
|