@triplesense/capacitor-rudder-stack
v1.0.0-6
Published
Rudder stack plugin
Downloads
3
Readme
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 ofcom.rudderstack.android.sdk:core
(default:1.0.22
)$rudderstackFirebaseIntegrationVersion
: version ofcom.rudderstack.android.integration:firebase
(default:2+
)$firebaseAnalyticsVersion
: version ofcom.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
| Param | Type |
| -------------- | --------------------------------------------------------- |
| writeKey
| string |
| endpoint
| string |
| callback
| RudderCallback |
Since: 1.0.0
identify(...)
identify(options: RudderStackIdentifyOptions, callback?: RudderCallback | undefined) => void
Identify your user
platforms: android, web, ios
| Param | Type |
| -------------- | --------------------------------------------------------------------------------- |
| options
| RudderStackIdentifyOptions |
| callback
| RudderCallback |
Since: 1.0.0
track(...)
track(options: RudderStackTrackOptions, callback?: RudderCallback | undefined) => void
Track your event with name and properties
platforms: android, web, ios
| Param | Type |
| -------------- | --------------------------------------------------------------------------- |
| options
| RudderStackTrackOptions |
| callback
| RudderCallback |
Since: 1.0.0
reset(...)
reset(callback?: RudderCallback | undefined) => void
Reset SDK
platforms: android, web, ios
| Param | Type |
| -------------- | --------------------------------------------------------- |
| callback
| RudderCallback |
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
| Param | Type |
| -------------- | --------------------------------------------------------- |
| callback
| RudderCallback |
Since: 1.0.0
Interfaces
Error
| Prop | Type |
| ------------- | ------------------- |
| name
| string |
| message
| string |
| stack
| string |
RudderStackIdentifyOptions
| Prop | Type | Description | Since |
| ------------- | ------------------- | ------------------------------------- | ----- |
| id
| string | User id | 1.0.0 |
| traits
| string | User traits serialized as JSON string | 1.0.0 |
| options
| any | Aditional options | 1.0.0 |
RudderStackTrackOptions
| Prop | Type | Description | Since |
| ---------------- | ------------------------------------ | ------------------------------------------ | ----- |
| event
| string | Event name | 1.0.0 |
| properties
| { [key: string]: any; } | Event properties serialized as JSON string | 1.0.0 |
| options
| any | Options | 1.0.0 |
Type Aliases
RudderCallback
(data?: any, error?: Error): void