インストール後のアクションとオンボーディング
インストール後のアクションは、ユーザーが Stripe アプリをインストールした直後に何が起こるかを決めます。よく設計されたインストール後の体験は、ユーザーを設定へ導き、アクティベーション率を高めます。
インストール後のアクションの種類
Stripe は 4 種類のインストール後アクションに対応しており、いずれもアプリのマニフェストで設定します。
1. アプリへのリンク(デフォルト)
既定のドロワービューポートでアプリを開きます。post_install_action を指定しない場合の既定の挙動です。
{ "post_install_action": { "type": "default" }}ユーザーには Stripe ダッシュボードのサイドバーでアプリの drawer.default ビューポートが表示されます。
2. オンボーディングへのリンク
アプリ専用のオンボーディングビューを開き、設定に集中できる体験を提供します。
{ "post_install_action": { "type": "onboarding" }}これにはマニフェストで onboarding ビューポートを宣言しておく必要があります。
{ "ui_extension": { "views": [ { "viewport": "stripe.dashboard.onboarding", "component": "OnboardingView" } ] }, "post_install_action": { "type": "onboarding" }}3. 設定へのリンク
アプリの設定ビューを開きます。利用前に API キーや構成が必要なアプリで役立ちます。
{ "post_install_action": { "type": "settings" }}これには settings ビューポートが必要です。
{ "ui_extension": { "views": [ { "viewport": "stripe.dashboard.settings", "component": "SettingsView" } ] }, "post_install_action": { "type": "settings" }}4. 外部 URL へのリンク
設定のためにユーザーを外部の URL へリダイレクトします。オンボーディングフローが Stripe ダッシュボードの外にある場合に使用します。
{ "post_install_action": { "type": "external", "url": "https://app.tajo.io/stripe/setup" }}Caution
外部 URL は HTTPS を使用し、allowed_redirect_uris に登録しておく必要があります。Stripe の審査チームは、その外部 URL が実際に機能する設定体験を提供しているかを確認します。
オンボーディングのベストプラクティス
手間をかけさせない
利用開始までに必要な手順を最小限にします。
- Stripe アカウントのコンテキストから取得できる情報をあらかじめ入力します
- 設定項目には妥当な既定値を使用します
- 任意の手順はスキップできるようにし、後から完了できる導線を明示します
- 複数ステップのフローではステップ表示で進捗を示します
カスタマイズできるようにする
ユーザーが自分のニーズに合わせて連携を設定できるようにします。
- データマッピングの選択肢、どの Stripe のフィールドを Brevo に同期するかをユーザーが選べるようにします
- 同期の頻度、リアルタイム、1 時間ごと、1 日ごとの同期を選べるようにします
- 選択的な同期、どの顧客や商品を同期するかをユーザーが選べるようにします
- 通知の設定、同期エラーや重要なイベントのアラートを設定できるようにします
関連性を持たせる
価値をすぐに示します。
- 連携を有効にする前に同期されるデータをプレビューできるようにします
- 設定を完了すると何が起こるかを示します
- 接続が機能するか確認できるテスト同期の手段を提供します
- 初回同期の完了後に成果の指標を表示します
OnboardingView コンポーネント
OnboardingView コンポーネントは、ユーザーがアプリをインストールしたときに集中しやすいモーダルとして描画されます。
import { Box, Button, Inline, Icon, Banner, TextField, Select, Divider,} from '@stripe/ui-extension-sdk/ui';import type { ExtensionContextValue } from '@stripe/ui-extension-sdk/context';import { useState } from 'react';
const OnboardingView = ({ environment, userContext }: ExtensionContextValue) => { const [step, setStep] = useState(1); const [brevoApiKey, setBrevoApiKey] = useState(''); const [syncMode, setSyncMode] = useState('realtime'); const [isConnecting, setIsConnecting] = useState(false); const [error, setError] = useState<string | null>(null);
const totalSteps = 3;
const handleConnect = async () => { setIsConnecting(true); setError(null);
try { // Store the API key securely await storeBrevoApiKey(brevoApiKey);
// Verify the connection const result = await verifyBrevoConnection(brevoApiKey);
if (result.success) { setStep(2); } else { setError('Unable to connect to Brevo. Please check your API key.'); } } catch (err) { setError('Connection failed. Please try again.'); } finally { setIsConnecting(false); } };
return ( <Box css={{ padding: 'large' }}> {/* Progress indicator */} <Inline css={{ marginBottom: 'large' }}> Step {step} of {totalSteps} </Inline>
{error && ( <Banner type="critical" title="Connection Error"> {error} </Banner> )}
{step === 1 && ( <Box> <Inline css={{ fontWeight: 'bold', fontSize: 'large' }}> Connect Your Brevo Account </Inline> <Inline css={{ marginTop: 'small', color: 'secondary' }}> Enter your Brevo API key to start syncing customer data. </Inline>
<TextField label="Brevo API Key" placeholder="xkeysib-..." value={brevoApiKey} onChange={(e) => setBrevoApiKey(e.target.value)} css={{ marginTop: 'medium' }} />
<Inline css={{ marginTop: 'xsmall', color: 'secondary', fontSize: 'small' }}> Find your API key in Brevo under Settings > SMTP & API > API Keys </Inline>
<Button type="primary" onPress={handleConnect} disabled={!brevoApiKey || isConnecting} css={{ marginTop: 'medium' }} > {isConnecting ? 'Connecting...' : 'Connect Brevo'} </Button> </Box> )}
{step === 2 && ( <Box> <Inline css={{ fontWeight: 'bold', fontSize: 'large' }}> Configure Sync Settings </Inline>
<Select label="Sync Mode" value={syncMode} onChange={(value) => setSyncMode(value)} css={{ marginTop: 'medium' }} > <option value="realtime">Real-time (recommended)</option> <option value="hourly">Every hour</option> <option value="daily">Once per day</option> </Select>
<Divider css={{ marginY: 'medium' }} />
<Button type="primary" onPress={() => setStep(3)}> Continue </Button> <Button type="secondary" onPress={() => setStep(1)}> Back </Button> </Box> )}
{step === 3 && ( <Box> <Banner type="default" title="Ready to Sync"> Your Brevo account is connected. Tajo will begin syncing customer data automatically. </Banner>
<Box css={{ marginTop: 'medium' }}> <Inline css={{ fontWeight: 'bold' }}>What happens next:</Inline> <ul> <li>Existing Stripe customers will sync to Brevo contacts</li> <li>New customers and events will sync in real-time</li> <li>View sync status on any customer's detail page</li> </ul> </Box>
<Button type="primary" onPress={() => {/* Navigate to dashboard */}}> Go to Dashboard </Button> </Box> )} </Box> );};
export default OnboardingView;SignInView によるログインフロー
アプリがユーザーに外部アカウント(Tajo など)へのログインを求める場合は、専用のログインビューを使用します。
import { Box, Button, Inline, TextField, Banner, Link,} from '@stripe/ui-extension-sdk/ui';import { useState } from 'react';
const SignInView = ({ onSignInComplete }) => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState<string | null>(null);
const handleSignIn = async () => { setIsLoading(true); setError(null);
try { const response = await fetch('https://api.tajo.io/v1/auth/stripe-app', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, password }), });
if (!response.ok) { throw new Error('Invalid credentials'); }
const { token } = await response.json();
// Store the auth token securely in Stripe's Secret Store await storeAuthToken(token);
onSignInComplete(); } catch (err) { setError('Sign-in failed. Please check your credentials and try again.'); } finally { setIsLoading(false); } };
return ( <Box css={{ padding: 'large' }}> <Inline css={{ fontWeight: 'bold', fontSize: 'large' }}> Sign in to Tajo </Inline> <Inline css={{ marginTop: 'small', color: 'secondary' }}> Connect your Tajo account to enable Brevo sync. </Inline>
{error && ( <Banner type="critical" title="Sign-in Failed"> {error} </Banner> )}
<TextField label="Email" type="email" value={email} onChange={(e) => setEmail(e.target.value)} css={{ marginTop: 'medium' }} />
<TextField label="Password" type="password" value={password} onChange={(e) => setPassword(e.target.value)} css={{ marginTop: 'small' }} />
<Button type="primary" onPress={handleSignIn} disabled={!email || !password || isLoading} css={{ marginTop: 'medium' }} > {isLoading ? 'Signing in...' : 'Sign In'} </Button>
<Link href="https://app.tajo.io/signup" external css={{ marginTop: 'small' }}> Don't have a Tajo account? Sign up </Link> </Box> );};クエリパラメータを使ったディープリンクの起動
ディープリンクのクエリパラメータを使うと、特定のオンボーディングステップを開いたり、データをあらかじめ入力したりできます。
import type { ExtensionContextValue } from '@stripe/ui-extension-sdk/context';
const OnboardingView = ({ environment }: ExtensionContextValue) => { // Access query parameters from the deep link const { queryParams } = environment;
// Pre-fill step from query parameter const initialStep = queryParams?.step ? parseInt(queryParams.step) : 1;
// Pre-fill API key from query parameter (e.g., from Tajo dashboard) const prefilledApiKey = queryParams?.brevo_key || '';
// Source tracking for analytics const installSource = queryParams?.source || 'marketplace';
const [step, setStep] = useState(initialStep); const [brevoApiKey, setBrevoApiKey] = useState(prefilledApiKey);
// ... rest of onboarding logic};オンボーディングのデータをあらかじめ入力するディープリンクを生成します。
// From your Tajo dashboard, generate a link that pre-fills the Brevo API keyconst onboardingLink = [ 'https://dashboard.stripe.com/live/acct_xxxxx/dashboard', '?apps[com.tajo.brevo-integration][modal]=stripe.dashboard.onboarding', '&apps[com.tajo.brevo-integration][queryParams][step]=1', '&apps[com.tajo.brevo-integration][queryParams][source]=tajo_dashboard',].join('');再訪ユーザーへの対応
オンボーディングを終えたユーザーがアプリを開いたときは、その状態を判定して適切なビューを表示します。
const MainView = ({ environment, userContext }: ExtensionContextValue) => { const [authState, setAuthState] = useState<'loading' | 'signed-out' | 'onboarding' | 'ready'>('loading');
useEffect(() => { checkUserState().then((state) => { setAuthState(state); }); }, []);
switch (authState) { case 'loading': return <Spinner label="Loading..." />; case 'signed-out': return <SignInView onSignInComplete={() => setAuthState('onboarding')} />; case 'onboarding': return <OnboardingView onComplete={() => setAuthState('ready')} />; case 'ready': return <DashboardView />; }};Tip
オンボーディングの完了状態は Stripe の Secret Store に保存しておくと、外部 API を呼び出さずに再訪ユーザーを判定できます。