diff --git a/packages/init/src/SliceMachineInitProcess.ts b/packages/init/src/SliceMachineInitProcess.ts index ad6cdb8eeb..0b17130934 100644 --- a/packages/init/src/SliceMachineInitProcess.ts +++ b/packages/init/src/SliceMachineInitProcess.ts @@ -133,10 +133,7 @@ export class SliceMachineInitProcess { )}\n`, ); } - await this.manager.telemetry.initTelemetry({ - appName: pkg.name, - appVersion: pkg.version, - }); + try { await setupSentry(); } catch (error) { @@ -144,6 +141,12 @@ export class SliceMachineInitProcess { // because of failed tracking set up. We probably couldn't determine the // Sentry environment. } + + await this.manager.telemetry.initTelemetry({ + appName: pkg.name, + appVersion: pkg.version, + }); + await this.manager.telemetry.track({ event: "command:init:start", repository: this.options.repository, diff --git a/packages/manager/src/managers/telemetry/TelemetryManager.ts b/packages/manager/src/managers/telemetry/TelemetryManager.ts index e72a08150d..68a7d5d4e9 100644 --- a/packages/manager/src/managers/telemetry/TelemetryManager.ts +++ b/packages/manager/src/managers/telemetry/TelemetryManager.ts @@ -90,7 +90,7 @@ export class TelemetryManager extends BaseManager { }; if (isTelemetryEnabled) { - await this.initExperiment(); + this.initExperiment(); } this._anonymousID = randomUUID(); @@ -272,15 +272,17 @@ export class TelemetryManager extends BaseManager { async checkIsTelemetryEnabled(): Promise { let root: string; try { - root = await this.project.getRoot(); + root = await this.project + .getRoot() + .catch(() => this.project.suggestRoot()); + + return readPrismicrc(root).telemetry !== false; } catch { - root = await this.project.suggestRoot(); + return false; } - - return readPrismicrc(root).telemetry !== false; } - private async initExperiment(): Promise { + private initExperiment(): void { try { this._experiment = Experiment.initializeRemote(API_TOKENS.AmplitudeKey); } catch (error) {