Aller au contenu

Prise en main

GitHub

Vous pouvez utiliser notre configuration assistée par IA pour installer le plugin. Ajoutez les skills Capgo à votre outil d'IA avec la commande suivante :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Utilisez ensuite le prompt suivant :

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-rudderstack` plugin in my project.

Si vous préférez une installation manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à chaque plateforme ci-dessous :

Fenêtre de terminal
bun add @capgo/capacitor-rudderstack
bunx cap sync
import { nativePlugin } from '@capgo/capacitor-rudderstack';
import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.initialize({
writeKey: 'YOUR_WRITE_KEY',
dataPlaneUrl: 'https://your.dataplane.rudderstack.com',
});
await nativePlugin.identify({ userId: 'user_123', traits: { plan: 'pro' } });
await nativePlugin.track({ event: 'Signed Up', properties: { source: 'mobile' } });
await nativePlugin.screen({
screen: 'Checkout',
properties: { step: 'payment' },
});
  • Initialiser une seule fois: répétés initialize() calls can duplicate SDK state, gate behind your app bootstrap.
  • Vider avant le passage en arrière-plan: appelez flush() lorsque iOS ou Android peut suspendre votre processus en plein upload.
  • Identifiants publicitaires: aideurs d'opt-in uniquement si votre politique de confidentialité couvre la collecte d'IDFA ou de GAID.

Initialise le client RudderStack.

La méthode conserve la signature Cordova : le second argument peut donc être soit un objet de configuration, soit un objet d'options Rudder.

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

Envoie un appel identify pour l'ID utilisateur fourni.

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

Envoie un appel group pour l'ID de groupe fourni.

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

Envoie un appel track pour le nom d'événement fourni.

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

Envoie un appel screen pour le nom d'écran fourni.

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

Crée un alias de l'utilisateur actuel vers un nouvel identifiant.

import { nativePlugin } from '@capgo/capacitor-rudderstack';
await nativePlugin.alias('new-id-123');

Réinitialise l'état d'identité RudderStack actuel.

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

Envoie immédiatement les événements en attente.

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

Définit le token push que RudderStack transmet aux destinations prises en charge.

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

Consultez les définitions source pour le contrat actuel.

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

Sets a custom advertising id value.

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

Consultez les définitions source pour le contrat actuel.

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

Définit une valeur d'ID anonyme personnalisée.

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

Active ou désactive l'opt-out du suivi RudderStack.

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

Clés de configuration prises en charge pour les SDK natifs RudderStack sous-jacents.

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

Options RudderStack par appel.

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

Payload de traits accepté par identify et group.

export type RudderTraits = Record<string, any>;

Payload de propriétés accepté par track et screen.

export type RudderProperties = Record<string, any>;

Payload de la version du plugin.

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

Valeurs de niveau de log RudderStack exposées pour faciliter la migration.

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

Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation lorsque l’API public change en amont.

Si vous utilisez Prise en main pour planifier les opérations du dashboard et de API, connectez-l’avec Utilisation de @capgo/capacitor-rudderstack pour la fonctionnalité native dans « Utilisation de @capgo/capacitor-rudderstack », Aperçu de API pour les détails d'implémentation dans « Vue d'ensemble de API », Introduction pour les détails d'implémentation dans l'introduction, Clés API pour les détails d'implémentation dans « Clés API », et Appareils pour les détails d'implémentation dans Devices.