跳过内容

开始使用

终端窗口
bun add @capgo/capacitor-rudderstack
bunx cap sync
import { nativePlugin } from '@capgo/capacitor-rudderstack';

初始化 RudderStack 客户端。

该方法保留了 Cordova 签名,因此第二个参数可以是配置对象或 Rudder 选项对象。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.initialize('value');

为提供的用户 ID 发送一个识别调用。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.identify('value');

为提供的组 ID 发送一个组调用。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.group('value');

为提供的事件名称发送一个跟踪调用。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.track('value');

screen

屏幕

发送一个屏幕呼叫,屏幕名为“__CAPGO_KEEP_0__”。

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();

将设备令牌发送到支持的目的地。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putDeviceToken('value');

查看当前合同的源定义。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAdvertisingId('value');

设置自定义广告 ID 值。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAdvertisingId('value');

查看当前合同的源定义。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.setAnonymousId('value');

设置一个自定义的匿名 ID 值。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.putAnonymousId('value');

切换 RudderStack 跟踪选项。

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.optOut(true);

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[];
}

每次调用 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>;
}

接受的特征载荷 identifygroup.

export type RudderTraits = Record<string, any>;

接受的属性载荷 trackscreen.

export type RudderProperties = Record<string, any>;

插件版本载荷

export interface PluginVersionResult {
/**
* Version identifier returned by the platform implementation.
*/
version: string;
}

为迁移提供便利,暴露了RudderStack日志级别值。

export type RudderLogLevelValue = 0 | 1 | 2 | 3 | 4 | 5;

本页由插件生成。 src/definitions.ts当公共API上游更改时,请重新运行同步。