Getting Started
复制一个包含安装步骤和此插件的完整 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.如果您更喜欢手动设置,请运行以下命令安装插件并按照以下平台特定的说明进行操作:
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
标题:设置设备令牌将推送令牌设置为RudderStack支持的目的地。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putDeviceToken('value');setAdvertisingId
标题:设置广告 ID查看当前合同的源定义。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAdvertisingId('value');putAdvertisingId
标题:设置广告 ID设置自定义广告 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
标题:"optOut"开关RudderStack跟踪选项。
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.optOut(true);类型参考
标题:"类型参考"RudderConfiguration
标题:"RudderConfiguration"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接受的特征载荷 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
RudderLogLevelValueRudderStack 日志级别值暴露给迁移方便。
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 密钥 的实现细节 设备 为设备 的实现细节