Skip to content

Commit

Permalink
Merge branch 'release-v4.0.0-pre.2' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi-agg committed Dec 6, 2023
2 parents 245c9ae + f414711 commit 9638c47
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- checkout
- install-node
- run:
name: Run browser comapt smoke tests
name: Run browser compat smoke tests
command: |
npm --prefix ./automation install
npm --prefix ./automation run link:glean
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Unreleased changes

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

# v4.0.0-pre.2 (2023-12-06)

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

[#1835](https://github.com/mozilla/glean.js/pull/1835): Added support for automatic page load instrumentation.

# v4.0.0-pre.1 (2023-12-01)

Expand All @@ -14,6 +20,8 @@

[#1808](https://github.com/mozilla/glean.js/pull/1808): **BREAKING CHANGE**: Make glean.js fully synchronous.

* [#1835](https://github.com/mozilla/glean.js/pull/1835): Automatic instrumentation of page load events for simple web properties.

# v3.0.0 (2023-11-16)

[Full changelog](https://github.com/mozilla/glean.js/compare/v3.0.0-pre.1...v3.0.0)
Expand Down
16 changes: 13 additions & 3 deletions automation/compat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { benchmark } from "./generated/pings.js";
import * as metrics from "./generated/sample.js";

Glean.setSourceTags(["automation"]);
Glean.initialize("glean-compat-benchmark", true);
Glean.initialize("glean-compat-benchmark", true, {
enableAutoPageLoadEvents: true
});

metrics.pageLoaded.set();
benchmark.submit();
Expand All @@ -18,6 +20,7 @@ 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.
let pingSubmissionCount = 0;
console.info = function () {
var message = "";
for (var i = 0; i < arguments.length; i++) {
Expand All @@ -29,7 +32,14 @@ console.info = function () {
}
console.log(message);
if (/successfully sent 200.$/.test(message)) {
var elem = document.getElementById("msg");
elem.innerHTML = "Ping submitted successfully.";
pingSubmissionCount++;

// Two pings should be submitted when run successfully
// 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.";
}
}
}
2 changes: 1 addition & 1 deletion automation/compat/tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export async function runWebTest(driver) {
await driver.wait(
until.elementTextIs(
successTextContainer,
"Ping submitted successfully."
"Pings submitted successfully."
), 11_000); // 1s more than the default upload timeout in Glean.

console.log("Test passed.");
Expand Down
16 changes: 7 additions & 9 deletions automation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion automation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"author": "The Glean Team <glean-team@mozilla.com>",
"license": "MPL-2.0",
"devDependencies": {
"@octokit/request": "^8.1.5",
"@octokit/request": "^8.1.6",
"browserstack-local": "^1.5.5",
"geckodriver": "^4.2.1",
"patch-package": "^8.0.0",
Expand Down
63 changes: 41 additions & 22 deletions glean/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions glean/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mozilla/glean",
"version": "4.0.0-pre.1",
"version": "4.0.0-pre.2",
"description": "An implementation of the Glean SDK, a modern cross-platform telemetry client, for JavaScript environments.",
"type": "module",
"sideEffects": false,
Expand All @@ -11,7 +11,8 @@
"./private/ping": "./dist/core/pings/ping_type.js",
"./uploader": "./dist/core/upload/uploader.js",
"./testing": "./dist/core/testing/index.js",
"./web": "./dist/entry/web.js"
"./web": "./dist/entry/web.js",
"./metrics": "./dist/core/glean_metrics.js"
},
"typesVersions": {
"*": {
Expand All @@ -32,6 +33,9 @@
],
"error": [
"./dist/types/core/error/error_type.d.ts"
],
"metrics": [
"./dist/types/core/glean_metrics.d.ts"
]
}
},
Expand Down
5 changes: 5 additions & 0 deletions glean/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export interface ConfigurationInterface {
// Migrate from legacy storage (IndexedDB) to the new one (LocalStorage).
// This should only be true for older projects that have existing data in IndexedDB.
readonly migrateFromLegacyStorage?: boolean,
// Allow the client to explicitly specify whether they want page load events to be
// collected automatically.
readonly enableAutoPageLoadEvents?: boolean,
}

// Important: the `Configuration` should only be used internally by the Glean singleton.
Expand All @@ -58,6 +61,7 @@ export class Configuration implements ConfigurationInterface {
readonly buildDate?: Date;
readonly maxEvents: number;
readonly migrateFromLegacyStorage?: boolean;
readonly enableAutoPageLoadEvents?: boolean;

// Debug configuration.
debug: DebugOptions;
Expand All @@ -71,6 +75,7 @@ export class Configuration implements ConfigurationInterface {
this.buildDate = config?.buildDate;
this.maxEvents = config?.maxEvents || DEFAULT_MAX_EVENTS;
this.migrateFromLegacyStorage = config?.migrateFromLegacyStorage;
this.enableAutoPageLoadEvents = config?.enableAutoPageLoadEvents;

this.debug = {};

Expand Down
2 changes: 1 addition & 1 deletion glean/src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const GLEAN_SCHEMA_VERSION = 1;
//
// PACKAGE_VERSION is defined as a global by webpack,
// we need a default here for testing when the app is not build with webpack.
export const GLEAN_VERSION = "4.0.0-pre.1";
export const GLEAN_VERSION = "4.0.0-pre.2";

// The name of a "ping" that will include Glean ping_info metrics,
// such as ping sequence numbers.
Expand Down
7 changes: 7 additions & 0 deletions glean/src/core/glean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import MetricsDatabase from "./metrics/database.js";
import EventsDatabase from "./metrics/events_database/index.js";
import PingsDatabase from "./pings/database.js";
import ErrorManager from "./error/index.js";
import GleanMetrics from "./glean_metrics.js";

const LOG_TAG = "core.Glean";

Expand Down Expand Up @@ -317,6 +318,12 @@ namespace Glean {
onUploadEnabled();
initializeCoreMetrics(config?.migrateFromLegacyStorage);

// Record a page load event if the client has auto page-load events enabled.
if (config?.enableAutoPageLoadEvents) {
// This function call has no parameters because auto-instrumentation
// means there are no overrides.
GleanMetrics.pageLoad();
}
} else {
// If upload is disabled, and we've never run before, only set the
// client_id to KNOWN_CLIENT_ID, but do not send a deletion request
Expand Down
Loading

0 comments on commit 9638c47

Please sign in to comment.