diff --git a/src/index.ts b/src/index.ts index 5a88eac..f0202d9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -115,12 +115,13 @@ async function main(): Promise { if (!help) { const { token, host } = await getCredentials(); - const telemetryEnabled = await isTelemetryEnabled(); + const telemetryEnabled = env.PRISMIC_TELEMETRY_ENABLED ?? (await isTelemetryEnabled()); + const sentryEnabled = env.PRISMIC_SENTRY_ENABLED ?? (telemetryEnabled && env.PROD); - if (env.PRISMIC_SENTRY_ENABLED ?? (telemetryEnabled && env.PROD)) { + if (sentryEnabled) { await initSentry({ host, repo }); } - if (env.PRISMIC_TELEMETRY_ENABLED ?? telemetryEnabled) { + if (telemetryEnabled) { await initTracking({ host, repo }); } @@ -132,7 +133,7 @@ async function main(): Promise { process.on("exit", () => spawnTokenRefresh()); } - if (!exp || exp > now) { + if ((sentryEnabled || telemetryEnabled) && (!exp || exp > now)) { getProfile({ token, host }) .then((profile) => { trackUser(profile); diff --git a/test/token-create.test.ts b/test/token-create.test.ts index b58ac62..441a395 100644 --- a/test/token-create.test.ts +++ b/test/token-create.test.ts @@ -44,7 +44,8 @@ it("creates an access token with --allow-releases", async ({ expect(auth!.scope).toBe("master+releases"); }); -it("creates a write token", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("creates a write token", async ({ expect, prismic, repo, token, host }) => { const { stdout, stderr, exitCode } = await prismic("token", ["create", "--write"]); expect(exitCode, stderr).toBe(0); expect(stdout).toContain("Token created:"); @@ -57,7 +58,14 @@ it("creates a write token", async ({ expect, prismic, repo, token, host }) => { expect(found).toBeDefined(); }); -it("creates a write token with a custom --name", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("creates a write token with a custom --name", async ({ + expect, + prismic, + repo, + token, + host, +}) => { const { stdout, stderr, exitCode } = await prismic("token", [ "create", "--write", @@ -75,7 +83,14 @@ it("creates a write token with a custom --name", async ({ expect, prismic, repo, expect(found!.app_name).toBe("My Seed Token"); }); -it("outputs a write token as JSON with --json", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("outputs a write token as JSON with --json", async ({ + expect, + prismic, + repo, + token, + host, +}) => { const { stdout, stderr, exitCode } = await prismic("token", ["create", "--write", "--json"]); expect(exitCode, stderr).toBe(0); diff --git a/test/token-delete.test.ts b/test/token-delete.test.ts index 35c773b..bb2e4b3 100644 --- a/test/token-delete.test.ts +++ b/test/token-delete.test.ts @@ -19,7 +19,8 @@ it("deletes an access token", async ({ expect, prismic, repo, token, host }) => expect(allAuths.find((a) => a.token === created.token)).toBeUndefined(); }); -it("deletes a write token", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("deletes a write token", async ({ expect, prismic, repo, token, host }) => { const created = await createWriteToken({ repo, token, host }); const { stdout, stderr, exitCode } = await prismic("token", ["delete", created.token]);