Skip to content

Commit

Permalink
Fix telemetry check which prevents init from running
Browse files Browse the repository at this point in the history
  • Loading branch information
hypervillain committed Feb 6, 2024
1 parent fda3f09 commit 93ed868
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 7 additions & 4 deletions packages/init/src/SliceMachineInitProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,20 @@ export class SliceMachineInitProcess {
)}\n`,
);
}
await this.manager.telemetry.initTelemetry({
appName: pkg.name,
appVersion: pkg.version,
});

try {
await setupSentry();
} catch (error) {
// noop - We don't want to stop the user from using Slice Machine
// 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,
Expand Down
14 changes: 8 additions & 6 deletions packages/manager/src/managers/telemetry/TelemetryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class TelemetryManager extends BaseManager {
};

if (isTelemetryEnabled) {
await this.initExperiment();
this.initExperiment();
}

this._anonymousID = randomUUID();
Expand Down Expand Up @@ -272,15 +272,17 @@ export class TelemetryManager extends BaseManager {
async checkIsTelemetryEnabled(): Promise<boolean> {
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<void> {
private initExperiment(): void {
try {
this._experiment = Experiment.initializeRemote(API_TOKENS.AmplitudeKey);
} catch (error) {
Expand Down

0 comments on commit 93ed868

Please sign in to comment.