claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🔄revenuecat-migrate

プラグイン
revenuecat

説明

生のStoreKitまたはGoogle Play BillingからRevenueCatへ移行する、あるいはRevenueCat SDKをメジャーバージョンアップグレードする際に使用します。 次のような場合に使用: ユーザーがRevenueCatへの移行、StoreKitからRevenueCat(RC)への切り替え、RevenueCat SDKのアップグレード、v4からv5への移行、Observerモード、RevenueCatのメジャーバージョンアップグレードについて言及している場合、またはすでにアプリ内購入を実装済みで、iOS・Android・Kotlin Multiplatform・Flutter・React NativeにRevenueCatを追加したい場合。

原文を表示

Migrate to RevenueCat from raw StoreKit or Google Play Billing, or upgrade the RevenueCat SDK across a major version. Use when the user says migrate to RevenueCat, switch from StoreKit to RC, upgrade RevenueCat SDK, from v4 to v5, observer mode, RevenueCat major version upgrade, or already have in app purchases and want to add RevenueCat on iOS, Android, Kotlin Multiplatform, Flutter, or React Native.

ユースケース

  • 生のStoreKitから移行するとき
  • Google Play Billingから移行するとき
  • RevenueCat SDKをメジャーバージョンアップするとき
  • 既存のアプリ内購入実装にRevenueCatを追加するとき

本文(日本語訳)

revenuecat-migrate: RevenueCatへの移行またはSDKのアップグレード

次のような場合に使用: ユーザーが、すでにアプリ内購入を実装済みのアプリにRevenueCatを導入したい場合、またはRevenueCat SDKをメジャーバージョン間でアップグレードしたい場合。

この2つのパスはいくつかの概念を共有しますが、リスクが異なります。 コードに手を加える前に、どちらが該当するかを特定してください。


1. プラットフォームの検出

作業ディレクトリを調べ、上から順に最初に一致するものを選択します:

  1. React Native: package.jsonreact-native-purchases のエントリがある、または react-native が依存関係に含まれる → platforms/react-native.md を読む。expo も依存関係にある場合は、Expoプロジェクトとして記録する。
  2. Flutter: プロジェクトルートに pubspec.yaml が存在する → platforms/flutter.md を読む。
  3. Kotlin Multiplatform: build.gradle.ktskotlin { … } マルチプラットフォームのソースセットブロックが含まれる、または com.revenuecat.purchases:purchases-kmp* に依存している → platforms/kmp.md を読む。
  4. Android(ネイティブ): build.gradle(.kts)com.android.application を適用している(かつKMPでない)→ platforms/android.md を読む。
  5. iOS(ネイティブ): プロジェクトルートに Package.swift*.xcodeproj*.xcworkspace、または Podfile がある → platforms/ios.md を読む。

複数が一致する場合(例: Flutterプロジェクト内に ios/ フォルダがある場合)、最も外側のプロジェクト、つまりビルドを管理しているものを選択してください。 それでも判断がつかない場合は、どのプラットフォームを設定したいかをユーザーに確認してください。


2. 移行パスの特定

ユーザーに確認するか、コードベースから推測します:

  • パスA: 新規導入。 アプリはすでにStoreKitまたはGoogle Play Billingに直接実装したアプリ内購入が動作している。RevenueCatをその上に追加する。
  • パスB: バージョンアップグレード。 アプリはすでにRevenueCatを使用しており、ユーザーが次のメジャーバージョンへ移行したい(例: v4からv5、v7からv8)。

両方のパスを同時に実施することもあります(例: 最新メジャーバージョンでRCを今日導入する場合)。 その場合はパスAを先に実行し、必要であればその後にパスBを実行してください。


3. 共通の概念

オブザーバーモード(パスA)

オブザーバーモードは、既存の購入コードを書き直すことなくRevenueCatを導入するための重要な機能です。 SDKは既存のStoreKit / Billing コードが処理したトランザクションを監視し、検証のためにRevenueCatバックエンドへ送信してサブスクライバーの状態を更新しますが、トランザクションの開始や完了は行いません。 既存の購入UI、レシート検証、トランザクション完了処理はそのまま維持されます。

設定時に以下のように指定します:

  • iOS: Configuration.BuilderpurchasesAreCompletedBy: .myAppstoreKitVersion: .storeKit1(または .storeKit2)をセットします。これらは別々のパラメーターであり、1つの関連値ではありません。
  • Android: PurchasesConfiguration.BuilderpurchasesAreCompletedBy(PurchasesAreCompletedBy.MY_APP) を指定します。
  • Flutter: PurchasesConfigurationconst PurchasesAreCompletedByMyApp(storeKitVersion: StoreKitVersion.storeKit2) を渡します。
  • React Native: configure呼び出しで purchasesAreCompletedBy: { type: PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP, storeKitVersion: STOREKIT_VERSION.STOREKIT_2 } を渡します。

デフォルトはRevenueCat完了モード(REVENUECAT / .revenueCat)であり、SDKがフロー全体を管理します。

オブザーバーモードで安定したら、後から自前の購入処理を削除して purchasesAreCompletedBy のオーバーライドを外し、RevenueCatフルモードに切り替えることもできます。

トランザクションの二重処理を避ける

purchasesAreCompletedBymyApp に設定した場合、RevenueCatはiOSでのトランザクション完了処理もAndroidでのacknowledge処理も行いません。 既存のコードが引き続きそれらを担う必要があります。

myApp フラグを外しながら、古いトランザクション完了処理コードをそのまま残した場合、トランザクションが2回acknowledgeされ、サブスクライバーの状態が一貫しなくなる可能性があります。

完了処理 / acknowledgeはどちらか一方だけが担うべきです。どちらかを選び、もう一方のコードは削除してください。

ユーザーの継続性(パスA)

アプリに独自の認証システムがすでに存在する場合、RevenueCatの設定後に一度 Purchases.logIn(existingAppUserID) を呼び出してください。 これにより、取り込み時に過去の購入履歴が正しいRevenueCatユーザーに紐付けられます。 この手順を省略すると、既存の購入が匿名のRCユーザーとして記録され、後からアプリの実際のユーザーレコードと照合することができなくなります。

アプリに認証済みユーザーの概念がない場合のみ、このステップをスキップしてください。

メジャーバージョンアップでは必須フィールドが変わる(パスB)

メジャーバージョンのアップグレードでは、設定の形式が変わり、非推奨APIが削除され、デフォルトの動作がリリースごとに変化します。 このスキルはバージョン間の差分を重複して記載しません。SDKリポジトリにある以下の公式情報を参照してください:

  • CHANGELOG: GitHubの該当SDKリポジトリにあります。インストール済みバージョンからターゲットバージョンまでのエントリを順に確認してください。
  • マイグレーションガイド: SDKリポジトリ内の *MIGRATION*.md に一致するファイル、または migrations/ ディレクトリを検索してください。メジャーバージョンアップには通常、専用のガイドが付属しています。リポジトリのGitHub Releasesページにあるそのメジャーバージョンのリリースノートには、通常そこへのリンクが記載されています。
  • リリースノート: リポジトリのGitHub Releasesページにある各メジャーバージョンのリリースノートに、破壊的変更の概要が記載されています。

SDKリポジトリのドキュメントを正式なものとして扱ってください。 ここにバージョン固有の差分を記載しても、時間の経過とともに内容が古くなります。 ターゲットプラットフォームの platforms/ 以下のファイルに、参照すべき正確なリポジトリが記載されています。

計画を立ててから移行する

すべてのプラットフォームで以下の順序で作業してください:

  1. ブランチ上でSDKを新しいメジャーバージョンに更新する。
  2. CHANGELOGの非推奨事項と削除事項を参考にしてコンパイルエラーを修正する。
  3. 初回起動時のSDKログを読み、ランタイムの動作の問題を修正する。
  4. マージ前に既存のテストスイートと手動のサンドボックスシナリオを実行する。

4. 実装

検出したプラットフォームに対応するプラットフォームファイルを読んでください:

  • platforms/ios.md
  • platforms/android.md
  • platforms/kmp.md
  • platforms/flutter.md
  • platforms/react-native.md

各プラットフォームファイルには、そのプラットフォームにおける両方の移行パスが記載されています。


5. 検証

以下がすべて満たされるまで、移行完了を宣言しないでください:

  1. アプリが新しいSDKバージョンでビルドでき、対象の非推奨APIに関する警告が出ていない。
  2. サンドボックス購入が成功し、RevenueCatダッシュボードのSandboxビューに期待どおりの appUserID でトランザクションが表示される。
  3. 移行前から存在するサブスクライバーがアプリを開いたとき、エンタイトルメントの状態が正しい。パスAでは、オブザーバーモードの取り込みが正常に機能したことの確認になります。パスBでは、バージョンアップによって状態が失われていないことの確認になります。
  4. デバッグログレベルのオーバーライドをリリース前に削除している。
原文(English)を表示

revenuecat-migrate: migrate to RevenueCat or upgrade the SDK

Use this skill when the user wants to either adopt RevenueCat in an app that already ships in app purchases, or upgrade the RevenueCat SDK across a major version.

These two paths share some concepts but have different risks. Identify which one applies before touching code.

1. Detect the platform

Inspect the working directory and pick the first match, from top to bottom:

  1. React Native: package.json has a react-native-purchases entry, or react-native as a dependency → read platforms/react-native.md. If expo is also a dependency, note it as an Expo project.
  2. Flutter: pubspec.yaml exists at the project root → read platforms/flutter.md.
  3. Kotlin Multiplatform: build.gradle.kts contains a kotlin { … } multiplatform source sets block, or depends on com.revenuecat.purchases:purchases-kmp* → read platforms/kmp.md.
  4. Android (native): build.gradle(.kts) applies com.android.application (and is not KMP) → read platforms/android.md.
  5. iOS (native): Package.swift, *.xcodeproj, *.xcworkspace, or Podfile at the project root → read platforms/ios.md.

If several match (e.g. an ios/ folder inside a Flutter project), pick the outermost project, the one that owns the build. If still ambiguous, ask the user which platform they want to configure.

2. Identify the migration path

Ask the user (or infer from the codebase):

  • Path A: adoption. The app already has working in app purchases implemented directly against StoreKit or Google Play Billing. RevenueCat is being added on top.
  • Path B: version upgrade. The app already uses RevenueCat, and the user wants to bump from one major version to the next (e.g. v4 to v5, v7 to v8).

Both paths can happen at once (e.g. adopt RC today on the latest major version). Run Path A first, then Path B if needed.

3. Shared concepts

Observer mode (Path A)

Observer mode is the key lever for adopting RevenueCat without rewriting purchase code. The SDK observes transactions that your existing StoreKit / Billing code processes, sends them to the RevenueCat backend for validation, and updates subscriber state, but does not initiate or finish the transactions. Your existing purchase UI, receipt validation, and transaction finishing stay in place.

Set this at configure time:

  • iOS: set purchasesAreCompletedBy: .myApp together with storeKitVersion: .storeKit1 (or .storeKit2) on Configuration.Builder. They are separate parameters, not a single associated value.
  • Android: purchasesAreCompletedBy(PurchasesAreCompletedBy.MY_APP) on PurchasesConfiguration.Builder.
  • Flutter: pass const PurchasesAreCompletedByMyApp(storeKitVersion: StoreKitVersion.storeKit2) to PurchasesConfiguration.
  • React Native: pass purchasesAreCompletedBy: { type: PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP, storeKitVersion: STOREKIT_VERSION.STOREKIT_2 } in the configure call.

The default is RevenueCat completed (REVENUECAT / .revenueCat), where the SDK owns the full flow.

Once stable in observer mode, you can optionally cut over to full RevenueCat mode later by removing your own purchase plumbing and dropping the purchasesAreCompletedBy override.

Do not double process transactions

When purchasesAreCompletedBy is set to myApp, RevenueCat does not finish transactions on iOS or acknowledge on Android. Your existing code must continue to do that. If you remove the myApp flag while leaving your old transaction finishing code in place, transactions get acknowledged twice and subscriber state can appear inconsistent.

Exactly one side must own finishing / acknowledging. Pick a side and remove the other.

User continuity (Path A)

If the app already has its own authentication system, call Purchases.logIn(existingAppUserID) once RevenueCat is configured. This attaches the prior purchase history to the right RevenueCat user on ingestion. Without this step, existing purchases get recorded against an anonymous RC user and cannot be matched to the app's actual user records later.

Only skip this if the app has no notion of authenticated users.

Version bumps change required fields (Path B)

Major version upgrades change configuration shape, drop deprecated APIs, and shift default behavior in ways that move with each release. This skill does not duplicate the per-version diff. Read the canonical sources from the SDK repo:

  • CHANGELOG: in the relevant SDK repo on GitHub. Walk entries from your installed version up to the target.
  • Migration guides: search the SDK repo for files matching *MIGRATION*.md or a migrations/ directory. Major bumps usually ship a dedicated guide there. The release notes for the major version on the repo's GitHub releases page typically link to it.
  • Release notes: each major version's release notes on the repo's GitHub releases page summarize the breaking changes.

Treat the SDK repo's docs as authoritative. Any version-specific diff written here would drift out of date. The platform file under platforms/ for your target lists the exact repo to consult.

Plan then migrate

Work in this order on every platform:

  1. Bump the SDK to the new major version in a branch.
  2. Fix compile errors using the CHANGELOG deprecations and removals as a guide.
  3. Fix runtime behavior by reading the SDK logs on first launch.
  4. Run the existing test suite and manual sandbox scenarios before merging.

4. Implementation

Read the platform file that matches detection:

  • platforms/ios.md
  • platforms/android.md
  • platforms/kmp.md
  • platforms/flutter.md
  • platforms/react-native.md

Each platform file covers both migration paths for that platform.

5. Verify

Do not declare migration done until:

  1. The app builds on the new SDK version with no warnings from deprecated APIs you care about.
  2. A sandbox purchase succeeds and the transaction shows up on the RevenueCat dashboard Sandbox view with the expected appUserID.
  3. An existing subscriber from before the migration opens the app, and their entitlement state is correct. For Path A this proves the observer mode ingest worked. For Path B this proves the version bump did not drop state.
  4. You have removed the debug log level override before shipping.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。