Skip to content

Commit

Permalink
feat(beta): improve beta URL logging
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk3 committed Nov 15, 2024
1 parent ad78245 commit a527f96
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/core/src/dev/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import { CancellationError } from '../shared/utilities/timeoutUtils'
import { isAmazonQ, isCloud9, productName } from '../shared/extensionUtilities'
import * as config from './config'
import { isReleaseVersion } from '../shared/vscode/env'
import { getRelativeDate } from '../shared/datetime'

const localize = nls.loadMessageBundle()
const logger = getLogger('dev/beta')

const downloadIntervalMs = 1000 * 60 * 60 * 24 // A day in milliseconds

Expand Down Expand Up @@ -57,12 +59,13 @@ export async function activate(ctx: vscode.ExtensionContext) {
* If this is the first time we are watching the beta version or if its been 24 hours since it was last checked then try to prompt for update
*/
export function watchBetaVSIX(vsixUrl: string): vscode.Disposable {
getLogger().info(`dev: watching ${vsixUrl} for beta artifacts`)

const toolkit = getBetaToolkitData(vsixUrl)
const lastCheckRel = toolkit ? getRelativeDate(new Date(toolkit.lastCheck)) : ''
logger.info('watching beta artifacts url (lastCheck: %s): %s', lastCheckRel, vsixUrl)

if (!toolkit || toolkit.needUpdate || Date.now() - toolkit.lastCheck > downloadIntervalMs) {
runAutoUpdate(vsixUrl).catch((e) => {
getLogger().error('runAutoUpdate failed: %s', (e as Error).message)
logger.error('runAutoUpdate failed: %s', (e as Error).message)
})
}

Expand All @@ -71,13 +74,13 @@ export function watchBetaVSIX(vsixUrl: string): vscode.Disposable {
}

async function runAutoUpdate(vsixUrl: string) {
getLogger().debug(`dev: checking ${vsixUrl} for a new version`)
logger.debug(`checking url for a new version: %s`, vsixUrl)

try {
await telemetry.aws_autoUpdateBeta.run(() => checkBetaUrl(vsixUrl))
} catch (e) {
if (!isUserCancelledError(e)) {
getLogger().warn(`dev: beta extension auto-update failed: %s`, e)
logger.warn('beta extension auto-update failed: %s', e)
}
}
}
Expand Down Expand Up @@ -165,7 +168,7 @@ async function promptInstallToolkit(pluginPath: vscode.Uri, newVersion: string,
switch (response) {
case installBtn:
try {
getLogger().info(`dev: installing artifact ${vsixName}`)
logger.info(`installing artifact: ${vsixName}`)
await vscode.commands.executeCommand('workbench.extensions.installExtension', pluginPath)
await updateBetaToolkitData(vsixUrl, {
lastCheck: Date.now(),
Expand Down

0 comments on commit a527f96

Please sign in to comment.