@whotracksme/reporting 12.1.20 → 12.1.22
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
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# v12.1.22 (Mon Nov 23 2026)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Fixed: page analysis of active tab cancels itself [#264](https://github.com/whotracksme/webextension-packages/pull/264) ([@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
|
+
# v12.1.21 (Fri Nov 20 2026)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- Fixed: the "ts" (the day) must be available before the duplicate check [#263](https://github.com/whotracksme/webextension-packages/pull/263) ([@philipp-classen](https://github.com/philipp-classen))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
1
25
|
# v12.1.20 (Fri Nov 20 2026)
|
|
2
26
|
|
|
3
27
|
#### 🐛 Bug Fix
|
package/package.json
CHANGED
|
@@ -30,6 +30,14 @@ export default class MessageSender {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async send(message) {
|
|
33
|
+
// Without "ts" (the day), the duplicate detector cannot tell
|
|
34
|
+
// days apart: it would also reject the same page on the next
|
|
35
|
+
// day. So set "ts" here, before the check.
|
|
36
|
+
// ("communication.send" sets it too, but only afterwards.)
|
|
37
|
+
const ts =
|
|
38
|
+
message.body.ts || this.communication.trustedClock.getTimeAsYYYYMMDD();
|
|
39
|
+
message = { ...message, body: { ...message.body, ts } };
|
|
40
|
+
|
|
33
41
|
logger.debug('Preparing to send message:', message);
|
|
34
42
|
const { ok, rollback, rejectReason } =
|
|
35
43
|
await this.duplicateDetector.trySend(message);
|
package/reporting/src/pages.js
CHANGED
|
@@ -681,6 +681,7 @@ export default class Pages {
|
|
|
681
681
|
pageId: ++this._pageIdGenerator,
|
|
682
682
|
};
|
|
683
683
|
this._initVisibility(tabId, entry, now);
|
|
684
|
+
this.openTabs.set(tabId, entry);
|
|
684
685
|
|
|
685
686
|
if (tab.active && isRealPage(tab.url)) {
|
|
686
687
|
this.activeTab.saveActiveTabInWindow({
|
|
@@ -695,7 +696,6 @@ export default class Pages {
|
|
|
695
696
|
}
|
|
696
697
|
}
|
|
697
698
|
}
|
|
698
|
-
this.openTabs.set(tabId, entry);
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
if (
|
package/reporting/test/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import './doublefetch-unbreak.spec.js';
|
|
|
16
16
|
import './url-analyzer.spec.js';
|
|
17
17
|
import './alive-check.spec.js';
|
|
18
18
|
import './alive-message-generator.spec.js';
|
|
19
|
+
import './message-sender.spec.js';
|
|
19
20
|
import './nav-tracking-detector.spec.js';
|
|
20
21
|
import './new-page-approver.spec.js';
|
|
21
22
|
import './network.spec.js';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhoTracks.Me
|
|
3
|
+
* https://whotracks.me/
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2017-present Ghostery GmbH. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
8
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
9
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { expect } from 'chai';
|
|
13
|
+
|
|
14
|
+
import MessageSender from '../src/message-sender.js';
|
|
15
|
+
import DuplicateDetector from '../src/duplicate-detector.js';
|
|
16
|
+
import { createInMemoryPersistedHashes } from './helpers/in-memory-persisted-hashes.js';
|
|
17
|
+
|
|
18
|
+
describe('#MessageSender', function () {
|
|
19
|
+
const YESTERDAY = '20251231';
|
|
20
|
+
const TODAY = '20260101';
|
|
21
|
+
const TOMORROW = '20260102';
|
|
22
|
+
|
|
23
|
+
let uut;
|
|
24
|
+
let currentDay;
|
|
25
|
+
let sentMessages;
|
|
26
|
+
let communication;
|
|
27
|
+
|
|
28
|
+
function somePageMessage(url = 'https://example.test/foo') {
|
|
29
|
+
return {
|
|
30
|
+
body: {
|
|
31
|
+
action: 'wtm.page',
|
|
32
|
+
payload: { url, t: 'Some title' },
|
|
33
|
+
ver: 4,
|
|
34
|
+
'anti-duplicates': Math.floor(Math.random() * 2 ** 32),
|
|
35
|
+
},
|
|
36
|
+
deduplicateBy: 'url',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
beforeEach(async function () {
|
|
41
|
+
currentDay = TODAY;
|
|
42
|
+
sentMessages = [];
|
|
43
|
+
communication = {
|
|
44
|
+
trustedClock: {
|
|
45
|
+
getTimeAsYYYYMMDD: () => currentDay,
|
|
46
|
+
},
|
|
47
|
+
async send(body) {
|
|
48
|
+
sentMessages.push(body);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const duplicateDetector = new DuplicateDetector(
|
|
53
|
+
createInMemoryPersistedHashes(),
|
|
54
|
+
);
|
|
55
|
+
await duplicateDetector.init();
|
|
56
|
+
uut = new MessageSender({
|
|
57
|
+
duplicateDetector,
|
|
58
|
+
communication,
|
|
59
|
+
jobScheduler: { registerHandler() {} },
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should send a message', async function () {
|
|
64
|
+
const message = somePageMessage();
|
|
65
|
+
await uut.send(message);
|
|
66
|
+
|
|
67
|
+
expect(sentMessages).to.have.lengthOf(1);
|
|
68
|
+
expect(sentMessages[0]).to.deep.include(message.body);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should send the same page only once per day', async function () {
|
|
72
|
+
await uut.send(somePageMessage());
|
|
73
|
+
await uut.send(somePageMessage());
|
|
74
|
+
|
|
75
|
+
expect(sentMessages).to.have.lengthOf(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should send the same page again on the next day', async function () {
|
|
79
|
+
await uut.send(somePageMessage());
|
|
80
|
+
currentDay = TOMORROW;
|
|
81
|
+
await uut.send(somePageMessage());
|
|
82
|
+
|
|
83
|
+
expect(sentMessages.map((x) => x.ts)).to.eql([TODAY, TOMORROW]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should send different pages on the same day', async function () {
|
|
87
|
+
await uut.send(somePageMessage('https://example.test/foo'));
|
|
88
|
+
await uut.send(somePageMessage('https://example.test/bar'));
|
|
89
|
+
|
|
90
|
+
expect(sentMessages).to.have.lengthOf(2);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should keep the timestamp of a message that has one', async function () {
|
|
94
|
+
const message = somePageMessage();
|
|
95
|
+
message.body.ts = YESTERDAY;
|
|
96
|
+
await uut.send(message);
|
|
97
|
+
|
|
98
|
+
expect(sentMessages).to.eql([message.body]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should be able to send a message again if the first attempt failed', async function () {
|
|
102
|
+
const message = somePageMessage();
|
|
103
|
+
const originalSend = communication.send;
|
|
104
|
+
communication.send = async () => {
|
|
105
|
+
throw new Error('network is down');
|
|
106
|
+
};
|
|
107
|
+
try {
|
|
108
|
+
await uut.send(message);
|
|
109
|
+
expect.fail('should have failed');
|
|
110
|
+
} catch (e) {
|
|
111
|
+
expect(e.message).to.eql('network is down');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
communication.send = originalSend;
|
|
115
|
+
await uut.send(message);
|
|
116
|
+
expect(sentMessages).to.have.lengthOf(1);
|
|
117
|
+
});
|
|
118
|
+
});
|