mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Bump @ogre-tools/* to 15.3.1 and fixup telemetry decorator
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
672ddc7b8d
commit
1c48dda707
52
package-lock.json
generated
52
package-lock.json
generated
@ -6283,6 +6283,8 @@
|
||||
},
|
||||
"node_modules/@ogre-tools/fp": {
|
||||
"version": "15.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@ogre-tools/fp/-/fp-15.3.1.tgz",
|
||||
"integrity": "sha512-ac+UTkht4QPRcp6WO7hrJOgV098NGK1NgeVlrQQiUXY4mCSoCaZNQJVkL0B6e7LLUsPtnLLzdg/F6SctwIMI6A==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"lodash": "^4.17.21"
|
||||
@ -6290,6 +6292,8 @@
|
||||
},
|
||||
"node_modules/@ogre-tools/injectable": {
|
||||
"version": "15.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@ogre-tools/injectable/-/injectable-15.3.1.tgz",
|
||||
"integrity": "sha512-4jbA0ENTJ++hyRcRb2trPC5NdRgVrCYCV9+JxsUa0+4pwfVnSTFhz3Kw64icnoO8289OlcHfdEKsSbCSV/IsMQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/fp": "*",
|
||||
@ -31326,8 +31330,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/react-application": "^1.0.0-alpha.0",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.1.2",
|
||||
"lodash": "^4.17.21",
|
||||
@ -31346,7 +31350,7 @@
|
||||
"rimraf": "^4.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0"
|
||||
"@ogre-tools/injectable": "^15.3.1"
|
||||
}
|
||||
},
|
||||
"packages/cluster-settings/node_modules/@types/node": {
|
||||
@ -31574,8 +31578,8 @@
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
|
||||
"@k8slens/test-utils": "^1.0.0-alpha.1",
|
||||
"@k8slens/utilities": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
@ -32548,8 +32552,8 @@
|
||||
"@k8slens/run-many": "^1.0.0-alpha.2",
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.2",
|
||||
"@k8slens/utilities": "^1.0.0-alpha.2",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
@ -33013,8 +33017,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/run-many": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"lodash": "^4.17.15"
|
||||
}
|
||||
@ -33032,7 +33036,7 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/run-many": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"electron": "^22.3.3",
|
||||
"lodash": "^4.17.21"
|
||||
@ -33046,7 +33050,7 @@
|
||||
"@k8slens/eslint-config": "^6.5.0-alpha.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0"
|
||||
"@ogre-tools/injectable": "^15.3.1"
|
||||
}
|
||||
},
|
||||
"packages/technical-features/feature-core": {
|
||||
@ -33057,7 +33061,7 @@
|
||||
"@k8slens/eslint-config": "^6.5.0-alpha.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0"
|
||||
"@ogre-tools/injectable": "^15.3.1"
|
||||
}
|
||||
},
|
||||
"packages/technical-features/messaging/agnostic": {
|
||||
@ -33071,7 +33075,7 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
@ -33091,8 +33095,8 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
@ -33111,7 +33115,7 @@
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.1.2",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"electron": "^22.3.3",
|
||||
"lodash": "^4.17.21"
|
||||
@ -33130,7 +33134,7 @@
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@k8slens/run-many": "^1.0.0-alpha.1",
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"electron": "^22.3.3",
|
||||
"lodash": "^4.17.21"
|
||||
@ -33147,8 +33151,8 @@
|
||||
"@async-fn/jest": "^1.6.4",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.2",
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mobx": "^6.9.0"
|
||||
@ -33167,8 +33171,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/application": "^6.5.0-alpha.2",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
@ -33299,8 +33303,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/test-utils": "^1.0.0-alpha.1",
|
||||
"@k8slens/utilities": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"type-fest": "^2.19.0",
|
||||
"typed-emitter": "^1.4.0",
|
||||
"uuid": "^8.3.2"
|
||||
@ -33327,7 +33331,7 @@
|
||||
"@types/lodash": "^4.14.191"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
"@testing-library/react": "^12.1.5",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/react-application": "^1.0.0-alpha.0",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.1.2",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@ -30,6 +30,6 @@
|
||||
"rimraf": "^4.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0"
|
||||
"@ogre-tools/injectable": "^15.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,8 +321,8 @@
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
|
||||
"@k8slens/test-utils": "^1.0.0-alpha.1",
|
||||
"@k8slens/utilities": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
* 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 { 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 telemetryWhiteListForParameterlessFunctionsInjectable from "./renderer/telemetry-white-list-for-parameterless-functions.injectable";
|
||||
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
import logErrorInjectable from "../../common/log-error.injectable";
|
||||
import telemetryDecoratorInjectable from "./renderer/telemetry-decorator.injectable";
|
||||
@ -24,66 +24,35 @@ describe("emit-telemetry-from-specific-function-calls", () => {
|
||||
let emitEventMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
di.override(telemetryWhiteListForFunctionsInjectable, () => [
|
||||
di.override(telemetryWhiteListForParameterlessFunctionsInjectable, () => new Set([
|
||||
"some-white-listed-function",
|
||||
|
||||
{
|
||||
id: "some-white-listed-function-with-white-listed-argument",
|
||||
getParams: (irrelevantArg, arg) => ({ someParam: arg }),
|
||||
},
|
||||
|
||||
{
|
||||
id: "some-white-listed-function-with-bad-config",
|
||||
|
||||
getParams: () => {
|
||||
throw new Error("some-error-from-bad-configuration");
|
||||
},
|
||||
},
|
||||
]);
|
||||
]));
|
||||
|
||||
emitEventMock = jest.fn();
|
||||
di.override(emitEventInjectable, () => emitEventMock);
|
||||
});
|
||||
|
||||
describe("given instances of white-listed and non-white-listed functions", () => {
|
||||
let whiteListedFunctionMock: jest.Mock;
|
||||
let nonWhiteListedFunctionMock: jest.Mock;
|
||||
let whiteListedFunction: jest.Mock;
|
||||
let whiteListedFunctionWithArgument: jest.Mock;
|
||||
let whiteListedFunctionWithFaultyConfig: jest.Mock;
|
||||
let nonWhiteListedFunction: jest.Mock;
|
||||
let logErrorMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
whiteListedFunctionMock = jest.fn();
|
||||
nonWhiteListedFunctionMock = jest.fn();
|
||||
logErrorMock = jest.fn();
|
||||
|
||||
const whiteListedInjectable = getInjectable({
|
||||
id: "some-white-listed-function",
|
||||
instantiate: () => whiteListedFunctionMock,
|
||||
});
|
||||
|
||||
const whiteListedInjectableWithArgument = getInjectable({
|
||||
id: "some-white-listed-function-with-white-listed-argument",
|
||||
instantiate: () => whiteListedFunctionMock,
|
||||
});
|
||||
|
||||
const whiteListedInjectableWithBadConfig = getInjectable({
|
||||
id: "some-white-listed-function-with-bad-config",
|
||||
instantiate: () => whiteListedFunctionMock,
|
||||
instantiate: () => jest.fn(),
|
||||
});
|
||||
|
||||
const nonWhiteListedInjectable = getInjectable({
|
||||
id: "some-non-white-listed-function",
|
||||
instantiate: () => nonWhiteListedFunctionMock,
|
||||
instantiate: () => jest.fn(),
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
di.register(
|
||||
whiteListedInjectable,
|
||||
whiteListedInjectableWithArgument,
|
||||
whiteListedInjectableWithBadConfig,
|
||||
nonWhiteListedInjectable,
|
||||
);
|
||||
});
|
||||
@ -91,15 +60,6 @@ describe("emit-telemetry-from-specific-function-calls", () => {
|
||||
di.override(logErrorInjectable, () => logErrorMock);
|
||||
|
||||
whiteListedFunction = di.inject(whiteListedInjectable);
|
||||
|
||||
whiteListedFunctionWithArgument = di.inject(
|
||||
whiteListedInjectableWithArgument,
|
||||
);
|
||||
|
||||
whiteListedFunctionWithFaultyConfig = di.inject(
|
||||
whiteListedInjectableWithBadConfig,
|
||||
);
|
||||
|
||||
nonWhiteListedFunction = di.inject(nonWhiteListedInjectable);
|
||||
});
|
||||
|
||||
@ -107,7 +67,7 @@ describe("emit-telemetry-from-specific-function-calls", () => {
|
||||
expect(emitEventMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("doesn't log errors, at least yet", () => {
|
||||
it("doesn't log errors yet", () => {
|
||||
expect(logErrorMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -125,89 +85,6 @@ describe("emit-telemetry-from-specific-function-calls", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a white-listed function with a white-listed argument is called with arguments", () => {
|
||||
beforeEach(() => {
|
||||
whiteListedFunctionWithArgument("some-arg", "some-other-arg");
|
||||
});
|
||||
|
||||
it("telemetry is emitted in event bus with the arguments as params", () => {
|
||||
expect(emitEventMock).toHaveBeenCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "some-white-listed-function-with-white-listed-argument",
|
||||
params: { someParam: "some-other-arg" },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a white-listed function with a white-listed argument is called without arguments", () => {
|
||||
beforeEach(() => {
|
||||
whiteListedFunctionWithArgument();
|
||||
});
|
||||
|
||||
it("telemetry is emitted in event bus without params", () => {
|
||||
expect(emitEventMock).toHaveBeenCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "some-white-listed-function-with-white-listed-argument",
|
||||
params: { someParam: undefined },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("given a faulty configuration, when a white-listed function is called", () => {
|
||||
beforeEach(() => {
|
||||
whiteListedFunctionWithFaultyConfig();
|
||||
});
|
||||
|
||||
it("telemetry is still emitted in event bus, but with params indicating bad configuration, ", () => {
|
||||
expect(emitEventMock).toHaveBeenCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "some-white-listed-function-with-bad-config",
|
||||
params: { error: "Tried to produce params for telemetry, but getParams() threw an error" },
|
||||
});
|
||||
});
|
||||
|
||||
it("logs error", () => {
|
||||
expect(logErrorMock).toHaveBeenCalledWith(
|
||||
'Tried to produce params for telemetry of "some-white-listed-function-with-bad-config", but getParams() threw an error',
|
||||
expect.objectContaining({ message: "some-error-from-bad-configuration" }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a white-listed function with a white-listed argument is called with MobX reactive content", () => {
|
||||
beforeEach(() => {
|
||||
const someComputedProperty = computed(() => "some-computed-value");
|
||||
|
||||
const someObservable = {
|
||||
someStaticProperty: "some-static-value",
|
||||
someComputedProperty,
|
||||
};
|
||||
|
||||
whiteListedFunctionWithArgument(
|
||||
"irrelevant-argument",
|
||||
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-with-white-listed-argument",
|
||||
|
||||
params: {
|
||||
someParam: {
|
||||
someStaticProperty: "some-static-value",
|
||||
someComputedProperty: "some-computed-value",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the non-white-listed function is called", () => {
|
||||
beforeEach(() => {
|
||||
nonWhiteListedFunction();
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable, createInstantiationTargetDecorator, instantiationDecoratorToken } from "@ogre-tools/injectable";
|
||||
import { pick } from "lodash";
|
||||
import { parseKubeApi } from "../../../common/k8s-api/kube-api-parse";
|
||||
import showDetailsInjectable from "../../../renderer/components/kube-detail-params/show-details.injectable";
|
||||
import emitTelemetryInjectable from "./emit-telemetry.injectable";
|
||||
@ -16,17 +17,26 @@ const telemetryDecoratorForShowDetailsInjectable = getInjectable({
|
||||
const showDetails = instantiate(di);
|
||||
|
||||
return (...args) => {
|
||||
emitTelemetry({
|
||||
action: showDetailsInjectable.id,
|
||||
params: {
|
||||
kind: (() => {
|
||||
const params = args[0]
|
||||
? {
|
||||
action: "open",
|
||||
...(() => {
|
||||
try {
|
||||
return parseKubeApi(args[0] || "").resource;
|
||||
} catch {
|
||||
return "";
|
||||
return {
|
||||
resource: pick(parseKubeApi(args[0]), "apiPrefix", "apiVersion", "apiGroup", "namespace", "resource", "name"),
|
||||
};
|
||||
} catch (error) {
|
||||
return { error: `${error}` };
|
||||
}
|
||||
})(),
|
||||
},
|
||||
}
|
||||
: {
|
||||
action: "close",
|
||||
};
|
||||
|
||||
emitTelemetry({
|
||||
action: showDetailsInjectable.id,
|
||||
params,
|
||||
});
|
||||
|
||||
return showDetails(...args);
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { injectionDecoratorToken, getInjectable } from "@ogre-tools/injectable";
|
||||
import { getInjectable, instantiationDecoratorToken, createInstantiationTargetDecorator } from "@ogre-tools/injectable";
|
||||
import assert from "assert";
|
||||
import emitTelemetryInjectable from "./emit-telemetry.injectable";
|
||||
import telemetryWhiteListForFunctionsInjectable from "./telemetry-white-list-for-functions.injectable";
|
||||
import telemetryWhiteListForParameterlessFunctionsInjectable from "./telemetry-white-list-for-parameterless-functions.injectable";
|
||||
import { isFunction } from "@k8slens/utilities";
|
||||
|
||||
const basicTelemetryDecoratorInjectable = getInjectable({
|
||||
id: "basic-telemetry-decorator",
|
||||
|
||||
instantiate: (diForDecorator) => ({
|
||||
instantiate: (diForDecorator) => createInstantiationTargetDecorator({
|
||||
decorate: (instantiateToBeDecorated) =>
|
||||
(di, instantiationParameter) => {
|
||||
const instance = instantiateToBeDecorated(di, instantiationParameter);
|
||||
@ -23,7 +23,7 @@ const basicTelemetryDecoratorInjectable = getInjectable({
|
||||
assert(currentContext);
|
||||
|
||||
const emitTelemetry = diForDecorator.inject(emitTelemetryInjectable);
|
||||
const whiteList = diForDecorator.inject(telemetryWhiteListForFunctionsInjectable);
|
||||
const whiteList = diForDecorator.inject(telemetryWhiteListForParameterlessFunctionsInjectable);
|
||||
|
||||
if (whiteList.has(currentContext.injectable.id)) {
|
||||
emitTelemetry({
|
||||
@ -40,7 +40,7 @@ const basicTelemetryDecoratorInjectable = getInjectable({
|
||||
}),
|
||||
|
||||
decorable: false,
|
||||
injectionToken: injectionDecoratorToken,
|
||||
injectionToken: instantiationDecoratorToken,
|
||||
});
|
||||
|
||||
export default basicTelemetryDecoratorInjectable;
|
||||
|
||||
@ -92,8 +92,8 @@ const externalActions = ["open-link-in-browser"];
|
||||
|
||||
const terminal = ["create-terminal-tab"];
|
||||
|
||||
const telemetryWhiteListForFunctionsInjectable = getInjectable({
|
||||
id: "telemetry-white-list-for-functions",
|
||||
const telemetryWhiteListForParameterlessFunctionsInjectable = getInjectable({
|
||||
id: "telemetry-white-list-for-parameterless-functions",
|
||||
instantiate: () => new Set([
|
||||
...navigateTo,
|
||||
...helmInjectableIds,
|
||||
@ -105,4 +105,4 @@ const telemetryWhiteListForFunctionsInjectable = getInjectable({
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
export default telemetryWhiteListForFunctionsInjectable;
|
||||
export default telemetryWhiteListForParameterlessFunctionsInjectable;
|
||||
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { EmitAppEvent } from "../../common/app-event-bus/emit-event.injectable";
|
||||
import emitAppEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
import type { ShowDetails } from "../../renderer/components/kube-detail-params/show-details.injectable";
|
||||
import showDetailsInjectable from "../../renderer/components/kube-detail-params/show-details.injectable";
|
||||
import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
|
||||
|
||||
describe("emit telemetry with params for calls to showDetails", () => {
|
||||
let emitAppEventMock: jest.MockedFunction<EmitAppEvent>;
|
||||
let showDetails: ShowDetails;
|
||||
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
|
||||
emitAppEventMock = jest.fn();
|
||||
di.override(emitAppEventInjectable, () => emitAppEventMock);
|
||||
showDetails = di.inject(showDetailsInjectable);
|
||||
});
|
||||
|
||||
it("when showDetails is called with no selflink (ie closing) should emit telemetry with param indicating closing the drawer", () => {
|
||||
showDetails(undefined);
|
||||
|
||||
expect(emitAppEventMock).toBeCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "show-details",
|
||||
params: {
|
||||
action: "close",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("when showDetails is called with empty selflink (ie closing) should emit telemetry with param indicating closing the drawer", () => {
|
||||
showDetails("");
|
||||
|
||||
expect(emitAppEventMock).toBeCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "show-details",
|
||||
params: {
|
||||
action: "close",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("when showDetails is called with valid selflink should emit telemetry with param indicating opening the drawer with that resource", () => {
|
||||
showDetails("/api/v1/namespaces/default/pods/some-name");
|
||||
|
||||
expect(emitAppEventMock).toBeCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "show-details",
|
||||
params: {
|
||||
action: "open",
|
||||
resource: {
|
||||
apiPrefix: "/api",
|
||||
apiGroup: "",
|
||||
apiVersion: "v1",
|
||||
name: "some-name",
|
||||
namespace: "default",
|
||||
resource: "pods",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("when showDetails is called with invalid selflink should emit telemetry with param indicating opening the drawer but also show error", () => {
|
||||
showDetails("some-non-self-link-value");
|
||||
|
||||
expect(emitAppEventMock).toBeCalledWith({
|
||||
action: "telemetry-from-business-action",
|
||||
destination: "auto-capture",
|
||||
name: "show-details",
|
||||
params: {
|
||||
action: "open",
|
||||
error: "Error: invalid apiPath: /some-non-self-link-value",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -201,8 +201,8 @@
|
||||
"@k8slens/run-many": "^1.0.0-alpha.2",
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.2",
|
||||
"@k8slens/utilities": "^1.0.0-alpha.2",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/run-many": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"lodash": "^4.17.15"
|
||||
},
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/run-many": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"electron": "^22.3.3",
|
||||
"lodash": "^4.17.21"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
"lint:fix": "lens-lint --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0"
|
||||
"@ogre-tools/injectable": "^15.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@k8slens/eslint-config": "^6.5.0-alpha.2"
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
"lint:fix": "lens-lint --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0"
|
||||
"@ogre-tools/injectable": "^15.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@k8slens/eslint-config": "^6.5.0-alpha.2"
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@ -34,8 +34,8 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.1.2",
|
||||
"electron": "^22.3.3",
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@k8slens/run-many": "^1.0.0-alpha.1",
|
||||
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"electron": "^22.3.3",
|
||||
"lodash": "^4.17.21"
|
||||
|
||||
@ -34,8 +34,8 @@
|
||||
"@async-fn/jest": "^1.6.4",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.2",
|
||||
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mobx": "^6.9.0"
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/application": "^6.5.0-alpha.2",
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/test-utils": "^1.0.0-alpha.1",
|
||||
"@k8slens/utilities": "^1.0.0-alpha.1",
|
||||
"@ogre-tools/fp": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/fp": "^15.3.1",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"type-fest": "^2.19.0",
|
||||
"typed-emitter": "^1.4.0",
|
||||
"uuid": "^8.3.2"
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
"build": "webpack"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/injectable": "^15.3.0",
|
||||
"@ogre-tools/injectable": "^15.3.1",
|
||||
"@ogre-tools/injectable-react": "^15.3.0",
|
||||
"@testing-library/react": "^12.1.5",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user