1.0.0-6 • Published 3 years ago

@triplesense/capacitor-rudder-stack v1.0.0-6

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 years ago

Capacitor Rudder Stack Plugin

Capacitor plugin for Rudder Stack.

Current version 1.0.0-2

See our detailed changelog for the latest features, improvements and bug fixes.

Installation

npm

npm install @triplesense/capacitor-rudder-stack
npx cap sync

Rudder Stack config

Capacitor.config

Add your Rudder Stack keys and planeUrl to capacitor.config.ts:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  ...
  plugins: {
    RudderStack: {
      planeUrl: 'YOUR_PLANE_URL',
      writeKey: 'YOUR_WRITE_KEY', // for android
      writeKeyIOS: 'YOUR_WRITE_KEY' // for ios
    },
  }
  ...

Android Variables

This plugin will use the following project variables (defined in your app's variables.gradle file):

  • $rudderstackSdkVersion: version of com.rudderstack.android.sdk:core (default: 1.0.22)
  • $rudderstackFirebaseIntegrationVersion: version of com.rudderstack.android.integration:firebase (default: 2+)
  • $firebaseAnalyticsVersion: version of com.google.firebase:firebase-analytics (default: 21.0.0)

Usage example

First make sure to import the plugin, then call the methods:

import { RudderStack } from '@triplesense/capacitor-rudder-stack';

@Component({
  selector: 'home-page',
  templateUrl: 'home.page.html',
})
export class HomePage implements OnInit {
  ngOnInit() {
    // tracks an event named HOME_PAGE_VIEWED, passing the time whe the event occurred
    RudderStack.track({
      event: 'HOME_PAGE_VIEWED',
      properties: { timestamp: Date.getTime() },
    });
  }
}

API

loadApi(...)

loadApi(writeKey: string, endpoint: string, callback?: RudderCallback | undefined) => void

Load Rudder Stack api

platform: web

ParamType
writeKeystring
endpointstring
callbackRudderCallback

Since: 1.0.0


identify(...)

identify(options: RudderStackIdentifyOptions, callback?: RudderCallback | undefined) => void

Identify your user

platforms: android, web, ios

ParamType
optionsRudderStackIdentifyOptions
callbackRudderCallback

Since: 1.0.0


track(...)

track(options: RudderStackTrackOptions, callback?: RudderCallback | undefined) => void

Track your event with name and properties

platforms: android, web, ios

ParamType
optionsRudderStackTrackOptions
callbackRudderCallback

Since: 1.0.0


reset(...)

reset(callback?: RudderCallback | undefined) => void

Reset SDK

platforms: android, web, ios

ParamType
callbackRudderCallback

Since: 1.0.0


putAdvertisementId(...)

putAdvertisementId(callback: RudderCallback) => void

Set advertisement id after user consent. should be called after permission granted by user

platforms: android, web, ios

ParamType
callbackRudderCallback

Since: 1.0.0


Interfaces

Error

PropType
namestring
messagestring
stackstring

RudderStackIdentifyOptions

PropTypeDescriptionSince
idstringUser id1.0.0
traitsstringUser traits serialized as JSON string1.0.0
optionsanyAditional options1.0.0

RudderStackTrackOptions

PropTypeDescriptionSince
eventstringEvent name1.0.0
properties{ key: string: any; }Event properties serialized as JSON string1.0.0
optionsanyOptions1.0.0

Type Aliases

RudderCallback

(data?: any, error?: Error): void

1.0.0-5

3 years ago

1.0.0-4

3 years ago

1.0.0-6

3 years ago

1.0.0-3

3 years ago

1.0.0-2

3 years ago

1.0.0-1

3 years ago