mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce a centralised way to emit telemetry from calls of injectable functions (#6164)
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Co-authored-by: Juho Heikka <juho.heikka@gmail.com>
This commit is contained in:
parent
60b538eec1
commit
fc3512daf2
10
package.json
10
package.json
@ -218,11 +218,11 @@
|
||||
"@hapi/subtext": "^7.0.4",
|
||||
"@kubernetes/client-node": "^0.17.0",
|
||||
"@material-ui/styles": "^4.11.5",
|
||||
"@ogre-tools/fp": "9.0.3",
|
||||
"@ogre-tools/injectable": "9.0.3",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "9.0.3",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "9.0.3",
|
||||
"@ogre-tools/injectable-react": "9.0.3",
|
||||
"@ogre-tools/fp": "10.1.0",
|
||||
"@ogre-tools/injectable": "10.1.0",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "10.1.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "10.1.0",
|
||||
"@ogre-tools/injectable-react": "10.1.0",
|
||||
"@sentry/electron": "^3.0.7",
|
||||
"@sentry/integrations": "^6.19.3",
|
||||
"@side/jest-runtime": "^1.0.1",
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import emitEventInjectable from "./emit-event.injectable";
|
||||
|
||||
export default getGlobalOverride(emitEventInjectable, () => () => {});
|
||||
@ -9,6 +9,7 @@ const appEventBusInjectable = getInjectable({
|
||||
id: "app-event-bus",
|
||||
instantiate: () => appEventBus,
|
||||
causesSideEffects: true,
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
export default appEventBusInjectable;
|
||||
|
||||
@ -8,6 +8,7 @@ import appEventBusInjectable from "./app-event-bus.injectable";
|
||||
const emitEventInjectable = getInjectable({
|
||||
id: "emit-event",
|
||||
instantiate: (di) => di.inject(appEventBusInjectable).emit,
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
export default emitEventInjectable;
|
||||
|
||||
@ -12,7 +12,7 @@ describe("kubernetesClusterCategory", () => {
|
||||
let kubernetesClusterCategory: KubernetesClusterCategory;
|
||||
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
kubernetesClusterCategory = di.inject(kubernetesClusterCategoryInjectable);
|
||||
});
|
||||
|
||||
@ -18,6 +18,7 @@ import { requestChannelListenerInjectionToken } from "./request-channel-listener
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
import { getPromiseStatus } from "../../test-utils/get-promise-status";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
type TestMessageChannel = MessageChannel<string>;
|
||||
type TestRequestChannel = RequestChannel<string, string>;
|
||||
@ -47,13 +48,17 @@ describe("channel", () => {
|
||||
});
|
||||
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
runInAction(() => {
|
||||
mainDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testChannelListenerInTestWindowInjectable);
|
||||
windowDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
mainDi = builder.mainDi;
|
||||
|
||||
@ -126,13 +131,17 @@ describe("channel", () => {
|
||||
});
|
||||
|
||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
||||
runInAction(() => {
|
||||
mainDi.register(testChannelListenerInMainInjectable);
|
||||
mainDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
|
||||
@ -172,13 +181,17 @@ describe("channel", () => {
|
||||
});
|
||||
|
||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
||||
runInAction(() => {
|
||||
mainDi.register(testChannelListenerInMainInjectable);
|
||||
mainDi.register(testRequestChannelInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testRequestChannelInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
|
||||
|
||||
@ -18,13 +18,17 @@ describe("sync-box", () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
||||
runInAction(() => {
|
||||
mainDi.register(someInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(someInjectable);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("given application is started, when value is set in main", () => {
|
||||
let valueInMain: string;
|
||||
|
||||
@ -19,7 +19,7 @@ describe("with-error-logging", () => {
|
||||
let decorated: (a: string, b: string) => number | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
loggerStub = {
|
||||
error: jest.fn(),
|
||||
@ -119,7 +119,7 @@ describe("with-error-logging", () => {
|
||||
let toBeDecorated: AsyncFnMock<typeof decorated>;
|
||||
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
loggerStub = {
|
||||
error: jest.fn(),
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { runInAction } from "mobx";
|
||||
import type { LensExtension } from "../../lens-extension";
|
||||
import { extensionRegistratorInjectionToken } from "../extension-registrator-injection-token";
|
||||
|
||||
@ -27,17 +28,23 @@ const extensionInjectable = getInjectable({
|
||||
getInjectablesOfExtension(instance),
|
||||
);
|
||||
|
||||
runInAction(() => {
|
||||
childDi.register(...injectables);
|
||||
});
|
||||
},
|
||||
|
||||
deregister: () => {
|
||||
runInAction(() => {
|
||||
parentDi.deregister(extensionInjectable);
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
parentDi.register(extensionInjectable);
|
||||
});
|
||||
|
||||
return parentDi.inject(extensionInjectable);
|
||||
},
|
||||
|
||||
@ -19,6 +19,7 @@ import quitAndInstallUpdateInjectable from "../../main/application-update/quit-a
|
||||
import appVersionInjectable from "../../common/vars/app-version.injectable";
|
||||
import periodicalCheckForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable";
|
||||
import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
|
||||
describe("analytics for installing update", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
@ -51,6 +52,8 @@ describe("analytics for installing update", () => {
|
||||
|
||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||
|
||||
mainDi.unoverride(emitEventInjectable);
|
||||
|
||||
const eventBus = mainDi.inject(appEventBusInjectable);
|
||||
|
||||
eventBus.addListener(analyticsListenerMock);
|
||||
@ -65,7 +68,6 @@ describe("analytics for installing update", () => {
|
||||
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
|
||||
|
||||
await builder.render();
|
||||
|
||||
});
|
||||
|
||||
it("sends event to analytics for being checked periodically", () => {
|
||||
|
||||
@ -10,7 +10,7 @@ import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import React from "react";
|
||||
import { navigateToRouteInjectionToken } from "../../../../common/front-end-routing/navigate-to-route-injection-token";
|
||||
import { routeSpecificComponentInjectionToken } from "../../../../renderer/routes/route-specific-component-injection-token";
|
||||
@ -45,8 +45,10 @@ describe("disable kube object detail items when cluster is not relevant", () =>
|
||||
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
|
||||
@ -39,8 +39,10 @@ describe("reactively hide kube object detail item", () => {
|
||||
} as unknown as ApiManager),
|
||||
);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import React from "react";
|
||||
import { navigateToRouteInjectionToken } from "../../../../common/front-end-routing/navigate-to-route-injection-token";
|
||||
import { routeSpecificComponentInjectionToken } from "../../../../renderer/routes/route-specific-component-injection-token";
|
||||
@ -32,8 +32,11 @@ describe("disable kube object menu items when cluster is not relevant", () => {
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
|
||||
@ -26,8 +26,10 @@ describe("reactively hide kube object menu item", () => {
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import React from "react";
|
||||
import { navigateToRouteInjectionToken } from "../../../../common/front-end-routing/navigate-to-route-injection-token";
|
||||
import { routeSpecificComponentInjectionToken } from "../../../../renderer/routes/route-specific-component-injection-token";
|
||||
@ -33,8 +33,11 @@ describe("disable kube object statuses when cluster is not relevant", () => {
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
|
||||
@ -29,8 +29,11 @@ describe("reactively hide kube object status", () => {
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import { useFakeTime } from "../../../common/test-utils/use-fake-time";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { IAtom } from "mobx";
|
||||
import { createAtom, computed } from "mobx";
|
||||
import { runInAction, createAtom, computed } from "mobx";
|
||||
import { frontEndRouteInjectionToken } from "../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { routeSpecificComponentInjectionToken } from "../../../renderer/routes/route-specific-component-injection-token";
|
||||
import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
@ -94,6 +94,7 @@ describe("show status for a kube object", () => {
|
||||
});
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(
|
||||
testRouteInjectable,
|
||||
testRouteComponentInjectable,
|
||||
@ -102,6 +103,8 @@ describe("show status for a kube object", () => {
|
||||
criticalStatusInjectable,
|
||||
someAtomInjectable,
|
||||
);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
@ -141,7 +144,9 @@ describe("show status for a kube object", () => {
|
||||
|
||||
describe("when status for irrelevant kube object kind emerges", () => {
|
||||
beforeEach(() => {
|
||||
runInAction(() => {
|
||||
windowDi.register(statusForIrrelevantKubeObjectKindInjectable);
|
||||
});
|
||||
|
||||
rerenderParent();
|
||||
});
|
||||
@ -161,7 +166,9 @@ describe("show status for a kube object", () => {
|
||||
|
||||
describe("when status for irrelevant kube object api version emerges", () => {
|
||||
beforeEach(() => {
|
||||
runInAction(() => {
|
||||
windowDi.register(statusForIrrelevantKubeObjectApiVersionInjectable);
|
||||
});
|
||||
|
||||
rerenderParent();
|
||||
});
|
||||
|
||||
@ -7,7 +7,7 @@ import type { RenderResult } from "@testing-library/react";
|
||||
import { fireEvent } from "@testing-library/react";
|
||||
import type { SidebarItemRegistration } from "../../renderer/components/layout/sidebar-items.injectable";
|
||||
import { sidebarItemsInjectionToken } from "../../renderer/components/layout/sidebar-items.injectable";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import { noop } from "lodash/fp";
|
||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
@ -22,9 +22,11 @@ describe("cluster - order of sidebar items", () => {
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
@ -11,7 +11,7 @@ import directoryForLensLocalStorageInjectable from "../../common/directory-for-l
|
||||
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
|
||||
import type { SidebarItemRegistration } from "../../renderer/components/layout/sidebar-items.injectable";
|
||||
import { sidebarItemsInjectionToken } from "../../renderer/components/layout/sidebar-items.injectable";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import { noop } from "lodash/fp";
|
||||
import routeIsActiveInjectable from "../../renderer/routes/route-is-active.injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../common/front-end-routing/front-end-route-injection-token";
|
||||
@ -51,11 +51,13 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
describe("given core registrations", () => {
|
||||
beforeEach(() => {
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable);
|
||||
windowDi.register(testRouteComponentInjectable);
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import type { SidebarItemRegistration } from "../../renderer/components/layout/sidebar-items.injectable";
|
||||
import { sidebarItemsInjectionToken } from "../../renderer/components/layout/sidebar-items.injectable";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
|
||||
import React from "react";
|
||||
import isAllowedResourceInjectable from "../../common/utils/is-allowed-resource.injectable";
|
||||
@ -25,11 +25,13 @@ describe("cluster - visibility of sidebar items", () => {
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable);
|
||||
windowDi.register(testRouteComponentInjectable);
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("given kube resource for route is not allowed", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
@ -8,7 +8,7 @@ import React from "react";
|
||||
import getRandomIdInjectable from "../../../../../common/utils/get-random-id.injectable";
|
||||
import { workloadOverviewDetailInjectionToken } from "../../../../../renderer/components/+workloads-overview/workload-overview-details/workload-overview-detail-injection-token";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
|
||||
describe("order of workload overview details", () => {
|
||||
let rendered: RenderResult;
|
||||
@ -20,12 +20,14 @@ describe("order of workload overview details", () => {
|
||||
windowDi.unoverride(getRandomIdInjectable);
|
||||
windowDi.permitSideEffects(getRandomIdInjectable);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(
|
||||
someCoreItemWithLowOrderNumberInjectable,
|
||||
someCoreItemWithHighOrderNumberInjectable,
|
||||
someCoreItemWithDefaultOrderNumberInjectable,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import React from "react";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { routeSpecificComponentInjectionToken } from "../renderer/routes/route-specific-component-injection-token";
|
||||
import { observer } from "mobx-react";
|
||||
@ -32,9 +32,11 @@ describe("navigating between routes", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteWithoutPathParametersInjectable);
|
||||
windowDi.register(testRouteWithoutPathParametersComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
@ -106,9 +108,11 @@ describe("navigating between routes", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(routeWithOptionalPathParametersInjectable);
|
||||
windowDi.register(routeWithOptionalPathParametersComponentInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/ge
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import currentPathInjectable from "../../renderer/routes/current-path.injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import { preferenceNavigationItemInjectionToken } from "../../renderer/components/+preferences/preferences-navigation/preference-navigation-items.injectable";
|
||||
import routeIsActiveInjectable from "../../renderer/routes/route-is-active.injectable";
|
||||
import { Preferences } from "../../renderer/components/+preferences";
|
||||
@ -30,11 +30,13 @@ describe("preferences - closing-preferences", () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testPreferencesRouteInjectable);
|
||||
windowDi.register(testPreferencesRouteComponentInjectable);
|
||||
windowDi.register(testFrontPageRouteInjectable);
|
||||
windowDi.register(testFrontPageRouteComponentInjectable);
|
||||
windowDi.register(testNavigationItemInjectable);
|
||||
});
|
||||
|
||||
windowDi.override(navigateToFrontPageInjectable, (di) => {
|
||||
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
|
||||
|
||||
@ -13,6 +13,7 @@ import focusApplicationInjectable from "../../main/electron-app/features/focus-a
|
||||
import type { CreateElectronWindow } from "../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
|
||||
import createElectronWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
|
||||
import splashWindowInjectable from "../../main/start-main-application/lens-window/splash-window/splash-window.injectable";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
describe("opening application window using tray", () => {
|
||||
describe("given application has started", () => {
|
||||
@ -61,10 +62,12 @@ describe("opening application window using tray", () => {
|
||||
return browserWindow;
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
(mainDi as any).decorateFunction(
|
||||
createElectronWindowInjectable,
|
||||
createElectronWindowMock,
|
||||
);
|
||||
});
|
||||
|
||||
expectWindowsToBeOpen = expectWindowsToBeOpenFor(builder);
|
||||
});
|
||||
|
||||
@ -0,0 +1,146 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { computed, runInAction } from "mobx";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
|
||||
import telemetryWhiteListForFunctionsInjectable from "./renderer/telemetry-white-list-for-functions.injectable";
|
||||
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
|
||||
describe("emit-telemetry-from-specific-function-calls", () => {
|
||||
let di: DiContainer;
|
||||
|
||||
beforeEach(() => {
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
});
|
||||
|
||||
describe("given a telemetry white-list for injectables which instantiate a function", () => {
|
||||
let emitEventMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
di.override(telemetryWhiteListForFunctionsInjectable, () => [
|
||||
"some-white-listed-function",
|
||||
]);
|
||||
|
||||
emitEventMock = jest.fn();
|
||||
di.override(emitEventInjectable, () => emitEventMock);
|
||||
});
|
||||
|
||||
describe("given instances of white-listed, non-white-listed and tagged functions", () => {
|
||||
let whiteListedFunctionMock: jest.Mock;
|
||||
let nonWhiteListedFunctionMock: jest.Mock;
|
||||
let taggedFunctionMock: jest.Mock;
|
||||
let injectedWhiteListedFunction: jest.Mock;
|
||||
let injectedNonWhiteListedFunction: jest.Mock;
|
||||
let injectedTaggedFunction: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
whiteListedFunctionMock = jest.fn();
|
||||
nonWhiteListedFunctionMock = jest.fn();
|
||||
taggedFunctionMock = jest.fn();
|
||||
|
||||
const whiteListedInjectable = getInjectable({
|
||||
id: "some-white-listed-function",
|
||||
instantiate: () => whiteListedFunctionMock,
|
||||
});
|
||||
|
||||
const nonWhiteListedInjectable = getInjectable({
|
||||
id: "some-non-white-listed-function",
|
||||
instantiate: () => nonWhiteListedFunctionMock,
|
||||
});
|
||||
|
||||
const taggedInjectable = getInjectable({
|
||||
id: "some-tagged-function",
|
||||
instantiate: () => taggedFunctionMock,
|
||||
tags: ["emit-telemetry"],
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
di.register(whiteListedInjectable);
|
||||
di.register(nonWhiteListedInjectable);
|
||||
di.register(taggedInjectable);
|
||||
});
|
||||
|
||||
injectedWhiteListedFunction = di.inject(whiteListedInjectable);
|
||||
injectedNonWhiteListedFunction = di.inject(nonWhiteListedInjectable);
|
||||
injectedTaggedFunction = di.inject(taggedInjectable);
|
||||
});
|
||||
|
||||
it("telemetry is not emitted yet", () => {
|
||||
expect(emitEventMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("when the white-listed function is called", () => {
|
||||
beforeEach(() => {
|
||||
injectedWhiteListedFunction("some-arg", "some-other-arg");
|
||||
});
|
||||
|
||||
it("telemetry is emitted in event bus", () => {
|
||||
expect(emitEventMock).toHaveBeenCalledWith({
|
||||
destination: "auto-capture",
|
||||
action: "telemetry-from-business-action",
|
||||
name: "some-white-listed-function",
|
||||
params: { args: ["some-arg", "some-other-arg"] },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the white-listed function is called with MobX reactive content", () => {
|
||||
beforeEach(() => {
|
||||
const someComputedProperty = computed(() => "some-computed-value");
|
||||
|
||||
const someObservable = {
|
||||
someStaticProperty: "some-static-value",
|
||||
someComputedProperty,
|
||||
};
|
||||
|
||||
injectedWhiteListedFunction(someObservable);
|
||||
});
|
||||
|
||||
it("telemetry is emitted in event bus without MobX internals or computeds", () => {
|
||||
expect(emitEventMock).toHaveBeenCalledWith({
|
||||
destination: "auto-capture",
|
||||
action: "telemetry-from-business-action",
|
||||
name: "some-white-listed-function",
|
||||
|
||||
params: {
|
||||
args: [
|
||||
{
|
||||
someStaticProperty: "some-static-value",
|
||||
someComputedProperty: "some-computed-value",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the non-white-listed function is called", () => {
|
||||
beforeEach(() => {
|
||||
injectedNonWhiteListedFunction();
|
||||
});
|
||||
|
||||
it("telemetry is not emitted", () => {
|
||||
expect(emitEventMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the tagged, but not white-listed function is called", () => {
|
||||
beforeEach(() => {
|
||||
injectedTaggedFunction("some-arg", "some-other-arg");
|
||||
});
|
||||
|
||||
it("telemetry is emitted in event bus", () => {
|
||||
expect(emitEventMock).toHaveBeenCalledWith({
|
||||
destination: "auto-capture",
|
||||
action: "telemetry-from-business-action",
|
||||
name: "some-tagged-function",
|
||||
params: { args: ["some-arg", "some-other-arg"] },
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
28
src/features/telemetry/renderer/emit-telemetry.injectable.ts
Normal file
28
src/features/telemetry/renderer/emit-telemetry.injectable.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
||||
import { toJS, observable } from "mobx";
|
||||
|
||||
const emitTelemetryInjectable = getInjectable({
|
||||
id: "emit-telemetry",
|
||||
|
||||
instantiate: (di) => {
|
||||
const emitEvent = di.inject(emitEventInjectable);
|
||||
|
||||
return ({ action, args }: { action: string; args: any[] }) => {
|
||||
emitEvent({
|
||||
destination: "auto-capture",
|
||||
action: "telemetry-from-business-action",
|
||||
name: action,
|
||||
params: { args: toJS(observable(args)) },
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
export default emitTelemetryInjectable;
|
||||
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type {
|
||||
DiContainerForInjection,
|
||||
Injectable,
|
||||
} from "@ogre-tools/injectable";
|
||||
|
||||
import {
|
||||
lifecycleEnum,
|
||||
getInjectable,
|
||||
instantiationDecoratorToken,
|
||||
} from "@ogre-tools/injectable";
|
||||
import assert from "assert";
|
||||
|
||||
import { isFunction } from "lodash/fp";
|
||||
import emitTelemetryInjectable from "./emit-telemetry.injectable";
|
||||
import telemetryWhiteListForFunctionsInjectable from "./telemetry-white-list-for-functions.injectable";
|
||||
|
||||
const telemetryDecoratorInjectable = getInjectable({
|
||||
id: "telemetry-decorator",
|
||||
|
||||
instantiate: (diForDecorator) => {
|
||||
const emitTelemetry = diForDecorator.inject(emitTelemetryInjectable);
|
||||
|
||||
const whiteList = diForDecorator.inject(
|
||||
telemetryWhiteListForFunctionsInjectable,
|
||||
);
|
||||
|
||||
const shouldEmitTelemetry = shouldEmitTelemetryFor(whiteList);
|
||||
|
||||
return {
|
||||
decorate:
|
||||
(instantiateToBeDecorated: any) =>
|
||||
(di: DiContainerForInjection, instantiationParameter: any) => {
|
||||
const instance = instantiateToBeDecorated(di, instantiationParameter);
|
||||
|
||||
if (isFunction(instance)) {
|
||||
return (...args: any[]) => {
|
||||
const currentContext = di.context.at(-1);
|
||||
|
||||
assert(currentContext);
|
||||
|
||||
if (shouldEmitTelemetry(currentContext.injectable)) {
|
||||
emitTelemetry({ action: currentContext.injectable.id, args });
|
||||
}
|
||||
|
||||
return instance(...args);
|
||||
};
|
||||
}
|
||||
|
||||
return instance;
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
decorable: false,
|
||||
// Todo: this is required because of imperfect typing in injectable.
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
injectionToken: instantiationDecoratorToken,
|
||||
});
|
||||
|
||||
const shouldEmitTelemetryFor =
|
||||
(whiteList: string[]) => (injectable: Injectable<any, any, any>) =>
|
||||
injectable.tags?.includes("emit-telemetry") ||
|
||||
whiteList.includes(injectable.id);
|
||||
|
||||
export default telemetryDecoratorInjectable;
|
||||
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
|
||||
const telemetryWhiteListForFunctionsInjectable = getInjectable({
|
||||
id: "telemetry-white-list-for-functions",
|
||||
instantiate: () => ["some-placeholder-injectable-id"],
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
export default telemetryWhiteListForFunctionsInjectable;
|
||||
@ -5,11 +5,15 @@
|
||||
import { createContainer } from "@ogre-tools/injectable";
|
||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { runInAction } from "mobx";
|
||||
import { Environments, setLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||
|
||||
export const getDi = () => {
|
||||
const di = createContainer("main");
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.main);
|
||||
|
||||
runInAction(() => {
|
||||
registerMobX(di);
|
||||
|
||||
autoRegister({
|
||||
@ -21,8 +25,7 @@ export const getDi = () => {
|
||||
require.context("../features", true, /.*\/(main|common)\/.*\.injectable\.(ts|tsx)$/),
|
||||
],
|
||||
});
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.main);
|
||||
});
|
||||
|
||||
return di;
|
||||
};
|
||||
|
||||
@ -55,7 +55,7 @@ import setupRunnablesBeforeClosingOfApplicationInjectable from "./electron-app/r
|
||||
import showMessagePopupInjectable from "./electron-app/features/show-message-popup.injectable";
|
||||
import clusterFramesInjectable from "../common/cluster-frames.injectable";
|
||||
import type { ClusterFrameInfo } from "../common/cluster-frames";
|
||||
import { observable } from "mobx";
|
||||
import { observable, runInAction } from "mobx";
|
||||
import waitForElectronToBeReadyInjectable from "./electron-app/features/wait-for-electron-to-be-ready.injectable";
|
||||
import setupListenerForCurrentClusterFrameInjectable from "./start-main-application/lens-window/current-cluster-frame/setup-listener-for-current-cluster-frame.injectable";
|
||||
import setupRunnablesAfterWindowIsOpenedInjectable from "./electron-app/runnables/setup-runnables-after-window-is-opened.injectable";
|
||||
@ -103,19 +103,21 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
|
||||
|
||||
const di = createContainer("main");
|
||||
|
||||
registerMobX(di);
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.main);
|
||||
|
||||
di.preventSideEffects();
|
||||
|
||||
const injectables: Injectable<any, any, any>[] = (global as any).mainInjectablePaths.map(
|
||||
(filePath: string) => require(filePath).default,
|
||||
);
|
||||
|
||||
runInAction(() => {
|
||||
registerMobX(di);
|
||||
|
||||
chunk(100)(injectables).forEach(chunkInjectables => {
|
||||
di.register(...chunkInjectables);
|
||||
});
|
||||
|
||||
di.preventSideEffects();
|
||||
});
|
||||
|
||||
if (doGeneralOverrides) {
|
||||
const globalOverrides: GlobalOverride[] = (global as any).mainGlobalOverridePaths.map(
|
||||
|
||||
@ -20,6 +20,7 @@ import type { SetRequired } from "type-fest";
|
||||
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
||||
import kubectlBinaryNameInjectable from "../kubectl/binary-name.injectable";
|
||||
import kubectlDownloadingNormalizedArchInjectable from "../kubectl/normalized-arch.injectable";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
describe("router", () => {
|
||||
let router: Router;
|
||||
@ -53,7 +54,9 @@ describe("router", () => {
|
||||
injectionToken: routeInjectionToken,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
di.register(injectable);
|
||||
});
|
||||
|
||||
router = di.inject(routerInjectable);
|
||||
});
|
||||
|
||||
@ -10,6 +10,7 @@ import appNameInjectable from "../../../app-paths/app-name/app-name.injectable";
|
||||
import appEventBusInjectable from "../../../../common/app-event-bus/app-event-bus.injectable";
|
||||
import waitUntilBundledExtensionsAreLoadedInjectable from "./wait-until-bundled-extensions-are-loaded.injectable";
|
||||
import { applicationWindowInjectionToken } from "./application-window-injection-token";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
const createApplicationWindowInjectable = getInjectable({
|
||||
id: "create-application-window",
|
||||
@ -49,7 +50,9 @@ const createApplicationWindowInjectable = getInjectable({
|
||||
},
|
||||
|
||||
onClose: () => {
|
||||
runInAction(() => {
|
||||
parentDi.deregister(windowInjectable);
|
||||
});
|
||||
},
|
||||
|
||||
beforeOpen: waitUntilBundledExtensionsAreLoaded,
|
||||
@ -59,7 +62,9 @@ const createApplicationWindowInjectable = getInjectable({
|
||||
injectionToken: applicationWindowInjectionToken,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
parentDi.register(windowInjectable);
|
||||
});
|
||||
|
||||
return parentDi.inject(windowInjectable);
|
||||
},
|
||||
|
||||
@ -20,7 +20,7 @@ describe("technical: resolve-system-proxy-from-electron", () => {
|
||||
let actualPromise: Promise<string>;
|
||||
|
||||
beforeEach(() => {
|
||||
di = getDiForUnitTesting();
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
logErrorMock = jest.fn();
|
||||
di.override(logErrorInjectable, () => logErrorMock);
|
||||
|
||||
@ -80,7 +80,7 @@ describe("CatalogEntityRegistry", () => {
|
||||
let catalogCategoryRegistry: CatalogCategoryRegistry;
|
||||
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
entityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||
catalogCategoryRegistry = di.inject(catalogCategoryRegistryInjectable);
|
||||
|
||||
@ -43,7 +43,7 @@ describe("Custom Category Columns", () => {
|
||||
let di: DiContainer;
|
||||
|
||||
beforeEach(() => {
|
||||
di = getDiForUnitTesting();
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
di.override(hotbarStoreInjectable, () => ({}));
|
||||
});
|
||||
|
||||
@ -16,7 +16,7 @@ describe("Custom Category Views", () => {
|
||||
let di: DiContainer;
|
||||
|
||||
beforeEach(() => {
|
||||
di = getDiForUnitTesting();
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
});
|
||||
|
||||
it("should order items correctly over all extensions", () => {
|
||||
|
||||
@ -14,7 +14,7 @@ import { ConfirmDialog } from "../confirm-dialog";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import { computed } from "mobx";
|
||||
import { computed, runInAction } from "mobx";
|
||||
import clusterInjectable from "./dependencies/cluster.injectable";
|
||||
import type { DiRender } from "../test-utils/renderFor";
|
||||
import { renderFor } from "../test-utils/renderFor";
|
||||
@ -34,11 +34,13 @@ describe("kube-object-menu", () => {
|
||||
beforeEach(() => {
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
runInAction(() => {
|
||||
di.register(
|
||||
someMenuItemInjectable,
|
||||
someOtherMenuItemInjectable,
|
||||
someAnotherMenuItemInjectable,
|
||||
);
|
||||
});
|
||||
|
||||
render = renderFor(di);
|
||||
|
||||
|
||||
@ -143,7 +143,9 @@ export const getApplicationBuilder = () => {
|
||||
doGeneralOverrides: true,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
mainDi.register(mainExtensionsStateInjectable);
|
||||
});
|
||||
|
||||
const overrideChannelsForWindow = overrideChannels(mainDi);
|
||||
|
||||
@ -184,7 +186,9 @@ export const getApplicationBuilder = () => {
|
||||
|
||||
overrideChannelsForWindow(windowDi, windowId);
|
||||
|
||||
runInAction(() => {
|
||||
windowDi.register(rendererExtensionsStateInjectable);
|
||||
});
|
||||
|
||||
windowDi.override(
|
||||
currentlyInClusterFrameInjectable,
|
||||
@ -552,10 +556,12 @@ export const getApplicationBuilder = () => {
|
||||
getExtensionFakeForMain(mainDi, extension.id, extension.name, extension.mainOptions || {}),
|
||||
);
|
||||
|
||||
runInAction(() => {
|
||||
mainExtensionInstances.forEach(
|
||||
enableExtensionFor(mainDi, mainExtensionsStateInjectable),
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
disable: (...extensions) => {
|
||||
|
||||
@ -6,11 +6,15 @@
|
||||
import { createContainer } from "@ogre-tools/injectable";
|
||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { runInAction } from "mobx";
|
||||
import { Environments, setLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||
|
||||
export const getDi = () => {
|
||||
const di = createContainer("renderer");
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.renderer);
|
||||
|
||||
runInAction(() => {
|
||||
registerMobX(di);
|
||||
|
||||
autoRegister({
|
||||
@ -22,8 +26,7 @@ export const getDi = () => {
|
||||
require.context("../features", true, /.*\/(renderer|common)\/.*\.injectable\.(ts|tsx)$/),
|
||||
],
|
||||
});
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.renderer);
|
||||
});
|
||||
|
||||
return di;
|
||||
};
|
||||
|
||||
@ -33,7 +33,7 @@ import lensResourcesDirInjectable from "../common/vars/lens-resources-dir.inject
|
||||
import broadcastMessageInjectable from "../common/ipc/broadcast-message.injectable";
|
||||
import apiManagerInjectable from "../common/k8s-api/api-manager/manager.injectable";
|
||||
import setupOnApiErrorListenersInjectable from "./api/setup-on-api-errors.injectable";
|
||||
import { observable, computed } from "mobx";
|
||||
import { observable, computed, runInAction } from "mobx";
|
||||
import defaultShellInjectable from "./components/+preferences/default-shell.injectable";
|
||||
import appVersionInjectable from "../common/vars/app-version.injectable";
|
||||
import requestAnimationFrameInjectable from "./components/animate/request-animation-frame.injectable";
|
||||
@ -68,26 +68,30 @@ import getEntitySettingCommandsInjectable from "./components/command-palette/reg
|
||||
import storageSaveDelayInjectable from "./utils/create-storage/storage-save-delay.injectable";
|
||||
import type { GlobalOverride } from "../common/test-utils/get-global-override";
|
||||
|
||||
export const getDiForUnitTesting = (opts: { doGeneralOverrides?: boolean } = {}) => {
|
||||
const {
|
||||
doGeneralOverrides = false,
|
||||
} = opts;
|
||||
export const getDiForUnitTesting = (
|
||||
opts: { doGeneralOverrides?: boolean } = {},
|
||||
) => {
|
||||
const { doGeneralOverrides = false } = opts;
|
||||
|
||||
const di = createContainer("renderer");
|
||||
|
||||
registerMobX(di);
|
||||
di.preventSideEffects();
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.renderer);
|
||||
|
||||
const injectables: Injectable<any, any, any>[] = (global as any).rendererInjectablePaths.map(
|
||||
const injectables: Injectable<any, any, any>[] = (
|
||||
global as any
|
||||
).rendererInjectablePaths.map(
|
||||
(filePath: string) => require(filePath).default,
|
||||
);
|
||||
|
||||
chunk(100)(injectables).forEach(chunkInjectables => {
|
||||
runInAction(() => {
|
||||
registerMobX(di);
|
||||
|
||||
chunk(100)(injectables).forEach((chunkInjectables) => {
|
||||
di.register(...chunkInjectables);
|
||||
});
|
||||
|
||||
di.preventSideEffects();
|
||||
});
|
||||
|
||||
if (doGeneralOverrides) {
|
||||
const globalOverrides: GlobalOverride[] = (global as any).rendererGlobalOverridePaths.map(
|
||||
|
||||
@ -33,6 +33,8 @@ const navigateToRouteInjectable = getInjectable({
|
||||
};
|
||||
},
|
||||
|
||||
tags: ["emit-telemetry"],
|
||||
|
||||
injectionToken: navigateToRouteInjectionToken,
|
||||
});
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { runInAction } from "mobx";
|
||||
import type { CreateStorage } from "./create-storage";
|
||||
import createStorageInjectable from "./create-storage.injectable";
|
||||
|
||||
@ -19,8 +20,10 @@ export const controlWhenStoragesAreReady = (di: DiContainer) => {
|
||||
return storage;
|
||||
};
|
||||
|
||||
runInAction(() => {
|
||||
// TODO: Remove when typing is added to the library
|
||||
(di as any).decorateFunction(createStorageInjectable, decorated);
|
||||
});
|
||||
|
||||
return async () => {
|
||||
await Promise.all(storagesAreReady);
|
||||
|
||||
54
yarn.lock
54
yarn.lock
@ -1240,46 +1240,46 @@
|
||||
mkdirp "^1.0.4"
|
||||
rimraf "^3.0.2"
|
||||
|
||||
"@ogre-tools/fp@9.0.3", "@ogre-tools/fp@^9.0.3":
|
||||
version "9.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/fp/-/fp-9.0.3.tgz#f8c9a3316b688c4782309e050c86aa04bebfc293"
|
||||
integrity sha512-j5TQAxiz6ncEfYFBcqnWXeLZY89Qd+dZ9UlfonBdw/C9okxjNeFL+2bmt+b/Vxscz1cOLGZ1F6nmlhQdTtHzPw==
|
||||
"@ogre-tools/fp@10.1.0", "@ogre-tools/fp@^10.1.0":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/fp/-/fp-10.1.0.tgz#e83c4dad97416c62d89913c0c0a34e734ae06b8b"
|
||||
integrity sha512-ZqGQXytucSWbSoNjrdyHAiIWO0LotxBU+aI5hCcqedWg9TzNzf78YKD6ngHXxVEwT/JYsslxXMxzE4LNdo8Cbg==
|
||||
dependencies:
|
||||
lodash "^4.17.21"
|
||||
|
||||
"@ogre-tools/injectable-extension-for-auto-registration@9.0.3":
|
||||
version "9.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-auto-registration/-/injectable-extension-for-auto-registration-9.0.3.tgz#a26d2a39e24ec3a0800fe21141c0f4f0e7d5504d"
|
||||
integrity sha512-0zjt4w1ACBX9a3FyhTD+/AAqk/xov2bw+Cnbte7NMOVWAbHDfQpmbdiKJlMnFcMUd8vdwOEMm1Z4ogT1VkUeqg==
|
||||
"@ogre-tools/injectable-extension-for-auto-registration@10.1.0":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-auto-registration/-/injectable-extension-for-auto-registration-10.1.0.tgz#a46d23cf5cf880e416a46238ecb54e7f933f9d89"
|
||||
integrity sha512-G9UKcaYr4DHViXHIKigzy6jI2ZhQC+K6idc1M4W/l4IazaV26Gwj1MSI5nrJ6Z4aRAzILFKM4dzkvZNFjkyGrw==
|
||||
dependencies:
|
||||
"@ogre-tools/fp" "^9.0.3"
|
||||
"@ogre-tools/injectable" "^9.0.3"
|
||||
"@ogre-tools/fp" "^10.1.0"
|
||||
"@ogre-tools/injectable" "^10.1.0"
|
||||
lodash "^4.17.21"
|
||||
|
||||
"@ogre-tools/injectable-extension-for-mobx@9.0.3":
|
||||
version "9.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-mobx/-/injectable-extension-for-mobx-9.0.3.tgz#24a14b940f51cae8b07645a2376d804b826c659e"
|
||||
integrity sha512-DgCbAIqMPKgeNETY/8nxz6llAk8fAihGcbs/fkKINe4N9zFgOBKsuk/w67Sx0rTE7l35L6HQenbo7nJhIqbCWA==
|
||||
"@ogre-tools/injectable-extension-for-mobx@10.1.0":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-mobx/-/injectable-extension-for-mobx-10.1.0.tgz#b1efaafb048f2ceb5588daad708dbeffbd2ec7d1"
|
||||
integrity sha512-G5A6FSgBMTlD6Qdd6xzeuVzcyHGS+tTUW7DCBbYLJqZ3Y8/PprSomhunrNrrcuZdM0K16BpQT8o6OHw4Z/Kqiw==
|
||||
dependencies:
|
||||
"@ogre-tools/fp" "^9.0.3"
|
||||
"@ogre-tools/injectable" "^9.0.3"
|
||||
"@ogre-tools/fp" "^10.1.0"
|
||||
"@ogre-tools/injectable" "^10.1.0"
|
||||
lodash "^4.17.21"
|
||||
|
||||
"@ogre-tools/injectable-react@9.0.3":
|
||||
version "9.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-react/-/injectable-react-9.0.3.tgz#bc125ef906b171c8894f711f8b61f38d49e81dd0"
|
||||
integrity sha512-6O9vr19Mcy0uUekZhRyjsM5nw8pgFXhbNvZ8JOnBQg6Lp1CqdasIFhJ0Hdxb8w8P9Zs+pd8pfevRVotq0ouV2Q==
|
||||
"@ogre-tools/injectable-react@10.1.0":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-react/-/injectable-react-10.1.0.tgz#5c9b4b5eb9e5843cc966629131104055180ba18c"
|
||||
integrity sha512-4ReLJm8QcruCEm4KFhbsXLki3YiKRwlg3Mg7C2d8KyUfg+MUA5VdvgQSn3HthnyejiXlYCinqJLw83IryX/GNA==
|
||||
dependencies:
|
||||
"@ogre-tools/fp" "^9.0.3"
|
||||
"@ogre-tools/injectable" "^9.0.3"
|
||||
"@ogre-tools/fp" "^10.1.0"
|
||||
"@ogre-tools/injectable" "^10.1.0"
|
||||
lodash "^4.17.21"
|
||||
|
||||
"@ogre-tools/injectable@9.0.3", "@ogre-tools/injectable@^9.0.3":
|
||||
version "9.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable/-/injectable-9.0.3.tgz#6d9e01a5be7e7c96e7bcbc727f928faad5e11884"
|
||||
integrity sha512-KCmqcMEl/1Jjwg6XzNve+JVaW/OtiJUOKBucTJx2ZKBlAQaKz1/VUP7IB4UoQ4RWVa0+mUKLTxBTQFBQfp05RA==
|
||||
"@ogre-tools/injectable@10.1.0", "@ogre-tools/injectable@^10.1.0":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable/-/injectable-10.1.0.tgz#5051cc6a673576028e00439fc3e3f053ecdda030"
|
||||
integrity sha512-7h7P5nfAFqnSny341FFT6cbJCmXVlGqA4zwTOpwKsGyC1h90NWtQZ+PUxY5MKl7rFWW/wpXgAKQqtf27Vy41Qw==
|
||||
dependencies:
|
||||
"@ogre-tools/fp" "^9.0.3"
|
||||
"@ogre-tools/fp" "^10.1.0"
|
||||
lodash "^4.17.21"
|
||||
|
||||
"@pmmmwh/react-refresh-webpack-plugin@^0.5.7":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user