@indiebob/tracker 0.2.3 → 0.3.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/CHANGELOG.md +80 -0
- package/README.md +125 -6
- package/dist/index.cjs +880 -2
- package/dist/index.d.mts +69 -11
- package/dist/index.d.ts +69 -11
- package/dist/index.global.js +3 -3
- package/dist/index.js +878 -2
- package/dist/server.d.mts +8 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +5 -7
- package/dist/server.mjs +5 -7
- package/dist/vue.cjs +904 -2
- package/dist/vue.global.js +3 -3
- package/dist/vue.js +900 -2
- package/package.json +11 -9
package/dist/server.d.mts
CHANGED
|
@@ -42,7 +42,15 @@ interface TrackerConfig {
|
|
|
42
42
|
formSubmit?: boolean;
|
|
43
43
|
/** Track clicks on outbound links. Default: true */
|
|
44
44
|
outboundClicks?: boolean;
|
|
45
|
+
/** Track clicks on links to files (pdf, zip, dmg, …) as `file_download`. Default: true */
|
|
46
|
+
fileDownloads?: boolean;
|
|
45
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Treat the URL hash as part of the page path (for `/#/route` routers):
|
|
50
|
+
* a hash-only change becomes a pageview and the hash is reported in the
|
|
51
|
+
* path. Default: false (a hash-only change is not a new page).
|
|
52
|
+
*/
|
|
53
|
+
hashMode?: boolean;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -42,7 +42,15 @@ interface TrackerConfig {
|
|
|
42
42
|
formSubmit?: boolean;
|
|
43
43
|
/** Track clicks on outbound links. Default: true */
|
|
44
44
|
outboundClicks?: boolean;
|
|
45
|
+
/** Track clicks on links to files (pdf, zip, dmg, …) as `file_download`. Default: true */
|
|
46
|
+
fileDownloads?: boolean;
|
|
45
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Treat the URL hash as part of the page path (for `/#/route` routers):
|
|
50
|
+
* a hash-only change becomes a pageview and the hash is reported in the
|
|
51
|
+
* path. Default: false (a hash-only change is not a new page).
|
|
52
|
+
*/
|
|
53
|
+
hashMode?: boolean;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/**
|
package/dist/server.js
CHANGED
|
@@ -14,16 +14,13 @@ function resolveConfig(input) {
|
|
|
14
14
|
debug: input.debug ?? false,
|
|
15
15
|
respectDnt: input.respectDnt ?? true,
|
|
16
16
|
respectGpc: input.respectGpc ?? true,
|
|
17
|
-
autoDetect: input.autoDetect ?? true
|
|
17
|
+
autoDetect: input.autoDetect ?? true,
|
|
18
|
+
hashMode: input.hashMode ?? false
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// src/core/transport.ts
|
|
22
23
|
var MAX_RETRIES = 3;
|
|
23
|
-
var RETRY_DELAYS = [1e3, 2e3, 4e3];
|
|
24
|
-
async function sleep(ms) {
|
|
25
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
26
|
-
}
|
|
27
24
|
async function sendBatchServer(payload, config) {
|
|
28
25
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
29
26
|
try {
|
|
@@ -36,7 +33,7 @@ async function sendBatchServer(payload, config) {
|
|
|
36
33
|
if (res.status >= 400 && res.status < 500) return false;
|
|
37
34
|
} catch {
|
|
38
35
|
}
|
|
39
|
-
if (attempt < MAX_RETRIES - 1) await
|
|
36
|
+
if (attempt < MAX_RETRIES - 1) await new Promise((resolve) => setTimeout(resolve, 1e3 << attempt));
|
|
40
37
|
}
|
|
41
38
|
return false;
|
|
42
39
|
}
|
|
@@ -69,6 +66,7 @@ var IndieBobServer = class _IndieBobServer {
|
|
|
69
66
|
buildEvent(type, extras) {
|
|
70
67
|
return {
|
|
71
68
|
v: 1,
|
|
69
|
+
id: generateId(),
|
|
72
70
|
projectId: this.config.projectId,
|
|
73
71
|
type,
|
|
74
72
|
anonymousId: `server_${generateId()}`,
|
|
@@ -80,7 +78,7 @@ var IndieBobServer = class _IndieBobServer {
|
|
|
80
78
|
device: { width: 0, height: 0, type: "desktop" },
|
|
81
79
|
locale: "en",
|
|
82
80
|
timezone: "UTC",
|
|
83
|
-
sdkVersion: "0.
|
|
81
|
+
sdkVersion: "0.3.0"
|
|
84
82
|
},
|
|
85
83
|
event: extras.event,
|
|
86
84
|
properties: extras.properties,
|
package/dist/server.mjs
CHANGED
|
@@ -12,16 +12,13 @@ function resolveConfig(input) {
|
|
|
12
12
|
debug: input.debug ?? false,
|
|
13
13
|
respectDnt: input.respectDnt ?? true,
|
|
14
14
|
respectGpc: input.respectGpc ?? true,
|
|
15
|
-
autoDetect: input.autoDetect ?? true
|
|
15
|
+
autoDetect: input.autoDetect ?? true,
|
|
16
|
+
hashMode: input.hashMode ?? false
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
// src/core/transport.ts
|
|
20
21
|
var MAX_RETRIES = 3;
|
|
21
|
-
var RETRY_DELAYS = [1e3, 2e3, 4e3];
|
|
22
|
-
async function sleep(ms) {
|
|
23
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
24
|
-
}
|
|
25
22
|
async function sendBatchServer(payload, config) {
|
|
26
23
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
27
24
|
try {
|
|
@@ -34,7 +31,7 @@ async function sendBatchServer(payload, config) {
|
|
|
34
31
|
if (res.status >= 400 && res.status < 500) return false;
|
|
35
32
|
} catch {
|
|
36
33
|
}
|
|
37
|
-
if (attempt < MAX_RETRIES - 1) await
|
|
34
|
+
if (attempt < MAX_RETRIES - 1) await new Promise((resolve) => setTimeout(resolve, 1e3 << attempt));
|
|
38
35
|
}
|
|
39
36
|
return false;
|
|
40
37
|
}
|
|
@@ -67,6 +64,7 @@ var IndieBobServer = class _IndieBobServer {
|
|
|
67
64
|
buildEvent(type, extras) {
|
|
68
65
|
return {
|
|
69
66
|
v: 1,
|
|
67
|
+
id: generateId(),
|
|
70
68
|
projectId: this.config.projectId,
|
|
71
69
|
type,
|
|
72
70
|
anonymousId: `server_${generateId()}`,
|
|
@@ -78,7 +76,7 @@ var IndieBobServer = class _IndieBobServer {
|
|
|
78
76
|
device: { width: 0, height: 0, type: "desktop" },
|
|
79
77
|
locale: "en",
|
|
80
78
|
timezone: "UTC",
|
|
81
|
-
sdkVersion: "0.
|
|
79
|
+
sdkVersion: "0.3.0"
|
|
82
80
|
},
|
|
83
81
|
event: extras.event,
|
|
84
82
|
properties: extras.properties,
|