@yuanze_dev/tracker 0.5.0 → 0.6.0
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/autocapture.js +8 -8
- package/dist/context.js +8 -8
- package/dist/events.d.ts +8 -8
- package/dist/node.js +1 -1
- package/dist/react.js +3 -3
- package/package.json +1 -1
package/dist/autocapture.js
CHANGED
|
@@ -39,9 +39,9 @@ export function setupAutocapture(tracker, options = {}) {
|
|
|
39
39
|
return;
|
|
40
40
|
const { captureClicks = true, allow = DEFAULT_ALLOW, deny = DEFAULT_DENY, sampleRate = 1, maxTextLength = 64, } = options;
|
|
41
41
|
const sendPageview = () => tracker.track("$pageview", {
|
|
42
|
-
url: redactUrl(location.pathname + location.search),
|
|
43
|
-
title: document.title,
|
|
44
|
-
referrer: redactUrl(document.referrer),
|
|
42
|
+
$url: redactUrl(location.pathname + location.search),
|
|
43
|
+
$title: document.title,
|
|
44
|
+
$referrer: redactUrl(document.referrer),
|
|
45
45
|
});
|
|
46
46
|
sendPageview();
|
|
47
47
|
const patch = (key) => {
|
|
@@ -82,16 +82,16 @@ export function setupAutocapture(tracker, options = {}) {
|
|
|
82
82
|
if (sampleRate < 1 && Math.random() >= sampleRate)
|
|
83
83
|
return;
|
|
84
84
|
const props = {
|
|
85
|
-
tag: el.tagName.toLowerCase(),
|
|
86
|
-
selector: elementSelector(el),
|
|
87
|
-
url: location.pathname,
|
|
85
|
+
$tag: el.tagName.toLowerCase(),
|
|
86
|
+
$selector: elementSelector(el),
|
|
87
|
+
$url: location.pathname,
|
|
88
88
|
};
|
|
89
89
|
const text = sanitizeText(el.textContent || "", maxTextLength);
|
|
90
90
|
if (text)
|
|
91
|
-
props
|
|
91
|
+
props.$text = text;
|
|
92
92
|
const href = el.getAttribute("href");
|
|
93
93
|
if (href && !href.startsWith("javascript:"))
|
|
94
|
-
props
|
|
94
|
+
props.$href = redactUrl(href);
|
|
95
95
|
tracker.trackUnsafe("$autocapture", props);
|
|
96
96
|
}, true);
|
|
97
97
|
}
|
package/dist/context.js
CHANGED
|
@@ -38,18 +38,18 @@ export function collectEnvContext() {
|
|
|
38
38
|
if (typeof navigator === "undefined")
|
|
39
39
|
return ctx;
|
|
40
40
|
const ua = navigator.userAgent || "";
|
|
41
|
-
ctx
|
|
42
|
-
ctx
|
|
41
|
+
ctx["$os"] = detectOS(ua);
|
|
42
|
+
ctx["$browser"] = detectBrowser(ua);
|
|
43
43
|
if (navigator.language)
|
|
44
|
-
ctx
|
|
44
|
+
ctx["$language"] = navigator.language;
|
|
45
45
|
if (typeof screen !== "undefined" && screen.width) {
|
|
46
|
-
ctx
|
|
47
|
-
ctx
|
|
46
|
+
ctx["$screen_width"] = screen.width;
|
|
47
|
+
ctx["$screen_height"] = screen.height;
|
|
48
48
|
}
|
|
49
49
|
if (typeof document !== "undefined" && document.referrer) {
|
|
50
|
-
ctx
|
|
50
|
+
ctx["$referrer"] = document.referrer;
|
|
51
51
|
try {
|
|
52
|
-
ctx
|
|
52
|
+
ctx["$referrer_domain"] = new URL(document.referrer).hostname;
|
|
53
53
|
}
|
|
54
54
|
catch {
|
|
55
55
|
}
|
|
@@ -60,7 +60,7 @@ export function collectEnvContext() {
|
|
|
60
60
|
for (const k of UTM_KEYS) {
|
|
61
61
|
const v = params.get(k);
|
|
62
62
|
if (v)
|
|
63
|
-
ctx[k] = v;
|
|
63
|
+
ctx[`$${k}`] = v;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
catch {
|
package/dist/events.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export interface SystemEvents {
|
|
2
2
|
$pageview: {
|
|
3
|
-
url: string;
|
|
4
|
-
title?: string;
|
|
5
|
-
referrer?: string;
|
|
3
|
+
$url: string;
|
|
4
|
+
$title?: string;
|
|
5
|
+
$referrer?: string;
|
|
6
6
|
};
|
|
7
7
|
$autocapture: {
|
|
8
|
-
tag: string;
|
|
9
|
-
selector: string;
|
|
10
|
-
url: string;
|
|
11
|
-
text?: string;
|
|
12
|
-
href?: string;
|
|
8
|
+
$tag: string;
|
|
9
|
+
$selector: string;
|
|
10
|
+
$url: string;
|
|
11
|
+
$text?: string;
|
|
12
|
+
$href?: string;
|
|
13
13
|
};
|
|
14
14
|
$experiment_exposure: {
|
|
15
15
|
experiment: string;
|
package/dist/node.js
CHANGED
|
@@ -13,7 +13,7 @@ export function machineDistinctId(salt = "yuanze-tracker") {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export function nodeEnvContext() {
|
|
16
|
-
return { os: platform(), runtime: `node/${process.versions.node}` };
|
|
16
|
+
return { $os: platform(), $runtime: `node/${process.versions.node}` };
|
|
17
17
|
}
|
|
18
18
|
export function createTracker(options) {
|
|
19
19
|
const { envContext = true, flushOnExit = true, ...rest } = options;
|
package/dist/react.js
CHANGED
|
@@ -49,9 +49,9 @@ export function useRouteTracking(path) {
|
|
|
49
49
|
return;
|
|
50
50
|
last.current = path;
|
|
51
51
|
tracker.track("$pageview", {
|
|
52
|
-
url: path,
|
|
53
|
-
title: typeof document !== "undefined" ? document.title : undefined,
|
|
54
|
-
referrer: typeof document !== "undefined" ? document.referrer : undefined,
|
|
52
|
+
$url: path,
|
|
53
|
+
$title: typeof document !== "undefined" ? document.title : undefined,
|
|
54
|
+
$referrer: typeof document !== "undefined" ? document.referrer : undefined,
|
|
55
55
|
});
|
|
56
56
|
}, [tracker, path]);
|
|
57
57
|
}
|