https://github.com/luke-hawk/nativescript-fb-analytics
Lightweight NativeScript plugin to add Facebook Analytics to iOS and Android apps.
https://github.com/luke-hawk/nativescript-fb-analytics
facebook-analytics nativescript nativescript-plugin
Last synced: over 1 year ago
JSON representation
Lightweight NativeScript plugin to add Facebook Analytics to iOS and Android apps.
- Host: GitHub
- URL: https://github.com/luke-hawk/nativescript-fb-analytics
- Owner: luke-hawk
- License: apache-2.0
- Created: 2020-07-07T09:42:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-14T01:01:42.000Z (over 3 years ago)
- Last Synced: 2024-04-23T20:41:24.739Z (about 2 years ago)
- Topics: facebook-analytics, nativescript, nativescript-plugin
- Language: TypeScript
- Homepage:
- Size: 2.02 MB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nativescript: Facebook Analytics
Adds *only* Facebook Analytics to your Nativescript app *not* the full Facebook SDK.
This plugin is based on [nativescript-facebook](https://github.com/NativeScript/nativescript-facebook) but only includes the Facebook Core Library which is needed for analytics. This way it **reduces the bundle size by 86%** compared to nativescript-facebook which includes the full Facebook SDK. If you want to learn more you may read this [blog post](https://developers.facebook.com/blog/post/2017/09/26/android-sdk-optimization/).
## Installation
```
tns plugin add nativescript-fb-analytics
```
## Configuration
The following configuration is needed in order to get started with Facebook Analytics. In order to obtain a Facebook App-ID please refer to the official [documentation](https://developers.facebook.com/docs/apps/).
Initialize the plugin before calling `app.run`:
```js
/* your-project/app/app.ts */
import * as app from "tns-core-modules/application";
import * as fbAnalytics from 'nativescript-fb-analytics';
app.on(app.launchEvent, function (args) {
fbAnalytics.initAnalytics();
});
```
Additional configs needed for **Android**:
```xml
YOUR_APP_ID
...
```
Additional configs needed for **iOS**:
```xml
CFBundleURLTypes
CFBundleURLSchemes
fbYOUR_APP_ID
FacebookAppID
YOUR_APP_ID
FacebookDisplayName
YOUR_APP_NAME
```
## Usage
You can log events from anywhere you want by importing
```js
import * as fbAnalytics from 'nativescript-fb-analytics';
```
and calling
```js
fbAnalytics.logEvent('Lead');
```
You may also add parameters to your event logging:
```js
const value = 5;
const parameters = [{
key: 'value',
value: value.toString(),
}];
fbAnalytics.logEvent(FundsAdded, parameters);
```