@nstudio/nativescript-aptabase
Aptabase Analytics for Apps. Privacy-First. Simple.
npm i --save @nstudio/nativescript-aptabase
- Version: 1.2.0
- GitHub: https://github.com/nstudio/nativescript-plugins
- NPM: https://www.npmjs.com/package/%40nstudio%2Fnativescript-aptabase
- Downloads:
- Last Day: 0
- Last Week: 2
- Last Month: 33
@nstudio/nativescript-aptabase
Instrument your NativeScript apps with Aptabase, an Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps.
Install
Install the SDK using your preferred JavaScript package manager
pnpm add @nstudio/nativescript-aptabase
# or
npm add @nstudio/nativescript-aptabase
# or
yarn add @nstudio/nativescript-aptabase
For iOS, configure your nativescript.config.ts
to use the Swift Package:
ios: {
SPMPackages: [
{
name: 'Aptabase',
libs: ['Aptabase'],
repositoryURL: 'https://github.com/aptabase/aptabase-swift.git',
version: '0.3.6'
}
]
}
Usage
First you need to get your App Key
from Aptabase, you can find it in the Instructions
menu on the left side menu.
Initialize the SDK using your App Key
and the initialize
function. We would recommend calling it as early as possible in your app life cycle.
import { Aptabase } from '@nstudio/nativescript-aptabase';
Aptabase.initialize('<YOUR_APP_KEY>'); // 👈 this is where you enter your App Key
Afterwards you can start tracking events with track
:
import { Aptabase } from '@nstudio/nativescript-aptabase';
// Track an event
Aptabase.track("connect_click");
// Track events with custom properties
Aptabase.track("play_music", {
name: "Here comes the sun"
});
A few important notes:
- The SDK will automatically enhance the event with some useful information, like the OS, the app version, and other things.
- You're in control of what is sent to Aptabase. This SDK does not automatically track any events, you need to call
track
manually.- Because of this, it's generally recommended to at least track an event at startup
- You do not need to await the
track
function, it'll run in the background. - Only strings and numbers values are allowed on custom properties
License
Apache License Version 2.0