@kitbase/analytics 0.1.6 → 0.1.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/README.md +3 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lite.js +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -346,6 +346,13 @@ interface AnalyticsConfig$1 {
|
|
|
346
346
|
* @default true
|
|
347
347
|
*/
|
|
348
348
|
autoTrackPageViews?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Track pageviews on bfcache restore (browser back/forward in MPAs).
|
|
351
|
+
* When enabled, a pageview is sent when the page is restored from the
|
|
352
|
+
* browser's back-forward cache (the `pageshow` event with `persisted`).
|
|
353
|
+
* @default true
|
|
354
|
+
*/
|
|
355
|
+
trackBfcacheRestore?: boolean;
|
|
349
356
|
/**
|
|
350
357
|
* Enable automatic outbound link click tracking
|
|
351
358
|
* Tracks when users click links to external domains
|
|
@@ -541,6 +548,13 @@ interface AnalyticsConfig {
|
|
|
541
548
|
* @default true
|
|
542
549
|
*/
|
|
543
550
|
autoTrackPageViews?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Track pageviews on bfcache restore (browser back/forward in MPAs).
|
|
553
|
+
* When enabled, a pageview is sent when the page is restored from the
|
|
554
|
+
* browser's back-forward cache (the `pageshow` event with `persisted`).
|
|
555
|
+
* @default true
|
|
556
|
+
*/
|
|
557
|
+
trackBfcacheRestore?: boolean;
|
|
544
558
|
/**
|
|
545
559
|
* Enable automatic outbound link click tracking
|
|
546
560
|
* Tracks when users click links to external domains
|
|
@@ -1147,6 +1161,7 @@ declare class PageViewPlugin implements KitbasePlugin {
|
|
|
1147
1161
|
private ctx;
|
|
1148
1162
|
private active;
|
|
1149
1163
|
private popstateListener;
|
|
1164
|
+
private pageshowListener;
|
|
1150
1165
|
setup(ctx: PluginContext): void | false;
|
|
1151
1166
|
teardown(): void;
|
|
1152
1167
|
get methods(): {
|
package/dist/index.d.ts
CHANGED
|
@@ -346,6 +346,13 @@ interface AnalyticsConfig$1 {
|
|
|
346
346
|
* @default true
|
|
347
347
|
*/
|
|
348
348
|
autoTrackPageViews?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Track pageviews on bfcache restore (browser back/forward in MPAs).
|
|
351
|
+
* When enabled, a pageview is sent when the page is restored from the
|
|
352
|
+
* browser's back-forward cache (the `pageshow` event with `persisted`).
|
|
353
|
+
* @default true
|
|
354
|
+
*/
|
|
355
|
+
trackBfcacheRestore?: boolean;
|
|
349
356
|
/**
|
|
350
357
|
* Enable automatic outbound link click tracking
|
|
351
358
|
* Tracks when users click links to external domains
|
|
@@ -541,6 +548,13 @@ interface AnalyticsConfig {
|
|
|
541
548
|
* @default true
|
|
542
549
|
*/
|
|
543
550
|
autoTrackPageViews?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Track pageviews on bfcache restore (browser back/forward in MPAs).
|
|
553
|
+
* When enabled, a pageview is sent when the page is restored from the
|
|
554
|
+
* browser's back-forward cache (the `pageshow` event with `persisted`).
|
|
555
|
+
* @default true
|
|
556
|
+
*/
|
|
557
|
+
trackBfcacheRestore?: boolean;
|
|
544
558
|
/**
|
|
545
559
|
* Enable automatic outbound link click tracking
|
|
546
560
|
* Tracks when users click links to external domains
|
|
@@ -1147,6 +1161,7 @@ declare class PageViewPlugin implements KitbasePlugin {
|
|
|
1147
1161
|
private ctx;
|
|
1148
1162
|
private active;
|
|
1149
1163
|
private popstateListener;
|
|
1164
|
+
private pageshowListener;
|
|
1150
1165
|
setup(ctx: PluginContext): void | false;
|
|
1151
1166
|
teardown(): void;
|
|
1152
1167
|
get methods(): {
|
package/dist/index.js
CHANGED
|
@@ -1459,6 +1459,7 @@ var PageViewPlugin = class {
|
|
|
1459
1459
|
ctx;
|
|
1460
1460
|
active = false;
|
|
1461
1461
|
popstateListener = null;
|
|
1462
|
+
pageshowListener = null;
|
|
1462
1463
|
setup(ctx) {
|
|
1463
1464
|
if (typeof window === "undefined") return false;
|
|
1464
1465
|
this.ctx = ctx;
|
|
@@ -1485,6 +1486,14 @@ var PageViewPlugin = class {
|
|
|
1485
1486
|
}
|
|
1486
1487
|
};
|
|
1487
1488
|
window.addEventListener("popstate", this.popstateListener);
|
|
1489
|
+
if (ctx.config.trackBfcacheRestore !== false) {
|
|
1490
|
+
this.pageshowListener = (e) => {
|
|
1491
|
+
if (e.persisted && this.active) {
|
|
1492
|
+
this.trackPageView().catch((err) => ctx.log("Failed to track page view (bfcache)", err));
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
window.addEventListener("pageshow", this.pageshowListener);
|
|
1496
|
+
}
|
|
1488
1497
|
ctx.log("Auto page view tracking enabled");
|
|
1489
1498
|
}
|
|
1490
1499
|
teardown() {
|
|
@@ -1493,6 +1502,10 @@ var PageViewPlugin = class {
|
|
|
1493
1502
|
window.removeEventListener("popstate", this.popstateListener);
|
|
1494
1503
|
this.popstateListener = null;
|
|
1495
1504
|
}
|
|
1505
|
+
if (this.pageshowListener) {
|
|
1506
|
+
window.removeEventListener("pageshow", this.pageshowListener);
|
|
1507
|
+
this.pageshowListener = null;
|
|
1508
|
+
}
|
|
1496
1509
|
}
|
|
1497
1510
|
get methods() {
|
|
1498
1511
|
return {
|