From 1c48dda707884a81bcb56f647a0274962618921b Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 6 Apr 2023 10:11:24 -0400 Subject: [PATCH] chore: Bump @ogre-tools/* to 15.3.1 and fixup telemetry decorator Signed-off-by: Sebastian Malton --- package-lock.json | 52 ++++--- .../keyboard-shortcuts/package.json | 4 +- packages/cluster-settings/package.json | 2 +- packages/core/package.json | 4 +- ...metry-from-specific-function-calls.test.ts | 137 +----------------- ...y-decorator-for-show-details.injectable.ts | 26 +++- .../telemetry-decorator.injectable.ts | 10 +- ...for-parameterless-functions.injectable.ts} | 6 +- .../telemetry/show-details-calls.test.ts | 84 +++++++++++ packages/open-lens/package.json | 4 +- .../application/agnostic/package.json | 4 +- .../application/electron-main/package.json | 2 +- .../legacy-extensions/package.json | 2 +- .../feature-core/package.json | 2 +- .../messaging/agnostic/package.json | 2 +- .../messaging/computed-channel/package.json | 4 +- .../messaging/electron/main/package.json | 2 +- .../messaging/electron/renderer/package.json | 2 +- .../message-bridge-fake/package.json | 4 +- .../react-application/package.json | 4 +- .../utility-features/run-many/package.json | 4 +- .../utility-features/test-utils/package.json | 2 +- 22 files changed, 169 insertions(+), 194 deletions(-) rename packages/core/src/features/telemetry/renderer/{telemetry-white-list-for-functions.injectable.ts => telemetry-white-list-for-parameterless-functions.injectable.ts} (93%) create mode 100644 packages/core/src/features/telemetry/show-details-calls.test.ts diff --git a/package-lock.json b/package-lock.json index 4563d56dfe..3ae244505b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/packages/business-features/keyboard-shortcuts/package.json b/packages/business-features/keyboard-shortcuts/package.json index d04af36606..2a5b4bce07 100644 --- a/packages/business-features/keyboard-shortcuts/package.json +++ b/packages/business-features/keyboard-shortcuts/package.json @@ -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", diff --git a/packages/cluster-settings/package.json b/packages/cluster-settings/package.json index debeac76ff..3d08ad7d66 100644 --- a/packages/cluster-settings/package.json +++ b/packages/cluster-settings/package.json @@ -30,6 +30,6 @@ "rimraf": "^4.4.1" }, "peerDependencies": { - "@ogre-tools/injectable": "^15.3.0" + "@ogre-tools/injectable": "^15.3.1" } } diff --git a/packages/core/package.json b/packages/core/package.json index 7b608f9bf6..620c74017c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -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", diff --git a/packages/core/src/features/telemetry/emit-telemetry-from-specific-function-calls.test.ts b/packages/core/src/features/telemetry/emit-telemetry-from-specific-function-calls.test.ts index 4185640ebc..2840c2a9fa 100644 --- a/packages/core/src/features/telemetry/emit-telemetry-from-specific-function-calls.test.ts +++ b/packages/core/src/features/telemetry/emit-telemetry-from-specific-function-calls.test.ts @@ -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(); diff --git a/packages/core/src/features/telemetry/renderer/telemetry-decorator-for-show-details.injectable.ts b/packages/core/src/features/telemetry/renderer/telemetry-decorator-for-show-details.injectable.ts index 2a48b2d0b1..39a729bc4d 100644 --- a/packages/core/src/features/telemetry/renderer/telemetry-decorator-for-show-details.injectable.ts +++ b/packages/core/src/features/telemetry/renderer/telemetry-decorator-for-show-details.injectable.ts @@ -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); diff --git a/packages/core/src/features/telemetry/renderer/telemetry-decorator.injectable.ts b/packages/core/src/features/telemetry/renderer/telemetry-decorator.injectable.ts index 5c5a423803..02f3d5fd02 100644 --- a/packages/core/src/features/telemetry/renderer/telemetry-decorator.injectable.ts +++ b/packages/core/src/features/telemetry/renderer/telemetry-decorator.injectable.ts @@ -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; diff --git a/packages/core/src/features/telemetry/renderer/telemetry-white-list-for-functions.injectable.ts b/packages/core/src/features/telemetry/renderer/telemetry-white-list-for-parameterless-functions.injectable.ts similarity index 93% rename from packages/core/src/features/telemetry/renderer/telemetry-white-list-for-functions.injectable.ts rename to packages/core/src/features/telemetry/renderer/telemetry-white-list-for-parameterless-functions.injectable.ts index 19fe990102..c5db5b14f8 100644 --- a/packages/core/src/features/telemetry/renderer/telemetry-white-list-for-functions.injectable.ts +++ b/packages/core/src/features/telemetry/renderer/telemetry-white-list-for-parameterless-functions.injectable.ts @@ -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; diff --git a/packages/core/src/features/telemetry/show-details-calls.test.ts b/packages/core/src/features/telemetry/show-details-calls.test.ts new file mode 100644 index 0000000000..736fe13530 --- /dev/null +++ b/packages/core/src/features/telemetry/show-details-calls.test.ts @@ -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; + 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", + }, + }); + }); +}); diff --git a/packages/open-lens/package.json b/packages/open-lens/package.json index 0f057cf6b1..a666ede8d1 100644 --- a/packages/open-lens/package.json +++ b/packages/open-lens/package.json @@ -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", diff --git a/packages/technical-features/application/agnostic/package.json b/packages/technical-features/application/agnostic/package.json index 2ae3a4d4a5..aad4339276 100644 --- a/packages/technical-features/application/agnostic/package.json +++ b/packages/technical-features/application/agnostic/package.json @@ -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" }, diff --git a/packages/technical-features/application/electron-main/package.json b/packages/technical-features/application/electron-main/package.json index fd01428dc2..9c6b70db5d 100644 --- a/packages/technical-features/application/electron-main/package.json +++ b/packages/technical-features/application/electron-main/package.json @@ -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" diff --git a/packages/technical-features/application/legacy-extensions/package.json b/packages/technical-features/application/legacy-extensions/package.json index 5083dab5f2..96c726c7d5 100644 --- a/packages/technical-features/application/legacy-extensions/package.json +++ b/packages/technical-features/application/legacy-extensions/package.json @@ -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" diff --git a/packages/technical-features/feature-core/package.json b/packages/technical-features/feature-core/package.json index 7b8a22f0b2..528f9d6c9b 100644 --- a/packages/technical-features/feature-core/package.json +++ b/packages/technical-features/feature-core/package.json @@ -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" diff --git a/packages/technical-features/messaging/agnostic/package.json b/packages/technical-features/messaging/agnostic/package.json index e2ea3de09a..6411fd9286 100644 --- a/packages/technical-features/messaging/agnostic/package.json +++ b/packages/technical-features/messaging/agnostic/package.json @@ -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", diff --git a/packages/technical-features/messaging/computed-channel/package.json b/packages/technical-features/messaging/computed-channel/package.json index f11df46a3c..7c1aea0c19 100644 --- a/packages/technical-features/messaging/computed-channel/package.json +++ b/packages/technical-features/messaging/computed-channel/package.json @@ -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", diff --git a/packages/technical-features/messaging/electron/main/package.json b/packages/technical-features/messaging/electron/main/package.json index 388d532ef8..d11e1aeef3 100644 --- a/packages/technical-features/messaging/electron/main/package.json +++ b/packages/technical-features/messaging/electron/main/package.json @@ -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", diff --git a/packages/technical-features/messaging/electron/renderer/package.json b/packages/technical-features/messaging/electron/renderer/package.json index a55fc9f0e9..37d93144ac 100644 --- a/packages/technical-features/messaging/electron/renderer/package.json +++ b/packages/technical-features/messaging/electron/renderer/package.json @@ -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" diff --git a/packages/technical-features/messaging/message-bridge-fake/package.json b/packages/technical-features/messaging/message-bridge-fake/package.json index 5f89bc74d3..efb167d807 100644 --- a/packages/technical-features/messaging/message-bridge-fake/package.json +++ b/packages/technical-features/messaging/message-bridge-fake/package.json @@ -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" diff --git a/packages/technical-features/react-application/package.json b/packages/technical-features/react-application/package.json index 9182ab56fb..fc05a9ab01 100644 --- a/packages/technical-features/react-application/package.json +++ b/packages/technical-features/react-application/package.json @@ -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", diff --git a/packages/utility-features/run-many/package.json b/packages/utility-features/run-many/package.json index 1966d0e853..43d0ae451c 100644 --- a/packages/utility-features/run-many/package.json +++ b/packages/utility-features/run-many/package.json @@ -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" diff --git a/packages/utility-features/test-utils/package.json b/packages/utility-features/test-utils/package.json index 33ff6aeb42..4072cdceac 100644 --- a/packages/utility-features/test-utils/package.json +++ b/packages/utility-features/test-utils/package.json @@ -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",