Skip to content

Commit 0279235

Browse files
author
Beatriz Rizental
authored
Merge pull request #1233 from brizental/1749494-build-date
Bug 1749494 - Include build date metric on client_info when present
2 parents 946c4ec + 82d607f commit 0279235

File tree

9 files changed

+50
-125
lines changed

9 files changed

+50
-125
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[Full changelog](https://github.com/mozilla/glean.js/compare/v0.32.0...main)
44

5+
* [#1233](https://github.com/mozilla/glean.js/pull/1233): Add optional `buildDate` argument to `initialize` configuration. The build date can be generated by glean_parser.
6+
* [#1233](https://github.com/mozilla/glean.js/pull/1233): Update glean_parser to version 5.1.0.
7+
58
# v0.32.0 (2022-03-01)
69

710
[Full changelog](https://github.com/mozilla/glean.js/compare/v0.31.0...v0.32.0)

glean/package-lock.json

Lines changed: 0 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glean/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const LOG_TAG = "CLI";
2626
const VIRTUAL_ENVIRONMENT_DIR = process.env.VIRTUAL_ENV || path.join(process.cwd(), ".venv");
2727

2828
// The version of glean_parser to install from PyPI.
29-
const GLEAN_PARSER_VERSION = "5.0.1";
29+
const GLEAN_PARSER_VERSION = "5.1.0";
3030

3131
// This script runs a given Python module as a "main" module, like
3232
// `python -m module`. However, it first checks that the installed

glean/src/core/config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,19 @@ export interface ConfigurationInterface {
4848
readonly architecture?: string,
4949
// The user-visible version of the operating system (e.g. "1.2.3").
5050
readonly osVersion?: string,
51+
// The build date, provided by glean_parser
52+
readonly buildDate?: Date,
5153
}
5254

5355
// Important: the `Configuration` should only be used internally by the Glean singleton.
5456
export class Configuration implements ConfigurationInterface {
55-
// Application release channel (e.g. "beta" or "nightly").
5657
readonly channel?: string;
57-
// The build identifier generated by the CI system (e.g. "1234/A").
5858
readonly appBuild?: string;
59-
// The user visible version string fro the application running Glean.js.
6059
readonly appDisplayVersion?: string;
61-
// The server pings are sent to.
6260
readonly serverEndpoint: string;
63-
// The architecture of the device (e.g. "arm", "x86").
6461
readonly architecture?: string;
65-
// The user-visible version of the operating system (e.g. "1.2.3").
6662
readonly osVersion?: string;
63+
readonly buildDate?: Date;
6764

6865
// Debug configuration.
6966
debug: DebugOptions;
@@ -76,6 +73,7 @@ export class Configuration implements ConfigurationInterface {
7673
this.appDisplayVersion = config?.appDisplayVersion;
7774
this.architecture = config?.architecture;
7875
this.osVersion = config?.osVersion;
76+
this.buildDate = config?.buildDate;
7977

8078
this.debug = {};
8179

glean/src/core/internal_metrics.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class CoreMetrics {
3232
readonly appChannel: StringMetricType;
3333
readonly appBuild: StringMetricType;
3434
readonly appDisplayVersion: StringMetricType;
35+
readonly buildDate: DatetimeMetricType;
3536

3637

3738
constructor() {
@@ -106,6 +107,14 @@ export class CoreMetrics {
106107
lifetime: Lifetime.Application,
107108
disabled: false,
108109
});
110+
111+
this.buildDate = new DatetimeMetricType({
112+
name: "build_date",
113+
category: "",
114+
sendInPings: ["glean_client_info"],
115+
lifetime: Lifetime.Application,
116+
disabled: false,
117+
}, "second");
109118
}
110119

111120
async initialize(): Promise<void> {
@@ -120,6 +129,9 @@ export class CoreMetrics {
120129
if (Context.config.channel) {
121130
await this.appChannel.setUndispatched(Context.config.channel);
122131
}
132+
if (Context.config.buildDate) {
133+
await this.buildDate.setUndispatched();
134+
}
123135
}
124136

125137
/**

glean/src/metrics.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,24 @@ glean.internal.metrics:
180180
- glean-team@mozilla.com
181181
expires: never
182182

183+
build_date:
184+
type: datetime
185+
time_unit: second
186+
lifetime: application
187+
send_in_pings:
188+
- glean_client_info
189+
description: |
190+
The date & time the application was built.
191+
bugs:
192+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1742448
193+
data_reviews:
194+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1742448#c17
195+
data_sensitivity:
196+
- technical
197+
notification_emails:
198+
- glean-team@mozilla.com
199+
expires: never
200+
183201
first_run_date:
184202
type: datetime
185203
lifetime: user

glean/tests/unit/core/glean.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,20 @@ describe("Glean", function() {
472472
assert.strictEqual(await metric.testGetValue(), undefined);
473473
});
474474

475-
it("appBuild and appDisplayVersion are correctly reported", async function () {
475+
it("appBuild, appDisplayVersion and buildDate are correctly reported", async function () {
476476
await testUninitializeGlean();
477477

478478
const testBuild = "test";
479479
const testDisplayVersion = "1.2.3-stella";
480480

481-
await testInitializeGlean(testAppId, true, { appBuild: testBuild, appDisplayVersion: testDisplayVersion });
481+
await testInitializeGlean(
482+
testAppId,
483+
true, {
484+
appBuild: testBuild,
485+
appDisplayVersion: testDisplayVersion,
486+
buildDate: new Date(),
487+
}
488+
);
482489
await Context.dispatcher.testBlockOnQueue();
483490

484491
assert.strictEqual(await Glean.coreMetrics.appBuild.testGetValue(), testBuild);

glean/tests/unit/core/pings/maker.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ describe("PingMaker", function() {
8686
channel: "channel",
8787
appBuild:"build",
8888
appDisplayVersion: "display version",
89+
buildDate: new Date(),
8990
serverEndpoint: "http://localhost:8080"
9091
});
9192

@@ -97,6 +98,7 @@ describe("PingMaker", function() {
9798
assert.ok("os_version" in clientInfo2);
9899
assert.ok("architecture" in clientInfo2);
99100
assert.ok("locale" in clientInfo2);
101+
assert.ok("build_date"in clientInfo2);
100102
assert.strictEqual(clientInfo2["app_channel"], "channel");
101103
assert.strictEqual(clientInfo2["app_build"], "build");
102104
assert.strictEqual(clientInfo2["app_display_version"], "display version");

samples/qt/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
glean_parser==5.0.1
1+
glean_parser==5.1.0

0 commit comments

Comments
 (0)