Skip to content

Commit 8885503

Browse files
committed
Merge branch 'release-v4.1.0-pre.0' into release
2 parents 84cde1f + cf13503 commit 8885503

27 files changed

+1110
-442
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# Unreleased changes
22

3-
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0...main)
3+
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.1.0-pre.0...main)
4+
5+
# v4.1.0-pre.0 (2024-03-05)
6+
7+
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0...v4.1.0-pre.0)
8+
9+
* [#1866](https://github.com/mozilla/glean.js/pull/1866): Added a new uploader that falls back to `fetch` if `navigator.sendBeacon` fails.
10+
* [#1876](https://github.com/mozilla/glean.js/pull/1876): **BREAKING CHANGE**: `navigator.sendBeacon` with fallback to `fetch` (see #1866) is now the default uploader. This can be changed manually.
11+
* [#1850](https://github.com/mozilla/glean.js/pull/1850): Automatically record basic session information (`session_id` & `session_count`) for web properties.
412

513
# v4.0.0 (2024-01-24)
614

715
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0-pre.3...v4.0.0)
816

9-
* This is the official release based on the v4.x.x-pre.x releases.
17+
* This is the official release based on the v4.0.0-pre.x releases.
1018

1119
# v4.0.0-pre.3 (2023-12-22)
1220

automation/compat/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<title>Glean Benchmarks Sample</title>
88
</head>
99
<body>
10-
<p id="msg"></p>
10+
<p id="ping_msg"></p>
11+
<p id="session_msg"></p>
1112
<script src="./dist/index.js"></script>
1213
</body>
1314
</html>

automation/compat/index.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import * as metrics from "./generated/sample.js";
1010

1111
Glean.setSourceTags(["automation"]);
1212
Glean.initialize("glean-compat-benchmark", true, {
13-
enableAutoPageLoadEvents: true
13+
enableAutoPageLoadEvents: true,
14+
// Setting the override to 0 means every action will trigger
15+
// a new session. We use this to check that the session ID
16+
// changes whenever a session has expired.
17+
sessionLengthInMinutesOverride: 0
1418
});
1519

1620
metrics.pageLoaded.set();
@@ -20,7 +24,12 @@ benchmark.submit();
2024
//
2125
// Overwrite the console.info function in order to know when (and if) the benchmark ping was sent.
2226
// If a success ping message is logged we show that in the document.
27+
//
28+
// We cannot use the ping testing APIs since these "tests" are actually checks
29+
// running on a live application. For us to utilize the ping testing APIs,
30+
// like `<ping>.testBeforeNextSubmit` we would need Glean to be running in testing mode.
2331
let pingSubmissionCount = 0;
32+
let sessionId = "";
2433
console.info = function () {
2534
var message = "";
2635
for (var i = 0; i < arguments.length; i++) {
@@ -30,6 +39,7 @@ console.info = function () {
3039
message += " ";
3140
}
3241
}
42+
3343
console.log(message);
3444
if (/successfully sent 200.$/.test(message)) {
3545
pingSubmissionCount++;
@@ -38,8 +48,27 @@ console.info = function () {
3848
// 1. The built-in page_load event, which submits an events ping.
3949
// 2. The benchmark ping.
4050
if (pingSubmissionCount == 2) {
41-
var elem = document.getElementById("msg");
42-
elem.innerHTML = "Pings submitted successfully.";
51+
var elem = document.getElementById("ping_msg");
52+
elem.innerText = "Pings submitted successfully.";
4353
}
4454
}
55+
56+
// Pull all user lifetime metrics from Glean.
57+
const userLifetimeMetrics = window.localStorage.getItem("userLifetimeMetrics");
58+
59+
// Extract the session id metric.
60+
const sessionInfo = /"session_id":".{36}"/.exec(userLifetimeMetrics);
61+
if (!!sessionInfo.length) {
62+
const currSessionId = sessionInfo[0].split(":")[1].split("\"")[1];
63+
if (!!sessionId) {
64+
if (currSessionId !== sessionId) {
65+
var elem = document.getElementById("session_msg");
66+
elem.innerText = "Session IDs updated successfully.";
67+
} else {
68+
console.log("Something went wrong...");
69+
}
70+
}
71+
72+
sessionId = currSessionId;
73+
}
4574
}

automation/compat/tests/utils.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export async function runWebTest(driver) {
7373
// will receive the text "Ping submitted successfully."
7474
await driver.get(`http://localhost:${PORT}/`);
7575
// Give it time to send the ping request.
76-
const successTextContainer = await driver.findElement(By.id("msg"));
76+
const pingTextContainer = await driver.findElement(By.id("ping_msg"));
7777

7878
const areGleanWindowVarsSet = await driver.executeScript(() => {
7979
// Verify that all Glean `window` vars are properly set.
@@ -100,10 +100,17 @@ export async function runWebTest(driver) {
100100

101101
await driver.wait(
102102
until.elementTextIs(
103-
successTextContainer,
103+
pingTextContainer,
104104
"Pings submitted successfully."
105105
), 11_000); // 1s more than the default upload timeout in Glean.
106106

107+
const sessionTextContainer = await driver.findElement(By.id("session_msg"));
108+
await driver.wait(
109+
until.elementTextIs(
110+
sessionTextContainer,
111+
"Session IDs updated successfully."
112+
), 1000);
113+
107114
console.log("Test passed.");
108115
} catch(e) {
109116
console.log("Test failed.", e);

0 commit comments

Comments
 (0)