swetrix 2.2.1 → 2.3.1
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 +2 -2
- package/dist/esnext/Lib.d.ts +6 -0
- package/dist/esnext/Lib.js +9 -6
- package/dist/esnext/Lib.js.map +1 -1
- package/dist/swetrix.cjs.js +314 -305
- package/dist/swetrix.es5.js +314 -305
- package/dist/swetrix.js +1 -1
- package/dist/swetrix.orig.js +314 -305
- package/package.json +15 -15
- package/src/Lib.ts +20 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swetrix",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "The JavaScript analytics client for Swetrix Analytics",
|
|
5
5
|
"main": "dist/swetrix.cjs.js",
|
|
6
6
|
"module": "dist/swetrix.es5.js",
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
"origbrowser": "dist/swetrix.orig.js",
|
|
9
9
|
"esnext": "dist/esnext/index.js",
|
|
10
10
|
"typings": "dist/esnext/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prebuild": "rimraf dist",
|
|
13
|
+
"prepublish": "npm run build",
|
|
14
|
+
"build": "rollup -c && tsc -p tsconfig.esnext.json",
|
|
15
|
+
"start": "rollup -c -w",
|
|
16
|
+
"tsc": "tsc -p tsconfig.esnext.json"
|
|
17
|
+
},
|
|
11
18
|
"keywords": [
|
|
12
19
|
"swetrix",
|
|
13
20
|
"analytics",
|
|
@@ -27,25 +34,18 @@
|
|
|
27
34
|
},
|
|
28
35
|
"homepage": "https://swetrix.com/docs",
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"tslib": "^2.
|
|
37
|
+
"@types/node": "^20.8.6",
|
|
38
|
+
"tslib": "^2.6.2"
|
|
32
39
|
},
|
|
33
40
|
"devDependencies": {
|
|
34
|
-
"@rollup/plugin-commonjs": "^
|
|
35
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
41
|
+
"@rollup/plugin-commonjs": "^25.0.5",
|
|
42
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
36
43
|
"rimraf": "^4.4.1",
|
|
37
44
|
"rollup": "^2.79.1",
|
|
38
45
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
39
46
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
40
|
-
"rollup-plugin-typescript2": "^0.
|
|
47
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
41
48
|
"rollup-plugin-uglify": "^6.0.4",
|
|
42
|
-
"typescript": "^5.
|
|
43
|
-
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"prebuild": "rimraf dist",
|
|
46
|
-
"prepublish": "npm run build",
|
|
47
|
-
"build": "rollup -c && tsc -p tsconfig.esnext.json",
|
|
48
|
-
"start": "rollup -c -w",
|
|
49
|
-
"tsc": "tsc -p tsconfig.esnext.json"
|
|
49
|
+
"typescript": "^5.2.2"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
package/src/Lib.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface TrackEventOptions {
|
|
|
30
30
|
|
|
31
31
|
/** If set to `true`, only 1 event with the same ID will be saved per user session. */
|
|
32
32
|
unique?: boolean
|
|
33
|
+
|
|
34
|
+
/** Event-related metadata object with string values. */
|
|
35
|
+
meta?: {
|
|
36
|
+
[key: string]: string
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
/**
|
|
@@ -58,6 +63,9 @@ export interface PageViewsOptions {
|
|
|
58
63
|
/** A list of Regular Expressions or string pathes to ignore. */
|
|
59
64
|
ignore?: Array<string | RegExp>
|
|
60
65
|
|
|
66
|
+
/** Do not send paths from ignore list to API. If set to `false`, the page view information will be sent to the Swetrix API, but the page will be displayed as a 'Redacted page' in the dashboard. */
|
|
67
|
+
doNotAnonymise?: boolean
|
|
68
|
+
|
|
61
69
|
/** Do not send Heartbeat requests to the server. */
|
|
62
70
|
noHeartbeat?: boolean
|
|
63
71
|
|
|
@@ -178,7 +186,6 @@ export class Lib {
|
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
188
|
|
|
181
|
-
|
|
182
189
|
private heartbeat(): void {
|
|
183
190
|
if (!this.pageViewsOptions?.heartbeatOnBackground && document.visibilityState === 'hidden') {
|
|
184
191
|
return
|
|
@@ -219,11 +226,13 @@ export class Lib {
|
|
|
219
226
|
// Assuming that this function is called in trackPage and this.activePage is not overwritten by new value yet
|
|
220
227
|
// That method of getting previous page works for SPA websites
|
|
221
228
|
if (this.activePage) {
|
|
222
|
-
|
|
229
|
+
const shouldIgnore = this.checkIgnore(this.activePage)
|
|
230
|
+
|
|
231
|
+
if (shouldIgnore && this.pageViewsOptions?.doNotAnonymise) {
|
|
223
232
|
return null
|
|
224
233
|
}
|
|
225
234
|
|
|
226
|
-
return this.activePage
|
|
235
|
+
return shouldIgnore ? null : this.activePage
|
|
227
236
|
}
|
|
228
237
|
|
|
229
238
|
// Checking if URL is supported by the browser (for example, IE11 does not support it)
|
|
@@ -245,11 +254,13 @@ export class Lib {
|
|
|
245
254
|
return null
|
|
246
255
|
}
|
|
247
256
|
|
|
248
|
-
|
|
257
|
+
const shouldIgnore = this.checkIgnore(pathname)
|
|
258
|
+
|
|
259
|
+
if (shouldIgnore && this.pageViewsOptions?.doNotAnonymise) {
|
|
249
260
|
return null
|
|
250
261
|
}
|
|
251
262
|
|
|
252
|
-
return pathname
|
|
263
|
+
return shouldIgnore ? null : pathname
|
|
253
264
|
} catch {
|
|
254
265
|
return null
|
|
255
266
|
}
|
|
@@ -262,7 +273,9 @@ export class Lib {
|
|
|
262
273
|
if (!this.pageData) return
|
|
263
274
|
this.pageData.path = pg
|
|
264
275
|
|
|
265
|
-
|
|
276
|
+
const shouldIgnore = this.checkIgnore(pg)
|
|
277
|
+
|
|
278
|
+
if (shouldIgnore && this.pageViewsOptions?.doNotAnonymise) return
|
|
266
279
|
|
|
267
280
|
const perf = this.getPerformanceStats()
|
|
268
281
|
|
|
@@ -281,7 +294,7 @@ export class Lib {
|
|
|
281
294
|
me: getUTMMedium(),
|
|
282
295
|
ca: getUTMCampaign(),
|
|
283
296
|
unique,
|
|
284
|
-
pg,
|
|
297
|
+
pg: shouldIgnore ? null : pg,
|
|
285
298
|
perf,
|
|
286
299
|
prev,
|
|
287
300
|
}
|