Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c40a23e
Consolidate glean.ts into one sync file
rosahbruno Nov 10, 2023
d7e73eb
Consolidate internal_metrics.ts into one sync file
rosahbruno Nov 10, 2023
65dc16f
Remove the dispatcher
rosahbruno Nov 10, 2023
67b8eb3
Remove plugins
rosahbruno Nov 10, 2023
d47632c
Consolidate platform_info.ts into one sync file
rosahbruno Nov 10, 2023
9878c04
Consolidate pings/database.ts into one sync file
rosahbruno Nov 10, 2023
84a505d
Consolidate pings/maker.ts into one sync file
rosahbruno Nov 10, 2023
59ccf10
Updates to ping_type
rosahbruno Nov 10, 2023
8108152
Consolidate error files into sync index & error_type
rosahbruno Nov 10, 2023
adb3735
Consolidate upload/manager.ts into one sync file
rosahbruno Nov 10, 2023
533934b
Consolidate upload/worker.ts into one sync file
rosahbruno Nov 10, 2023
38c98c6
Updates to upload/task.ts imports
rosahbruno Nov 10, 2023
edf5c7f
Consolidate metrics/database.ts into one sync file
rosahbruno Nov 10, 2023
2806dcd
Consolidate metrics/events_database into sync index & recorded_event …
rosahbruno Nov 10, 2023
7818757
Remove async/sync implementations for metrics
rosahbruno Nov 10, 2023
b5a557c
Consolidate storage.ts into one sync file
rosahbruno Nov 10, 2023
8531020
Consolidate entry/base.ts into one sync file
rosahbruno Nov 10, 2023
ffbb12e
entry/web.ts import updates
rosahbruno Nov 10, 2023
f2e1c73
Remove events plugin implementation
rosahbruno Nov 10, 2023
5ace3b2
Remove plugins from config.ts
rosahbruno Nov 10, 2023
1a72498
Remove async/sync implementations from context
rosahbruno Nov 10, 2023
3a51e8b
Update testing helpers
rosahbruno Nov 10, 2023
2e5ad25
Update core/utils.ts to remove async/sync implementations
rosahbruno Nov 10, 2023
5fdc58d
Remove unnecessary OptionalAsync type
rosahbruno Nov 10, 2023
11cf912
Update platform/web implementation
rosahbruno Nov 10, 2023
7c9314d
Consolidate platform/index.ts into one sync file
rosahbruno Nov 10, 2023
c7b58d5
Update platform/test utils
rosahbruno Nov 10, 2023
91ace1a
Update integration tests
rosahbruno Nov 10, 2023
479419a
Update metrics tests
rosahbruno Nov 10, 2023
f0e13a4
Update pings tests
rosahbruno Nov 10, 2023
7536c76
Update upload tests
rosahbruno Nov 10, 2023
75a9888
Update unit/core tests
rosahbruno Nov 10, 2023
3f79555
Update unit/platform tests
rosahbruno Nov 10, 2023
be886d7
Update test utils
rosahbruno Nov 10, 2023
8b3c4ae
Delete qt/requirements.txt
rosahbruno Nov 10, 2023
f9efc4e
Update glean/src/core/metrics/database.ts
rosahbruno Nov 20, 2023
46da2c9
Add space back to error_type
rosahbruno Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions glean/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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