开始使用
复制包含安装步骤和本插件全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.
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');track
跟踪发送给指定事件名称的跟踪呼叫。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.track('value');screen
屏幕发送给指定屏幕名称的屏幕呼叫。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.screen('value');alias
别名将当前用户别名为新标识符。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.alias('value');reset
重置重置当前RudderStack身份状态。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.reset();flush
清空立即清空队列事件。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.flush();putDeviceToken
设置推送令牌将推送令牌传递给支持的目的地。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putDeviceToken('value');setAdvertisingId
查看当前合同的源定义。复制到剪贴板
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAdvertisingId('value');putAdvertisingId
设置广告标识设置自定义广告标识值。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAdvertisingId('value');setAnonymousId
设置匿名标识查看当前合同的源定义。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAnonymousId('value');putAnonymousId
设置自定义匿名标识复制到剪贴板
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAnonymousId('value');optOut
切换RudderStack跟踪优惠复制到剪贴板
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.optOut(true);类型参考
类型参考RudderConfiguration
rudder配置rudder栈原生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
rudder栈选项rudder栈每次调用选项
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
rudder栈特征rudder栈接受的特征载荷 identify 和 group.
export type RudderTraits = Record<string, any>;RudderProperties
RudderProperties接受的属性载荷 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发生变化时,请重新同步。