diff --git a/src/hooks/telemetryPrerun.ts b/src/hooks/telemetryPrerun.ts index abd4867e..6bec7aa3 100644 --- a/src/hooks/telemetryPrerun.ts +++ b/src/hooks/telemetryPrerun.ts @@ -5,14 +5,11 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import { join } from 'node:path'; -import { Hook, Performance } from '@oclif/core'; -import { SfError, Lifecycle } from '@salesforce/core'; -import { JsonMap } from '@salesforce/ts-types'; +import type { Hook } from '@oclif/core'; +import type { SfError } from '@salesforce/core'; +import type { JsonMap } from '@salesforce/ts-types'; import enabledCheck from '@salesforce/telemetry/enabledCheck'; -import Telemetry from '../telemetry.js'; -import { TelemetryGlobal } from '../telemetryGlobal.js'; -import { CommandExecution } from '../commandExecution.js'; +import type { TelemetryGlobal } from '../telemetryGlobal.js'; import { debug } from '../debugger.js'; declare const global: TelemetryGlobal; @@ -38,6 +35,14 @@ const hook: Hook.Prerun = async function (options): Promise { } try { + const [path, Performance, Lifecycle, Telemetry, CommandExecution] = await Promise.all([ + await import('node:path'), + (await import('@oclif/core')).Performance, + (await import('@salesforce/core')).Lifecycle, + (await import('../telemetry.js')).default, + (await import('../commandExecution.js')).CommandExecution, + ]); + const errors: Array<{ event: JsonMap; error: SfError }> = []; // Instantiating telemetry shows data collection warning. @@ -118,7 +123,8 @@ const hook: Hook.Prerun = async function (options): Promise { telemetry.record({ eventName: 'INSTALL', installType: - this.config.binPath?.includes(join('sfdx', 'client')) ?? this.config.binPath?.includes(join('sf', 'client')) + this.config.binPath?.includes(path.join('sfdx', 'client')) ?? + this.config.binPath?.includes(path.join('sf', 'client')) ? 'installer' : 'npm', platform: this.config.platform,