in glean/src/core/glean.ts [490:520]
export function setPlatform(platform: Platform): void {
// Platform can only be set if Glean is uninitialized,
// because initialize will make sure to recreate any
// databases in case another platform was set previously.
//
// **Note**: Users should only be able to replace the platform in testing
// situations, if they call initialize before calling testReset
// We want to replace whatever platform was set by initialize with the
// testing platforms in this case and that is possible because testResetGlean
// uninitializes Glean before setting the testing platform.
if (Context.initialized) {
return;
}
if (
Context.isPlatformSet() &&
Context.platform.name !== platform.name &&
!Context.testing
) {
log(
LOG_TAG,
[
`IMPOSSIBLE: Attempted to change Glean's targeted platform",
"from "${Context.platform.name}" to "${platform.name}". Ignoring.`,
],
LoggingLevel.Error
);
}
Context.platform = platform;
}