@whotracksme/reporting 7.3.0 โ 7.4.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/CHANGELOG.md +28 -0
- package/package.json +3 -2
- package/reporting/example/index.js +2 -2
- package/reporting/package.json +5 -5
- package/reporting/snapshots/0001/snapshot.json +14 -14
- package/reporting/snapshots/0002/snapshot.json +14 -14
- package/reporting/snapshots/0003/snapshot.json +6 -6
- package/reporting/snapshots/0004/snapshot.json +6 -6
- package/reporting/snapshots/0005/snapshot.json +14 -14
- package/reporting/snapshots/0006/snapshot.json +16 -16
- package/reporting/src/alive-message-generator.js +29 -32
- package/reporting/src/communication-proxy/attrack-message-handler.js +1 -1
- package/reporting/src/errors.js +6 -0
- package/reporting/src/job-scheduler.js +81 -14
- package/reporting/src/reporting.js +1 -8
- package/reporting/src/request/index.js +28 -4
- package/reporting/test/alive-message-generator.spec.js +12 -20
- package/reporting/test/job-scheduler.spec.js +118 -25
- package/reporting/test/reporting.spec.js +0 -1
- package/reporting/test/request/index.spec.js +0 -1
- package/reporting/test/request/index.test.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# v7.4.1 (Tue Jul 29 2025)
|
|
2
|
+
|
|
3
|
+
#### ๐ Bug Fix
|
|
4
|
+
|
|
5
|
+
- Job scheduling: tweaked scheduling and misconfiguration detection [#163](https://github.com/whotracksme/webextension-packages/pull/163) ([@philipp-classen](https://github.com/philipp-classen))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Philipp Claรen ([@philipp-classen](https://github.com/philipp-classen))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v7.4.0 (Tue Jul 01 2025)
|
|
14
|
+
|
|
15
|
+
#### ๐ Enhancement
|
|
16
|
+
|
|
17
|
+
- Remove browserInfoProvider dependency [#162](https://github.com/whotracksme/webextension-packages/pull/162) ([@philipp-classen](https://github.com/philipp-classen))
|
|
18
|
+
|
|
19
|
+
#### ๐ Internal
|
|
20
|
+
|
|
21
|
+
- Uses the staging patterns for the example extension [#161](https://github.com/whotracksme/webextension-packages/pull/161) ([@philipp-classen](https://github.com/philipp-classen))
|
|
22
|
+
|
|
23
|
+
#### Authors: 1
|
|
24
|
+
|
|
25
|
+
- Philipp Claรen ([@philipp-classen](https://github.com/philipp-classen))
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
1
29
|
# v7.3.0 (Wed May 21 2025)
|
|
2
30
|
|
|
3
31
|
#### ๐ Enhancement
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whotracksme/reporting",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"scripts": {
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"idb": "^7.1.1",
|
|
47
47
|
"linkedom": "^0.18.10",
|
|
48
48
|
"pako": "^2.1.0",
|
|
49
|
-
"tldts-experimental": "^6.0.11"
|
|
49
|
+
"tldts-experimental": "^6.0.11",
|
|
50
|
+
"bowser": "^2.11.0"
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -73,7 +73,8 @@ const communication = {
|
|
|
73
73
|
const config = {
|
|
74
74
|
url: {
|
|
75
75
|
ALLOWED_COUNTRY_CODES: ['de'],
|
|
76
|
-
PATTERNS_URL:
|
|
76
|
+
PATTERNS_URL:
|
|
77
|
+
'https://cdn2.ghostery.com/staging-patterns/wtm-chrome-desktop/patterns.json',
|
|
77
78
|
CONFIG_URL: 'https://api.ghostery.net/api/v1/config',
|
|
78
79
|
},
|
|
79
80
|
request: {
|
|
@@ -88,7 +89,6 @@ const urlReporter = new UrlReporter({
|
|
|
88
89
|
storage: createStorage(),
|
|
89
90
|
connectDatabase: createStorage,
|
|
90
91
|
communication,
|
|
91
|
-
browserInfoProvider: async () => ({ browser: 'test' }),
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
const requestReporter = new RequestReporter(config.request, {
|
package/reporting/package.json
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"@rollup/plugin-commonjs": "^23.0.0",
|
|
18
18
|
"@rollup/plugin-json": "^5.0.0",
|
|
19
19
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
20
|
-
"chai": "^
|
|
21
|
-
"chai-as-promised": "^
|
|
20
|
+
"chai": "^5.2.0",
|
|
21
|
+
"chai-as-promised": "^8.0.1",
|
|
22
22
|
"fake-indexeddb": "^6.0.0",
|
|
23
23
|
"fast-check": "^3.3.0",
|
|
24
24
|
"karma": "^6.4.1",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"karma-mocha-reporter": "^2.2.5",
|
|
29
29
|
"karma-rollup-preprocessor": "^7.0.8",
|
|
30
30
|
"karma-sinon": "^1.0.5",
|
|
31
|
-
"mocha": "^
|
|
31
|
+
"mocha": "^11.7.1",
|
|
32
32
|
"rollup": "^2.79.1",
|
|
33
33
|
"rollup-plugin-copy": "^3.5.0",
|
|
34
34
|
"rollup-plugin-polyfill-node": "^0.8.0",
|
|
35
35
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
36
|
-
"sinon": "^
|
|
37
|
-
"sinon-chai": "^
|
|
36
|
+
"sinon": "^21.0.0",
|
|
37
|
+
"sinon-chai": "^4.0.0",
|
|
38
38
|
"sinon-chrome": "^3.0.1",
|
|
39
39
|
"web-ext": "^8.2.0"
|
|
40
40
|
},
|
|
@@ -1619,7 +1619,7 @@
|
|
|
1619
1619
|
},
|
|
1620
1620
|
"ts": "",
|
|
1621
1621
|
"type": "wtm.request",
|
|
1622
|
-
"userAgent": "
|
|
1622
|
+
"userAgent": ""
|
|
1623
1623
|
},
|
|
1624
1624
|
{
|
|
1625
1625
|
"action": "wtm.attrack.tp_events",
|
|
@@ -3251,7 +3251,7 @@
|
|
|
3251
3251
|
},
|
|
3252
3252
|
"ts": "",
|
|
3253
3253
|
"type": "wtm.request",
|
|
3254
|
-
"userAgent": "
|
|
3254
|
+
"userAgent": ""
|
|
3255
3255
|
},
|
|
3256
3256
|
{
|
|
3257
3257
|
"action": "wtm.attrack.tokensv2",
|
|
@@ -3272,7 +3272,7 @@
|
|
|
3272
3272
|
},
|
|
3273
3273
|
"ts": "",
|
|
3274
3274
|
"type": "wtm.request",
|
|
3275
|
-
"userAgent": "
|
|
3275
|
+
"userAgent": ""
|
|
3276
3276
|
},
|
|
3277
3277
|
{
|
|
3278
3278
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3462,7 +3462,7 @@
|
|
|
3462
3462
|
},
|
|
3463
3463
|
"ts": "",
|
|
3464
3464
|
"type": "wtm.request",
|
|
3465
|
-
"userAgent": "
|
|
3465
|
+
"userAgent": ""
|
|
3466
3466
|
},
|
|
3467
3467
|
{
|
|
3468
3468
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3652,7 +3652,7 @@
|
|
|
3652
3652
|
},
|
|
3653
3653
|
"ts": "",
|
|
3654
3654
|
"type": "wtm.request",
|
|
3655
|
-
"userAgent": "
|
|
3655
|
+
"userAgent": ""
|
|
3656
3656
|
},
|
|
3657
3657
|
{
|
|
3658
3658
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3678,7 +3678,7 @@
|
|
|
3678
3678
|
},
|
|
3679
3679
|
"ts": "",
|
|
3680
3680
|
"type": "wtm.request",
|
|
3681
|
-
"userAgent": "
|
|
3681
|
+
"userAgent": ""
|
|
3682
3682
|
},
|
|
3683
3683
|
{
|
|
3684
3684
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3704,7 +3704,7 @@
|
|
|
3704
3704
|
},
|
|
3705
3705
|
"ts": "",
|
|
3706
3706
|
"type": "wtm.request",
|
|
3707
|
-
"userAgent": "
|
|
3707
|
+
"userAgent": ""
|
|
3708
3708
|
},
|
|
3709
3709
|
{
|
|
3710
3710
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3730,7 +3730,7 @@
|
|
|
3730
3730
|
},
|
|
3731
3731
|
"ts": "",
|
|
3732
3732
|
"type": "wtm.request",
|
|
3733
|
-
"userAgent": "
|
|
3733
|
+
"userAgent": ""
|
|
3734
3734
|
},
|
|
3735
3735
|
{
|
|
3736
3736
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3756,7 +3756,7 @@
|
|
|
3756
3756
|
},
|
|
3757
3757
|
"ts": "",
|
|
3758
3758
|
"type": "wtm.request",
|
|
3759
|
-
"userAgent": "
|
|
3759
|
+
"userAgent": ""
|
|
3760
3760
|
},
|
|
3761
3761
|
{
|
|
3762
3762
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3782,7 +3782,7 @@
|
|
|
3782
3782
|
},
|
|
3783
3783
|
"ts": "",
|
|
3784
3784
|
"type": "wtm.request",
|
|
3785
|
-
"userAgent": "
|
|
3785
|
+
"userAgent": ""
|
|
3786
3786
|
},
|
|
3787
3787
|
{
|
|
3788
3788
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3808,7 +3808,7 @@
|
|
|
3808
3808
|
},
|
|
3809
3809
|
"ts": "",
|
|
3810
3810
|
"type": "wtm.request",
|
|
3811
|
-
"userAgent": "
|
|
3811
|
+
"userAgent": ""
|
|
3812
3812
|
},
|
|
3813
3813
|
{
|
|
3814
3814
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3834,7 +3834,7 @@
|
|
|
3834
3834
|
},
|
|
3835
3835
|
"ts": "",
|
|
3836
3836
|
"type": "wtm.request",
|
|
3837
|
-
"userAgent": "
|
|
3837
|
+
"userAgent": ""
|
|
3838
3838
|
},
|
|
3839
3839
|
{
|
|
3840
3840
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3860,6 +3860,6 @@
|
|
|
3860
3860
|
},
|
|
3861
3861
|
"ts": "",
|
|
3862
3862
|
"type": "wtm.request",
|
|
3863
|
-
"userAgent": "
|
|
3863
|
+
"userAgent": ""
|
|
3864
3864
|
}
|
|
3865
|
-
]
|
|
3865
|
+
]
|
|
@@ -1108,7 +1108,7 @@
|
|
|
1108
1108
|
},
|
|
1109
1109
|
"ts": "",
|
|
1110
1110
|
"type": "wtm.request",
|
|
1111
|
-
"userAgent": "
|
|
1111
|
+
"userAgent": ""
|
|
1112
1112
|
},
|
|
1113
1113
|
{
|
|
1114
1114
|
"action": "wtm.attrack.tp_events",
|
|
@@ -2225,7 +2225,7 @@
|
|
|
2225
2225
|
},
|
|
2226
2226
|
"ts": "",
|
|
2227
2227
|
"type": "wtm.request",
|
|
2228
|
-
"userAgent": "
|
|
2228
|
+
"userAgent": ""
|
|
2229
2229
|
},
|
|
2230
2230
|
{
|
|
2231
2231
|
"action": "wtm.attrack.tokensv2",
|
|
@@ -2246,7 +2246,7 @@
|
|
|
2246
2246
|
},
|
|
2247
2247
|
"ts": "",
|
|
2248
2248
|
"type": "wtm.request",
|
|
2249
|
-
"userAgent": "
|
|
2249
|
+
"userAgent": ""
|
|
2250
2250
|
},
|
|
2251
2251
|
{
|
|
2252
2252
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2272,7 +2272,7 @@
|
|
|
2272
2272
|
},
|
|
2273
2273
|
"ts": "",
|
|
2274
2274
|
"type": "wtm.request",
|
|
2275
|
-
"userAgent": "
|
|
2275
|
+
"userAgent": ""
|
|
2276
2276
|
},
|
|
2277
2277
|
{
|
|
2278
2278
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2298,7 +2298,7 @@
|
|
|
2298
2298
|
},
|
|
2299
2299
|
"ts": "",
|
|
2300
2300
|
"type": "wtm.request",
|
|
2301
|
-
"userAgent": "
|
|
2301
|
+
"userAgent": ""
|
|
2302
2302
|
},
|
|
2303
2303
|
{
|
|
2304
2304
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2324,7 +2324,7 @@
|
|
|
2324
2324
|
},
|
|
2325
2325
|
"ts": "",
|
|
2326
2326
|
"type": "wtm.request",
|
|
2327
|
-
"userAgent": "
|
|
2327
|
+
"userAgent": ""
|
|
2328
2328
|
},
|
|
2329
2329
|
{
|
|
2330
2330
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2350,7 +2350,7 @@
|
|
|
2350
2350
|
},
|
|
2351
2351
|
"ts": "",
|
|
2352
2352
|
"type": "wtm.request",
|
|
2353
|
-
"userAgent": "
|
|
2353
|
+
"userAgent": ""
|
|
2354
2354
|
},
|
|
2355
2355
|
{
|
|
2356
2356
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2376,7 +2376,7 @@
|
|
|
2376
2376
|
},
|
|
2377
2377
|
"ts": "",
|
|
2378
2378
|
"type": "wtm.request",
|
|
2379
|
-
"userAgent": "
|
|
2379
|
+
"userAgent": ""
|
|
2380
2380
|
},
|
|
2381
2381
|
{
|
|
2382
2382
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2402,7 +2402,7 @@
|
|
|
2402
2402
|
},
|
|
2403
2403
|
"ts": "",
|
|
2404
2404
|
"type": "wtm.request",
|
|
2405
|
-
"userAgent": "
|
|
2405
|
+
"userAgent": ""
|
|
2406
2406
|
},
|
|
2407
2407
|
{
|
|
2408
2408
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2428,7 +2428,7 @@
|
|
|
2428
2428
|
},
|
|
2429
2429
|
"ts": "",
|
|
2430
2430
|
"type": "wtm.request",
|
|
2431
|
-
"userAgent": "
|
|
2431
|
+
"userAgent": ""
|
|
2432
2432
|
},
|
|
2433
2433
|
{
|
|
2434
2434
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2454,7 +2454,7 @@
|
|
|
2454
2454
|
},
|
|
2455
2455
|
"ts": "",
|
|
2456
2456
|
"type": "wtm.request",
|
|
2457
|
-
"userAgent": "
|
|
2457
|
+
"userAgent": ""
|
|
2458
2458
|
},
|
|
2459
2459
|
{
|
|
2460
2460
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2480,7 +2480,7 @@
|
|
|
2480
2480
|
},
|
|
2481
2481
|
"ts": "",
|
|
2482
2482
|
"type": "wtm.request",
|
|
2483
|
-
"userAgent": "
|
|
2483
|
+
"userAgent": ""
|
|
2484
2484
|
},
|
|
2485
2485
|
{
|
|
2486
2486
|
"action": "wtm.attrack.keysv2",
|
|
@@ -2506,6 +2506,6 @@
|
|
|
2506
2506
|
},
|
|
2507
2507
|
"ts": "",
|
|
2508
2508
|
"type": "wtm.request",
|
|
2509
|
-
"userAgent": "
|
|
2509
|
+
"userAgent": ""
|
|
2510
2510
|
}
|
|
2511
|
-
]
|
|
2511
|
+
]
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
},
|
|
197
197
|
"ts": "",
|
|
198
198
|
"type": "wtm.request",
|
|
199
|
-
"userAgent": "
|
|
199
|
+
"userAgent": ""
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"action": "wtm.attrack.tp_events",
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
},
|
|
399
399
|
"ts": "",
|
|
400
400
|
"type": "wtm.request",
|
|
401
|
-
"userAgent": "
|
|
401
|
+
"userAgent": ""
|
|
402
402
|
},
|
|
403
403
|
{
|
|
404
404
|
"action": "wtm.attrack.tokensv2",
|
|
@@ -419,7 +419,7 @@
|
|
|
419
419
|
},
|
|
420
420
|
"ts": "",
|
|
421
421
|
"type": "wtm.request",
|
|
422
|
-
"userAgent": "
|
|
422
|
+
"userAgent": ""
|
|
423
423
|
},
|
|
424
424
|
{
|
|
425
425
|
"action": "wtm.attrack.keysv2",
|
|
@@ -609,7 +609,7 @@
|
|
|
609
609
|
},
|
|
610
610
|
"ts": "",
|
|
611
611
|
"type": "wtm.request",
|
|
612
|
-
"userAgent": "
|
|
612
|
+
"userAgent": ""
|
|
613
613
|
},
|
|
614
614
|
{
|
|
615
615
|
"action": "wtm.attrack.keysv2",
|
|
@@ -799,6 +799,6 @@
|
|
|
799
799
|
},
|
|
800
800
|
"ts": "",
|
|
801
801
|
"type": "wtm.request",
|
|
802
|
-
"userAgent": "
|
|
802
|
+
"userAgent": ""
|
|
803
803
|
}
|
|
804
|
-
]
|
|
804
|
+
]
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
},
|
|
184
184
|
"ts": "",
|
|
185
185
|
"type": "wtm.request",
|
|
186
|
-
"userAgent": "
|
|
186
|
+
"userAgent": ""
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
"action": "wtm.attrack.tp_events",
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
},
|
|
370
370
|
"ts": "",
|
|
371
371
|
"type": "wtm.request",
|
|
372
|
-
"userAgent": "
|
|
372
|
+
"userAgent": ""
|
|
373
373
|
},
|
|
374
374
|
{
|
|
375
375
|
"action": "wtm.attrack.tokensv2",
|
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
},
|
|
391
391
|
"ts": "",
|
|
392
392
|
"type": "wtm.request",
|
|
393
|
-
"userAgent": "
|
|
393
|
+
"userAgent": ""
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
"action": "wtm.attrack.keysv2",
|
|
@@ -572,7 +572,7 @@
|
|
|
572
572
|
},
|
|
573
573
|
"ts": "",
|
|
574
574
|
"type": "wtm.request",
|
|
575
|
-
"userAgent": "
|
|
575
|
+
"userAgent": ""
|
|
576
576
|
},
|
|
577
577
|
{
|
|
578
578
|
"action": "wtm.attrack.keysv2",
|
|
@@ -754,6 +754,6 @@
|
|
|
754
754
|
},
|
|
755
755
|
"ts": "",
|
|
756
756
|
"type": "wtm.request",
|
|
757
|
-
"userAgent": "
|
|
757
|
+
"userAgent": ""
|
|
758
758
|
}
|
|
759
|
-
]
|
|
759
|
+
]
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
},
|
|
131
131
|
"ts": "",
|
|
132
132
|
"type": "wtm.request",
|
|
133
|
-
"userAgent": "
|
|
133
|
+
"userAgent": ""
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
"action": "wtm.attrack.tp_events",
|
|
@@ -252,7 +252,7 @@
|
|
|
252
252
|
},
|
|
253
253
|
"ts": "",
|
|
254
254
|
"type": "wtm.request",
|
|
255
|
-
"userAgent": "
|
|
255
|
+
"userAgent": ""
|
|
256
256
|
},
|
|
257
257
|
{
|
|
258
258
|
"action": "wtm.attrack.tp_events",
|
|
@@ -693,7 +693,7 @@
|
|
|
693
693
|
},
|
|
694
694
|
"ts": "",
|
|
695
695
|
"type": "wtm.request",
|
|
696
|
-
"userAgent": "
|
|
696
|
+
"userAgent": ""
|
|
697
697
|
},
|
|
698
698
|
{
|
|
699
699
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1142,7 +1142,7 @@
|
|
|
1142
1142
|
},
|
|
1143
1143
|
"ts": "",
|
|
1144
1144
|
"type": "wtm.request",
|
|
1145
|
-
"userAgent": "
|
|
1145
|
+
"userAgent": ""
|
|
1146
1146
|
},
|
|
1147
1147
|
{
|
|
1148
1148
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1275,7 +1275,7 @@
|
|
|
1275
1275
|
},
|
|
1276
1276
|
"ts": "",
|
|
1277
1277
|
"type": "wtm.request",
|
|
1278
|
-
"userAgent": "
|
|
1278
|
+
"userAgent": ""
|
|
1279
1279
|
},
|
|
1280
1280
|
{
|
|
1281
1281
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1397,7 +1397,7 @@
|
|
|
1397
1397
|
},
|
|
1398
1398
|
"ts": "",
|
|
1399
1399
|
"type": "wtm.request",
|
|
1400
|
-
"userAgent": "
|
|
1400
|
+
"userAgent": ""
|
|
1401
1401
|
},
|
|
1402
1402
|
{
|
|
1403
1403
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1838,7 +1838,7 @@
|
|
|
1838
1838
|
},
|
|
1839
1839
|
"ts": "",
|
|
1840
1840
|
"type": "wtm.request",
|
|
1841
|
-
"userAgent": "
|
|
1841
|
+
"userAgent": ""
|
|
1842
1842
|
},
|
|
1843
1843
|
{
|
|
1844
1844
|
"action": "wtm.attrack.tp_events",
|
|
@@ -2287,7 +2287,7 @@
|
|
|
2287
2287
|
},
|
|
2288
2288
|
"ts": "",
|
|
2289
2289
|
"type": "wtm.request",
|
|
2290
|
-
"userAgent": "
|
|
2290
|
+
"userAgent": ""
|
|
2291
2291
|
},
|
|
2292
2292
|
{
|
|
2293
2293
|
"action": "wtm.attrack.tokensv2",
|
|
@@ -2308,7 +2308,7 @@
|
|
|
2308
2308
|
},
|
|
2309
2309
|
"ts": "",
|
|
2310
2310
|
"type": "wtm.request",
|
|
2311
|
-
"userAgent": "
|
|
2311
|
+
"userAgent": ""
|
|
2312
2312
|
},
|
|
2313
2313
|
{
|
|
2314
2314
|
"action": "wtm.attrack.keysv2",
|
|
@@ -4590,7 +4590,7 @@
|
|
|
4590
4590
|
},
|
|
4591
4591
|
"ts": "",
|
|
4592
4592
|
"type": "wtm.request",
|
|
4593
|
-
"userAgent": "
|
|
4593
|
+
"userAgent": ""
|
|
4594
4594
|
},
|
|
4595
4595
|
{
|
|
4596
4596
|
"action": "wtm.attrack.keysv2",
|
|
@@ -6876,7 +6876,7 @@
|
|
|
6876
6876
|
},
|
|
6877
6877
|
"ts": "",
|
|
6878
6878
|
"type": "wtm.request",
|
|
6879
|
-
"userAgent": "
|
|
6879
|
+
"userAgent": ""
|
|
6880
6880
|
},
|
|
6881
6881
|
{
|
|
6882
6882
|
"action": "wtm.attrack.keysv2",
|
|
@@ -6902,7 +6902,7 @@
|
|
|
6902
6902
|
},
|
|
6903
6903
|
"ts": "",
|
|
6904
6904
|
"type": "wtm.request",
|
|
6905
|
-
"userAgent": "
|
|
6905
|
+
"userAgent": ""
|
|
6906
6906
|
},
|
|
6907
6907
|
{
|
|
6908
6908
|
"action": "wtm.attrack.keysv2",
|
|
@@ -6928,6 +6928,6 @@
|
|
|
6928
6928
|
},
|
|
6929
6929
|
"ts": "",
|
|
6930
6930
|
"type": "wtm.request",
|
|
6931
|
-
"userAgent": "
|
|
6931
|
+
"userAgent": ""
|
|
6932
6932
|
}
|
|
6933
|
-
]
|
|
6933
|
+
]
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
},
|
|
112
112
|
"ts": "",
|
|
113
113
|
"type": "wtm.request",
|
|
114
|
-
"userAgent": "
|
|
114
|
+
"userAgent": ""
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
"action": "wtm.attrack.tp_events",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
},
|
|
238
238
|
"ts": "",
|
|
239
239
|
"type": "wtm.request",
|
|
240
|
-
"userAgent": "
|
|
240
|
+
"userAgent": ""
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"action": "wtm.attrack.tp_events",
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
},
|
|
409
409
|
"ts": "",
|
|
410
410
|
"type": "wtm.request",
|
|
411
|
-
"userAgent": "
|
|
411
|
+
"userAgent": ""
|
|
412
412
|
},
|
|
413
413
|
{
|
|
414
414
|
"action": "wtm.attrack.tp_events",
|
|
@@ -526,7 +526,7 @@
|
|
|
526
526
|
},
|
|
527
527
|
"ts": "",
|
|
528
528
|
"type": "wtm.request",
|
|
529
|
-
"userAgent": "
|
|
529
|
+
"userAgent": ""
|
|
530
530
|
},
|
|
531
531
|
{
|
|
532
532
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1006,7 +1006,7 @@
|
|
|
1006
1006
|
},
|
|
1007
1007
|
"ts": "",
|
|
1008
1008
|
"type": "wtm.request",
|
|
1009
|
-
"userAgent": "
|
|
1009
|
+
"userAgent": ""
|
|
1010
1010
|
},
|
|
1011
1011
|
{
|
|
1012
1012
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1120,7 +1120,7 @@
|
|
|
1120
1120
|
},
|
|
1121
1121
|
"ts": "",
|
|
1122
1122
|
"type": "wtm.request",
|
|
1123
|
-
"userAgent": "
|
|
1123
|
+
"userAgent": ""
|
|
1124
1124
|
},
|
|
1125
1125
|
{
|
|
1126
1126
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1246,7 +1246,7 @@
|
|
|
1246
1246
|
},
|
|
1247
1247
|
"ts": "",
|
|
1248
1248
|
"type": "wtm.request",
|
|
1249
|
-
"userAgent": "
|
|
1249
|
+
"userAgent": ""
|
|
1250
1250
|
},
|
|
1251
1251
|
{
|
|
1252
1252
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1417,7 +1417,7 @@
|
|
|
1417
1417
|
},
|
|
1418
1418
|
"ts": "",
|
|
1419
1419
|
"type": "wtm.request",
|
|
1420
|
-
"userAgent": "
|
|
1420
|
+
"userAgent": ""
|
|
1421
1421
|
},
|
|
1422
1422
|
{
|
|
1423
1423
|
"action": "wtm.attrack.tp_events",
|
|
@@ -1535,7 +1535,7 @@
|
|
|
1535
1535
|
},
|
|
1536
1536
|
"ts": "",
|
|
1537
1537
|
"type": "wtm.request",
|
|
1538
|
-
"userAgent": "
|
|
1538
|
+
"userAgent": ""
|
|
1539
1539
|
},
|
|
1540
1540
|
{
|
|
1541
1541
|
"action": "wtm.attrack.tp_events",
|
|
@@ -2015,7 +2015,7 @@
|
|
|
2015
2015
|
},
|
|
2016
2016
|
"ts": "",
|
|
2017
2017
|
"type": "wtm.request",
|
|
2018
|
-
"userAgent": "
|
|
2018
|
+
"userAgent": ""
|
|
2019
2019
|
},
|
|
2020
2020
|
{
|
|
2021
2021
|
"action": "wtm.attrack.tokensv2",
|
|
@@ -2036,7 +2036,7 @@
|
|
|
2036
2036
|
},
|
|
2037
2037
|
"ts": "",
|
|
2038
2038
|
"type": "wtm.request",
|
|
2039
|
-
"userAgent": "
|
|
2039
|
+
"userAgent": ""
|
|
2040
2040
|
},
|
|
2041
2041
|
{
|
|
2042
2042
|
"action": "wtm.attrack.keysv2",
|
|
@@ -3734,7 +3734,7 @@
|
|
|
3734
3734
|
},
|
|
3735
3735
|
"ts": "",
|
|
3736
3736
|
"type": "wtm.request",
|
|
3737
|
-
"userAgent": "
|
|
3737
|
+
"userAgent": ""
|
|
3738
3738
|
},
|
|
3739
3739
|
{
|
|
3740
3740
|
"action": "wtm.attrack.keysv2",
|
|
@@ -5432,7 +5432,7 @@
|
|
|
5432
5432
|
},
|
|
5433
5433
|
"ts": "",
|
|
5434
5434
|
"type": "wtm.request",
|
|
5435
|
-
"userAgent": "
|
|
5435
|
+
"userAgent": ""
|
|
5436
5436
|
},
|
|
5437
5437
|
{
|
|
5438
5438
|
"action": "wtm.attrack.keysv2",
|
|
@@ -5458,7 +5458,7 @@
|
|
|
5458
5458
|
},
|
|
5459
5459
|
"ts": "",
|
|
5460
5460
|
"type": "wtm.request",
|
|
5461
|
-
"userAgent": "
|
|
5461
|
+
"userAgent": ""
|
|
5462
5462
|
},
|
|
5463
5463
|
{
|
|
5464
5464
|
"action": "wtm.attrack.keysv2",
|
|
@@ -5484,6 +5484,6 @@
|
|
|
5484
5484
|
},
|
|
5485
5485
|
"ts": "",
|
|
5486
5486
|
"type": "wtm.request",
|
|
5487
|
-
"userAgent": "
|
|
5487
|
+
"userAgent": ""
|
|
5488
5488
|
}
|
|
5489
|
-
]
|
|
5489
|
+
]
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import logger from './logger';
|
|
13
|
-
import { requireParam, requireString
|
|
13
|
+
import { requireParam, requireString } from './utils';
|
|
14
|
+
import Bowser from 'bowser';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Responsible for generating information to be included in the "alive" message.
|
|
@@ -24,27 +25,21 @@ import { requireParam, requireString, lazyInitAsync } from './utils';
|
|
|
24
25
|
* breaks something on Windows.
|
|
25
26
|
*/
|
|
26
27
|
export default class AliveMessageGenerator {
|
|
27
|
-
constructor({
|
|
28
|
-
browserInfoProvider,
|
|
29
|
-
navigatorApi,
|
|
30
|
-
quorumChecker,
|
|
31
|
-
storage,
|
|
32
|
-
storageKey,
|
|
33
|
-
}) {
|
|
34
|
-
requireParam(browserInfoProvider);
|
|
28
|
+
constructor({ navigatorApi, quorumChecker, storage, storageKey }) {
|
|
35
29
|
this.quorumChecker = requireParam(quorumChecker);
|
|
36
30
|
this.storage = requireParam(storage);
|
|
37
31
|
this.storageKey = requireString(storageKey);
|
|
38
32
|
this.navigatorApi = navigatorApi || globalThis.navigator;
|
|
33
|
+
}
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
get staticConfig() {
|
|
36
|
+
this._staticConfig ||= this._generateBaseConfig();
|
|
37
|
+
return this._staticConfig;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
async generateMessage(ctry, hour) {
|
|
46
41
|
const config = {
|
|
47
|
-
...
|
|
42
|
+
...this.staticConfig,
|
|
48
43
|
ctry,
|
|
49
44
|
};
|
|
50
45
|
|
|
@@ -71,35 +66,37 @@ export default class AliveMessageGenerator {
|
|
|
71
66
|
browser: '',
|
|
72
67
|
version: '',
|
|
73
68
|
os: '',
|
|
69
|
+
platform: '',
|
|
70
|
+
engine: '',
|
|
74
71
|
language: '',
|
|
75
72
|
ctry: '--',
|
|
76
73
|
t: hour,
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
_generateBaseConfig(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
_generateBaseConfig() {
|
|
78
|
+
let browser, version, os, platform, engine;
|
|
79
|
+
const { language, userAgent } = this.navigatorApi;
|
|
80
|
+
if (userAgent) {
|
|
81
|
+
const browserInfo = Bowser.parse(userAgent);
|
|
82
|
+
browser = browserInfo.browser?.name;
|
|
83
|
+
os = browserInfo.os?.name;
|
|
84
|
+
platform = browserInfo.platform?.type;
|
|
85
|
+
engine = browserInfo.engine?.name;
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
'"navigator" API unavailable (should only happen when run in NodeJs 20 or lower)',
|
|
95
|
-
);
|
|
87
|
+
// extracts only the major version (e.g. "96.0.1" -> 96)
|
|
88
|
+
const majorVersion = parseInt(browserInfo.browser?.version, 10);
|
|
89
|
+
if (!isNaN(majorVersion)) {
|
|
90
|
+
version = String(majorVersion);
|
|
91
|
+
}
|
|
96
92
|
}
|
|
97
|
-
language = language || '';
|
|
98
93
|
|
|
99
94
|
return {
|
|
100
|
-
browser:
|
|
101
|
-
version, // major version
|
|
102
|
-
os:
|
|
95
|
+
browser: browser || '',
|
|
96
|
+
version: version || '', // major version
|
|
97
|
+
os: os || '',
|
|
98
|
+
platform: platform || '', // e.g. 'desktop'
|
|
99
|
+
engine: engine || '', // e.g. 'Blink'
|
|
103
100
|
language: language || '', // e.g. 'en-US'
|
|
104
101
|
};
|
|
105
102
|
}
|
package/reporting/src/errors.js
CHANGED
|
@@ -47,6 +47,12 @@ class PermanentError extends ExtendableError {
|
|
|
47
47
|
*/
|
|
48
48
|
export class BadJobError extends PermanentError {}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* For job handlers that are ill-formed (e.g. have missing or invalid fields
|
|
52
|
+
* in their configuration).
|
|
53
|
+
*/
|
|
54
|
+
export class BadJobHandlerError extends PermanentError {}
|
|
55
|
+
|
|
50
56
|
/**
|
|
51
57
|
* If trying to override HTTP headers, but the platform does not support it.
|
|
52
58
|
*/
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import logger from './logger';
|
|
13
13
|
import { randomBetween } from './random';
|
|
14
|
-
import { BadJobError } from './errors';
|
|
14
|
+
import { BadJobError, BadJobHandlerError } from './errors';
|
|
15
15
|
import SeqExecutor from './seq-executor';
|
|
16
16
|
import { equalityCanBeProven } from './utils';
|
|
17
17
|
import SelfCheck from './self-check';
|
|
@@ -55,21 +55,38 @@ class JobTester {
|
|
|
55
55
|
return jobEntries.splice(0, pos);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Computes the priority of a job. Smaller is of higher priority.
|
|
60
|
+
*
|
|
61
|
+
* When ordering jobs by their priority, the order should remain stable over time.
|
|
62
|
+
* Formally, if "p(t,j)" is the priority function for job "j" at a given time "t",
|
|
63
|
+
* the following property should hold:
|
|
64
|
+
*
|
|
65
|
+
* For all jobs j1,j2 and for all times t1, t2 with t2 > t1:
|
|
66
|
+
* ```
|
|
67
|
+
* p(t1,j1) <= p(t1,j2) ==> p(t2,j1) <= p(t2,j2)
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* Note: it automatically holds if p does not rely on the time. In other
|
|
71
|
+
* words, this is a sufficient, but not necessary condition:
|
|
72
|
+
* ```
|
|
73
|
+
* For all times t1, t2 and for all jobs j: p(t1,j) == p(t2,j)
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
59
76
|
computePriority(jobEntry) {
|
|
60
|
-
//
|
|
61
|
-
|
|
77
|
+
// This will order jobs primarily by the time when they become ready.
|
|
78
|
+
// It also guarantees that jobs that are ready will be sorted before
|
|
79
|
+
// jobs that are still blocked.
|
|
80
|
+
//
|
|
81
|
+
// To break ties between multiple jobs that are ready, it will run the
|
|
82
|
+
// oldest jobs first; thus, eliminating the possiblity of starvation.
|
|
83
|
+
//
|
|
84
|
+
// Note: preserves ordering, since the time is not used.
|
|
85
|
+
return Math.max(jobEntry._meta.createdAt, jobEntry._meta.readyAt);
|
|
62
86
|
}
|
|
63
87
|
|
|
64
88
|
compareJobsByPriority(jobEntry1, jobEntry2) {
|
|
65
|
-
|
|
66
|
-
return -1;
|
|
67
|
-
} else if (this.isJobReady(jobEntry2)) {
|
|
68
|
-
return 1;
|
|
69
|
-
}
|
|
70
|
-
const prio1 = this.computePriority(jobEntry1);
|
|
71
|
-
const prio2 = this.computePriority(jobEntry2);
|
|
72
|
-
return prio1 - prio2;
|
|
89
|
+
return this.computePriority(jobEntry1) - this.computePriority(jobEntry2);
|
|
73
90
|
}
|
|
74
91
|
|
|
75
92
|
sortJobs(jobEntries) {
|
|
@@ -166,6 +183,7 @@ export default class JobScheduler {
|
|
|
166
183
|
// TODO: maybe add a flag to control if failed jobs should be put in the dlq
|
|
167
184
|
// (and only added back if there was was a successful execution of that type before)
|
|
168
185
|
};
|
|
186
|
+
this._ensureValidHandlerConfig(this.defaultConfig);
|
|
169
187
|
this.handlerConfigs = {};
|
|
170
188
|
|
|
171
189
|
// Note: this data structure is intended to be in a format that can be
|
|
@@ -189,6 +207,9 @@ export default class JobScheduler {
|
|
|
189
207
|
}
|
|
190
208
|
|
|
191
209
|
registerHandler(type, handler, config = {}) {
|
|
210
|
+
const fullConfig = { ...this.defaultConfig, ...config };
|
|
211
|
+
this._ensureValidHandlerConfig(fullConfig);
|
|
212
|
+
|
|
192
213
|
if (this.active) {
|
|
193
214
|
logger.warn(
|
|
194
215
|
'Job handler for type',
|
|
@@ -202,12 +223,12 @@ export default class JobScheduler {
|
|
|
202
223
|
logger.warn('Redefining handler for type:', type);
|
|
203
224
|
}
|
|
204
225
|
this.handlers[type] = handler;
|
|
205
|
-
this.handlerConfigs[type] =
|
|
226
|
+
this.handlerConfigs[type] = fullConfig;
|
|
206
227
|
logger.debug(
|
|
207
228
|
'Registered job handler for',
|
|
208
229
|
type,
|
|
209
230
|
'with config:',
|
|
210
|
-
|
|
231
|
+
fullConfig,
|
|
211
232
|
);
|
|
212
233
|
this._resetPrecomputed();
|
|
213
234
|
}
|
|
@@ -846,6 +867,52 @@ export default class JobScheduler {
|
|
|
846
867
|
}
|
|
847
868
|
}
|
|
848
869
|
|
|
870
|
+
// Validates the config that is passed when registering job handlers.
|
|
871
|
+
_ensureValidHandlerConfig(config) {
|
|
872
|
+
if (!config) {
|
|
873
|
+
throw new BadJobHandlerError('Missing config');
|
|
874
|
+
}
|
|
875
|
+
let numCheckedKeys = 0;
|
|
876
|
+
const expectInt = (key, extraCheck) => {
|
|
877
|
+
if (!Number.isInteger(config[key])) {
|
|
878
|
+
throw new BadJobHandlerError(
|
|
879
|
+
`Expected field "${key}" to be an integer, but got: ${config[key]}`,
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
if (extraCheck && !extraCheck(config[key])) {
|
|
883
|
+
throw new BadJobHandlerError(
|
|
884
|
+
`Illegal value found in field "${key}": <<${config[key]}>>`,
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
numCheckedKeys += 1;
|
|
888
|
+
};
|
|
889
|
+
const expectBool = (key) => {
|
|
890
|
+
if (config[key] !== true && config[key] !== false) {
|
|
891
|
+
throw new BadJobHandlerError(
|
|
892
|
+
`Expected field "${key}" to be bool, but got: ${config[key]}`,
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
numCheckedKeys += 1;
|
|
896
|
+
};
|
|
897
|
+
const nonNegative = (x) => x >= 0;
|
|
898
|
+
|
|
899
|
+
expectInt('priority');
|
|
900
|
+
expectInt('ttlInMs', nonNegative);
|
|
901
|
+
expectInt('maxJobsTotal', nonNegative);
|
|
902
|
+
expectInt('cooldownInMs', nonNegative);
|
|
903
|
+
expectInt('maxAutoRetriesAfterError', nonNegative);
|
|
904
|
+
expectBool('autoRetryAfterError');
|
|
905
|
+
|
|
906
|
+
if (numCheckedKeys !== Object.keys(config).length) {
|
|
907
|
+
const unexpectedKeys = Object.keys(config).filter(
|
|
908
|
+
(key) => !Object.hasOwn(this.defaultConfig, key),
|
|
909
|
+
);
|
|
910
|
+
throw new BadJobHandlerError(
|
|
911
|
+
`Invalid config: found unexpected keys: [${unexpectedKeys.join(', ')}]`,
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
849
916
|
async selfChecks(check = new SelfCheck()) {
|
|
850
917
|
const restoredJobs = JSON.parse(JSON.stringify(this.jobQueues));
|
|
851
918
|
if (!equalityCanBeProven(this.jobQueues, restoredJobs)) {
|
|
@@ -38,13 +38,7 @@ import { BloomFilter } from './bloom-filters';
|
|
|
38
38
|
const SECOND = 1000;
|
|
39
39
|
|
|
40
40
|
export default class Reporting {
|
|
41
|
-
constructor({
|
|
42
|
-
config,
|
|
43
|
-
storage,
|
|
44
|
-
communication,
|
|
45
|
-
connectDatabase,
|
|
46
|
-
browserInfoProvider,
|
|
47
|
-
}) {
|
|
41
|
+
constructor({ config, storage, communication, connectDatabase }) {
|
|
48
42
|
// Defines whether Reporting is fully initialized and has permission
|
|
49
43
|
// to collect data.
|
|
50
44
|
this.isActive = false;
|
|
@@ -152,7 +146,6 @@ export default class Reporting {
|
|
|
152
146
|
});
|
|
153
147
|
|
|
154
148
|
const aliveMessageGenerator = new AliveMessageGenerator({
|
|
155
|
-
browserInfoProvider,
|
|
156
149
|
quorumChecker: this.quorumChecker,
|
|
157
150
|
storage,
|
|
158
151
|
storageKey: 'alive_config',
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import Bowser from 'bowser';
|
|
13
|
+
|
|
12
14
|
/* eslint-disable no-param-reassign */
|
|
13
15
|
import { isLocalIP } from '../network.js';
|
|
14
16
|
import Config from './config.js';
|
|
@@ -42,13 +44,14 @@ const DAY_CHANGE_INTERVAL = 20 * 1000;
|
|
|
42
44
|
const RECENTLY_MODIFIED_TTL = 30 * 1000;
|
|
43
45
|
|
|
44
46
|
export default class RequestReporter {
|
|
47
|
+
#userAgent;
|
|
48
|
+
|
|
45
49
|
constructor(
|
|
46
50
|
settings,
|
|
47
51
|
{
|
|
48
52
|
trustedClock,
|
|
49
53
|
countryProvider,
|
|
50
54
|
onMessageReady,
|
|
51
|
-
getBrowserInfo,
|
|
52
55
|
onTrackerInteraction = (event, state) => {
|
|
53
56
|
logger.info('Tracker', event, 'with url:', state.url);
|
|
54
57
|
},
|
|
@@ -61,7 +64,6 @@ export default class RequestReporter {
|
|
|
61
64
|
this.trustedClock = trustedClock;
|
|
62
65
|
this.countryProvider = countryProvider;
|
|
63
66
|
this.onTrackerInteraction = onTrackerInteraction;
|
|
64
|
-
this.getBrowserInfo = getBrowserInfo;
|
|
65
67
|
this.isRequestAllowed = isRequestAllowed;
|
|
66
68
|
if (dryRunMode) {
|
|
67
69
|
logger.warn(
|
|
@@ -166,6 +168,30 @@ export default class RequestReporter {
|
|
|
166
168
|
this.onMessageReady(message);
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
get userAgent() {
|
|
172
|
+
if (this.#userAgent === undefined) {
|
|
173
|
+
try {
|
|
174
|
+
const userAgent = globalThis.navigator?.userAgent;
|
|
175
|
+
if (userAgent) {
|
|
176
|
+
const { browser } = Bowser.parse(userAgent);
|
|
177
|
+
this.#userAgent = {
|
|
178
|
+
'Chrome': 'chrome',
|
|
179
|
+
'Chromium': 'chrome',
|
|
180
|
+
'Firefox': 'firefox',
|
|
181
|
+
'Microsoft Edge': 'edge',
|
|
182
|
+
'Opera': 'opera',
|
|
183
|
+
'Safari': 'safari',
|
|
184
|
+
'Yandex Browser': 'yandex',
|
|
185
|
+
}[browser?.name];
|
|
186
|
+
}
|
|
187
|
+
} catch (e) {
|
|
188
|
+
logger.warn('Failed to determine userAgent', e);
|
|
189
|
+
}
|
|
190
|
+
this.#userAgent ||= '';
|
|
191
|
+
}
|
|
192
|
+
return this.#userAgent;
|
|
193
|
+
}
|
|
194
|
+
|
|
169
195
|
/** Global module initialisation.
|
|
170
196
|
*/
|
|
171
197
|
async init() {
|
|
@@ -210,8 +236,6 @@ export default class RequestReporter {
|
|
|
210
236
|
|
|
211
237
|
await this.pageStore.init();
|
|
212
238
|
|
|
213
|
-
this.userAgent = (await this.getBrowserInfo()).name;
|
|
214
|
-
|
|
215
239
|
this.pageLogger = new PageLogger(this.config.placeHolder);
|
|
216
240
|
this.cookieContext = new CookieContext(this.config, this.qs_whitelist);
|
|
217
241
|
await this.cookieContext.init();
|
|
@@ -18,18 +18,15 @@ describe('#AliveMessageGenerator', function () {
|
|
|
18
18
|
const anotherHour = '2024030804';
|
|
19
19
|
|
|
20
20
|
const storageKey = 'some-storage-key';
|
|
21
|
-
let browserInfoProvider;
|
|
22
21
|
let navigatorApi;
|
|
23
22
|
let quorumChecker;
|
|
24
23
|
let storage;
|
|
25
24
|
let uut;
|
|
26
25
|
|
|
27
|
-
let _browserInfo;
|
|
28
26
|
let _shouldPassQuorum;
|
|
29
27
|
|
|
30
28
|
function newAliveMessageGenerator() {
|
|
31
29
|
return new AliveMessageGenerator({
|
|
32
|
-
browserInfoProvider,
|
|
33
30
|
navigatorApi,
|
|
34
31
|
quorumChecker,
|
|
35
32
|
storage,
|
|
@@ -37,8 +34,8 @@ describe('#AliveMessageGenerator', function () {
|
|
|
37
34
|
});
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
// Helper that
|
|
41
|
-
// it keeps the storage but purges everything that was in memory.
|
|
37
|
+
// Helper that simulates an event like a restart of the service worker/background script:
|
|
38
|
+
// it keeps the storage, but purges everything that was in memory.
|
|
42
39
|
async function simulateRestart() {
|
|
43
40
|
uut = newAliveMessageGenerator();
|
|
44
41
|
}
|
|
@@ -52,16 +49,11 @@ describe('#AliveMessageGenerator', function () {
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
beforeEach(() => {
|
|
55
|
-
_browserInfo = {
|
|
56
|
-
browser: 'Firefox',
|
|
57
|
-
version: '122',
|
|
58
|
-
os: 'Linux',
|
|
59
|
-
language: 'en-US',
|
|
60
|
-
};
|
|
61
52
|
navigatorApi = {
|
|
53
|
+
userAgent:
|
|
54
|
+
'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0',
|
|
62
55
|
language: 'en-US',
|
|
63
56
|
};
|
|
64
|
-
browserInfoProvider = async () => _browserInfo;
|
|
65
57
|
|
|
66
58
|
quorumChecker = {
|
|
67
59
|
_incCalls: 0,
|
|
@@ -154,19 +146,17 @@ describe('#AliveMessageGenerator', function () {
|
|
|
154
146
|
runGenericTests();
|
|
155
147
|
|
|
156
148
|
it('should share the config', async function () {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
version: '122.1',
|
|
160
|
-
os: 'Linux',
|
|
161
|
-
language: 'en-US',
|
|
162
|
-
};
|
|
149
|
+
navigatorApi.userAgent =
|
|
150
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36';
|
|
163
151
|
navigatorApi.language = 'de-DE';
|
|
164
152
|
|
|
165
153
|
const message = await uut.generateMessage('de', '2024010203');
|
|
166
154
|
expect(message).to.eql({
|
|
167
|
-
browser: '
|
|
168
|
-
version: '
|
|
155
|
+
browser: 'Chrome',
|
|
156
|
+
version: '138', // only major version
|
|
169
157
|
os: 'Linux',
|
|
158
|
+
platform: 'desktop',
|
|
159
|
+
engine: 'Blink',
|
|
170
160
|
language: 'de-DE', // from window.navigator
|
|
171
161
|
ctry: 'de',
|
|
172
162
|
t: '2024010203',
|
|
@@ -184,6 +174,8 @@ describe('#AliveMessageGenerator', function () {
|
|
|
184
174
|
browser: '',
|
|
185
175
|
version: '',
|
|
186
176
|
os: '',
|
|
177
|
+
platform: '',
|
|
178
|
+
engine: '',
|
|
187
179
|
language: '',
|
|
188
180
|
ctry: '--',
|
|
189
181
|
t: '2024010203',
|
|
@@ -25,11 +25,11 @@ const YEAR = 365 * DAY;
|
|
|
25
25
|
function mockStorage(storageKey) {
|
|
26
26
|
return {
|
|
27
27
|
async get(key) {
|
|
28
|
-
expect(key).to.
|
|
28
|
+
expect(key).to.eql(storageKey);
|
|
29
29
|
return this._content;
|
|
30
30
|
},
|
|
31
31
|
async set(key, obj) {
|
|
32
|
-
expect(key).to.
|
|
32
|
+
expect(key).to.eql(storageKey);
|
|
33
33
|
this._content = obj;
|
|
34
34
|
},
|
|
35
35
|
};
|
|
@@ -296,7 +296,7 @@ describe('#JobScheduler', function () {
|
|
|
296
296
|
await passesSelfChecks();
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
-
it('should allow to processPendingJobs when the queue, but jobs are registered', async function () {
|
|
299
|
+
it('should allow to processPendingJobs when the queue is empty, but jobs are registered', async function () {
|
|
300
300
|
uut.registerHandler('dummy', () => expect.fail('should never be called'));
|
|
301
301
|
await uut.init();
|
|
302
302
|
await uut.processPendingJobs();
|
|
@@ -450,7 +450,7 @@ describe('#JobScheduler', function () {
|
|
|
450
450
|
await uut.registerJob(job1);
|
|
451
451
|
await uut.processPendingJobs();
|
|
452
452
|
expectJobIsDone(job1);
|
|
453
|
-
expect(uut.stats.jobRegistered).to.
|
|
453
|
+
expect(uut.stats.jobRegistered).to.eql(1);
|
|
454
454
|
expect(uut.stats.jobSucceeded).to.eql(1);
|
|
455
455
|
|
|
456
456
|
// job2 -> undefined (does not spawn)
|
|
@@ -458,7 +458,7 @@ describe('#JobScheduler', function () {
|
|
|
458
458
|
await uut.registerJob(job2);
|
|
459
459
|
await uut.processPendingJobs();
|
|
460
460
|
expectJobIsDone(job2);
|
|
461
|
-
expect(uut.stats.jobRegistered).to.
|
|
461
|
+
expect(uut.stats.jobRegistered).to.eql(2);
|
|
462
462
|
expect(uut.stats.jobSucceeded).to.eql(2);
|
|
463
463
|
|
|
464
464
|
// job3 -> [] (does not spawn)
|
|
@@ -466,7 +466,7 @@ describe('#JobScheduler', function () {
|
|
|
466
466
|
await uut.registerJob(job3);
|
|
467
467
|
await uut.processPendingJobs();
|
|
468
468
|
expectJobIsDone(job3);
|
|
469
|
-
expect(uut.stats.jobRegistered).to.
|
|
469
|
+
expect(uut.stats.jobRegistered).to.eql(3);
|
|
470
470
|
expect(uut.stats.jobSucceeded).to.eql(3);
|
|
471
471
|
|
|
472
472
|
// job4 -> job5
|
|
@@ -479,11 +479,76 @@ describe('#JobScheduler', function () {
|
|
|
479
479
|
await uut.processPendingJobs();
|
|
480
480
|
expectJobIsDone(job4);
|
|
481
481
|
expectJobIsDone(job5);
|
|
482
|
-
|
|
482
|
+
|
|
483
483
|
expectJobIsDone(job7);
|
|
484
|
-
expect(uut.stats.jobRegistered).to.
|
|
484
|
+
expect(uut.stats.jobRegistered).to.eql(7);
|
|
485
485
|
expect(uut.stats.jobSucceeded).to.eql(7);
|
|
486
486
|
});
|
|
487
|
+
|
|
488
|
+
it('should not let one long-lived job block newly added short-lived jobs forever', async function () {
|
|
489
|
+
this.timeout(20 * SECOND);
|
|
490
|
+
|
|
491
|
+
const type = 'testjob';
|
|
492
|
+
uut.registerHandler(type, () => {});
|
|
493
|
+
await uut.init();
|
|
494
|
+
|
|
495
|
+
const start = Date.now();
|
|
496
|
+
const longLivedJob = {
|
|
497
|
+
type,
|
|
498
|
+
args: {
|
|
499
|
+
name: 'long-lived',
|
|
500
|
+
createdAt: Date.now(),
|
|
501
|
+
},
|
|
502
|
+
config: {
|
|
503
|
+
readyAt: start + DAY,
|
|
504
|
+
ttlInMs: 2 * DAY,
|
|
505
|
+
},
|
|
506
|
+
};
|
|
507
|
+
await uut.registerJob(longLivedJob);
|
|
508
|
+
expect(uut.stats.jobRegistered).to.eql(1);
|
|
509
|
+
expect(uut.stats.jobSucceeded).to.eql(0);
|
|
510
|
+
|
|
511
|
+
let shortLiveJobsCount = 0;
|
|
512
|
+
const mkShortLivedJob = () => {
|
|
513
|
+
return {
|
|
514
|
+
type,
|
|
515
|
+
args: {
|
|
516
|
+
name: ++shortLiveJobsCount,
|
|
517
|
+
createdAt: Date.now(),
|
|
518
|
+
},
|
|
519
|
+
config: {
|
|
520
|
+
readyIn: { min: 10 * SECOND },
|
|
521
|
+
ttlInMs: 2 * HOUR,
|
|
522
|
+
},
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
await passesSelfChecks();
|
|
526
|
+
|
|
527
|
+
while (Date.now() < longLivedJob.config.readyAt) {
|
|
528
|
+
expect(uut.stats.jobSucceeded).to.be.below(uut.stats.jobRegistered);
|
|
529
|
+
await uut.processPendingJobs();
|
|
530
|
+
expect(uut.stats.jobSucceeded).to.be.at.most(uut.stats.jobRegistered);
|
|
531
|
+
|
|
532
|
+
await uut.registerJob(mkShortLivedJob());
|
|
533
|
+
expect(uut.stats.jobRejected).to.eql(0);
|
|
534
|
+
expect(uut.stats.jobExpired).to.eql(0);
|
|
535
|
+
expect(uut.stats.jobFailed).to.eql(0);
|
|
536
|
+
expect(uut.stats.jobRegistered).to.eql(1 + shortLiveJobsCount);
|
|
537
|
+
expect(uut.stats.jobSucceeded).to.be.below(uut.stats.jobRegistered);
|
|
538
|
+
|
|
539
|
+
await clock.tickAsync(10 * MINUTE);
|
|
540
|
+
await passesSelfChecks();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
await uut.processPendingJobs();
|
|
544
|
+
await clock.runAllAsync();
|
|
545
|
+
|
|
546
|
+
expect(uut.stats.jobExpired).to.eql(0);
|
|
547
|
+
expect(uut.stats.jobSucceeded).to.eql(uut.stats.jobRegistered);
|
|
548
|
+
expect(uut.stats.jobRejected).to.eql(0);
|
|
549
|
+
expect(uut.stats.jobFailed).to.eql(0);
|
|
550
|
+
await passesSelfChecks();
|
|
551
|
+
});
|
|
487
552
|
});
|
|
488
553
|
|
|
489
554
|
describe('after an extension restart', function () {
|
|
@@ -562,6 +627,8 @@ describe('#JobScheduler', function () {
|
|
|
562
627
|
maxJobTypes = 20,
|
|
563
628
|
minReadyIn = 0,
|
|
564
629
|
maxReadyIn = 1 * MONTH,
|
|
630
|
+
minExpireIn = 1 * SECOND,
|
|
631
|
+
maxExpireIn = 1 * MONTH,
|
|
565
632
|
minTTL = 1 * SECOND,
|
|
566
633
|
maxTTL = 12 * MONTH,
|
|
567
634
|
maxJobsPerType = 10000,
|
|
@@ -569,31 +636,57 @@ describe('#JobScheduler', function () {
|
|
|
569
636
|
maxAutoRetriesAfterError = 100,
|
|
570
637
|
maxClockJump = 6 * MONTH, // also simulates if a machines goes to sleep
|
|
571
638
|
} = {}) {
|
|
639
|
+
// these fields are reserved for the config passed to the jobHandler
|
|
640
|
+
const commonJobConfigFields = () => ({
|
|
641
|
+
priority: fc.integer(),
|
|
642
|
+
ttlInMs: fc.integer({ min: minTTL, max: maxTTL }),
|
|
643
|
+
maxJobsTotal: fc.integer({ min: 1, max: maxJobsPerType }),
|
|
644
|
+
cooldownInMs: fc.nat(maxCooldown),
|
|
645
|
+
autoRetryAfterError: fc.boolean(),
|
|
646
|
+
maxAutoRetriesAfterError: fc.nat(maxAutoRetriesAfterError),
|
|
647
|
+
});
|
|
648
|
+
const individualJobConfigFields = () => ({
|
|
649
|
+
readyIn: fc.record(
|
|
650
|
+
{
|
|
651
|
+
min: fc.nat(minReadyIn),
|
|
652
|
+
max: fc.option(fc.integer({ min: minReadyIn, max: maxReadyIn })),
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
requiredKeys: ['min'],
|
|
656
|
+
},
|
|
657
|
+
),
|
|
658
|
+
expireIn: fc.record(
|
|
659
|
+
{
|
|
660
|
+
min: fc.nat(minExpireIn),
|
|
661
|
+
max: fc.option(fc.integer({ min: minExpireIn, max: maxExpireIn })),
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
requiredKeys: ['min'],
|
|
665
|
+
},
|
|
666
|
+
),
|
|
667
|
+
});
|
|
668
|
+
|
|
572
669
|
const numToJobType = (x) => `testjob${x}`;
|
|
573
670
|
const arbitraryJobType = () => fc.nat(maxJobTypes - 1).map(numToJobType);
|
|
574
671
|
const arbitraryJobArgs = () => fc.array(fc.nat());
|
|
575
|
-
const arbitraryJobConfig = () =>
|
|
576
|
-
|
|
577
|
-
priority: fc.option(fc.integer()),
|
|
578
|
-
ttlInMs: fc.option(fc.integer({ min: minTTL, max: maxTTL })),
|
|
579
|
-
readyIn: fc.option(
|
|
580
|
-
fc.record({
|
|
581
|
-
min: fc.nat(minReadyIn),
|
|
582
|
-
max: fc.option(fc.integer({ min: minReadyIn, max: maxReadyIn })),
|
|
583
|
-
}),
|
|
584
|
-
),
|
|
585
|
-
maxJobsTotal: fc.option(fc.nat(fc.nat(1, maxJobsPerType))),
|
|
586
|
-
cooldownInMs: fc.option(fc.nat(maxCooldown)),
|
|
587
|
-
autoRetryAfterError: fc.option(fc.boolean()),
|
|
588
|
-
maxAutoRetriesAfterError: fc.option(fc.nat(maxAutoRetriesAfterError)),
|
|
589
|
-
});
|
|
590
|
-
};
|
|
672
|
+
const arbitraryJobConfig = () =>
|
|
673
|
+
fc.record(commonJobConfigFields(), { requiredKeys: [] });
|
|
591
674
|
const arbitraryJob = () => {
|
|
592
675
|
return fc
|
|
593
676
|
.tuple(
|
|
594
677
|
arbitraryJobType(),
|
|
595
678
|
fc.option(arbitraryJobArgs()),
|
|
596
|
-
fc.option(
|
|
679
|
+
fc.option(
|
|
680
|
+
fc.record(
|
|
681
|
+
{
|
|
682
|
+
...commonJobConfigFields(),
|
|
683
|
+
...individualJobConfigFields(),
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
requiredKeys: [],
|
|
687
|
+
},
|
|
688
|
+
),
|
|
689
|
+
),
|
|
597
690
|
)
|
|
598
691
|
.map(([type, args, config]) => ({
|
|
599
692
|
type,
|