Getting Started
__CAPGO_KEEP_4__
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.
__CAPGO_KEEP_11__
《安装》您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:
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.如果您prefer Manual Setup,安装插件并运行以下命令并遵循以下平台特定的说明:
bun add @capgo/capacitor-rudderstackbunx cap sync导入
《导入》import { nativePlugin } from '@capgo/capacitor-rudderstack';API 介绍
标题:API 介绍initialize
标题:初始化初始化 RudderStack 客户端。
该方法保留了 Cordova 签名,因此第二个参数可以是配置对象或 Rudder 选项对象。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.initialize('value');identify
标题:识别为提供的用户 ID 发送识别调用。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.identify('value');group
标题:组为提供的组 ID 发送组调用。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.group('value');Sends a track call for the provided event name.
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.track('value');screen
Section titled “screen”Sends a screen call for the provided screen name.
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.screen('value');Aliases the current user to a new identifier.
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.alias('value');Resets the current RudderStack identity state.
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.reset();立即清空缓存事件。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.flush();putDeviceToken
Section titled “putDeviceToken”将推送令牌传递给支持的目的地。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putDeviceToken('value');setAdvertisingId
Section titled “setAdvertisingId”查看当前合同的源定义。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAdvertisingId('value');putAdvertisingId
Section titled “putAdvertisingId”设置自定义广告 ID 值。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAdvertisingId('value');setAnonymousId
设置匿名ID查看当前合同的源定义。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAnonymousId('value');putAnonymousId
设置匿名ID设置自定义匿名ID值。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAnonymousId('value');optOut
设置RudderStack跟踪选项复制到剪贴板
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.optOut(true);类型参考
Rudder配置RudderConfiguration
Rudder配置本地 RudderStack 原生 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;真实来源
名为“真实来源”的部分本页面是由插件自动生成的 src/definitions.ts当公共API在上游发生变化时,请重新运行同步。
继续从开始使用中
《从 Getting Started 开始继续》如果您正在使用 Getting Started 来规划仪表板和API操作,连接它与 使用@capgo/capacitor-rudderstack 为native能力在使用@capgo/capacitor-rudderstack中 API概述 为API概述的实现细节 介绍 为介绍的实现细节 API密钥 为API密钥的实现细节 设备 为设备的实现细节.