Skip to content

Commit

Permalink
Merge branch 'release-v4.0.0-pre.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexterp37 committed Nov 27, 2023
2 parents ce6fabf + e41374a commit c138e71
Show file tree
Hide file tree
Showing 121 changed files with 2,527 additions and 8,711 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Unreleased changes

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

# v4.0.0-pre.0 (2023-11-27)

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

# v3.0.0 (2023-11-16)

Expand Down
30 changes: 8 additions & 22 deletions glean/package-lock.json

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

10 changes: 2 additions & 8 deletions glean/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mozilla/glean",
"version": "3.0.0",
"version": "4.0.0-pre.0",
"description": "An implementation of the Glean SDK, a modern cross-platform telemetry client, for JavaScript environments.",
"type": "module",
"sideEffects": false,
Expand All @@ -9,7 +9,6 @@
"./package.json": "./package.json",
"./private/metrics/*": "./dist/core/metrics/types/*.js",
"./private/ping": "./dist/core/pings/ping_type.js",
"./plugins/*": "./dist/plugins/*.js",
"./uploader": "./dist/core/upload/uploader.js",
"./testing": "./dist/core/testing/index.js",
"./web": "./dist/entry/web.js"
Expand All @@ -25,9 +24,6 @@
"private/metrics/*": [
"./dist/types/core/metrics/types/*"
],
"plugins/*": [
"./dist/types/plugins/*"
],
"uploader": [
"./dist/types/core/upload/uploader.d.ts"
],
Expand All @@ -51,9 +47,8 @@
"test": "run-s test:unit test:integration",
"test:integration": "npm run test:base -- \"tests/integration/**/*.spec.ts\" --recursive",
"pretest:integration": "../bin/parser-for-schema-testing.sh && ../bin/python-env-vars-test.sh",
"test:unit": "run-s test:unit:core test:unit:platform test:unit:plugins",
"test:unit": "run-s test:unit:core test:unit:platform",
"test:unit:core": "npm run test:base -- \"tests/unit/core/**/*.spec.ts\" --recursive",
"test:unit:plugins": "npm run test:base -- \"tests/unit/plugins/**/*.spec.ts\" --recursive",
"test:unit:platform": "npm run test:base -- \"tests/unit/platform/**/*.spec.ts\" --recursive --timeout 0",
"test:base": "node --experimental-modules --experimental-specifier-resolution=node --loader=ts-node/esm node_modules/mocha/lib/cli/cli.js",
"lint": "run-s lint:eslint lint:circular-deps lint:glinter",
Expand Down Expand Up @@ -129,7 +124,6 @@
},
"dependencies": {
"fflate": "^0.8.0",
"jose": "^4.0.4",
"tslib": "^2.3.1",
"uuid": "^9.0.0"
},
Expand Down
3 changes: 0 additions & 3 deletions glean/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { DEFAULT_TELEMETRY_ENDPOINT, GLEAN_MAX_SOURCE_TAGS } from "./constants.js";
import type Plugin from "../plugins/index.js";
import { validateHeader, validateURL } from "./utils.js";
import type Uploader from "./upload/uploader.js";
import log, { LoggingLevel } from "./log.js";
Expand Down Expand Up @@ -41,8 +40,6 @@ export interface ConfigurationInterface {
readonly serverEndpoint?: string,
// The maximum number of events to store before submitting the events ping.
readonly maxEvents?: number,
// Optional list of plugins to include in current Glean instance.
plugins?: Plugin[],
// The HTTP client implementation to use for uploading pings.
httpClient?: Uploader,
// The build date, provided by glean_parser
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 = "3.0.0";
export const GLEAN_VERSION = "4.0.0-pre.0";

// The name of a "ping" that will include Glean ping_info metrics,
// such as ping sequence numbers.
Expand Down
72 changes: 24 additions & 48 deletions glean/src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type MetricsDatabase from "./metrics/database/async.js";
import type MetricsDatabaseSync from "./metrics/database/sync.js";

import type EventsDatabase from "./metrics/events_database/async.js";
import type { EventsDatabaseSync } from "./metrics/events_database/sync.js";

import type PingsDatabase from "./pings/database/async.js";
import type PingsDatabaseSync from "./pings/database/sync.js";

import type ErrorManager from "./error/async.js";
import type ErrorManagerSync from "./error/sync.js";

import type Platform from "../platform/async.js";
import type PlatformSync from "../platform/sync.js";

import type { CoreMetrics } from "./internal_metrics/async.js";
import type { CoreMetricsSync } from "./internal_metrics/sync.js";
import type MetricsDatabase from "./metrics/database.js";
import type EventsDatabase from "./metrics/events_database/index.js";
import type PingsDatabase from "./pings/database.js";
import type ErrorManager from "./error/index.js";
import type Platform from "../platform/index.js";
import type { CoreMetrics } from "./internal_metrics.js";

import type { Configuration } from "./config.js";
import type CorePings from "./internal_pings.js";
import type { Metric } from "./metrics/metric.js";
import type { JSONValue } from "./utils.js";

import Dispatcher from "./dispatcher.js";
import log, { LoggingLevel } from "./log.js";

const LOG_TAG = "core.Context";
Expand All @@ -45,20 +33,17 @@ const LOG_TAG = "core.Context";
export class Context {
private static _instance?: Context;

// The dispatcher is only used with the non-web (async) implementation.
private dispatcher: Dispatcher;

private platform!: Platform | PlatformSync;
private platform!: Platform;
private corePings!: CorePings;
private coreMetrics!: CoreMetrics | CoreMetricsSync;
private coreMetrics!: CoreMetrics;

// The following group of properties are all set on Glean.initialize
// Attempting to get them before they are set will log an error.
private uploadEnabled!: boolean;
private metricsDatabase!: MetricsDatabase | MetricsDatabaseSync;
private eventsDatabase!: EventsDatabase | EventsDatabaseSync;
private pingsDatabase!: PingsDatabase | PingsDatabaseSync;
private errorManager!: ErrorManager | ErrorManagerSync;
private metricsDatabase!: MetricsDatabase;
private eventsDatabase!: EventsDatabase;
private pingsDatabase!: PingsDatabase;
private errorManager!: ErrorManager;
private applicationId!: string;
private config!: Configuration;

Expand All @@ -79,7 +64,6 @@ export class Context {

private constructor() {
this.startTime = new Date();
this.dispatcher = new Dispatcher();
}

static get instance(): Context {
Expand All @@ -99,10 +83,6 @@ export class Context {
Context._instance = undefined;
}

static get dispatcher(): Dispatcher {
return Context.instance.dispatcher;
}

static get uploadEnabled(): boolean {
if (typeof Context.instance.uploadEnabled === "undefined") {
log(
Expand All @@ -121,7 +101,7 @@ export class Context {
Context.instance.uploadEnabled = upload;
}

static get metricsDatabase(): MetricsDatabase | MetricsDatabaseSync {
static get metricsDatabase(): MetricsDatabase {
if (typeof Context.instance.metricsDatabase === "undefined") {
log(
LOG_TAG,
Expand All @@ -135,11 +115,11 @@ export class Context {
return Context.instance.metricsDatabase;
}

static set metricsDatabase(db: MetricsDatabase | MetricsDatabaseSync) {
static set metricsDatabase(db: MetricsDatabase) {
Context.instance.metricsDatabase = db;
}

static get eventsDatabase(): EventsDatabase | EventsDatabaseSync {
static get eventsDatabase(): EventsDatabase {
if (typeof Context.instance.eventsDatabase === "undefined") {
log(
LOG_TAG,
Expand All @@ -153,11 +133,11 @@ export class Context {
return Context.instance.eventsDatabase;
}

static set eventsDatabase(db: EventsDatabase | EventsDatabaseSync) {
static set eventsDatabase(db: EventsDatabase) {
Context.instance.eventsDatabase = db;
}

static get pingsDatabase(): PingsDatabase | PingsDatabaseSync {
static get pingsDatabase(): PingsDatabase {
if (typeof Context.instance.pingsDatabase === "undefined") {
log(
LOG_TAG,
Expand All @@ -171,11 +151,11 @@ export class Context {
return Context.instance.pingsDatabase;
}

static set pingsDatabase(db: PingsDatabase | PingsDatabaseSync) {
static set pingsDatabase(db: PingsDatabase) {
Context.instance.pingsDatabase = db;
}

static get errorManager(): ErrorManager | ErrorManagerSync {
static get errorManager(): ErrorManager {
if (typeof Context.instance.errorManager === "undefined") {
log(
LOG_TAG,
Expand All @@ -189,7 +169,7 @@ export class Context {
return Context.instance.errorManager;
}

static set errorManager(db: ErrorManager | ErrorManagerSync) {
static set errorManager(db: ErrorManager) {
Context.instance.errorManager = db;
}

Expand Down Expand Up @@ -257,19 +237,19 @@ export class Context {
Context.instance.corePings = pings;
}

static get coreMetrics(): CoreMetrics | CoreMetricsSync {
static get coreMetrics(): CoreMetrics {
return Context.instance.coreMetrics;
}

static set coreMetrics(metrics: CoreMetrics | CoreMetricsSync) {
static set coreMetrics(metrics: CoreMetrics) {
Context.instance.coreMetrics = metrics;
}

static set platform(platform: Platform | PlatformSync) {
static set platform(platform: Platform) {
Context.instance.platform = platform;
}

static get platform(): Platform | PlatformSync {
static get platform(): Platform {
if (typeof Context.instance.platform === "undefined") {
log(
LOG_TAG,
Expand All @@ -287,10 +267,6 @@ export class Context {
return !!Context.instance.platform;
}

static isPlatformSync(): boolean {
return Context.instance.platform?.name === "web";
}

static getSupportedMetric(
type: string
): (new (v: unknown) => Metric<JSONValue, JSONValue>) | undefined {
Expand Down
Loading

0 comments on commit c138e71

Please sign in to comment.