mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Include reason for checking for updates in analytic event
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
02c373f480
commit
b7e165cdba
@ -17,6 +17,7 @@ import type { DownloadPlatformUpdate } from "../../main/application-update/downl
|
|||||||
import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||||
import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable";
|
import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable";
|
||||||
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||||
|
import periodicalCheckForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable";
|
||||||
|
|
||||||
describe("analytics for installing update", () => {
|
describe("analytics for installing update", () => {
|
||||||
let applicationBuilder: ApplicationBuilder;
|
let applicationBuilder: ApplicationBuilder;
|
||||||
@ -26,6 +27,8 @@ describe("analytics for installing update", () => {
|
|||||||
let mainDi: DiContainer;
|
let mainDi: DiContainer;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
global.Date.now = () => new Date("2015-10-21T07:28:00Z").getTime();
|
global.Date.now = () => new Date("2015-10-21T07:28:00Z").getTime();
|
||||||
|
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
@ -55,32 +58,70 @@ describe("analytics for installing update", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainDi = applicationBuilder.dis.mainDi;
|
mainDi = applicationBuilder.dis.mainDi;
|
||||||
|
|
||||||
await applicationBuilder.render();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sends event to analytics about the current version", () => {
|
describe("given application is started and checking updates periodically", () => {
|
||||||
expect(analyticsListenerMock).toHaveBeenCalledWith({
|
beforeEach(async () => {
|
||||||
name: "app",
|
mainDi.unoverride(periodicalCheckForUpdatesInjectable);
|
||||||
action: "current-version",
|
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
|
||||||
|
|
||||||
|
await applicationBuilder.render();
|
||||||
|
|
||||||
params: {
|
|
||||||
version: "42.0.0",
|
|
||||||
currentDateTime: "2015-10-21T07:28:00Z",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("when checking for updates", () => {
|
it("sends event to analytics for being checked periodically", () => {
|
||||||
beforeEach(() => {
|
expect(analyticsListenerMock).toHaveBeenCalledWith({
|
||||||
|
name: "app",
|
||||||
|
action: "checking-for-updates",
|
||||||
|
|
||||||
|
params: {
|
||||||
|
currentDateTime: "2015-10-21T07:28:00Z",
|
||||||
|
source: "periodic",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("when enough time passes to check for updates again, sends event to analytics for being checked periodically", () => {
|
||||||
analyticsListenerMock.mockClear();
|
analyticsListenerMock.mockClear();
|
||||||
|
|
||||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
jest.advanceTimersByTime(1000 * 60 * 60 * 2);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
expect(analyticsListenerMock).toHaveBeenCalledWith({
|
||||||
|
name: "app",
|
||||||
|
action: "checking-for-updates",
|
||||||
|
|
||||||
|
params: {
|
||||||
|
currentDateTime: "2015-10-21T07:28:00Z",
|
||||||
|
source: "periodic",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when application is started", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
analyticsListenerMock.mockClear();
|
||||||
|
|
||||||
|
await applicationBuilder.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sends event to analytics about checking for updates", () => {
|
it("sends event to analytics about the current version", () => {
|
||||||
|
expect(analyticsListenerMock).toHaveBeenCalledWith({
|
||||||
|
name: "app",
|
||||||
|
action: "current-version",
|
||||||
|
|
||||||
|
params: {
|
||||||
|
version: "42.0.0",
|
||||||
|
currentDateTime: "2015-10-21T07:28:00Z",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("when checking for updates using tray, sends event to analytics for being checked from tray", async () => {
|
||||||
|
analyticsListenerMock.mockClear();
|
||||||
|
|
||||||
|
applicationBuilder.tray.click("check-for-updates");
|
||||||
|
|
||||||
expect(analyticsListenerMock.mock.calls).toEqual([
|
expect(analyticsListenerMock.mock.calls).toEqual([
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -89,14 +130,40 @@ describe("analytics for installing update", () => {
|
|||||||
|
|
||||||
params: {
|
params: {
|
||||||
currentDateTime: "2015-10-21T07:28:00Z",
|
currentDateTime: "2015-10-21T07:28:00Z",
|
||||||
|
source: "tray",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("when checking for updates using application menu, sends event to analytics for being checked from application menu", async () => {
|
||||||
|
analyticsListenerMock.mockClear();
|
||||||
|
|
||||||
|
applicationBuilder.applicationMenu.click("root.check-for-updates");
|
||||||
|
|
||||||
|
expect(analyticsListenerMock.mock.calls).toEqual([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: "app",
|
||||||
|
action: "checking-for-updates",
|
||||||
|
|
||||||
|
params: {
|
||||||
|
currentDateTime: "2015-10-21T07:28:00Z",
|
||||||
|
source: "application-menu",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when check for updates resolves with new update being available", () => {
|
describe("given checking for updates, when check for updates resolves with new update being available", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
analyticsListenerMock.mockClear();
|
analyticsListenerMock.mockClear();
|
||||||
|
|
||||||
await checkForPlatformUpdatesMock.resolve({
|
await checkForPlatformUpdatesMock.resolve({
|
||||||
|
|||||||
@ -77,7 +77,7 @@ describe("downgrading version update", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(expect.any(Object), { allowDowngrade: downgradeIsAllowed });
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(expect.any(Object), { allowDowngrade: downgradeIsAllowed });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -67,7 +67,7 @@ describe("installing update", () => {
|
|||||||
|
|
||||||
describe("when started", () => {
|
describe("when started", () => {
|
||||||
let rendered: RenderResult;
|
let rendered: RenderResult;
|
||||||
let processCheckingForUpdates: () => Promise<void>;
|
let processCheckingForUpdates: (source: string) => Promise<void>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
rendered = await applicationBuilder.render();
|
rendered = await applicationBuilder.render();
|
||||||
@ -83,7 +83,7 @@ describe("installing update", () => {
|
|||||||
let processCheckingForUpdatesPromise: Promise<void>;
|
let processCheckingForUpdatesPromise: Promise<void>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
processCheckingForUpdatesPromise = processCheckingForUpdates();
|
processCheckingForUpdatesPromise = processCheckingForUpdates("irrelevant");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("checks for updates", () => {
|
it("checks for updates", () => {
|
||||||
|
|||||||
@ -72,7 +72,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
describe("when started", () => {
|
describe("when started", () => {
|
||||||
let rendered: RenderResult;
|
let rendered: RenderResult;
|
||||||
let processCheckingForUpdates: () => Promise<void>;
|
let processCheckingForUpdates: (source: string) => Promise<void>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
rendered = await applicationBuilder.render();
|
rendered = await applicationBuilder.render();
|
||||||
@ -97,7 +97,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
selectedUpdateChannel.setValue(updateChannels.alpha.id);
|
selectedUpdateChannel.setValue(updateChannels.alpha.id);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checks updates from update channel "alpha"', () => {
|
it('checks updates from update channel "alpha"', () => {
|
||||||
@ -191,7 +191,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
describe("when checking for updates", () => {
|
describe("when checking for updates", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when update from "beta" channel is discovered', () => {
|
describe('when update from "beta" channel is discovered', () => {
|
||||||
@ -241,7 +241,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object));
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object));
|
||||||
});
|
});
|
||||||
@ -259,7 +259,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.latest, expect.any(Object));
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.latest, expect.any(Object));
|
||||||
});
|
});
|
||||||
@ -273,7 +273,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
||||||
updateChannels.latest,
|
updateChannels.latest,
|
||||||
@ -290,7 +290,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.alpha, expect.any(Object));
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.alpha, expect.any(Object));
|
||||||
});
|
});
|
||||||
@ -304,7 +304,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object));
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object));
|
||||||
});
|
});
|
||||||
@ -324,7 +324,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||||
|
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("irrelevant");
|
||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object));
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object));
|
||||||
});
|
});
|
||||||
|
|||||||
@ -59,7 +59,7 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
|
|||||||
|
|
||||||
click: pipeline(
|
click: pipeline(
|
||||||
async () => {
|
async () => {
|
||||||
await processCheckingForUpdates();
|
await processCheckingForUpdates("tray");
|
||||||
|
|
||||||
await showApplicationWindow();
|
await showApplicationWindow();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,11 +31,11 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
|
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
|
||||||
const emitEvent = di.inject(emitEventInjectable);
|
const emitEvent = di.inject(emitEventInjectable);
|
||||||
|
|
||||||
return async () => {
|
return async (source: string) => {
|
||||||
emitEvent({
|
emitEvent({
|
||||||
name: "app",
|
name: "app",
|
||||||
action: "checking-for-updates",
|
action: "checking-for-updates",
|
||||||
params: { currentDateTime: getCurrentDateTime() },
|
params: { currentDateTime: getCurrentDateTime(), source },
|
||||||
});
|
});
|
||||||
|
|
||||||
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
|
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
|
||||||
|
|||||||
@ -16,11 +16,11 @@ const periodicalCheckForUpdatesInjectable = getInjectable({
|
|||||||
const TWO_HOURS = 1000 * 60 * 60 * 2;
|
const TWO_HOURS = 1000 * 60 * 60 * 2;
|
||||||
|
|
||||||
// Note: intentional orphan promise to make checking for updates happen in the background
|
// Note: intentional orphan promise to make checking for updates happen in the background
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("periodic");
|
||||||
|
|
||||||
const intervalId = setInterval(() => {
|
const intervalId = setInterval(() => {
|
||||||
// Note: intentional orphan promise to make checking for updates happen in the background
|
// Note: intentional orphan promise to make checking for updates happen in the background
|
||||||
processCheckingForUpdates();
|
processCheckingForUpdates("periodic");
|
||||||
}, TWO_HOURS);
|
}, TWO_HOURS);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@ -71,9 +71,10 @@ const applicationMenuItemsInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
...ignoreIf(!updatingIsEnabled, [
|
...ignoreIf(!updatingIsEnabled, [
|
||||||
{
|
{
|
||||||
|
id: "check-for-updates",
|
||||||
label: "Check for updates",
|
label: "Check for updates",
|
||||||
click() {
|
click() {
|
||||||
processCheckingForUpdates().then(() => showApplicationWindow());
|
processCheckingForUpdates("application-menu").then(() => showApplicationWindow());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
@ -285,7 +286,7 @@ const applicationMenuItemsInjectable = getInjectable({
|
|||||||
{
|
{
|
||||||
label: "Check for updates",
|
label: "Check for updates",
|
||||||
click() {
|
click() {
|
||||||
processCheckingForUpdates().then(() =>
|
processCheckingForUpdates("periodic").then(() =>
|
||||||
showApplicationWindow(),
|
showApplicationWindow(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user