Skip to content

Getting Started

Terminal window
bun add @capgo/capacitor-rudderstack
bunx cap sync
import { nativePlugin } from '@capgo/capacitor-rudderstack';

Initializes the RudderStack client.

The method keeps the Cordova signature, so the second argument may be either a config object or a Rudder options object.

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

Sends an identify call for the provided user id.

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

Sends a group call for the provided 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');

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

Flushes queued events immediately.

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

Sets the push token that RudderStack forwards to supported destinations.

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

See the source definitions for the current contract.

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

Sets a custom advertising id value.

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

See the source definitions for the current contract.

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

Sets a custom anonymous id value.

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

Toggles RudderStack tracking opt-out.

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

Supported configuration keys for the underlying RudderStack native SDKs.

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 per-call options.

export interface RudderOptions {
/**
* External identifiers forwarded with the event.
*/
externalIds?: Record<string, string>;
/**
* Destination enablement flags keyed by integration name.
*/
integrations?: Record<string, boolean>;
}

Traits payload accepted by identify and group.

export type RudderTraits = Record<string, any>;

Properties payload accepted by track and screen.

export type RudderProperties = Record<string, any>;

Plugin version payload.

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

RudderStack log level values exposed for migration convenience.

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

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.