Skip to content

Commit

Permalink
Merge branch 'release-v4.1.0-pre.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexterp37 committed Mar 5, 2024
2 parents 84cde1f + cf13503 commit 8885503
Show file tree
Hide file tree
Showing 27 changed files with 1,110 additions and 442 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Unreleased changes

[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0...main)
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.1.0-pre.0...main)

# v4.1.0-pre.0 (2024-03-05)

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

* [#1866](https://github.com/mozilla/glean.js/pull/1866): Added a new uploader that falls back to `fetch` if `navigator.sendBeacon` fails.
* [#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.
* [#1850](https://github.com/mozilla/glean.js/pull/1850): Automatically record basic session information (`session_id` & `session_count`) for web properties.

# v4.0.0 (2024-01-24)

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

* This is the official release based on the v4.x.x-pre.x releases.
* This is the official release based on the v4.0.0-pre.x releases.

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

Expand Down
3 changes: 2 additions & 1 deletion automation/compat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<title>Glean Benchmarks Sample</title>
</head>
<body>
<p id="msg"></p>
<p id="ping_msg"></p>
<p id="session_msg"></p>
<script src="./dist/index.js"></script>
</body>
</html>
35 changes: 32 additions & 3 deletions automation/compat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import * as metrics from "./generated/sample.js";

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

metrics.pageLoaded.set();
Expand All @@ -20,7 +24,12 @@ benchmark.submit();
//
// Overwrite the console.info function in order to know when (and if) the benchmark ping was sent.
// If a success ping message is logged we show that in the document.
//
// We cannot use the ping testing APIs since these "tests" are actually checks
// running on a live application. For us to utilize the ping testing APIs,
// like `<ping>.testBeforeNextSubmit` we would need Glean to be running in testing mode.
let pingSubmissionCount = 0;
let sessionId = "";
console.info = function () {
var message = "";
for (var i = 0; i < arguments.length; i++) {
Expand All @@ -30,6 +39,7 @@ console.info = function () {
message += " ";
}
}

console.log(message);
if (/successfully sent 200.$/.test(message)) {
pingSubmissionCount++;
Expand All @@ -38,8 +48,27 @@ console.info = function () {
// 1. The built-in page_load event, which submits an events ping.
// 2. The benchmark ping.
if (pingSubmissionCount == 2) {
var elem = document.getElementById("msg");
elem.innerHTML = "Pings submitted successfully.";
var elem = document.getElementById("ping_msg");
elem.innerText = "Pings submitted successfully.";
}
}

// Pull all user lifetime metrics from Glean.
const userLifetimeMetrics = window.localStorage.getItem("userLifetimeMetrics");

// Extract the session id metric.
const sessionInfo = /"session_id":".{36}"/.exec(userLifetimeMetrics);
if (!!sessionInfo.length) {
const currSessionId = sessionInfo[0].split(":")[1].split("\"")[1];
if (!!sessionId) {
if (currSessionId !== sessionId) {
var elem = document.getElementById("session_msg");
elem.innerText = "Session IDs updated successfully.";
} else {
console.log("Something went wrong...");
}
}

sessionId = currSessionId;
}
}
11 changes: 9 additions & 2 deletions automation/compat/tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function runWebTest(driver) {
// will receive the text "Ping submitted successfully."
await driver.get(`http://localhost:${PORT}/`);
// Give it time to send the ping request.
const successTextContainer = await driver.findElement(By.id("msg"));
const pingTextContainer = await driver.findElement(By.id("ping_msg"));

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

await driver.wait(
until.elementTextIs(
successTextContainer,
pingTextContainer,
"Pings submitted successfully."
), 11_000); // 1s more than the default upload timeout in Glean.

const sessionTextContainer = await driver.findElement(By.id("session_msg"));
await driver.wait(
until.elementTextIs(
sessionTextContainer,
"Session IDs updated successfully."
), 1000);

console.log("Test passed.");
} catch(e) {
console.log("Test failed.", e);
Expand Down
Loading

0 comments on commit 8885503

Please sign in to comment.