Skip to content

Commit f681acb

Browse files
authored
refactor(error-tracking): reuse the no-framework abort (#1349)
1 parent d8c09f2 commit f681acb

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎src/lib/programs/__tests__/error-tracking.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,23 @@ describe('error-tracking project picker report', () => {
162162
});
163163

164164
describe('error-tracking ciPreRun', () => {
165+
test('stops when no framework is detected', async () => {
166+
vi.mocked(detectFramework).mockResolvedValue(undefined);
167+
const session = {
168+
installDir: '/tmp/error-tracking-ci',
169+
frameworkContext: {},
170+
} as unknown as WizardSession;
171+
172+
await errorTrackingConfig.ciPreRun?.(session);
173+
174+
expect(wizardAbort).toHaveBeenCalledWith(
175+
expect.objectContaining({ code: ErrorCodes.DetectNoFramework }),
176+
);
177+
expect(session.integration).toBeUndefined();
178+
expect(session.frameworkConfig).toBeUndefined();
179+
expect(session.skillId).toBeUndefined();
180+
});
181+
165182
test('stops KMP before it sets the framework', async () => {
166183
vi.mocked(detectFramework).mockResolvedValue(Integration.kmp);
167184
const session = {

‎src/lib/programs/error-tracking/index.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { preinstallPostHogCliOnce } from '@lib/programs/shared/posthog-cli-prein
1717
import { analytics } from '@utils/analytics';
1818
import { wizardAbort } from '@utils/wizard-abort';
1919
import { ErrorCodes } from '@shared/errors';
20+
import { abortNoFrameworkDetected } from '@lib/programs/shared/abort-no-framework';
2021

2122
const ERROR_TRACKING_REPORT_FILE = 'posthog-error-tracking-report.md';
2223
const ERROR_TRACKING_DOCS_URL = 'https://posthog.com/docs/error-tracking';
@@ -184,10 +185,7 @@ export const errorTrackingConfig: ProgramConfig = {
184185

185186
const integration = await detectFramework(session.installDir);
186187
if (!integration) {
187-
await wizardAbort({
188-
code: ErrorCodes.DetectNoFramework,
189-
message: 'Could not auto-detect your framework for this project.',
190-
});
188+
await abortNoFrameworkDetected();
191189
return;
192190
}
193191
if (ERROR_TRACKING_UNSUPPORTED.has(integration)) {

0 commit comments

Comments
 (0)