The Telerik Platform product is retired.Learn more

Monitor Integration in NativeScript

This article will describe how to integrate Analytics in your NativeScript application.

The integration process consists of 3 steps:

  1. Unzip the provided package in your application folder
  2. Create and start the monitor
  3. Start tracking interesting statistics

Before getting started you must create an application and obtain a product id. You will need this id in the integration section. Read more about how to Add Analytics to Your Application. It is important to select the javascript project type when creating the new project.

The NativeScript module requires the following permissions in Android to work correctly (those permissions are automatically added to the corresponding manifests when adding the android platform using the tns platform add android command):


Step 1: Add the library to your application

Download the NativeScript zip package which contains the following structure:
├── NativeScriptMonitor
│   ├── package.json
│   ├── DeviceInfo.js
│   ├── EqatecMonitor.js
│   └── NativeScriptMonitor.js
└── tns_modules
    └── platform-ext
        ├── platform-ext.ios.js  
        └── package.json

Create a new NativeScript application:

tns create hello-world

Add some platforms to it:

cd hello-world
tns platform add android

Unzip the contents of the downloaded package inside the app folder of your nativescript application so that the target directory structure looks like this:

├── app
│   ├── app.css
│   ├── app.js
│   ├── main-page.js
│   ├── main-view-model.js
│   ├── main-page.xml
│   ├── NativeScriptMonitor
│   │   ├── package.json
│   │   ├── DeviceInfo.js
│   │   ├── EqatecMonitor.js
│   │   └── NativeScriptMonitor.js
│   └── tns_modules
│       ├── platform-ext
│       │   ├──
│       │   ├── platform-ext.ios.js  
│       │   └── package.json
│       └── ...
├── lib
│   ├── android
│   └── ios
└── platforms
    ├── android
    └── ios

Step 2: Create and start the monitor

The Nativescript module can be included in your app.js file and an instance of the monitor created at application startup. This instance can be later reused in the application:

var application = require('application');
application.mainModule = 'main-page';
application.cssFile = './app.css';

application.onLaunch = function(context) {
  // including the Analytics module
  var NativeScriptMonitor = require('./NativeScriptMonitor').Monitor;

  // Create an instance of the Analytics monitor
  var analytics = new NativeScriptMonitor({
    productId: 'PUT-YOUR-PRODUCTID-HERE', // required GUID obtained when creating the application in the Analytics module
    version: '1.2.3', // optional version of the monitored application
    useHttps: true // optional flag specifying the protocol used for calling the Analytics endpoint

  // Starting a new analytics session

  // Store the analytics instance so that we can track some features in our view models later = analytics;

application.onExit = function() {
  // Stoping the analytics session at application exit;


That's it, really. If you run your application now it will start reporting basic analytics data:

tns run android

Step 3: Start tracking interesting statistics

The next natural step is to track interesting events and exceptions occurring in your application.

The NativeScript monitor exposes the same SDK methods as its javascript counterpart.

var application = require('application');

// Tracking features'SomeFeature');

// Tracking exceptions
try {
catch (e) {, e.message);

// Tracking timing'SomeLongOperation');

// Tracking numeric values'SomeFeatureValue', 1234);


After completing the steps in this guide, Analytics should be integrated into your application. When you run it, you should see data within 5 minutes on the Analytics client dashboard. If not then please check the article on Your First Data.

See Also

Contact us: +1-888-365-2779
Copyright © 2016-2018, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.