Skip to content

Commit 84cde1f

Browse files
committed
Merge branch 'release-v4.0.0' into release
2 parents 627555a + 0119cb8 commit 84cde1f

File tree

14 files changed

+237
-79
lines changed

14 files changed

+237
-79
lines changed

.dictionary

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 76
1+
personal_ws-1.1 en 82
22
API's
33
APIs
44
BUGFIX
@@ -12,8 +12,10 @@ ESM
1212
Glean's
1313
Gzip
1414
HTTPS
15+
IndexedDB
1516
JSDoc
1617
JWK
18+
LocalStorage
1719
MPL
1820
PingType
1921
PlatformInfo
@@ -30,6 +32,7 @@ UI
3032
UUID
3133
UploadResult
3234
UploadResultStatus
35+
async
3336
benchmarking
3437
boolean
3538
booleans
@@ -63,10 +66,12 @@ mdroettboom
6366
mozilla
6467
npm
6568
prerelease
69+
queueing
6670
runtime
6771
schemas
6872
setRawNanos
6973
setUploadEnabled
74+
ssr
7075
timespan
7176
travis
7277
unminified
@@ -77,8 +82,3 @@ uuid
7782
virtualenv
7883
webext
7984
webpack
80-
async
81-
queueing
82-
LocalStorage
83-
IndexedDB
84-
ssr

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Unreleased changes
22

3-
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0-pre.3...main)
3+
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0...main)
4+
5+
# v4.0.0 (2024-01-24)
6+
7+
[Full changelog](https://github.com/mozilla/glean.js/compare/v4.0.0-pre.3...v4.0.0)
8+
9+
* This is the official release based on the v4.x.x-pre.x releases.
410

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

automation/package-lock.json

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

docs/reference/metrics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ In addition to those built-in metrics, the following metrics are added to the pi
2222

2323
| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) |
2424
| --- | --- | --- | --- | --- | --- | --- |
25+
| glean.client.annotation.experimentation_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |An experimentation identifier derived and provided by the application for the purpose of experimentation enrollment. |[Bug 1848201](https://bugzilla.mozilla.org/show_bug.cgi?id=1848201#c5)||never |1 |
2526
| glean.error.invalid_label |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counts the number of times a metric was set with an invalid label. The labels are the `category.name` identifier of the metric. |[Bug 1499761](https://bugzilla.mozilla.org/show_bug.cgi?id=1499761#c5)||never |1 |
2627
| glean.error.invalid_overflow |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counts the number of times a metric was set a value that overflowed. The labels are the `category.name` identifier of the metric. |[Bug 1591912](https://bugzilla.mozilla.org/show_bug.cgi?id=1591912#c3)||never |1 |
2728
| glean.error.invalid_state |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counts the number of times a timing metric was used incorrectly. The labels are the `category.name` identifier of the metric. |[Bug 1499761](https://bugzilla.mozilla.org/show_bug.cgi?id=1499761#c5)||never |1 |

glean/package-lock.json

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

glean/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mozilla/glean",
3-
"version": "4.0.0-pre.3",
3+
"version": "4.0.0",
44
"description": "An implementation of the Glean SDK, a modern cross-platform telemetry client, for JavaScript environments.",
55
"type": "module",
66
"sideEffects": false,

glean/src/core/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export interface ConfigurationInterface {
5353
// Allow the client to explicitly specify whether they want to automatically capture
5454
// element clicks.
5555
readonly enableAutoElementClickEvents?: boolean,
56+
// Experimentation identifier to be set in all pings
57+
experimentationId?: string,
5658
}
5759

5860
// Important: the `Configuration` should only be used internally by the Glean singleton.
@@ -66,6 +68,7 @@ export class Configuration implements ConfigurationInterface {
6668
readonly migrateFromLegacyStorage?: boolean;
6769
readonly enableAutoPageLoadEvents?: boolean;
6870
readonly enableAutoElementClickEvents?: boolean;
71+
experimentationId?: string;
6972

7073
// Debug configuration.
7174
debug: DebugOptions;
@@ -81,6 +84,7 @@ export class Configuration implements ConfigurationInterface {
8184
this.migrateFromLegacyStorage = config?.migrateFromLegacyStorage;
8285
this.enableAutoPageLoadEvents = config?.enableAutoPageLoadEvents;
8386
this.enableAutoElementClickEvents = config?.enableAutoElementClickEvents;
87+
this.experimentationId = config?.experimentationId;
8488

8589
this.debug = {};
8690

glean/src/core/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const GLEAN_SCHEMA_VERSION = 1;
88
//
99
// PACKAGE_VERSION is defined as a global by webpack,
1010
// we need a default here for testing when the app is not build with webpack.
11-
export const GLEAN_VERSION = "4.0.0-pre.3";
11+
export const GLEAN_VERSION = "4.0.0";
1212

1313
// The name of a "ping" that will include Glean ping_info metrics,
1414
// such as ping sequence numbers.

glean/src/core/glean.ts

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import type Platform from "../platform/index.js";
88
import { CLIENT_INFO_STORAGE, KNOWN_CLIENT_ID } from "./constants.js";
99
import { Configuration } from "./config.js";
1010
import PingUploadManager from "./upload/manager.js";
11-
import { extractBooleanFromString, isBoolean, isString, sanitizeApplicationId } from "./utils.js";
11+
import {
12+
extractBooleanFromString,
13+
isBoolean,
14+
isString,
15+
sanitizeApplicationId,
16+
} from "./utils.js";
1217
import { CoreMetrics } from "./internal_metrics.js";
1318
import { DatetimeMetric } from "./metrics/types/datetime.js";
1419
import CorePings from "./internal_pings.js";
@@ -26,7 +31,7 @@ const LOG_TAG = "core.Glean";
2631
enum DebugOption {
2732
DebugTag = "DebugTag",
2833
SourceTags = "SourceTags",
29-
LogPings = "LogPings"
34+
LogPings = "LogPings",
3035
}
3136
type DebugOptionValue = keyof typeof DebugOption;
3237

@@ -36,7 +41,10 @@ type DebugOptionValue = keyof typeof DebugOption;
3641
* @param option The debug option key to set.
3742
* @param value The value of the debug option.
3843
*/
39-
const setDebugOptionInSessionStorage = (option: DebugOptionValue, value: boolean | string | string[]) => {
44+
const setDebugOptionInSessionStorage = (
45+
option: DebugOptionValue,
46+
value: boolean | string | string[]
47+
) => {
4048
const key = `Glean.${option.toString()}`;
4149

4250
switch (option) {
@@ -58,7 +66,9 @@ const setDebugOptionInSessionStorage = (option: DebugOptionValue, value: boolean
5866
* @param option The debug option key to fetch the value of.
5967
* @returns The stringified value.
6068
*/
61-
const getDebugOptionFromSessionStorage = (option: DebugOptionValue): string | undefined => {
69+
const getDebugOptionFromSessionStorage = (
70+
option: DebugOptionValue
71+
): string | undefined => {
6272
return sessionStorage.getItem(`Glean.${option.toString()}`) || undefined;
6373
};
6474

@@ -185,7 +195,10 @@ namespace Glean {
185195
*/
186196
function setDebugOptionsFromSessionStorage() {
187197
// If we cannot access browser APIs, we do nothing.
188-
if (typeof window === "undefined" || typeof window.sessionStorage === "undefined") {
198+
if (
199+
typeof window === "undefined" ||
200+
typeof window.sessionStorage === "undefined"
201+
) {
189202
return;
190203
}
191204

@@ -259,7 +272,11 @@ namespace Glean {
259272
}
260273

261274
if (!Context.platform) {
262-
log(LOG_TAG, "Unable to initialize Glean, platform has not been set.", LoggingLevel.Error);
275+
log(
276+
LOG_TAG,
277+
"Unable to initialize Glean, platform has not been set.",
278+
LoggingLevel.Error
279+
);
263280
return;
264281
}
265282

@@ -383,7 +400,7 @@ namespace Glean {
383400
[
384401
"Changing upload enabled before Glean is initialized is not supported.\n",
385402
"Pass the correct state into `initialize`.\n",
386-
"See documentation at https://mozilla.github.io/glean/book/user/general-api.html#initializing-the-glean-sdk`"
403+
"See documentation at https://mozilla.github.io/glean/book/user/general-api.html#initializing-the-glean-sdk`",
387404
],
388405
LoggingLevel.Error
389406
);
@@ -409,6 +426,15 @@ namespace Glean {
409426
}
410427
}
411428

429+
/**
430+
* Sets the experimentation identifier
431+
*
432+
* @param experimentationId The string identifier to set
433+
*/
434+
export function setExperimentationId(experimentationId: string): void {
435+
Context.config.experimentationId = experimentationId;
436+
}
437+
412438
/**
413439
* Sets the `logPings` debug option.
414440
*
@@ -484,12 +510,16 @@ namespace Glean {
484510
return;
485511
}
486512

487-
if (Context.isPlatformSet() && Context.platform.name !== platform.name && !Context.testing) {
513+
if (
514+
Context.isPlatformSet() &&
515+
Context.platform.name !== platform.name &&
516+
!Context.testing
517+
) {
488518
log(
489519
LOG_TAG,
490520
[
491521
`IMPOSSIBLE: Attempted to change Glean's targeted platform",
492-
"from "${Context.platform.name}" to "${platform.name}". Ignoring.`
522+
"from "${Context.platform.name}" to "${platform.name}". Ignoring.`,
493523
],
494524
LoggingLevel.Error
495525
);
@@ -506,17 +536,22 @@ declare global {
506536
setLogPings: (flag: boolean) => void;
507537
setDebugViewTag: (value: string) => void;
508538
setSourceTags: (value: string[]) => void;
509-
}
539+
};
510540
}
511541
}
512542

513543
// Only set `Glean` values whenever running inside of a browser.
514-
if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
544+
if (
545+
typeof window !== "undefined" &&
546+
typeof window.sessionStorage !== "undefined"
547+
) {
515548
window.Glean = {
516549
setLogPings: (flag: boolean) => {
517550
setDebugOptionInSessionStorage(DebugOption.LogPings, flag);
518551
Glean.setLogPings(flag);
519-
console.log("Pings will be logged to the console until this tab is closed.");
552+
console.log(
553+
"Pings will be logged to the console until this tab is closed."
554+
);
520555
},
521556
setDebugViewTag: (value: string) => {
522557
setDebugOptionInSessionStorage(DebugOption.DebugTag, value);
@@ -528,8 +563,10 @@ if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined
528563
setSourceTags: (value: string[]) => {
529564
setDebugOptionInSessionStorage(DebugOption.SourceTags, value);
530565
Glean.setSourceTags(value);
531-
console.log("Pings will be given the specified tags until the tab is closed.");
532-
}
566+
console.log(
567+
"Pings will be given the specified tags until the tab is closed."
568+
);
569+
},
533570
};
534571
}
535572

0 commit comments

Comments
 (0)