mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improved metrics for updating application (#5607)
This commit is contained in:
1 parent
7b0521f3b2
commit
5c049ecca0
15 files changed
+373
-32
No files matched your search
@@ -59,7 +59,7 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
|
||||
|
||||
click: pipeline(
|
||||
async () => {
|
||||
await processCheckingForUpdates();
|
||||
await processCheckingForUpdates("tray");
|
||||
|
||||
await showApplicationWindow();
|
||||
},
|
||||
|
||||
+17
-2
@@ -8,11 +8,13 @@ import updatesAreBeingDiscoveredInjectable from "../../../common/application-upd
|
||||
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
||||
import { runInAction } from "mobx";
|
||||
import askBooleanInjectable from "../../ask-boolean/ask-boolean.injectable";
|
||||
import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and-install-update.injectable";
|
||||
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
||||
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
|
||||
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
|
||||
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
|
||||
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
||||
import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time";
|
||||
import quitAndInstallUpdateInjectable from "../quit-and-install-update.injectable";
|
||||
|
||||
const processCheckingForUpdatesInjectable = getInjectable({
|
||||
id: "process-checking-for-updates",
|
||||
@@ -27,8 +29,15 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
||||
const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable);
|
||||
const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable);
|
||||
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
|
||||
const emitEvent = di.inject(emitEventInjectable);
|
||||
|
||||
return async (source: string) => {
|
||||
emitEvent({
|
||||
name: "app",
|
||||
action: "checking-for-updates",
|
||||
params: { currentDateTime: getCurrentDateTime(), source },
|
||||
});
|
||||
|
||||
return async () => {
|
||||
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
|
||||
|
||||
runInAction(() => {
|
||||
@@ -50,6 +59,12 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
||||
|
||||
const { version, actualUpdateChannel } = result;
|
||||
|
||||
emitEvent({
|
||||
name: "app",
|
||||
action: "update-was-discovered",
|
||||
params: { version, currentDateTime: getCurrentDateTime() },
|
||||
});
|
||||
|
||||
broadcastChangeInUpdatingStatus({
|
||||
eventId: "download-for-update-started",
|
||||
version,
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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 { afterApplicationIsLoadedInjectionToken } from "../start-main-application/runnable-tokens/after-application-is-loaded-injection-token";
|
||||
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
import { getCurrentDateTime } from "../../common/utils/date/get-current-date-time";
|
||||
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
|
||||
const emitCurrentVersionToAnalyticsInjectable = getInjectable({
|
||||
id: "emit-current-version-to-analytics",
|
||||
|
||||
instantiate: (di) => {
|
||||
const emitEvent = di.inject(emitEventInjectable);
|
||||
const appVersion = di.inject(appVersionInjectable);
|
||||
|
||||
return {
|
||||
run: () => {
|
||||
emitEvent({
|
||||
name: "app",
|
||||
action: "current-version",
|
||||
|
||||
params: {
|
||||
version: appVersion,
|
||||
currentDateTime: getCurrentDateTime(),
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||
});
|
||||
|
||||
export default emitCurrentVersionToAnalyticsInjectable;
|
||||
@@ -5,12 +5,12 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import { trayMenuItemInjectionToken } from "../tray/tray-menu-item/tray-menu-item-injection-token";
|
||||
import quitAndInstallUpdateInjectable from "../electron-app/features/quit-and-install-update.injectable";
|
||||
import discoveredUpdateVersionInjectable from "../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
||||
import updateIsBeingDownloadedInjectable from "../../common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable";
|
||||
import { withErrorSuppression } from "../../common/utils/with-error-suppression/with-error-suppression";
|
||||
import { pipeline } from "@ogre-tools/fp";
|
||||
import withErrorLoggingInjectable from "../../common/utils/with-error-logging/with-error-logging.injectable";
|
||||
import quitAndInstallUpdateInjectable from "./quit-and-install-update.injectable";
|
||||
|
||||
const installApplicationUpdateTrayItemInjectable = getInjectable({
|
||||
id: "install-update-tray-item",
|
||||
|
||||
+6
-5
@@ -5,22 +5,23 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
|
||||
import processCheckingForUpdatesInjectable from "../check-for-updates/process-checking-for-updates.injectable";
|
||||
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
|
||||
|
||||
const periodicalCheckForUpdatesInjectable = getInjectable({
|
||||
id: "periodical-check-for-updates",
|
||||
|
||||
instantiate: (di) => {
|
||||
const processCheckingForUpdates = di.inject(processCheckingForUpdatesInjectable);
|
||||
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
|
||||
const processCheckingForUpdates = withOrphanPromise(di.inject(processCheckingForUpdatesInjectable));
|
||||
|
||||
return getStartableStoppable("periodical-check-for-updates", () => {
|
||||
const TWO_HOURS = 1000 * 60 * 60 * 2;
|
||||
|
||||
// Note: intentional orphan promise to make checking for updates happen in the background
|
||||
processCheckingForUpdates();
|
||||
processCheckingForUpdates("periodic");
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
// Note: intentional orphan promise to make checking for updates happen in the background
|
||||
processCheckingForUpdates();
|
||||
|
||||
processCheckingForUpdates("periodic");
|
||||
}, TWO_HOURS);
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 electronQuitAndInstallUpdateInjectable from "../electron-app/features/electron-quit-and-install-update.injectable";
|
||||
import { getCurrentDateTime } from "../../common/utils/date/get-current-date-time";
|
||||
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
import discoveredUpdateVersionInjectable from "../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
||||
|
||||
const quitAndInstallUpdateInjectable = getInjectable({
|
||||
id: "quit-and-install-update",
|
||||
|
||||
instantiate: (di) => {
|
||||
const electronQuitAndInstallUpdate = di.inject(
|
||||
electronQuitAndInstallUpdateInjectable,
|
||||
);
|
||||
|
||||
const emitEvent = di.inject(emitEventInjectable);
|
||||
const discoveredUpdateVersion = di.inject(discoveredUpdateVersionInjectable);
|
||||
|
||||
return () => {
|
||||
const discoveredVersion = discoveredUpdateVersion.value.get();
|
||||
|
||||
if (!discoveredVersion) {
|
||||
throw new Error("Tried to install update but no update was discovered.");
|
||||
}
|
||||
|
||||
emitEvent({
|
||||
name: "app",
|
||||
action: "start-installing-update",
|
||||
|
||||
params: {
|
||||
version: discoveredVersion.version,
|
||||
updateChannel: discoveredVersion.updateChannel.id,
|
||||
currentDateTime: getCurrentDateTime(),
|
||||
},
|
||||
});
|
||||
|
||||
electronQuitAndInstallUpdate();
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default quitAndInstallUpdateInjectable;
|
||||
+3
-3
@@ -5,8 +5,8 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import electronUpdaterInjectable from "./electron-updater.injectable";
|
||||
|
||||
const quitAndInstallUpdateInjectable = getInjectable({
|
||||
id: "quit-and-install-update",
|
||||
const electronQuitAndInstallUpdateInjectable = getInjectable({
|
||||
id: "electron-quit-and-install-update",
|
||||
|
||||
instantiate: (di) => {
|
||||
const electronUpdater = di.inject(electronUpdaterInjectable);
|
||||
@@ -17,4 +17,4 @@ const quitAndInstallUpdateInjectable = getInjectable({
|
||||
},
|
||||
});
|
||||
|
||||
export default quitAndInstallUpdateInjectable;
|
||||
export default electronQuitAndInstallUpdateInjectable;
|
||||
@@ -72,7 +72,7 @@ import getElectronThemeInjectable from "./electron-app/features/get-electron-the
|
||||
import syncThemeFromOperatingSystemInjectable from "./electron-app/features/sync-theme-from-operating-system.injectable";
|
||||
import platformInjectable from "../common/vars/platform.injectable";
|
||||
import productNameInjectable from "./app-paths/app-name/product-name.injectable";
|
||||
import quitAndInstallUpdateInjectable from "./electron-app/features/quit-and-install-update.injectable";
|
||||
import electronQuitAndInstallUpdateInjectable from "./electron-app/features/electron-quit-and-install-update.injectable";
|
||||
import electronUpdaterIsActiveInjectable from "./electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "./application-update/publish-is-configured.injectable";
|
||||
import checkForPlatformUpdatesInjectable from "./application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
@@ -250,7 +250,7 @@ const overrideElectronFeatures = (di: DiContainer) => {
|
||||
di.override(ipcMainInjectable, () => ({}));
|
||||
di.override(getElectronThemeInjectable, () => () => "dark");
|
||||
di.override(syncThemeFromOperatingSystemInjectable, () => ({ start: () => {}, stop: () => {} }));
|
||||
di.override(quitAndInstallUpdateInjectable, () => () => {});
|
||||
di.override(electronQuitAndInstallUpdateInjectable, () => () => {});
|
||||
di.override(setUpdateOnQuitInjectable, () => () => {});
|
||||
di.override(downloadPlatformUpdateInjectable, () => async () => ({ downloadWasSuccessful: true }));
|
||||
|
||||
|
||||
@@ -71,9 +71,10 @@ const applicationMenuItemsInjectable = getInjectable({
|
||||
},
|
||||
...ignoreIf(!updatingIsEnabled, [
|
||||
{
|
||||
id: "check-for-updates",
|
||||
label: "Check for updates",
|
||||
click() {
|
||||
processCheckingForUpdates().then(() => showApplicationWindow());
|
||||
processCheckingForUpdates("application-menu").then(() => showApplicationWindow());
|
||||
},
|
||||
},
|
||||
]),
|
||||
@@ -285,7 +286,7 @@ const applicationMenuItemsInjectable = getInjectable({
|
||||
{
|
||||
label: "Check for updates",
|
||||
click() {
|
||||
processCheckingForUpdates().then(() =>
|
||||
processCheckingForUpdates("periodic").then(() =>
|
||||
showApplicationWindow(),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user