スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-rudderstack`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/rudderstack/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」セクションAIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用します:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-rudderstack` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-rudderstackbunx cap syncインポート
「インポート」セクションimport { nativePlugin } from '@capgo/capacitor-rudderstack';クイックスタート
「クイックスタート」セクションimport { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.initialize({ writeKey: 'YOUR_WRITE_KEY', dataPlaneUrl: 'https://your.dataplane.rudderstack.com',});await nativePlugin.identify({ userId: 'user_123', traits: { plan: 'pro' } });await nativePlugin.track({ event: 'Signed Up', properties: { source: 'mobile' } });例:画面トラッキング
「例:画面トラッキング」というタイトルのセクションawait nativePlugin.screen({ screen: 'Checkout', properties: { step: 'payment' },});よくある落とし穴
「よくある落とし穴」セクション- 一度だけ初期化:重複の可能性
initialize()呼び出しによって SDK の状態が重複する可能性があるため、アプリのブートストラップ時に制御してください。 - バックグラウンド移行前にフラッシュ:呼び出し
flush()iOSやAndroidでは、アップロード中にプロセスが中断される可能性があるためです。 - 広告用ID:プライバシーポリシーでIDFAまたはGAIDの収集について明記している場合にのみ、オプトインのヘルパーを使用してください。
API の概要
「API 概要」セクションinitialize
「initialize」セクションRudderStackクライアントを初期化します。
このメソッドはCordovaのシグネチャを維持しているため、第2引数にはconfigオブジェクトまたはRudderのoptionsオブジェクトのどちらかを渡すことができます。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.initialize('write-key-123');identify
「identify」セクション指定したユーザーIDでidentifyコールを送信します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.identify('user-id-123');group
「group」セクション指定したグループIDでgroupコールを送信します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.group('group-id-123');track
「track」セクション指定したイベント名でtrackコールを送信します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.track('event');screen
「screen」セクション指定したスクリーン名でscreenコールを送信します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.screen('screen');alias
「alias」セクション現在のユーザーを新しい識別子にエイリアスします。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.alias('new-id-123');reset
「reset」セクション現在のRudderStackのアイデンティティ状態をリセットします。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.reset();flush
「flush」セクションキューに溜まっているイベントを即座にフラッシュします。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.flush();putDeviceToken
「putDeviceToken」セクションRudderStackがサポートされている送信先に転送するプッシュトークンを設定します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putDeviceToken('device-token-123');setAdvertisingId
「setAdvertisingId」セクション現在のコントラクトのソース定義を参照してください。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAdvertisingId('advertising-id-123');putAdvertisingId
「putAdvertisingId」セクションカスタムの広告ID値を設定します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAdvertisingId('advertising-id-123');setAnonymousId
「setAnonymousId」セクション現在のコントラクトのソース定義を参照してください。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAnonymousId('anonymous-id-123');putAnonymousId
「putAnonymousId」セクションカスタムの匿名IDを設定します。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAnonymousId('anonymous-id-123');optOut
「optOut」セクションRudderStackのトラッキングオプトアウトを切り替えます。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.optOut(true);型リファレンス
「型リファレンス」セクションRudderConfiguration
「RudderConfiguration」セクション基盤となるRudderStack native SDKでサポートされている設定キーです。
export interface RudderConfiguration { /** * RudderStack data plane URL. */ dataPlaneUrl?: string;
/** * Number of events to batch before a flush. */ flushQueueSize?: number;
/** * Database row threshold that triggers pruning on Android and iOS. */ dbCountThreshold?: number;
/** * Server config refresh interval in hours. */ configRefreshInterval?: number;
/** * RudderStack log verbosity. */ logLevel?: RudderLogLevelValue;
/** * Sleep timeout / sleep count used by the native SDK. */ sleepTimeOut?: number;
/** * Android only. Lets the native SDK collect the advertising identifier automatically. */ autoCollectAdvertId?: boolean;
/** * Tracks `Application Installed`, `Application Updated`, and `Application Opened` automatically. */ trackLifecycleEvents?: boolean;
/** * RudderStack control plane URL. */ controlPlaneUrl?: string;
/** * Enables automatic screen tracking where supported by the native SDK. */ recordScreenViews?: boolean;
/** * Ignored in this Capacitor port. * * The Cordova SDK uses this field to bootstrap native destination factories from companion plugins. * Those extension packages are not implemented in this first Capacitor release. */ factories?: any[];}RudderOptions
「RudderOptions」セクションRudderStackの呼び出しごとのオプションです。
export interface RudderOptions { /** * External identifiers forwarded with the event. */ externalIds?: Record<string, string>;
/** * Destination enablement flags keyed by integration name. */ integrations?: Record<string, boolean>;}RudderTraits
「RudderTraits」セクション受け入れられるTraitsペイロード: identify と group.
export type RudderTraits = Record<string, any>;RudderProperties
「RudderProperties」セクション受け入れられるPropertiesペイロード: track と screen.
export type RudderProperties = Record<string, any>;PluginVersionResult
「PluginVersionResult」セクションプラグインバージョンのペイロード。
export interface PluginVersionResult { /** * Version identifier returned by the platform implementation. */ version: string;}RudderLogLevelValue
「RudderLogLevelValue」セクション移行をスムーズにするために公開されている、RudderStackのログレベル値です。
export type RudderLogLevelValue = 0 | 1 | 2 | 3 | 4 | 5;Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-rudderstack の使用 @capgo/capacitor-rudderstack を使用して Native Build の機能を利用する場合、 API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。