Skip to content

Commit 2953d4c

Browse files
committed
refactor(vercel): Enhance Vercel integration handling with ResultAsync and improve error management
- Updated VercelSettingsPresenter to utilize ResultAsync for better error handling and flow control. - Refactored API key regeneration to sync directly with Vercel, improving reliability. - Enhanced onboarding and connection routes to handle optional parameters and errors more gracefully. - Improved JSON parsing with safe handling using Result from neverthrow. - Updated referral source management to use Zod for type safety. - General code cleanup and consistency improvements across Vercel-related services and routes.
1 parent 077a366 commit 2953d4c

12 files changed

+1596
-1560
lines changed

apps/webapp/app/components/integrations/VercelOnboardingModal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { BuildSettingsFields } from "~/components/integrations/VercelBuildSettin
3333
import { OctoKitty } from "~/components/GitHubLoginButton";
3434
import {
3535
ConnectGitHubRepoModal,
36-
type GitHubAppInstallation,
3736
} from "~/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.github";
3837
import {
3938
type SyncEnvVarsMapping,
@@ -337,7 +336,7 @@ export function VercelOnboardingModal({
337336
setState("loading-env-vars");
338337
}
339338
}
340-
}, [state, onboardingData, hasStagingEnvironment]);
339+
}, [state, onboardingData, hasStagingEnvironment, fromMarketplaceContext]);
341340

342341
const secretEnvVars = envVars.filter((v) => v.isSecret);
343342
const syncableEnvVars = envVars.filter((v) => !v.isSecret);
@@ -990,7 +989,7 @@ export function VercelOnboardingModal({
990989
<div className="flex flex-col gap-3">
991990
<div className="flex items-center gap-3">
992991
<ConnectGitHubRepoModal
993-
gitHubAppInstallations={gitHubAppInstallations as GitHubAppInstallation[]}
992+
gitHubAppInstallations={gitHubAppInstallations}
994993
organizationSlug={organizationSlug}
995994
projectSlug={projectSlug}
996995
environmentSlug={environmentSlug}

apps/webapp/app/models/orgIntegration.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export class OrgIntegrationRepository {
109109
// The user goes to Vercel's marketplace to install the integration
110110
// After installation, Vercel redirects to our callback with the authorization code
111111
const redirectUri = encodeURIComponent(`${env.APP_ORIGIN}/vercel/callback`);
112-
return `https://vercel.com/integrations/${env.VERCEL_INTEGRATION_APP_SLUG}/new?state=${state}&redirect_uri=${redirectUri}`;
112+
const encodedState = encodeURIComponent(state);
113+
return `https://vercel.com/integrations/${env.VERCEL_INTEGRATION_APP_SLUG}/new?state=${encodedState}&redirect_uri=${redirectUri}`;
113114
}
114115

115116
static slackAuthorizationUrl(

0 commit comments

Comments
 (0)