Closed
Bug 1701652
Opened 5 years ago
Closed 5 years ago
Disallow changing the platform after Glean has been initialized
Categories
(Data Platform and Tools Graveyard :: Glean.js, task, P1)
Data Platform and Tools Graveyard
Glean.js
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: brizental, Assigned: brizental)
Details
Attachments
(1 file)
Glean.js is built to run in different platforms. In order to deal with the different APIs in each platform, we abstract all platform specific information in a Platform structure.
Before initializing Glean, we set the platform (qt, webext). We do the same when initializing Glean for tests (testInitialize).
When we exposed Glean.testResetGlean in Bug 1693025 we suddenly have two APIs for initializing Glean and each sets a different platform. That can cause bugs, if a user attempts to override their usual Glean.initialize call with a Glean.testResetGlean in tests.
Looking at the simplified example of Bergamot's Glean integration.
// Bergamot.ts
import Glean from "@mozilla/glean/webext"
import { custom } from "./generated/pings"
class Bergamot {
constructor() {
// Other init tasks...
Glean.initialize("bergamot", true)
}
submitSomething() {
// Other submission tasks...
custom.submit()
}
}
export default new Bergamot()
And their test code.
// Telemetry.spec.ts
import Glean from "@mozilla/glean/webext"
import Bergamot from "./Bergamot"
import { string, counter } from "./generated/examples"
describe("Telemetry", function () {
beforeEach(async function () {
await Glean.testResetGlean("bergamot-test")
})
it("check that ping is sent when something is submitted", async function () {
// Execute metric recording code...
assert(await string.testGetValue("custom"), "hey ho")
assert(await counter.testGetValue("custom"), 1)
// Because Javascript lazy loads imports, this is the moment Telemetry
// is instantiated, thus also the moment Glean is initialized.
//
// Initialization is ignored with "Glean is already initialized. Ignoring",
// but the platform is changed to the web ext platform.
Bergamot.submitSomething()
assert(await string.testGetValue("custom"), undefined)
assert(await counter.testGetValue("custom"), undefined)
})
})
| Assignee | ||
Updated•5 years ago
|
Priority: P4 → P2
Whiteboard: [telemetry:glean-js:m?]
| Assignee | ||
Updated•5 years ago
|
Assignee: nobody → brizental
Priority: P2 → P1
Comment 1•5 years ago
|
||
| Assignee | ||
Updated•5 years ago
|
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Updated•4 years ago
|
Product: Data Platform and Tools → Data Platform and Tools Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•