开始使用
复制一个包含安装步骤和此插件的完整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 助手设置来安装插件。将 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手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
bun add @capgo/capacitor-rudderstackbunx cap syncimport { nativePlugin } from '@capgo/capacitor-rudderstack';initialize
Section titled “初始化”初始化 RudderStack 客户端。
该方法保留 Cordova 签名,因此第二个参数可以是配置对象或 Rudder 选项对象。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.initialize('write-key-123');identify
Section titled “识别”发送一个识别调用,提供的用户 ID。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.identify('user-id-123');group
Section titled “组”发送一个群组呼叫,根据提供的群组 ID。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.group('group-id-123');track
标题:“track”发送一个跟踪呼叫,根据提供的事件名称。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.track('event');screen
标题:“屏幕”发送一个屏幕呼叫,根据提供的屏幕名称。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.screen('screen');alias
标题:“别名”将当前用户别名为一个新的标识符。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.alias('new-id-123');reset
标题:“重置”重置当前RudderStack身份状态。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.reset();flush
标题:“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
标题:设置匿名 ID查看当前合同的源定义。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAnonymousId('anonymous-id-123');putAnonymousId
标题:设置匿名 ID设置自定义匿名 ID 值。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAnonymousId('anonymous-id-123');optOut
标题:放弃切换 RudderStack 跟踪放弃。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.optOut(true);类型参考
类型参考RudderConfiguration
RudderStack配置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
RudderStack选项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
RudderStack属性和 identify and group.
export type RudderTraits = Record<string, any>;RudderProperties
RudderStack特征载荷接受的属性载荷 track 和 screen.
export type RudderProperties = Record<string, any>;PluginVersionResult
插件版本结果插件版本载荷
export interface PluginVersionResult { /** * Version identifier returned by the platform implementation. */ version: string;}RudderLogLevelValue
鲁德栈日志级别值真实来源
export type RudderLogLevelValue = 0 | 1 | 2 | 3 | 4 | 5;此页面是从插件的
源代码生成的此页面是从插件的源代码生成的 src/definitions.ts重新同步时,公共API上游发生变化。
继续从Getting Started
标题:继续从Getting Started如果您正在使用 Getting Started 规划仪表板和API操作时,连接它到 使用@capgo/capacitor-rudderstack 使用@capgo/capacitor-rudderstack API概述 API概述 介绍 介绍 API 键 API Keys 设备 设备