1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Stop including MobX internals as part of telemetry

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

Co-authored-by: Juho Heikka <juho.heikka@gmail.com>
Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
Iku-turso 2022-09-02 13:53:49 +03:00
parent 7ddaa7544d
commit 26aa98f5bf
2 changed files with 34 additions and 3 deletions

View File

@ -2,14 +2,14 @@
* Copyright (c) OpenLens Authors. All rights reserved. * Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information. * 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 type { DiContainer } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting"; import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
import telemetryWhiteListForFunctionsInjectable from "./renderer/telemetry-white-list-for-functions.injectable"; import telemetryWhiteListForFunctionsInjectable from "./renderer/telemetry-white-list-for-functions.injectable";
import { runInAction } from "mobx";
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable"; import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
describe("sending-telemetry-from-white-listed-function-calls", () => { describe("emit-telemetry-from-specific-function-calls", () => {
let di: DiContainer; let di: DiContainer;
beforeEach(() => { beforeEach(() => {
@ -87,6 +87,36 @@ describe("sending-telemetry-from-white-listed-function-calls", () => {
}); });
}); });
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", () => { describe("when the non-white-listed function is called", () => {
beforeEach(() => { beforeEach(() => {
injectedNonWhiteListedFunction(); injectedNonWhiteListedFunction();

View File

@ -4,6 +4,7 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable"; import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
import { toJS, observable } from "mobx";
const emitTelemetryInjectable = getInjectable({ const emitTelemetryInjectable = getInjectable({
id: "emit-telemetry", id: "emit-telemetry",
@ -16,7 +17,7 @@ const emitTelemetryInjectable = getInjectable({
destination: "auto-capture", destination: "auto-capture",
action: "telemetry-from-business-action", action: "telemetry-from-business-action",
name: action, name: action,
params: { args }, params: { args: toJS(observable(args)) },
}); });
}; };
}, },