diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..496ee2ca --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/legacy_docs/cordova/19.9.3.md b/legacy_docs/cordova/19.9.3.md index 3f9f87f3..44f717db 100644 --- a/legacy_docs/cordova/19.9.3.md +++ b/legacy_docs/cordova/19.9.3.md @@ -2,49 +2,69 @@ Setting up Countly SDK inside your Phonegap, Cordova, Icenium or Meteor application is straightforward. Just follow these steps.

-

Using SDK

+

Using SDK

First run the following to create a Countly demo application.

-
cordova create countly-demo-js com.countly.demo countly-demo-js
cd countly-demo-js
+
cordova create countly-demo-js com.countly.demo countly-demo-js
+cd countly-demo-js

Add Countly core plugin

-
cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
# OR
cordova plugin add countly-sdk-js@19.9.3
+
cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
+# OR
+cordova plugin add countly-sdk-js@19.9.3

Now add platform of your choice

-
cordova platform add android
cordova platform add ios
+
cordova platform add android
+cordova platform add ios

It's important that you make sure you build it with Cordova, as Cordova links folders very well.

-
cordova build android
cordova build ios
+
cordova build android
+cordova build ios

Now run the application directly for Android,

-
cordova run android
+
cordova run android

Or iOS:

-
cordova run ios
+
cordova run ios

Alternatively, you can open the source in Xcode, or Eclipse and move on with further development.

-

Using SDK with Meteor app

+

Using SDK with Meteor app

Run this command for Meteor:

-
meteor add countly:countly-sdk-js
-

Ionic 2.0

-
npm install -g ionic cordova
ionic start countly-demo-ionic blank
cd countly-demo-ionic
ionic cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
ionic serve
# Note to ionic devs: This plugin does not work on a browser.
+
meteor add countly:countly-sdk-js
+

Ionic 2.0

+
npm install -g ionic cordova
+ionic start countly-demo-ionic blank
+cd countly-demo-ionic
+ionic cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
+ionic serve
+# Note to ionic devs: This plugin does not work on a browser.

In your index.html, use the following lines:

-
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="Countly.js"></script>
+
<script type="text/javascript" src="cordova.js"></script>
+<script type="text/javascript" src="Countly.js"></script>

If you looking to try out example code, you may wanna look at the index.html in the countly-sdk-cordova repo in master branch.

Copy and paste into your www/index.html

It has all the required examples you need.

-

Implementation

+

Implementation

Below you can find necessary code snippets to initialize the SDK for sending data to Countly servers. Where possible, use your server URL instead of try.count.ly in case you have your own server.

-
// initialize
// use your server name below if required.
Countly.init("https://try.count.ly","App_Key");

//example to start and stop Countly
Countly.start();
Countly.stop();

//example to halt Countly
Countly.halt();
-

Enabling logging

+
// initialize
+// use your server name below if required.
+Countly.init("https://try.count.ly","App_Key");
+
+//example to start and stop Countly
+Countly.start();
+Countly.stop();
+
+//example to halt Countly
+Countly.halt();
+

Enabling logging

If logging is enabled then our sdk will print out debug messages about it's internal state and encountered problems. @@ -52,9 +72,9 @@

When advise doing this while implementing countly features in your application.

-
// example for setLoggingEnabled
+
// example for setLoggingEnabled
 Countly.setLoggingEnabled();
-

Forcing HTTP POST

+

Forcing HTTP POST

If the data sent to the server is short enough, the sdk will use HTTP GET requests. In case you want an override so that HTTP POST is used in all cases, call the @@ -62,18 +82,18 @@ Countly.setLoggingEnabled();

to later in the apps life cycle disable the override. This function has to be called every time the app starts.

-
Countly.setHttpPostForced(true); // default is false
+
Countly.setHttpPostForced(true); // default is false
 
-

Parameter Tampering Protection

+

Parameter Tampering Protection

You can set optional salt to be used for calculating checksum of request data, which will be sent with each request using &checksum field. You need to set exactly the same salt on Countly server. If salt on Countly server is set, all requests would be checked for validity of &checksum field before being processed.

-
// sending data with salt
+
// sending data with salt
 Countly.enableParameterTamperingProtection("salt");
-

Setting up custom events

+

Setting up custom events

A custom event is any type of action that you can send to a Countly instance, e.g purchase, settings changed, view enabled and so. This way it's possible to @@ -82,7 +102,7 @@ Countly.enableParameterTamperingProtection("salt");

- Data passed should be in UTF-8 + Data passed should be in UTF-8

All data passed to Countly server via SDK or API should be in UTF-8. @@ -93,45 +113,45 @@ Countly.enableParameterTamperingProtection("salt");

what information each usage will provide us:

-

1. Event key and count

-
// example for sending basic custom event
+

1. Event key and count

+
// example for sending basic custom event
 var events = {"key":"Basic Event","count":1};
 Countly.recordEvent(events);
-

2. Event key, count and sum

-
// example for event with sum
+

2. Event key, count and sum

+
// example for event with sum
 var events = {"key":"Event With Sum","count":1,"sum":"0.99"};
 Countly.recordEvent(events);
-

3. Event key and count with segmentation(s)

-
// example for event with segment
+

3. Event key and count with segmentation(s)

+
// example for event with segment
 var events = {"key":"Event With Segment","count":1};
 events.segments = {"Country" : "Turkey", "Age" : "28"};
 Countly.recordEvent(events);
-

4. Event key, count and sum with segmentation(s)

-
// example for event with segment and sum
+

4. Event key, count and sum with segmentation(s)

+
// example for event with segment and sum
 var events = {"key":"Event With Segment And Sum","count":1,"sum":"0.99"};
 events.segments = {"Country" : "Turkey", "Age" : "28"};
 Countly.recordEvent(events);
-

5. Event key, count, sum and duration with segmentation(s)

-
var events = {
+

5. Event key, count, sum and duration with segmentation(s)

+
var events = {
   "key": "Event With Sum And Segment duration",
   "count": 1,
   "Sum": "0.99",
@@ -147,25 +167,30 @@ Countly.recordEvent(events);
extend those examples and use country, app_version, game_level, time_of_day and any other segmentation that will provide you valuable insights.

-

Timed events

+

Timed events

It's possible to create to create timed events by defining a start and stop moment.

-
// Time Event
-Countly.startEvent("Timed Event");
setTimeout(function() { +
// Time Event
+Countly.startEvent("Timed Event");
+setTimeout(function() {
     Countly.endEvent({ "key": "Timed Event");
-}, 1000);
+}, 1000); + // Time Event With Sum Countly.startEvent("Timed Event With Sum"); -setTimeout(function() {
countly.endEvent({"key": "Timed Event With Sum", "sum": "0.99"});
}, 1000);
+setTimeout(function() { + countly.endEvent({"key": "Timed Event With Sum", "sum": "0.99"}); +}, 1000);

When ending a event you can also provide additional information. But in that case you have to provide segmentation, count and sum. The default values for those are "null", 1 and 0.

-

+

 // Time Event with segment
-Countly.startEvent("Timed Event With Segment");
setTimeout(function() { +Countly.startEvent("Timed Event With Segment"); +setTimeout(function() { var events = { "key": "Timed Event With Segment" }; @@ -174,9 +199,11 @@ Countly.startEvent("Timed Event With Segment");
setTimeout(function() { "Age": "28" }; Countly.endEvent(events); -}, 1000)
+}, 1000) + // Time Event with Segment, sum and count -Countly.startEvent("Timed Event With Segment, Sum And Count");
setTimeout(function() { +Countly.startEvent("Timed Event With Segment, Sum And Count"); +setTimeout(function() { var events = { "key": "timedEvent", "count": 1, @@ -186,74 +213,82 @@ Countly.startEvent("Timed Event With Segment, Sum And Count");
setTimeout(fun "Country": "Turkey", "Age": "28" }; - Countly.endEvent(events);
}, 1000);
-

Device ID

+ Countly.endEvent(events); +}, 1000);
+

Device ID

- When the SDK is initialized for the first time and no device ID is provided, a device ID will be generated by SDK. + When the SDK is initialized for the first time and no device ID is provided, a device ID will be generated by SDK.

- For iOS: the device ID generated by SDK is the Identifier For Vendor (IDFV)
For Android:  the device ID generated by SDK is the OpenUDID or Google Advertising ID
+ For iOS: the device ID generated by SDK is the Identifier For Vendor (IDFV)
+ For Android:  the device ID generated by SDK is the OpenUDID or Google Advertising ID

- You may provide your own custom device ID when initializing the SDK + You may provide your own custom device ID when initializing the SDK

-
Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
-

- Changing the Device ID +
Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
+

+ Changing the Device ID

- You may configure/change the device ID anytime using:
+ You may configure/change the device ID anytime using:
+  

-
Countly.changeDeviceId(DEVICE_ID, ON_SERVER);
+
Countly.changeDeviceId(DEVICE_ID, ON_SERVER);

- You may either allow the device to be counted as a new device or merge existing data on the server. If - theonServer bool is set to true, - the old device ID on the server will be replaced with the new one, and data associated with the old device ID will be merged automatically.
Otherwise, if onServer bool is set to false, the device will be counted as a new device on the server.
+ You may either allow the device to be counted as a new device or merge existing + data on the server. If theonServer bool is set to + true, the old device ID on the server will be replaced with the + new one, and data associated with the old device ID will be merged automatically.
+ Otherwise, if onServer bool is set to + false, the device will be counted as a new device on the server.
+  

-

Temporary Device ID

+

Temporary Device ID

You may use a temporary device ID mode for keeping all requests on hold until the real device ID is set later. 

You can enable temporary device ID - when initializing the SDK: + when initializing the SDK:

-
Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")
+
Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")

To enable a temporary device ID after init, you would call:

-
Countly.changeDeviceId(Countly."TemporaryDeviceID", ON_SERVER);
+
Countly.changeDeviceId(Countly."TemporaryDeviceID", ON_SERVER);

-  Note: When passing TemporaryDeviceID for deviceID parameter, - argument for onServerparameter does not matter. +  Note: When passing TemporaryDeviceID for deviceID parameter, + argument for onServerparameter does not matter.

- As long as the device ID value is TemporaryDeviceID, - the SDK will be in temporary device ID mode and all requests will be on hold, - but they will be persistently stored. + As long as the device ID value is TemporaryDeviceID, the SDK will + be in temporary device ID mode and all requests will be on hold, but they will + be persistently stored.

When in temporary device ID mode, method calls for presenting feedback widgets and updating remote config will be ignored.

- Later, when the real device ID is set using Countly.changeDeviceId(DEVICE_ID, ON_SERVER); method, - all requests which have been kept on hold until that point will start with the - real device ID + Later, when the real device ID is set using + Countly.changeDeviceId(DEVICE_ID, ON_SERVER); method, all requests + which have been kept on hold until that point will start with the real device + ID

-

Retrieving the device id and its type

+

Retrieving the device id and its type

You may wanty to see what device id Countly is assigning for the specific device and what the source of that id is. For that you may use the following calls. The id type is an enum with the possible values of: "DEVELOPER_SUPPLIED", "OPEN_UDID", "ADVERTISING_ID".

-
// get device id
+
// get device id
 Countly.getDeviceID(function(deviceId){
   console.log(deviceId);
 }, function(getDeviceIDError){
   console.log(getDeviceIDError);
 });
-

User location

+

User location

While integrating this SDK into your application, you might want to track your user location. You could use this information to better know your apps user base @@ -261,14 +296,14 @@ Countly.getDeviceID(function(deviceId){ are 4 fields that can be provided:

    -
  • country code in the 2 letter iso standard
  • -
  • city name (has to be set together with country code)
  • -
  • +
  • country code in the 2 letter iso standard
  • +
  • city name (has to be set together with country code)
  • +
  • Comma separate latitude and longitude values, for example "56.42345,123.45325"
  • -
  • ip address of your user
  • +
  • ip address of your user
-
// send user location
+
// send user location
 Countly.setLocation("28.006324", "-82.7166183");

When those values are set, they will be sent every time when initiating a session. @@ -283,13 +318,13 @@ Countly.setLocation("28.006324", "-82.7166183");

It will erase cached location data from the device and the server.

-

Remote Config

+

Remote Config

Remote config allows you to modiffy how your app functions or looks by requesting key-value pairs from your Countly server. The returned values can be modiffied based on the user profile. For more details please see Remote Config documentation.

-

Automatic Remote Config download

+

Automatic Remote Config download

There are two ways of acquiring remote config data, by automatic download or manual request. By default, automatic remote config is disabled and therefore @@ -305,7 +340,8 @@ Countly.setLocation("28.006324", "-82.7166183");

Note: call setRemoteConfigAutomaticDownload method before init

-
// Call this method before init
Countly.setRemoteConfigAutomaticDownload(function(r){ +
// Call this method before init
+Countly.setRemoteConfigAutomaticDownload(function(r){
   alert(r)
 }, function(r){
   alert(r);
@@ -321,14 +357,14 @@ Countly.setLocation("28.006324", "-82.7166183");
instead). It is possible that a previously valid key returns no value after an update.

-

Manual Remote Config download

+

Manual Remote Config download

There are three ways for manually requesting a Remote Config update:

    -
  • Manually updating everything
  • -
  • Manually updating specific keys
  • -
  • Manually updating everything except specific keys
  • +
  • Manually updating everything
  • +
  • Manually updating specific keys
  • +
  • Manually updating everything except specific keys

Each of these requests also has a callback. If that returns a non-null value, @@ -341,7 +377,7 @@ Countly.setLocation("28.006324", "-82.7166183");

The advantage is that you can make the request whenever it is desirable for you. It has a callback to let you know when it has finished.

-
Countly.remoteConfigUpdate(function(r){
+
Countly.remoteConfigUpdate(function(r){
   alert(r)
 }, function(r){
   alert(r);
@@ -352,7 +388,7 @@ Countly.setLocation("28.006324", "-82.7166183");
updated. That list is an array with string values of those keys. It has a callback to let you know when the request has finished.

-
Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
+
Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
   alert(r)
 }, function(r){
   alert(r);
@@ -362,7 +398,7 @@ Countly.setLocation("28.006324", "-82.7166183");
updateRemoteConfigExceptKeys. The key list is a array with string values of the keys. It has a callback to let you know when the request has finished.

-
Countly.updateRemoteConfigExceptKeys(["url"], function(r){
+
Countly.updateRemoteConfigExceptKeys(["url"], function(r){
   alert(r)
 }, function(r){
   alert(r);
@@ -373,7 +409,7 @@ Countly.setLocation("28.006324", "-82.7166183");
will update all values. This means that it will also erase all keys not returned by the server.

-

Getting Remote Config values

+

Getting Remote Config values

To request a stored value, call getRemoteConfigValueForKey with the specified key. If it returns null then no value was found. The SDK has no @@ -381,22 +417,22 @@ Countly.setLocation("28.006324", "-82.7166183");

needs to cast it to the appropriate type. The returned values can also be a JSONArray, JSONObject or just a simple value like int.

-
Countly.getRemoteConfigValueForKey("name", function(r){
+
Countly.getRemoteConfigValueForKey("name", function(r){
    alert(r)
  }, function(r){
    alert(r);
  });
-

Clearing stored Remote Config values

+

Clearing stored Remote Config values

At some point you might want to erase all values downloaded from the server. To achieve that you need to call one function, depicted below:

-
Countly.remoteConfigClearValues(function(r){
+
Countly.remoteConfigClearValues(function(r){
   alert(r)
 }, function(r){
   alert(r);
 });
-

Setting up User Profiles

+

Setting up User Profiles

Available with Enterprise Edition, User Profiles is a tool which helps you identify users, their devices, event timeline and application crash information. User @@ -415,7 +451,7 @@ Countly.setLocation("28.006324", "-82.7166183");

After you have provided user profile information, you must save it by calling Countly.userData.save().

-
/ example for setting user data
+
/ example for setting user data
 var options = {};
 options.name = "Nicola Tesla";
 options.username = "nicola";
@@ -428,55 +464,59 @@ options.gender = "Male";
 options.byear = 1919;
 Countly.setUserData(options);

The keys for predefined user data fields are as follows:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyTypeDescription
nameStringUser's full name
usernameStringUser's nickname
emailStringUser's email address
organizationStringUser's organisation name
phoneStringUser's phone number
pictureStringURL to avatar or profile picture of the user
genderStringUser's gender as M for male and F for female
byearStringUser's year of birth as integer
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyTypeDescription
nameStringUser's full name
usernameStringUser's nickname
emailStringUser's email address
organizationStringUser's organisation name
phoneStringUser's phone number
pictureStringURL to avatar or profile picture of the user
genderStringUser's gender as M for male and F for female
byearStringUser's year of birth as integer
+

Using "" for strings or a negative number for 'byear' will effectively delete that property. @@ -486,13 +526,13 @@ Countly.setUserData(options);

on your Countly backend. Note: keys with . or $ symbols will have those symbols removed.

-

Modifying custom data

+

Modifying custom data

Additionally you can do different manipulations on your custom data values, like increment current value on server or store a array of values under the same property.

Below is the list of available methods:

-
// example for extra user features
+
// example for extra user features
 
 Countly.userData.setProperty("setProperty", "My Property");
 Countly.userData.increment("increment");
@@ -501,11 +541,13 @@ Countly.userData.multiply("multiply", 20);
 Countly.userData.saveMax("saveMax", 100);
 Countly.userData.saveMin("saveMin", 50);
 Countly.userData.setOnce("setOnce", 200);
-Countly.userData.pushUniqueValue("pushUniqueValue","morning");
Countly.userData.pushValue("pushValue", "morning");
Countly.userData.pullValue("pullValue", "morning");
+Countly.userData.pushUniqueValue("pushUniqueValue","morning"); +Countly.userData.pushValue("pushValue", "morning"); +Countly.userData.pullValue("pullValue", "morning");

In the end always call Countly.userData.save() to send them to the server.

-

User Consent management

+

User Consent management

To be compliant with GDPR, starting from 18.04, Countly provides ways to toggle different Countly features on/off depending on the given consent. @@ -515,7 +557,7 @@ Countly.userData.pushUniqueValue("pushUniqueValue","morning");
Countly.userDa By default the requirement for consent is disabled. To enable it, you have to call setRequiresConsent with true, before initializing Countly.

-
Countly.setRequiresConsent(true);
+
Countly.setRequiresConsent(true);

By default no consent is given. That means that if no consent is enabled, Countly will not work and no network requests, related to features, will be sent. When @@ -542,48 +584,48 @@ Countly.userData.pushUniqueValue("pushUniqueValue","morning");
Countly.userDa

The current features are:

    -
  • +
  • sessions - tracking when, how often and how long users use your app
  • -
  • events - allow sending custom events to server
  • -
  • views - allow tracking which views user visits
  • -
  • location - allow sending location information
  • -
  • crashes - allow tracking crashes, exceptions and errors
  • -
  • +
  • events - allow sending custom events to server
  • +
  • views - allow tracking which views user visits
  • +
  • location - allow sending location information
  • +
  • crashes - allow tracking crashes, exceptions and errors
  • +
  • attribution - allow tracking from which campaign did user come
  • -
  • +
  • users - allow collecting/providing user information, including custom properties
  • -
  • push - allow push notifications
  • -
  • starRating - allow to send their rating and feedback
  • -
  • apm - allow application performance monitoring
  • +
  • push - allow push notifications
  • +
  • starRating - allow to send their rating and feedback
  • +
  • apm - allow application performance monitoring
-

Changing consent

+

Changing consent

There are 3 ways of changing feature consent:

    -
  • +
  • giveConsent/removeConsent - gives or removes consent to a specific feature
-
//giveConsent
+
//giveConsent
 Countly.giveConsent(["events", "views", "star-rating", "crashes"]);
 
 // removeConsent
 Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
    -
  • +
  • giveAllConsent/removeAllConsent - giveAll or removeAll consent to a specific feature
-
//giveAllConsent
+
//giveAllConsent
 Countly.giveAllConsent();
 
 //removeAllConsent
 Countly.removeAllConsent();
 
-

Crash reporting

+

Crash reporting

With this feature, Countly SDK will generate a crash report if your application crashes due to an exception, and send it to Countly server for further inspection. @@ -593,19 +635,22 @@ Countly.removeAllConsent(); unavailable server), then SDK stores the crash report locally in order to try again later.

-

- Please add to your html file: - -

-
// Using countly crash reports
+  

+ +
// Using countly crash reports
 Countly.enableCrashReporting();
 

You can also send a custom crash log to Countly using code below.

-

+

 // Send a custom crash log
 Countly.addCrashLog("My crash log from JavaScript");
 
@@ -628,20 +673,20 @@ app.addCrashLog = function(){
   },1000);
 
 }
-

View tracking

+

View tracking

You can manually add your own views in your application, and each view will be visible under Analytics > Views. Below you can see two examples of sending a view using Countly.recordview function.

-
// record a view on your application
+
// record a view on your application
 Countly.recordView("My Home Page");
 Countly.recordView("Profile Page");
 
-

Application Performance Monitoring

+

Application Performance Monitoring

- Minimum Countly SDK Version + Minimum Countly SDK Version

This feature is only supported by the minimum SDK version 20.4.0. @@ -656,22 +701,27 @@ Countly.recordView("Profile Page"); Here is how you can utilize Performance Monitoring feature in your apps:

First, you need to enable Performance Monitoring feature::

-
Countly.enableApm(); // Enable APM features.
+
Countly.enableApm(); // Enable APM features.

With this, Countly SDK will start measuring some performance traces automatically. Those include app foreground time, app background time. Additionally, custom traces and network traces can be manually recorded.

-

Custom trace

+

Custom trace

- You may also measure any operation you want and record it using custom traces. First, you need to start a trace by using the startTrace(traceKey) method: + You may also measure any operation you want and record it using custom traces. First, you need to start a trace by using the startTrace(traceKey) method:

-
Countly.startTrace(traceKey);
+
Countly.startTrace(traceKey);

Then you may end it using the - endTrace(traceKey, customMetric)method, optionally passing any metrics as key-value pairs: + endTrace(traceKey, customMetric)method, optionally passing any metrics as key-value pairs:

-
String traceKey = "Trace Key";
Map<String, int> customMetric = {
"ABC": 1233,
"C44C": 1337
};
Countly.endTrace(traceKey, customMetric);
+
String traceKey = "Trace Key";
+Map<String, int> customMetric = {
+  "ABC": 1233,
+  "C44C": 1337
+};
+Countly.endTrace(traceKey, customMetric);

The duration of the custom trace will be automatically calculated on ending. Trace names should be non-zero length valid strings. Trying to start a custom @@ -679,17 +729,17 @@ Countly.recordView("Profile Page"); custom trace with already ended (or not yet started) name will have no effect.

- You may also cancel any custom trace you started, using cancelTrace(traceKey)method: + You may also cancel any custom trace you started, using cancelTrace(traceKey)method:

-
Countly.cancelTrace(traceKey);
+
Countly.cancelTrace(traceKey);

Additionally, if you need you may cancel all custom traces you started, using - clearAllTraces()method: + clearAllTraces()method:

-
Countly.clearAllTraces(traceKey);
-

Network trace

+
Countly.clearAllTraces(traceKey);
+

Network trace

- You may record manual network traces using therecordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime) method. + You may record manual network traces using therecordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime) method.

A network trace is a collection of measured information about a network request.
@@ -708,8 +758,8 @@ Countly.recordView("Profile Page"); - endTime: UNIX time stamp in milliseconds for the ending time of the request

-
Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
-

Getting user feedback

+
Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
+

Getting user feedback

There are two ways of getting feedback from your users: Star rating dialog, feedback widget. @@ -718,12 +768,12 @@ Countly.recordView("Profile Page"); Star rating dialog allows users to give feedback as a rating from 1 to 5. The feedback widget allows to get the same 1 to 5 rating and also a text comment.

-

Feedback widget

+

Feedback widget

- Feedback widget shows a server configured widget to your user devices. + Feedback widget shows a server configured widget to your user devices.

- 072bb00-t1.png + 072bb00-t1.png

It's possible to configure any of the shown text fields and replace with a custom @@ -744,13 +794,14 @@ Countly.recordView("Profile Page"); you first have to get the widget ID from your server:

- 2dd58c6-t2.png + 2dd58c6-t2.png

-

- Using that you can call the function to show the widget popup: +

+ Using that you can call the function to show the widget popup:

-
// Feedback Modal
countly.askForFeedback("5e425407975d006a22535fc", "close");
-

Star rating dialog

+
// Feedback Modal
+countly.askForFeedback("5e425407975d006a22535fc", "close");
+

Star rating dialog

Star rating integration provides a dialog for getting user's feedback about the application. It contains a title, simple message explaining what it is for, a @@ -765,16 +816,17 @@ Countly.recordView("Profile Page");

Star-rating dialog's title, message and dismiss button text can be customized - either through the init function or the SetStarRatingDialogTexts function. + either through the init function or the SetStarRatingDialogTexts function. If you don't want to override one of those values, set it to "null".

-
// Star Rating 
countly.askForStarRating(Function(ratingResult){
console.log(ratingResult);
});
+
// Star Rating 
+countly.askForStarRating(Function(ratingResult){
+    console.log(ratingResult);
+});
-
- -
+
-

Push notifications

+

Push notifications

Countly uses PhoneGap push notifications plugin. Here is the link @@ -783,73 +835,84 @@ Countly.recordView("Profile Page");

Here are the steps to make push notifications work:

    -
  1. +
  2. Go to https://firebase.google.com
  3. -
  4. +
  5. Register / Login to the Firebase console. You should be logged in to https://console.firebase.google.com.
  6. -
  7. Create and select a project if you haven't done before.
  8. -
  9. Go to Settings > Project settings.
  10. -
  11. Create an app for Android and iOS.
  12. -
  13. +
  14. Create and select a project if you haven't done before.
  15. +
  16. Go to Settings > Project settings.
  17. +
  18. Create an app for Android and iOS.
  19. +
  20. Download the google-services.json for Android and GoogleService-Info.plist for iOS.
  21. -
  22. +
  23. Place both files under your root project folder. i.e. above www folder.
  24. -
  25. - Put these tags in config.xml file for Android and iOS: +
  26. +

    Put these tags in config.xml file for Android and iOS:

    For Android for iOS
    -
    <platform name="android">
    +        
    <platform name="android">
        <resource-file src="google-services.json" target="app/google-services.json" />
     </platform>
  27. -
  28. - Install the push notifications plugin. -
    cordova plugin add phonegap-plugin-push
    +
  29. +

    Install the push notifications plugin.

    +
    cordova plugin add phonegap-plugin-push
  30. -
  31. Build your app, and test push notifications.
  32. +
  33. Build your app, and test push notifications.

- Limitations of Cordova + Limitations of Cordova

Due to limitations of the way push is handled in a Cordova application, it's not possible to report back actions done when a push notification is received.

-

Push Method Implementation

+

Push Method Implementation

- First, when setting up push for the Cordova SDK, you would first select the push token mode. This would allow you to choose either test or production modes, push + First, when setting up push for the Cordova SDK, you would first select the push + token mode. This would allow you to choose either test or production modes, push token mode should be set before init.

-
// Important call this method before init method
Countly.pushTokenType(Countly.messagingMode.DEVELOPMENT, "Channel Name", "Channel Description");
// Countly.messagingMode.DEVELOPMENT
// Countly.messagingMode.PRODUCTION
// Countly.messagingMode.ADHOC
+
// Important call this method before init method
+Countly.pushTokenType(Countly.messagingMode.DEVELOPMENT, "Channel Name", "Channel Description");
+// Countly.messagingMode.DEVELOPMENT
+// Countly.messagingMode.PRODUCTION
+// Countly.messagingMode.ADHOC

- When you are finally ready to initialize Countly push, you would call Countly.askForNotificationPermission(), this function should be call after init. + When you are finally ready to initialize Countly push, you would call Countly.askForNotificationPermission(), + this function should be call after init.

-
// Call this method any time.
Countly.askForNotificationPermission();
// This method will ask for permission,
// and send push token to countly server.
+
// Call this method any time.
+Countly.askForNotificationPermission();
+// This method will ask for permission, 
+// and send push token to countly server.

Cordova code to receive notification data. Call anywhere or event before init.

-
Countly.registerForNotification(function(theNotification){
console.log(JSON.stringify(theNotification));
});
-

Rich Push Notification

+
Countly.registerForNotification(function(theNotification){
+console.log(JSON.stringify(theNotification));
+});
+

Rich Push Notification

For Android, there is no special procedure required, you can install the community plugin, and it should work. @@ -858,14 +921,16 @@ Countly.recordView("Profile Page"); For iOS, you will need to follow these instruction: https://resources.count.ly/docs/countly-sdk-for-ios-and-os-x#section-rich-push-notifications-ios10-only-

-

Removing Plugin

-
cordova plugin remove countly-sdk-js
cordova platform remove android
cordova platform remove ios
-

Troubleshooting

+

Removing Plugin

+
cordova plugin remove countly-sdk-js
+cordova platform remove android 
+cordova platform remove ios
+

Troubleshooting

If you get the following error during implementation (for versions before v1.0 SDK):

-
NSPersistentStoreCoordinator with a nil model
+
NSPersistentStoreCoordinator with a nil model

In this case, go to https://github.com/Countly/countly-sdk-cordova/tree/master/src/ios/sdk. @@ -874,7 +939,7 @@ Countly.recordView("Profile Page");

- Warning about Java + Warning about Java

Note: As per the new release v1.0 you will need Java 1.8 to bundle the application. @@ -885,7 +950,7 @@ Countly.recordView("Profile Page");

If you would like to set logging, use code snippet below in your code.

-
// example for setLoggingEnabled
+
// example for setLoggingEnabled
 //Countly.setLoggingEnabled();
 

@@ -900,13 +965,13 @@ Countly.recordView("Profile Page");

The optional parameters are:

    -
  • Country code: ISO Country code for the user's country
  • -
  • City: Name of the user's city
  • -
  • +
  • Country code: ISO Country code for the user's country
  • +
  • City: Name of the user's city
  • +
  • Location: Comma separate latitude and longitude values, for example "56.42345,123.45325"
-

+

 //setting optional parameters
 Countly.setOptionalParametersForInitialization({
     city: "Tampa",
diff --git a/legacy_docs/cordova/20.11.md b/legacy_docs/cordova/20.11.md
index f8cac047..bb8c1d59 100644
--- a/legacy_docs/cordova/20.11.md
+++ b/legacy_docs/cordova/20.11.md
@@ -21,15 +21,15 @@
   Github repo.
   It should show how most of the functionalities can be used.
 

-

Adding the SDK to the project

+

Adding the SDK to the project

The core of this SDK is developed around Cordova. We have a minimum version requirement for it's core and android, ios modules that have to be satisfied:

    -
  • cordova >= 9.0.0
  • -
  • cordova-android >= 8.0.0
  • -
  • cordova-ios >= 5.0.0
  • +
  • cordova >= 9.0.0
  • +
  • cordova-android >= 8.0.0
  • +
  • cordova-ios >= 5.0.0

If you would integrate this SDK in any other project similar to cordova (like @@ -37,9 +37,8 @@ platform requirements for those projects similar to these.

- Note : Development on PhoneGap stopped in - 14 Aug 2020. To the best of our knowledge, this SDK should still - be compatible with the final release. + Note : Development on PhoneGap stopped in 14 Aug 2020. To the + best of our knowledge, this SDK should still be compatible with the final release.

For more information about PhoneGap shut down, @@ -57,88 +56,86 @@ Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

-
cd PATH_TO_YOUR_PROJECT
+
cd PATH_TO_YOUR_PROJECT
 
 cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
 
 # OR
 
 cordova plugin add countly-sdk-js@20.11.0
-

If iOS/Android Platform are already added in your project, first remove them

-
cordova platform remove android
+
cordova platform remove android
 cordova platform remove ios

Now add platform of your choice

-
cordova platform add android
+
cordova platform add android
 cordova platform add ios

It's important that you make sure you build it with Cordova, as Cordova links folders very well.

-
cordova build android
+
cordova build android
 ordova build ios

Now run the application directly for Android,

-
cordova run android
+
cordova run android

Or iOS:

-
cordova run ios
+
cordova run ios

Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

- Ionic + Ionic

Add Countly SDK in your Ionic project using following commands:
Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

-
cd PATH_TO_YOUR_PROJECT
+
cd PATH_TO_YOUR_PROJECT
 
 ionic cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
 
 # OR
 
 ionic cordova plugin add countly-sdk-js@20.11.0
-

If iOS/Android Platform are already added in your project, first remove them

-
ionic cordova platform remove android
+
ionic cordova platform remove android
 ionic cordova platform remove ios

Now add platform of your choice

-
ionic cordova platform add android
+
ionic cordova platform add android
 ionic cordova platform add ios

Now prepare the platforms you have added

-
ionic cordova prepare android
+
ionic cordova prepare android
 ionic cordova prepare ios

It's important that you make sure you build it with Cordova, as Cordova links folders very well.

-
ionic cordova build android
+
ionic cordova build android
 ionic cordova build ios

Now run the application directly for Android,

-
ionic cordova run android
+
ionic cordova run android

Or iOS:

-
ionic cordova run ios
+
ionic cordova run ios

Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

In your index.html, use the following lines:

-
<script type="text/javascript" src="cordova.js"></script>
+
<script type="text/javascript" src="cordova.js"></script>
 <script type="text/javascript" src="Countly.js"></script>
-

SDK Integration

-

Minimal setup

+

SDK Integration

+

Minimal setup

Below you can find necessary code snippets to initialize the SDK for sending data to Countly servers. Where possible, use your server URL instead of try.count.ly in case you have your own server.

-
// initialize
+
// initialize
 Countly.isInitialized().then((result) => {
             if(result  != "true") {
                 Countly.init("https://try.count.ly", "YOUR_API_KEY").then((result) => {
@@ -150,13 +147,12 @@ Countly.isInitialized().then((result) => {
         },(err) => {
             console.error(err);
         });
-

For more information on how to acquire your application key (appKey) and server URL, check here.

-

Enable logging

+

Enable logging

If logging is enabled then our sdk will print out debug messages about it's internal state and encountered problems. @@ -164,9 +160,9 @@ Countly.isInitialized().then((result) => {

When advise doing this while implementing countly features in your application.

-
// example for setLoggingEnabled
+
// example for setLoggingEnabled
 Countly.setLoggingEnabled();
-

Device ID

+

Device ID

When the SDK is initialized for the first time and no device ID is provided, a device ID will be generated by SDK. @@ -178,21 +174,21 @@ Countly.setLoggingEnabled();

You may provide your own custom device ID when initializing the SDK

-
Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
-

SDK data storage

+
Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
+

SDK data storage

For iOS: SDK data is stored in Application Support Directory in file named "Countly.dat" For Android: SDK data is stored in SharedPreferences. A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them.

-

Crash reporting

+

Crash reporting

The Countly SDK has the ability to collect crash reports, which you may examine and resolve later on the server.

-

Automatic crash handling

+

Automatic crash handling

With this feature, the Countly SDK will generate a crash report if your application crashes due to an exception and send it to the Countly server for further inspection. @@ -206,16 +202,17 @@ Countly.setLoggingEnabled();

You will need to call the following method before calling init in order to activate automatic crash reporting.

-

- - -

-
// Using countly crash reports
+  

+ +
// Using countly crash reports
 Countly.enableCrashReporting();
 
-

Handled exceptions

+

Handled exceptions

You might catch an exception or similar error during your app’s runtime.

@@ -226,7 +223,7 @@ Countly.enableCrashReporting();

You can also send a custom crash log to Countly using code below.

-
// Send Exception to the server
+
// Send Exception to the server
 Countly.logException(["My Customized error message"], true, {"_facebook_version": "0.0.1"});
 Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments);

@@ -242,7 +239,7 @@ Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments); 1. Manually report handled exception

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -256,11 +253,10 @@ Countly.logException("ERROR_STRING", true);
 
 // With array of strings
 Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true);
-

2. Manually report handled exception with segmentation

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -274,11 +270,10 @@ Countly.logException("ERROR_STRING", true, {"\_facebook_version": "0.0.1"});
 
 // With array of strings
 Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true, {"\_facebook_version": "0.0.1"});
-

3. Manually report fatal exception

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -292,11 +287,10 @@ Countly.logException("ERROR_STRING", false);
 
 // With array of strings
 Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false);
-

4. Manually report fatal exception with segmentation

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -310,18 +304,17 @@ Countly.logException("ERROR_STRING", false, {"\_facebook_version": "0.0.1"});
 
 // With array of strings
 Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false, {"\_facebook_version": "0.0.1"});
- -

Crash breadcrumbs

+

Crash breadcrumbs

Throughout your app you can leave crash breadcrumbs which would describe previous steps that were taken in your app before the crash. After a crash happens, they will be sent together with the crash report.

Following the command adds crash breadcrumb:

-
// Add crash breadcrumb
+
// Add crash breadcrumb
 Countly.addCrashLog("My crash log from JavaScript");
 
-

Events

+

Events

An Event is any type of action that you can send to a Countly instance, e.g purchase, settings changed, @@ -332,21 +325,21 @@ Countly.addCrashLog("My crash log from JavaScript"); Here are the detail about properties which we can use with event:

    -
  • +
  • key identifies the event
  • -
  • +
  • count is the number of times this event occurred
  • -
  • +
  • sum is an overall numerical data set tied to an event. For example, total amount of in-app purchase event.
  • -
  • +
  • duration is used to record and track the duration of events.
  • -
  • +
  • segmentation is a key-value pairs, we can use segmentation to track additional information. The only valid data types are: "String", "Integer", "Double" and "Boolean". All other types @@ -355,35 +348,35 @@ Countly.addCrashLog("My crash log from JavaScript");

- Data passed should be in UTF-8 + Data passed should be in UTF-8

All data passed to Countly server via SDK or API should be in UTF-8.

-

Recording events

+

Recording events

We will be recording a purchase event. Here is a quick summary of what information each usage will provide us:

    -
  • +
  • Usage 1: how many times purchase event occurred.
  • -
  • +
  • Usage 2: how many times purchase event occurred + the total amount of those purchases.
  • -
  • +
  • Usage 3: how many times purchase event occurred + which countries and application versions those purchases were made from.
  • -
  • +
  • Usage 4: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions.
  • -
  • +
  • Usage 5: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions + the total duration of those events. @@ -392,33 +385,33 @@ Countly.addCrashLog("My crash log from JavaScript");

    1. Event key and count

    -
    // example for sending basic event
    +
    // example for sending basic event
     var events = {"key":"Basic Event","count":1};
     Countly.recordEvent(events);

    2. Event key, count and sum

    -
    // example for event with sum
    +
    // example for event with sum
     var events = {"key":"Event With Sum","count":1,"sum":"0.99"};
     Countly.recordEvent(events);

    3. Event key and count with segmentation(s)

    -
    // example for event with segment
    +
    // example for event with segment
     var events = {"key":"Event With Segment","count":1};
     events.segments = {"Country" : "Turkey", "Age" : "28"};
     Countly.recordEvent(events);

    4. Event key, count and sum with segmentation(s)

    -
    // example for event with segment and sum
    +
    // example for event with segment and sum
     var events = {"key":"Event With Segment And Sum","count":1,"sum":"0.99"};
     events.segments = {"Country" : "Turkey", "Age" : "28"};
     Countly.recordEvent(events);

    5. Event key, count, sum and duration with segmentation(s)

    -
    var events = {
    +
    var events = {
       "key": "Event With Sum And Segment duration",
       "count": 1,
       "Sum": "0.99",
    @@ -434,11 +427,11 @@ Countly.recordEvent(events);
    those examples and use country, app_version, game_level, time_of_day and any other segmentation that will provide you valuable insights.

    -

    Timed events

    +

    Timed events

    It's possible to create timed events by defining a start and stop moment.

    -
    // Time Event
    +
    // Time Event
     Countly.startEvent("Timed Event");
     setTimeout(function() {
         Countly.endEvent({ "key": "Timed Event");
    @@ -449,13 +442,12 @@ Countly.startEvent("Timed Event With Sum");
     setTimeout(function() {
     countly.endEvent({"key": "Timed Event With Sum", "sum": "0.99"});
     }, 1000);
    -

    When ending an event you can also provide additional information. But in that case, you have to provide segmentation, count and sum. The default values for those are "null", 1 and 0.

    -
    
    +
    
     // Time Event with segment
     Countly.startEvent("Timed Event With Segment");
     setTimeout(function() {
    @@ -483,29 +475,28 @@ events.segments = {
     };
     Countly.endEvent(events);
     }, 1000);
    - -

    Sessions

    -

    Automatic session tracking

    +

    Sessions

    +

    Automatic session tracking

    To start recording an automatic session tracking you would call:

    -
    Countly.start();
    +
    Countly.start();

    Countly.start(); will handle the start session, update session and end session automatically.
    This is how it works:

      -
    • +
    • Start/Begin session Request: It is sent on Countly.start(); call and when the app comes back to the foreground from the background, and it includes basic metrics.
    • -
    • +
    • Update Session Request: It automatically sends a periodical (60 sec by default) update session request while the app is in the foreground.
    • -
    • +
    • End Session Request: It is sent at the end of a session when the app goes to the background or terminates.
    • @@ -513,15 +504,15 @@ Countly.endEvent(events);

      If you want to end automatic session tracking you would call:

      -
      Countly.stop();
      -

      View tracking

      +
      Countly.stop();
      +

      View tracking

      You may track custom views with the following code snippet:

      -
      Countly.recordView("View Name")
      +
      Countly.recordView("View Name")

      While manually tracking views, you may add your custom segmentation to them like this:

      -
      var viewSegmentation = { "Country": "Germany", "Age": "28" };
      +
      var viewSegmentation = { "Country": "Germany", "Age": "28" };
       Countly.recordView("View Name", viewSegmentation);

      To review the resulting data, open the dashboard and go to @@ -532,7 +523,7 @@ Countly.recordView("View Name", viewSegmentation);

      -

      Device ID management

      +

      Device ID management

      A device ID is a unique identifier for your users. You may specify the device ID yourself or allow the SDK to generate it. When providing one yourself, keep @@ -540,7 +531,7 @@ Countly.recordView("View Name", viewSegmentation);

    an id could be the username, email or some other internal ID used by your other systems.

    -

    Device ID generation

    +

    Device ID generation

    When the SDK is initialized for the first time with no device ID, then SDK will generate a device ID. @@ -552,9 +543,9 @@ Countly.recordView("View Name", viewSegmentation);

    For iOS: the device ID generated by SDK is the Identifier For Vendor (IDFV)
    For Android: the device ID generated by SDK is the OpenUDID

    -

    Changing the Device ID

    +

    Changing the Device ID

    You may configure/change the device ID anytime using:

    -
    Countly.changeDeviceId(DEVICE_ID, ON_SERVER);
    +
    Countly.changeDeviceId(DEVICE_ID, ON_SERVER);

    You may either allow the device to be counted as a new device or merge existing data on the server. If theonServer bool is set to @@ -563,7 +554,7 @@ Countly.recordView("View Name", viewSegmentation);

    Otherwise, if onServer bool is set to false, the device will be counted as a new device on the server.

    -

    Temporary Device ID

    +

    Temporary Device ID

    You may use a temporary device ID mode for keeping all requests on hold until the real device ID is set later. @@ -571,9 +562,9 @@ Countly.recordView("View Name", viewSegmentation);

    You can enable temporary device ID when initializing the SDK:

    -
    Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")
    +
    Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")

    To enable a temporary device ID after init, you would call:

    -
    Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);
    +
    Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);

    Note: When passing TemporaryDeviceID for deviceID parameter, argument for onServerparameter @@ -594,75 +585,79 @@ Countly.recordView("View Name", viewSegmentation);

    which have been kept on hold until that point will start with the real device ID

    -

    Retrieving current device ID

    +

    Retrieving current device ID

    You may want to see what device id Countly is assigning for the specific device. For that you may use the following call:

    -
    // get device id
    +
    // get device id
     Countly.getCurrentDeviceId(function(deviceId){
       console.log(deviceId);
     }, function(getDeviceIDError){
       console.log(getDeviceIDError);
     });
    -

    Push notifications

    -

    Integration

    -

    Android setup

    +

    Push notifications

    +

    Integration

    +

    Android setup

    Here are the steps to make push notifications work on Android:

      -
    1. +
    2. For FCM credentials setup please follow the instruction from this URL https://support.count.ly/hc/en-us/articles/360037754031-Android#getting-fcm-credentials.
    3. -
    4. +
    5. Make sure you have google-services.json from https://firebase.google.com/
    6. -
    7. +
    8. Make sure the app package name and the google-services.json package_name matches.
    9. -
    10. +
    11. Place this google-services.json file under your root project folder. i.e. above www folder.
    12. -
    13. - Put these tags in config.xml file for Android: +
    14. +

      Put these tags in config.xml file for Android:

      -
      <platform name="android">
      +        
      <platform name="android">
          <resource-file src="google-services.json" target="app/google-services.json" />
       </platform>
    15. -
    16. - Put these tags in config.xml file if you are using cordova-android 9.x or - greater: +
    17. +

      + Put these tags in config.xml file if you are using cordova-android 9.x + or greater: +

      -
      <preference name="GradlePluginGoogleServicesEnabled" value="true" />
      +        
      <preference name="GradlePluginGoogleServicesEnabled" value="true" />
       <preference name="GradlePluginGoogleServicesVersion" value="4.2.0" />
    18. -
    19. - Install the google services plugin if you use cordova-android below version - 9 -
      cordova plugin add cordova-support-google-services --save
      +
    20. +

      + Install the google services plugin if you use cordova-android below version + 9 +

      +
      cordova plugin add cordova-support-google-services --save
    21. -
    22. Build your app, and test push notifications.
    23. +
    24. Build your app, and test push notifications.
    -

    iOS setup

    +

    iOS setup

    - By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode. + By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode.

    - Minimum Countly SDK Version + Minimum Countly SDK Version

    This COUNTLY_EXCLUDE_PUSHNOTIFICATIONS is only supported by the minimum SDK @@ -673,25 +668,25 @@ Countly.getCurrentDeviceId(function(deviceId){ There are no additional steps required for iOS,everything is set up for you by the Countly Cordova SDK.

    -

    Enabling push

    +

    Enabling push

    First, when setting up push for the Cordova SDK, you would first select the push token mode. This would allow you to choose either test or production modes, push token mode should be set before init.

    -
    // Set messaging mode for push notifications
    +
    // Set messaging mode for push notifications
     Countly.pushTokenType(Countly.messagingMode.DEVELOPMENT, "Channel Name", "Channel Description");

    When you are finally ready to initialise Countly push, you would call this:

    -
    // This method will ask for permission, enables push notification and send push token to countly server.
    +
    // This method will ask for permission, enables push notification and send push token to countly server.
     Countly.askForNotificationPermission();
    -

    Handling push callbacks

    +

    Handling push callbacks

    To register a Push Notification callback after initializing the SDK, use the method below.

    -
    Countly.registerForNotification(function(theNotification){
    +
    Countly.registerForNotification(function(theNotification){
       console.log(JSON.stringify(theNotification));
     });

    @@ -699,12 +694,13 @@ Countly.askForNotificationPermission();

    code in AppDelegate.m

    Add header files

    -
    #import "CountlyNative.h"
    #import <UserNotifications/UserNotifications.h> +
    #import "CountlyNative.h"
    +#import <UserNotifications/UserNotifications.h>
     

    Before @end add these methods

    -
    // Required for the notification event. You must call the completion handler after handling the remote notification.
    +
    // Required for the notification event. You must call the completion handler after handling the remote notification.
     - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
     {
         [CountlyNative onNotification: userInfo];
    @@ -725,7 +721,7 @@ Countly.askForNotificationPermission();
    [CountlyNative onNotification: notification.request.content.userInfo]; completionHandler(0); }
    -

    User location

    +

    User location

    While integrating this SDK into your application, you might want to track your user location. You could use this information to better know your apps user base @@ -733,14 +729,14 @@ completionHandler(0); are 4 fields that can be provided:

      -
    • country code in the 2 letter iso standard
    • -
    • city name (has to be set together with country code)
    • -
    • +
    • country code in the 2 letter iso standard
    • +
    • city name (has to be set together with country code)
    • +
    • Comma separate latitude and longitude values, for example "56.42345,123.45325"
    • -
    • ip address of your user
    • +
    • ip address of your user
    -
    // send user location
    +
    // send user location
     Countly.setLocation("28.006324", "-82.7166183");

    When those values are set, they will be sent every time when initiating a session. @@ -755,13 +751,13 @@ Countly.setLocation("28.006324", "-82.7166183");

    It will erase cached location data from the device and the server.

    -

    Remote Config

    +

    Remote Config

    Remote config allows you to modiffy how your app functions or looks by requesting key-value pairs from your Countly server. The returned values can be modiffied based on the user profile. For more details please see Remote Config documentation.

    -

    Automatic remote config

    +

    Automatic remote config

    There are two ways of acquiring remote config data, by automatic download or manual request. By default, automatic remote config is disabled and therefore @@ -777,7 +773,7 @@ Countly.setLocation("28.006324", "-82.7166183");

    Note: call setRemoteConfigAutomaticDownload method before init

    -
    // Call this method before init
    +
    // Call this method before init
     Countly.setRemoteConfigAutomaticDownload(function(r){
       alert(r)
     }, function(r){
    @@ -794,14 +790,14 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       instead). It is possible that a previously valid key returns no value after an
       update.
     

    -

    Manual remote config

    +

    Manual remote config

    There are three ways for manually requesting a Remote Config update:

      -
    • Manually updating everything
    • -
    • Manually updating specific keys
    • -
    • Manually updating everything except specific keys
    • +
    • Manually updating everything
    • +
    • Manually updating specific keys
    • +
    • Manually updating everything except specific keys

    Each of these requests also has a callback. If that returns a non-null value, @@ -814,7 +810,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ The advantage is that you can make the request whenever it is desirable for you. It has a callback to let you know when it has finished.

    -
    Countly.remoteConfigUpdate(function(r){
    +
    Countly.remoteConfigUpdate(function(r){
       alert(r)
     }, function(r){
       alert(r);
    @@ -825,7 +821,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       updated. That list is an array with string values of those keys. It has a callback
       to let you know when the request has finished.
     

    -
    Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
    +
    Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
       alert(r)
     }, function(r){
       alert(r);
    @@ -835,7 +831,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       updateRemoteConfigExceptKeys. The key list is a array with string values of the
       keys. It has a callback to let you know when the request has finished.
     

    -
    Countly.updateRemoteConfigExceptKeys(["url"], function(r){
    +
    Countly.updateRemoteConfigExceptKeys(["url"], function(r){
       alert(r)
     }, function(r){
       alert(r);
    @@ -846,7 +842,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       will update all values. This means that it will also erase all keys not returned
       by the server.
     

    -

    Getting Remote Config values

    +

    Getting Remote Config values

    To request a stored value, call getRemoteConfigValueForKey with the specified key. If it returns null then no value was found. The SDK has no @@ -854,22 +850,22 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ needs to cast it to the appropriate type. The returned values can also be a JSONArray, JSONObject or just a simple value like int.

    -
    Countly.getRemoteConfigValueForKey("name", function(r){
    +
    Countly.getRemoteConfigValueForKey("name", function(r){
        alert(r)
      }, function(r){
        alert(r);
      });
    -

    Clearing stored values

    +

    Clearing stored values

    At some point you might want to erase all values downloaded from the server. To achieve that you need to call one function, depicted below:

    -
    Countly.remoteConfigClearValues(function(r){
    +
    Countly.remoteConfigClearValues(function(r){
       alert(r)
     }, function(r){
       alert(r);
     });
    -

    User feedback

    +

    User feedback

    There are two ways of getting feedback from your users: Star rating dialog, feedback widget. @@ -878,7 +874,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ Star rating dialog allows users to give feedback as a rating from 1 to 5. The feedback widget allows to get the same 1 to 5 rating and also a text comment.

    -

    Star rating dialog

    +

    Star rating dialog

    Star rating integration provides a dialog for getting user's feedback about the application. It contains a title, simple message explaining what it is for, a @@ -896,17 +892,17 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ either through the init function or the SetStarRatingDialogTexts function. If you don't want to override one of those values, set it to "null".

    -
    // Star Rating
    +
    // Star Rating
     countly.askForStarRating(Function(ratingResult){
       console.log(ratingResult);
     });
    -

    Rating widget

    +

    Rating widget

    Feedback widget shows a server configured widget to your user devices.

    - 072bb00-t1.png + 072bb00-t1.png

    It's possible to configure any of the shown text fields and replace with a custom @@ -927,14 +923,14 @@ countly.askForStarRating(Function(ratingResult){ you first have to get the widget ID from your server:

    - 2dd58c6-t2.png + 2dd58c6-t2.png

    Using that you can call the function to show the widget popup:

    -
    // Feedback Modal
    +
    // Feedback Modal
     countly.askForFeedback("5e425407975d006a22535fc", "close");
    -

    User Profiles

    +

    User Profiles

    Available with Enterprise Edition, User Profiles is a tool which helps you identify users, their devices, event timeline and application crash information. User @@ -953,7 +949,7 @@ countly.askForFeedback("5e425407975d006a22535fc", "close");

    After you have provided user profile information, you must save it by calling Countly.userData.save().

    -
    / example for setting user data
    +
    / example for setting user data
     var options = {};
     options.name = "Nicola Tesla";
     options.username = "nicola";
    @@ -966,55 +962,59 @@ options.gender = "Male";
     options.byear = 1919;
     Countly.setUserData(options);

    The keys for predefined user data fields are as follows:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    KeyTypeDescription
    nameStringUser's full name
    usernameStringUser's nickname
    emailStringUser's email address
    organizationStringUser's organisation name
    phoneStringUser's phone number
    pictureStringURL to avatar or profile picture of the user
    genderStringUser's gender as M for male and F for female
    byearStringUser's year of birth as integer
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyTypeDescription
    nameStringUser's full name
    usernameStringUser's nickname
    emailStringUser's email address
    organizationStringUser's organisation name
    phoneStringUser's phone number
    pictureStringURL to avatar or profile picture of the user
    genderStringUser's gender as M for male and F for female
    byearStringUser's year of birth as integer
    +

    Using "" for strings or a negative number for 'byear' will effectively delete that property. @@ -1024,13 +1024,13 @@ Countly.setUserData(options);

    on your Countly backend. Note: keys with . or $ symbols will have those symbols removed.

    -

    Setting custom values

    +

    Setting custom values

    Additionally you can do different manipulations on your custom data values, like increment current value on server or store a array of values under the same property.

    Below is the list of available methods:

    -
    // example for extra user features
    +
    // example for extra user features
     
     Countly.userData.setProperty("setProperty", "My Property");
     Countly.userData.increment("increment");
    @@ -1042,14 +1042,13 @@ Countly.userData.setOnce("setOnce", 200);
     Countly.userData.pushUniqueValue("pushUniqueValue","morning");
     Countly.userData.pushValue("pushValue", "morning");
     Countly.userData.pullValue("pullValue", "morning");
    -

    In the end always call Countly.userData.save() to send them to the server.

    -

    Application Performance Monitoring

    +

    Application Performance Monitoring

    - Minimum Countly SDK Version + Minimum Countly SDK Version

    This feature is only supported by the minimum SDK version 20.4.0. @@ -1064,20 +1063,20 @@ Countly.userData.pullValue("pullValue", "morning");

    Here is how you can utilize Performance Monitoring feature in your apps:

    First, you need to enable Performance Monitoring feature::

    -
    Countly.enableApm(); 
    +
    Countly.enableApm(); 
     // Enable APM features.

    With this, Countly SDK will start measuring some performance traces automatically. Those include app foreground time, app background time. Additionally, custom traces and network traces can be manually recorded.

    -

    App Start Time

    +

    App Start Time

    For the app start time to be recorded, you need to call the appLoadingFinished method. Make sure this method is called after init.

    -
    // Example of appLoadingFinished
    +
    // Example of appLoadingFinished
     Countly.init("https://try.count.ly", "YOUR_API_KEY").then((result) => {
       Countly.appLoadingFinished();
     },(err) => {
    @@ -1092,19 +1091,19 @@ Countly.init("https://try.count.ly", "YOUR_API_KEY").then((result) => {
       the app launch time can be recorded only once per app launch. So, the second
       and following calls to this method will be ignored.
     

    -

    Custom traces

    +

    Custom traces

    You may also measure any operation you want and record it using custom traces. First, you need to start a trace by using the startTrace(traceKey) method:

    -
    Countly.startTrace(traceKey);
    +
    Countly.startTrace(traceKey);

    Then you may end it using the endTrace(traceKey, customMetric)method, optionally passing any metrics as key-value pairs:

    -
    String traceKey = "Trace Key"
    +
    String traceKey = "Trace Key"
     ;
     Map<String, int> customMetric = {
       "ABC": 1233,
    @@ -1121,13 +1120,13 @@ Countly.endTrace(traceKey, customMetric);
    You may also cancel any custom trace you started, using cancelTrace(traceKey)method:

    -
    Countly.cancelTrace(traceKey);
    +
    Countly.cancelTrace(traceKey);

    Additionally, if you need you may cancel all custom traces you started, using clearAllTraces()method:

    -
    Countly.clearAllTraces(traceKey);
    -

    Network traces

    +
    Countly.clearAllTraces(traceKey);
    +

    Network traces

    You may record manual network traces using theecordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime) method. @@ -1147,9 +1146,9 @@ Countly.endTrace(traceKey, customMetric);

    time of the request - endTime: UNIX time stamp in milliseconds for the ending time of the request

    -
    Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
    +
    Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
    -

    User Consent

    +

    User Consent

    To be compliant with GDPR, starting from 18.04, Countly provides ways to toggle different Countly features on/off depending on the given consent. @@ -1159,7 +1158,7 @@ Countly.endTrace(traceKey, customMetric);

    By default the requirement for consent is disabled. To enable it, you have to call setRequiresConsent with true, before initializing Countly.

    -
    Countly.setRequiresConsent(true);
    +
    Countly.setRequiresConsent(true);

    By default no consent is given. That means that if no consent is enabled, Countly will not work and no network requests, related to features, will be sent. When @@ -1186,78 +1185,75 @@ Countly.endTrace(traceKey, customMetric);

    The current features are:

      -
    • +
    • sessions - tracking when, how often and how long users use your app
    • -
    • events - allow sending events to server
    • -
    • views - allow tracking which views user visits
    • -
    • location - allow sending location information
    • -
    • crashes - allow tracking crashes, exceptions and errors
    • -
    • +
    • events - allow sending events to server
    • +
    • views - allow tracking which views user visits
    • +
    • location - allow sending location information
    • +
    • crashes - allow tracking crashes, exceptions and errors
    • +
    • attribution - allow tracking from which campaign did user come
    • -
    • +
    • users - allow collecting/providing user information, including custom properties
    • -
    • push - allow push notifications
    • -
    • starRating - allow to send their rating and feedback
    • -
    • apm - allow application performance monitoring
    • -
    • +
    • push - allow push notifications
    • +
    • starRating - allow to send their rating and feedback
    • +
    • apm - allow application performance monitoring
    • +
    • remote-config - allows downloading remote config values from your server
    -

    Changing consent

    +

    Changing consent

    There are 3 ways of changing feature consent:

      -
    • +
    • giveConsentInit - To add consent for a single feature (string parameter) or a subset of features (array of strings parameter). Use this method for giving consent before initializing.
    -
    //giveConsent
    +
    //giveConsent
     Countly.giveConsentInit(["events", "views", "star-rating", "crashes"]);
     
     // removeConsent
     Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
    -
      -
    • +
    • giveConsent/removeConsent - gives or removes consent to a specific feature
    -
    //giveConsent
    +
    //giveConsent
     Countly.giveConsent(["events", "views", "star-rating", "crashes"]);
     
     // removeConsent
     Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
    -
      -
    • +
    • giveAllConsent/removeAllConsent - giveAll or removeAll consent to a specific feature
    -
    //giveAllConsent
    +
    //giveAllConsent
     Countly.giveAllConsent();
     
     //removeAllConsent
     Countly.removeAllConsent();
     
    -
    -

    Security and privacy

    -

    Parameter Tampering Protection

    +

    Security and privacy

    +

    Parameter Tampering Protection

    You can set optional salt to be used for calculating checksum of request data, which will be sent with each request using &checksum field. You need to set exactly the same salt on Countly server. If salt on Countly server is set, all requests would be checked for validity of &checksum field before being processed.

    -
    // sending data with salt
    +
    // sending data with salt
     Countly.enableParameterTamperingProtection("salt");
    -

    Other features

    -

    Forcing HTTP POST

    +

    Other features

    +

    Forcing HTTP POST

    If the data sent to the server is short enough, the sdk will use HTTP GET requests. In case you want an override so that HTTP POST is used in all cases, call the @@ -1265,9 +1261,9 @@ Countly.enableParameterTamperingProtection("salt");

    to later in the apps life cycle disable the override. This function has to be called every time the app starts.

    -
    Countly.setHttpPostForced(true); // default is false
    +
    Countly.setHttpPostForced(true); // default is false
     
    -

    Optional parameters during initialization

    +

    Optional parameters during initialization

    You can provide optional parameters that will be used during begin_session request. They must be set right after the init function so that they are @@ -1279,13 +1275,13 @@ Countly.enableParameterTamperingProtection("salt");

    The optional parameters are:

      -
    • Country code: ISO Country code for the user's country
    • -
    • City: Name of the user's city
    • -
    • +
    • Country code: ISO Country code for the user's country
    • +
    • City: Name of the user's city
    • +
    • Location: Comma separate latitude and longitude values, for example "56.42345,123.45325"
    -
    
    +
    
     //setting optional parameters
     Countly.setOptionalParametersForInitialization({
         city: "Tampa",
    diff --git a/legacy_docs/cordova/21.11.md b/legacy_docs/cordova/21.11.md
    index 8d29d6b5..492938ef 100644
    --- a/legacy_docs/cordova/21.11.md
    +++ b/legacy_docs/cordova/21.11.md
    @@ -19,15 +19,15 @@
       Github repo.
       It should show how most of the functionalities can be used.
     

    -

    Adding the SDK to the project

    +

    Adding the SDK to the project

    The core of this SDK is developed around Cordova. We have a minimum version requirement for it's core and android, ios modules that have to be satisfied:

      -
    • cordova >= 9.0.0
    • -
    • cordova-android >= 8.0.0
    • -
    • cordova-ios >= 5.0.0
    • +
    • cordova >= 9.0.0
    • +
    • cordova-android >= 8.0.0
    • +
    • cordova-ios >= 5.0.0

    If you would integrate this SDK in any other project similar to cordova (like @@ -35,9 +35,8 @@ platform requirements for those projects similar to these.

    - Note : Development on PhoneGap stopped in - 14 Aug 2020. To the best of our knowledge, this SDK should still - be compatible with the final release. + Note : Development on PhoneGap stopped in 14 Aug 2020. To the + best of our knowledge, this SDK should still be compatible with the final release.

    For more information about PhoneGap shut down, @@ -55,7 +54,7 @@ Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

    -
    cd PATH_TO_YOUR_PROJECT
    +
    cd PATH_TO_YOUR_PROJECT
     
     cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
     
    @@ -65,34 +64,34 @@ cordova plugin add countly-sdk-js@20.11.0

    If iOS/Android Platform are already added in your project, first remove them

    -
    cordova platform remove android
    +
    cordova platform remove android
     cordova platform remove ios

    Now add platform of your choice

    -
    cordova platform add android
    +
    cordova platform add android
     cordova platform add ios

    It's important that you make sure you build it with Cordova, as Cordova links folders very well.

    -
    cordova build android
    +
    cordova build android
     ordova build ios

    Now run the application directly for Android,

    -
    cordova run android
    +
    cordova run android

    Or iOS:

    -
    cordova run ios
    +
    cordova run ios

    Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

    - Ionic + Ionic

    Add Countly SDK in your Ionic project using following commands:
    Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

    -
    cd PATH_TO_YOUR_PROJECT
    +
    cd PATH_TO_YOUR_PROJECT
     
     ionic cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
     
    @@ -102,39 +101,39 @@ ionic cordova plugin add countly-sdk-js@20.11.0

    If iOS/Android Platform are already added in your project, first remove them

    -
    ionic cordova platform remove android
    +
    ionic cordova platform remove android
     ionic cordova platform remove ios

    Now add platform of your choice

    -
    ionic cordova platform add android
    +
    ionic cordova platform add android
     ionic cordova platform add ios

    Now prepare the platforms you have added

    -
    ionic cordova prepare android
    +
    ionic cordova prepare android
     ionic cordova prepare ios

    It's important that you make sure you build it with Cordova, as Cordova links folders very well.

    -
    ionic cordova build android
    +
    ionic cordova build android
     ionic cordova build ios

    Now run the application directly for Android,

    -
    ionic cordova run android
    +
    ionic cordova run android

    Or iOS:

    -
    ionic cordova run ios
    +
    ionic cordova run ios

    Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

    In your index.html, use the following lines:

    -
    <script type="text/javascript" src="cordova.js"></script>
    +
    <script type="text/javascript" src="cordova.js"></script>
     <script type="text/javascript" src="Countly.js"></script>
    -

    SDK Integration

    -

    Minimal setup

    +

    SDK Integration

    +

    Minimal setup

    Below you can find necessary code snippets to initialize the SDK for sending data to Countly servers. Where possible, use your server URL instead of try.count.ly in case you have your own server.

    -
    // initialize
    +
    // initialize
     Countly.isInitialized().then((result) => {
                 if(result  != "true") {
                     Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
    @@ -159,7 +158,7 @@ Countly.isInitialized().then((result) => {
         here.
       

    -

    Enable logging

    +

    Enable logging

    If logging is enabled then our sdk will print out debug messages about it's internal state and encountered problems. @@ -167,9 +166,9 @@ Countly.isInitialized().then((result) => {

    When advise doing this while implementing countly features in your application.

    -
    // example for setLoggingEnabled
    +
    // example for setLoggingEnabled
     Countly.setLoggingEnabled();
    -

    Device ID

    +

    Device ID

    When the SDK is initialized for the first time and no device ID is provided, a device ID will be generated by SDK. @@ -181,21 +180,21 @@ Countly.setLoggingEnabled();

    You may provide your own custom device ID when initializing the SDK

    -
    Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
    -

    SDK data storage

    +
    Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
    +

    SDK data storage

    For iOS: SDK data is stored in Application Support Directory in file named "Countly.dat" For Android: SDK data is stored in SharedPreferences. A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them.

    -

    Crash reporting

    +

    Crash reporting

    The Countly SDK has the ability to collect crash reports, which you may examine and resolve later on the server.

    -

    Automatic crash handling

    +

    Automatic crash handling

    With this feature, the Countly SDK will generate a crash report if your application crashes due to an exception and send it to the Countly server for further inspection. @@ -209,15 +208,17 @@ Countly.setLoggingEnabled();

    You will need to call the following method before calling init in order to activate automatic crash reporting.

    -

    - -

    -
    // Using countly crash reports
    +  

    + +
    // Using countly crash reports
     Countly.enableCrashReporting();
     
    -

    Handled exceptions

    +

    Handled exceptions

    You might catch an exception or similar error during your app’s runtime.

    @@ -228,7 +229,7 @@ Countly.enableCrashReporting();

    You can also send a custom crash log to Countly using code below.

    -
    // Send Exception to the server
    +
    // Send Exception to the server
     Countly.logException(["My Customized error message"], true, {"_facebook_version": "0.0.1"});
     Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments);

    @@ -244,7 +245,7 @@ Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments); 1. Manually report handled exception

    -
    // With stackframes
    +
    // With stackframes
     try {
       // your code here...
     } catch (err) {
    @@ -261,7 +262,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true);

    2. Manually report handled exception with segmentation

    -
    // With stackframes
    +
    // With stackframes
     try {
       // your code here...
     } catch (err) {
    @@ -278,7 +279,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true, {"\_facebook_vers
     

    3. Manually report fatal exception

    -
    // With stackframes
    +
    // With stackframes
     try {
       // your code here...
     } catch (err) {
    @@ -295,7 +296,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false);

    4. Manually report fatal exception with segmentation

    -
    // With stackframes
    +
    // With stackframes
     try {
       // your code here...
     } catch (err) {
    @@ -309,17 +310,17 @@ Countly.logException("ERROR_STRING", false, {"\_facebook_version": "0.0.1"});
     
     // With array of strings
     Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false, {"\_facebook_version": "0.0.1"});
    -

    Crash breadcrumbs

    +

    Crash breadcrumbs

    Throughout your app you can leave crash breadcrumbs which would describe previous steps that were taken in your app before the crash. After a crash happens, they will be sent together with the crash report.

    Following the command adds crash breadcrumb:

    -
    // Add crash breadcrumb
    +
    // Add crash breadcrumb
     Countly.addCrashLog("My crash log from JavaScript");
     
    -

    Events

    +

    Events

    An Event is any type of action that you can send to a Countly instance, e.g purchase, settings changed, @@ -330,21 +331,21 @@ Countly.addCrashLog("My crash log from JavaScript"); Here are the detail about properties which we can use with event:

      -
    • +
    • key identifies the event
    • -
    • +
    • count is the number of times this event occurred
    • -
    • +
    • sum is an overall numerical data set tied to an event. For example, total amount of in-app purchase event.
    • -
    • +
    • duration is used to record and track the duration of events.
    • -
    • +
    • segmentation is a key-value pairs, we can use segmentation to track additional information. The only valid data types are: "String", "Integer", "Double" and "Boolean". All other types @@ -352,34 +353,36 @@ Countly.addCrashLog("My crash log from JavaScript");
    - Data passed should be in UTF-8 +

    + Data passed should be in UTF-8 +

    All data passed to Countly server via SDK or API should be in UTF-8.

    -

    Recording events

    +

    Recording events

    We will be recording a purchase event. Here is a quick summary of what information each usage will provide us:

      -
    • +
    • Usage 1: how many times purchase event occurred.
    • -
    • +
    • Usage 2: how many times purchase event occurred + the total amount of those purchases.
    • -
    • +
    • Usage 3: how many times purchase event occurred + which countries and application versions those purchases were made from.
    • -
    • +
    • Usage 4: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions.
    • -
    • +
    • Usage 5: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions + the total duration of those events. @@ -388,33 +391,33 @@ Countly.addCrashLog("My crash log from JavaScript");

      1. Event key and count

      -
      // example for sending basic event
      +
      // example for sending basic event
       var events = {"key":"Basic Event","count":1};
       Countly.recordEvent(events);

      2. Event key, count and sum

      -
      // example for event with sum
      +
      // example for event with sum
       var events = {"key":"Event With Sum","count":1,"sum":"0.99"};
       Countly.recordEvent(events);

      3. Event key and count with segmentation(s)

      -
      // example for event with segment
      +
      // example for event with segment
       var events = {"key":"Event With Segment","count":1};
       events.segments = {"Country" : "Turkey", "Age" : "28"};
       Countly.recordEvent(events);

      4. Event key, count and sum with segmentation(s)

      -
      // example for event with segment and sum
      +
      // example for event with segment and sum
       var events = {"key":"Event With Segment And Sum","count":1,"sum":"0.99"};
       events.segments = {"Country" : "Turkey", "Age" : "28"};
       Countly.recordEvent(events);

      5. Event key, count, sum and duration with segmentation(s)

      -
      var events = {
      +
      var events = {
         "key": "Event With Sum And Segment duration",
         "count": 1,
         "Sum": "0.99",
      @@ -430,11 +433,11 @@ Countly.recordEvent(events);
      those examples and use country, app_version, game_level, time_of_day and any other segmentation that will provide you valuable insights.

      -

      Timed events

      +

      Timed events

      It's possible to create timed events by defining a start and stop moment.

      -
      // Time Event
      +
      // Time Event
       Countly.startEvent("Timed Event");
       setTimeout(function() {
           Countly.endEvent({ "key": "Timed Event");
      @@ -450,7 +453,7 @@ countly.endEvent({"key": "Timed Event With Sum", "sum": "0.99"});
         case, you have to provide segmentation, count and sum. The default values for
         those are "null", 1 and 0.
       

      -
      
      +
      
       // Time Event with segment
       Countly.startEvent("Timed Event With Segment");
       setTimeout(function() {
      @@ -478,28 +481,28 @@ events.segments = {
       };
       Countly.endEvent(events);
       }, 1000);
      -

      Sessions

      -

      Automatic session tracking

      +

      Sessions

      +

      Automatic session tracking

      To start recording an automatic session tracking you would call:

      -
      Countly.start();
      +
      Countly.start();

      Countly.start(); will handle the start session, update session and end session automatically.
      This is how it works:

        -
      • +
      • Start/Begin session Request: It is sent on Countly.start(); call and when the app comes back to the foreground from the background, and it includes basic metrics.
      • -
      • +
      • Update Session Request: It automatically sends a periodical (60 sec by default) update session request while the app is in the foreground.
      • -
      • +
      • End Session Request: It is sent at the end of a session when the app goes to the background or terminates.
      • @@ -507,15 +510,15 @@ Countly.endEvent(events);

        If you want to end automatic session tracking you would call:

        -
        Countly.stop();
        -

        View tracking

        +
        Countly.stop();
        +

        View tracking

        You may track custom views with the following code snippet:

        -
        Countly.recordView("View Name")
        +
        Countly.recordView("View Name")

        While manually tracking views, you may add your custom segmentation to them like this:

        -
        var viewSegmentation = { "Country": "Germany", "Age": "28" };
        +
        var viewSegmentation = { "Country": "Germany", "Age": "28" };
         Countly.recordView("View Name", viewSegmentation);

        To review the resulting data, open the dashboard and go to @@ -524,9 +527,9 @@ Countly.recordView("View Name", viewSegmentation);

        here.

        - 001.png + 001.png
        -

        Device ID management

        +

        Device ID management

        A device ID is a unique identifier for your users. You may specify the device ID yourself or allow the SDK to generate it. When providing one yourself, keep @@ -534,7 +537,7 @@ Countly.recordView("View Name", viewSegmentation);

      an id could be the username, email or some other internal ID used by your other systems.

      -

      Device ID generation

      +

      Device ID generation

      When the SDK is initialized for the first time with no device ID, then SDK will generate a device ID. @@ -546,9 +549,9 @@ Countly.recordView("View Name", viewSegmentation);

      For iOS: the device ID generated by SDK is the Identifier For Vendor (IDFV)
      For Android: the device ID generated by SDK is the OpenUDID

      -

      Changing the Device ID

      +

      Changing the Device ID

      You may configure/change the device ID anytime using:

      -
      Countly.changeDeviceId(DEVICE_ID, ON_SERVER);
      +
      Countly.changeDeviceId(DEVICE_ID, ON_SERVER);

      You may either allow the device to be counted as a new device or merge existing data on the server. If theonServer bool is set to @@ -557,7 +560,7 @@ Countly.recordView("View Name", viewSegmentation);

      Otherwise, if onServer bool is set to false, the device will be counted as a new device on the server.

      -

      Temporary Device ID

      +

      Temporary Device ID

      You may use a temporary device ID mode for keeping all requests on hold until the real device ID is set later. @@ -565,9 +568,9 @@ Countly.recordView("View Name", viewSegmentation);

      You can enable temporary device ID when initializing the SDK:

      -
      Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")
      +
      Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")

      To enable a temporary device ID after init, you would call:

      -
      Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);
      +
      Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);

      Note: When passing TemporaryDeviceID for deviceID parameter, argument for onServerparameter @@ -588,77 +591,83 @@ Countly.recordView("View Name", viewSegmentation);

      which have been kept on hold until that point will start with the real device ID

      -

      Retrieving current device ID

      +

      Retrieving current device ID

      You may want to see what device id Countly is assigning for the specific device. For that you may use the following call:

      -
      // get device id
      +
      // get device id
       Countly.getCurrentDeviceId(function(deviceId){
         console.log(deviceId);
       }, function(getDeviceIDError){
         console.log(getDeviceIDError);
       });
      -

      Push notifications

      -

      Integration

      -

      Android setup

      +

      Push notifications

      +

      Integration

      +

      Android setup

      Here are the steps to make push notifications work on Android:

        -
      1. +
      2. For FCM credentials setup please follow the instruction from this URL https://support.count.ly/hc/en-us/articles/360037754031-Android#getting-fcm-credentials.
      3. -
      4. +
      5. Make sure you have google-services.json from https://firebase.google.com/
      6. -
      7. +
      8. Make sure the app package name and the google-services.json package_name matches.
      9. -
      10. +
      11. Place this google-services.json file under your root project folder. i.e. above www folder.
      12. -
      13. - Put these tags in config.xml file for Android: +
      14. +

        Put these tags in config.xml file for Android:

        -
        <platform name="android">
        +        
        <platform name="android">
            <resource-file src="google-services.json" target="app/google-services.json" />
         </platform>
      15. -
      16. - Put these tags in config.xml file if you are using cordova-android 9.x or - greater: +
      17. +

        + Put these tags in config.xml file if you are using cordova-android 9.x + or greater: +

        -
        <preference name="GradlePluginGoogleServicesEnabled" value="true" />
        +        
        <preference name="GradlePluginGoogleServicesEnabled" value="true" />
         <preference name="GradlePluginGoogleServicesVersion" value="4.2.0" />
      18. -
      19. - Install the google services plugin if you use cordova-android below version - 9 -
        cordova plugin add cordova-support-google-services --save
        +
      20. +

        + Install the google services plugin if you use cordova-android below version + 9 +

        +
        cordova plugin add cordova-support-google-services --save
      21. -
      22. Build your app, and test push notifications.
      23. +
      24. Build your app, and test push notifications.
      -

      iOS setup

      +

      iOS setup

      - By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode. + By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode.

      Screenshot_2022-06-27_at_5.35.43_PM.png

      - Minimum Countly SDK Version +

      + Minimum Countly SDK Version +

      This COUNTLY_EXCLUDE_PUSHNOTIFICATIONS is only supported by the minimum SDK version 20.11.3. @@ -668,25 +677,25 @@ Countly.getCurrentDeviceId(function(deviceId){ There are no additional steps required for iOS,everything is set up for you by the Countly Cordova SDK.

      -

      Enabling push

      +

      Enabling push

      First, when setting up push for the Cordova SDK, you would first select the push token mode. This would allow you to choose either test or production modes, push token mode should be set before init.

      -
      // Set messaging mode for push notifications
      +
      // Set messaging mode for push notifications
       Countly.pushTokenType(Countly.messagingMode.DEVELOPMENT, "Channel Name", "Channel Description");

      When you are finally ready to initialise Countly push, you would call this:

      -
      // This method will ask for permission, enables push notification and send push token to countly server.
      +
      // This method will ask for permission, enables push notification and send push token to countly server.
       Countly.askForNotificationPermission();
      -

      Handling push callbacks

      +

      Handling push callbacks

      To register a Push Notification callback after initializing the SDK, use the method below.

      -
      Countly.registerForNotification(function(theNotification){
      +
      Countly.registerForNotification(function(theNotification){
         console.log(JSON.stringify(theNotification));
       });

      @@ -694,12 +703,13 @@ Countly.askForNotificationPermission();

      code in AppDelegate.m

      Add header files

      -
      #import "CountlyNative.h"
      #import <UserNotifications/UserNotifications.h> +
      #import "CountlyNative.h"
      +#import <UserNotifications/UserNotifications.h>
       

      Before @end add these methods

      -
      // Required for the notification event. You must call the completion handler after handling the remote notification.
      +
      // Required for the notification event. You must call the completion handler after handling the remote notification.
       - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
       {
           [CountlyNative onNotification: userInfo];
      @@ -720,16 +730,49 @@ Countly.askForNotificationPermission();
      [CountlyNative onNotification: notification.request.content.userInfo]; completionHandler(0); }
      -

      Data Structure Received in Push Callbacks

      +

      Data Structure Received in Push Callbacks

      - Here is the example of how data will receive in push callbacks:Screenshot_2022-06-24_at_7.04.23_PM.png
      + Here is the example of how data will receive in push callbacks:Screenshot_2022-06-24_at_7.04.23_PM.png

      Data Received for Android platform:

      -
      {
      "c.e.cc": "TR",
      "c.e.dt": "mobile",
      "Key": "value",
      "c.i": "62b59b979f05a1f5e5592036",
      "c.l": "https:\/\/www.google.com\/",
      "c.m": "https:\/\/count.ly\/images\/logos\/countly-logo-mark.png?v2",
      "c.li": "notify_icon",
      "badge": "1",
      "sound": "custom",
      "title": "title",
      "message": "Message"
      }
      +
      {
      +"c.e.cc": "TR",
      +"c.e.dt": "mobile",
      +"Key": "value",
      +"c.i": "62b59b979f05a1f5e5592036",
      +"c.l": "https:\/\/www.google.com\/",
      +"c.m": "https:\/\/count.ly\/images\/logos\/countly-logo-mark.png?v2",
      +"c.li": "notify_icon",
      +"badge": "1",
      +"sound": "custom",
      +"title": "title",
      +"message": "Message"
      +}

      Data Received for iOS platform:

      -
      {
      Key = value;
      aps = {
      alert = {
      body = Message;
      subtitle = subtitle;
      title = title;
      };
      badge = 1;
      "mutable-content" = 1;
      sound = custom;
      };
      c = {
      a = "https://count.ly/images/logos/countly-logo-mark.png";
      e = {
      cc = TR;
      dt = mobile;
      };
      i = 62b5b945cabedb0870e9f217;
      l = "https://www.google.com/";
      };
      }
      -

      User location

      +
      {
      +Key = value;
      + aps = {
      +  alert = {
      +   body = Message;
      +   subtitle = subtitle;
      +   title = title;
      +  };
      + badge = 1;
      + "mutable-content" = 1;
      + sound = custom;
      + };
      + c = {
      +  a = "https://count.ly/images/logos/countly-logo-mark.png";
      +   e = {
      +    cc = TR;
      +    dt = mobile;
      +   };
      +  i = 62b5b945cabedb0870e9f217;
      +  l = "https://www.google.com/";
      + };
      +}
      +

      User location

      While integrating this SDK into your application, you might want to track your user location. You could use this information to better know your apps user base @@ -737,14 +780,14 @@ completionHandler(0); are 4 fields that can be provided:

        -
      • country code in the 2 letter iso standard
      • -
      • city name (has to be set together with country code)
      • -
      • +
      • country code in the 2 letter iso standard
      • +
      • city name (has to be set together with country code)
      • +
      • Comma separate latitude and longitude values, for example "56.42345,123.45325"
      • -
      • ip address of your user
      • +
      • ip address of your user
      -
      // send user location
      +
      // send user location
       Countly.setLocation("28.006324", "-82.7166183");

      When those values are set, they will be sent every time when initiating a session. @@ -759,13 +802,13 @@ Countly.setLocation("28.006324", "-82.7166183");

      It will erase cached location data from the device and the server.

      -

      Remote Config

      +

      Remote Config

      Remote config allows you to modiffy how your app functions or looks by requesting key-value pairs from your Countly server. The returned values can be modiffied based on the user profile. For more details please see Remote Config documentation.

      -

      Automatic remote config

      +

      Automatic remote config

      There are two ways of acquiring remote config data, by automatic download or manual request. By default, automatic remote config is disabled and therefore @@ -781,7 +824,7 @@ Countly.setLocation("28.006324", "-82.7166183");

      Note: call setRemoteConfigAutomaticDownload method before init

      -
      // Call this method before init
      +
      // Call this method before init
       Countly.setRemoteConfigAutomaticDownload(function(r){
         alert(r)
       }, function(r){
      @@ -798,14 +841,14 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
         instead). It is possible that a previously valid key returns no value after an
         update.
       

      -

      Manual remote config

      +

      Manual remote config

      There are three ways for manually requesting a Remote Config update:

        -
      • Manually updating everything
      • -
      • Manually updating specific keys
      • -
      • Manually updating everything except specific keys
      • +
      • Manually updating everything
      • +
      • Manually updating specific keys
      • +
      • Manually updating everything except specific keys

      Each of these requests also has a callback. If that returns a non-null value, @@ -818,7 +861,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ The advantage is that you can make the request whenever it is desirable for you. It has a callback to let you know when it has finished.

      -
      Countly.remoteConfigUpdate(function(r){
      +
      Countly.remoteConfigUpdate(function(r){
         alert(r)
       }, function(r){
         alert(r);
      @@ -829,7 +872,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
         updated. That list is an array with string values of those keys. It has a callback
         to let you know when the request has finished.
       

      -
      Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
      +
      Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
         alert(r)
       }, function(r){
         alert(r);
      @@ -839,7 +882,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
         updateRemoteConfigExceptKeys. The key list is a array with string values of the
         keys. It has a callback to let you know when the request has finished.
       

      -
      Countly.updateRemoteConfigExceptKeys(["url"], function(r){
      +
      Countly.updateRemoteConfigExceptKeys(["url"], function(r){
         alert(r)
       }, function(r){
         alert(r);
      @@ -850,7 +893,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
         will update all values. This means that it will also erase all keys not returned
         by the server.
       

      -

      Getting Remote Config values

      +

      Getting Remote Config values

      To request a stored value, call getRemoteConfigValueForKey with the specified key. If it returns null then no value was found. The SDK has no @@ -858,22 +901,22 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ needs to cast it to the appropriate type. The returned values can also be a JSONArray, JSONObject or just a simple value like int.

      -
      Countly.getRemoteConfigValueForKey("name", function(r){
      +
      Countly.getRemoteConfigValueForKey("name", function(r){
          alert(r)
        }, function(r){
          alert(r);
        });
      -

      Clearing stored values

      +

      Clearing stored values

      At some point you might want to erase all values downloaded from the server. To achieve that you need to call one function, depicted below:

      -
      Countly.remoteConfigClearValues(function(r){
      +
      Countly.remoteConfigClearValues(function(r){
         alert(r)
       }, function(r){
         alert(r);
       });
      -

      User Feedback

      +

      User Feedback

      There are two ways of getting feedback from your users: Star rating dialog, feedback widget. @@ -882,8 +925,8 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ Star rating dialog allows users to give feedback as a rating from 1 to 5. The feedback widget allows to get the same 1 to 5 rating and also a text comment.

      -

      Ratings

      -

      Star Rating Dialog

      +

      Ratings

      +

      Star Rating Dialog

      Star rating integration provides a dialog for getting user's feedback about the application. It contains a title, simple message explaining what it is for, a @@ -901,17 +944,17 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ either through the init function or the SetStarRatingDialogTexts function. If you don't want to override one of those values, set it to "null".

      -
      // Star Rating
      +
      // Star Rating
       countly.askForStarRating(Function(ratingResult){
         console.log(ratingResult);
       });
      -

      Rating Widget

      +

      Rating Widget

      Feedback widget shows a server configured widget to your user devices.

      - 002.png + 002.png

      It's possible to configure any of the shown text fields and replace with a custom @@ -932,14 +975,14 @@ countly.askForStarRating(Function(ratingResult){ you first have to get the widget ID from your server:

      - 003.png + 003.png

      Using that you can call the function to show the widget popup:

      -
      // Feedback Modal
      +
      // Feedback Modal
       countly.askForFeedback("5e425407975d006a22535fc", "close");
      -

      User Profiles

      +

      User Profiles

      Available with Enterprise Edition, User Profiles is a tool which helps you identify users, their devices, event timeline and application crash information. User @@ -958,7 +1001,7 @@ countly.askForFeedback("5e425407975d006a22535fc", "close");

      After you have provided user profile information, you must save it by calling Countly.userData.save().

      -
      / example for setting user data
      +
      / example for setting user data
       var options = {};
       options.name = "Nicola Tesla";
       options.username = "nicola";
      @@ -971,55 +1014,59 @@ options.gender = "Male";
       options.byear = 1919;
       Countly.setUserData(options);

      The keys for predefined user data fields are as follows:

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      KeyTypeDescription
      nameStringUser's full name
      usernameStringUser's nickname
      emailStringUser's email address
      organizationStringUser's organisation name
      phoneStringUser's phone number
      pictureStringURL to avatar or profile picture of the user
      genderStringUser's gender as M for male and F for female
      byearStringUser's year of birth as integer
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      KeyTypeDescription
      nameStringUser's full name
      usernameStringUser's nickname
      emailStringUser's email address
      organizationStringUser's organisation name
      phoneStringUser's phone number
      pictureStringURL to avatar or profile picture of the user
      genderStringUser's gender as M for male and F for female
      byearStringUser's year of birth as integer
      +

      Using "" for strings or a negative number for 'byear' will effectively delete that property. @@ -1029,13 +1076,13 @@ Countly.setUserData(options);

      on your Countly backend. Note: keys with . or $ symbols will have those symbols removed.

      -

      Setting custom values

      +

      Setting custom values

      Additionally you can do different manipulations on your custom data values, like increment current value on server or store a array of values under the same property.

      Below is the list of available methods:

      -
      // example for extra user features
      +
      // example for extra user features
       
       Countly.userData.setProperty("setProperty", "My Property");
       Countly.userData.increment("increment");
      @@ -1050,9 +1097,11 @@ Countly.userData.pullValue("pullValue", "morning");

      In the end always call Countly.userData.save() to send them to the server.

      -

      Application Performance Monitoring

      +

      Application Performance Monitoring

      - Minimum Countly SDK Version +

      + Minimum Countly SDK Version +

      This feature is only supported by the minimum SDK version 20.4.0.

      @@ -1066,20 +1115,20 @@ Countly.userData.pullValue("pullValue", "morning");
      Here is how you can utilize Performance Monitoring feature in your apps:

      First, you need to enable Performance Monitoring feature::

      -
      Countly.enableApm(); 
      +
      Countly.enableApm(); 
       // Enable APM features.

      With this, Countly SDK will start measuring some performance traces automatically. Those include app foreground time, app background time. Additionally, custom traces and network traces can be manually recorded.

      -

      App Start Time

      +

      App Start Time

      For the app start time to be recorded, you need to call the appLoadingFinished method. Make sure this method is called after init.

      -
      // Example of appLoadingFinished
      +
      // Example of appLoadingFinished
       Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
         Countly.appLoadingFinished();
       },(err) => {
      @@ -1094,19 +1143,19 @@ Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
         the app launch time can be recorded only once per app launch. So, the second
         and following calls to this method will be ignored.
       

      -

      Custom traces

      +

      Custom traces

      You may also measure any operation you want and record it using custom traces. First, you need to start a trace by using the startTrace(traceKey) method:

      -
      Countly.startTrace(traceKey);
      +
      Countly.startTrace(traceKey);

      Then you may end it using the endTrace(traceKey, customMetric)method, optionally passing any metrics as key-value pairs:

      -
      String traceKey = "Trace Key"
      +
      String traceKey = "Trace Key"
       ;
       Map<String, int> customMetric = {
         "ABC": 1233,
      @@ -1123,13 +1172,13 @@ Countly.endTrace(traceKey, customMetric);
      You may also cancel any custom trace you started, using cancelTrace(traceKey)method:

      -
      Countly.cancelTrace(traceKey);
      +
      Countly.cancelTrace(traceKey);

      Additionally, if you need you may cancel all custom traces you started, using clearAllTraces()method:

      -
      Countly.clearAllTraces(traceKey);
      -

      Network traces

      +
      Countly.clearAllTraces(traceKey);
      +

      Network traces

      You may record manual network traces using theecordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime) method. @@ -1149,9 +1198,9 @@ Countly.endTrace(traceKey, customMetric);

      time of the request - endTime: UNIX time stamp in milliseconds for the ending time of the request

      -
      Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
      +
      Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
      -

      User Consent

      +

      User Consent

      To be compliant with GDPR, starting from 18.04, Countly provides ways to toggle different Countly features on/off depending on the given consent. @@ -1161,7 +1210,7 @@ Countly.endTrace(traceKey, customMetric);

      By default the requirement for consent is disabled. To enable it, you have to call setRequiresConsent with true, before initializing Countly.

      -
      Countly.setRequiresConsent(true);
      +
      Countly.setRequiresConsent(true);

      By default no consent is given. That means that if no consent is enabled, Countly will not work and no network requests, related to features, will be sent. When @@ -1188,104 +1237,96 @@ Countly.endTrace(traceKey, customMetric);

      The current features are:

        -
      • +
      • sessions - tracking when, how often and how long users use your app
      • -
      • events - allow sending events to server
      • -
      • views - allow tracking which views user visits
      • -
      • location - allow sending location information
      • -
      • crashes - allow tracking crashes, exceptions and errors
      • -
      • +
      • events - allow sending events to server
      • +
      • views - allow tracking which views user visits
      • +
      • location - allow sending location information
      • +
      • crashes - allow tracking crashes, exceptions and errors
      • +
      • attribution - allow tracking from which campaign did user come
      • -
      • +
      • users - allow collecting/providing user information, including custom properties
      • -
      • push - allow push notifications
      • -
      • starRating - allow to send their rating and feedback
      • -
      • apm - allow application performance monitoring
      • -
      • +
      • push - allow push notifications
      • +
      • starRating - allow to send their rating and feedback
      • +
      • apm - allow application performance monitoring
      • +
      • remote-config - allows downloading remote config values from your server
      -

      Changing consent

      +

      Changing consent

      There are 3 ways of changing feature consent:

        -
      • +
      • giveConsentInit - To add consent for a single feature (string parameter) or a subset of features (array of strings parameter). Use this method for giving consent before initializing.
      -
      //giveConsent
      +
      //giveConsent
       Countly.giveConsentInit(["events", "views", "star-rating", "crashes"]);
       
       // removeConsent
       Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
        -
      • +
      • giveConsent/removeConsent - gives or removes consent to a specific feature
      -
      //giveConsent
      +
      //giveConsent
       Countly.giveConsent(["events", "views", "star-rating", "crashes"]);
       
       // removeConsent
       Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
        -
      • +
      • giveAllConsent/removeAllConsent - giveAll or removeAll consent to a specific feature
      -
      //giveAllConsent
      +
      //giveAllConsent
       Countly.giveAllConsent();
       
       //removeAllConsent
       Countly.removeAllConsent();
       
      -

      Security and privacy

      -

      Parameter Tampering Protection

      +

      Security and privacy

      +

      Parameter Tampering Protection

      You can set optional salt to be used for calculating checksum of request data, which will be sent with each request using &checksum field. You need to set exactly the same salt on Countly server. If salt on Countly server is set, all requests would be checked for validity of &checksum field before being processed.

      -
      // sending data with salt
      +
      // sending data with salt
       Countly.enableParameterTamperingProtection("salt");
      -

      Using Proguard

      +

      Using Proguard

      If you are using Countly Messaging in your Android application, it is recommended to obfuscate the Countly Messaging classes using Proguard. To do so, please follow the instructions below:

        -
      1. -

        - Locate the app/proguard-rules.pro file within the /android/app/ folder. -

        -
      2. -
      3. -

        Add the following lines to the file:

        +
      4. + Locate the app/proguard-rules.pro file within the /android/app/ folder.
      5. +
      6. Add the following lines to the file:
      -
      -keep class ly.count.android.sdk.** { *; }
      +
      -keep class ly.count.android.sdk.** { *; }
       
        -
      1. -

        - If Proguard is not yet configured, you must first enable shrinking and - obfuscation in the build file. To do so, locate the build.gradle file - within the /android/app/ folder. -

        -
      2. -
      3. -

        Add the following lines in bold to the build.gradle file:

        +
      4. + If Proguard is not yet configured, you must first enable shrinking and obfuscation + in the build file. To do so, locate the build.gradle file within the /android/app/ + folder.
      5. +
      6. Add the following lines in bold to the build.gradle file:
      -
      ...
      +
      ...
       
       buildTypes {
               release { // Enables code shrinking, obfuscation, and optimization for only your project's release build type.
      @@ -1300,8 +1341,8 @@ buildTypes {
         By following these steps, the Countly Messaging classes will be obfuscated using
         Proguard and your application will be better protected against reverse engineering.
       

      -

      Other features

      -

      Forcing HTTP POST

      +

      Other features

      +

      Forcing HTTP POST

      If the data sent to the server is short enough, the sdk will use HTTP GET requests. In case you want an override so that HTTP POST is used in all cases, call the @@ -1309,9 +1350,9 @@ buildTypes { to later in the apps life cycle disable the override. This function has to be called every time the app starts.

      -
      Countly.setHttpPostForced(true); // default is false
      +
      Countly.setHttpPostForced(true); // default is false
       
      -

      Optional parameters during initialization

      +

      Optional parameters during initialization

      You can provide optional parameters that will be used during begin_session request. They must be set right after the init function so that they are @@ -1323,13 +1364,13 @@ buildTypes {

      The optional parameters are:

        -
      • Country code: ISO Country code for the user's country
      • -
      • City: Name of the user's city
      • -
      • +
      • Country code: ISO Country code for the user's country
      • +
      • City: Name of the user's city
      • +
      • Location: Comma separate latitude and longitude values, for example "56.42345,123.45325"
      -
      
      +
      
       //setting optional parameters
       Countly.setOptionalParametersForInitialization({
           city: "Tampa",
      @@ -1340,4 +1381,4 @@ Countly.setOptionalParametersForInitialization({
       });
       
       //and then call the below code
      -Countly.init(this, "https://YOUR_SERVER", "YOUR_APP_KEY", "YOUR_DEVICE_ID")
      +Countly.init(this, "https://YOUR_SERVER", "YOUR_APP_KEY", "YOUR_DEVICE_ID")
      \ No newline at end of file diff --git a/legacy_docs/cordova/current.md b/legacy_docs/cordova/current.md index 352b81ae..c40d011a 100644 --- a/legacy_docs/cordova/current.md +++ b/legacy_docs/cordova/current.md @@ -19,15 +19,15 @@ Github repo. It should show how most of the functionalities can be used.

      -

      Adding the SDK to the project

      +

      Adding the SDK to the project

      The core of this SDK is developed around Cordova. We have a minimum version requirement for it's core and android, ios modules that have to be satisfied:

        -
      • cordova >= 9.0.0
      • -
      • cordova-android >= 8.0.0
      • -
      • cordova-ios >= 5.0.0
      • +
      • cordova >= 9.0.0
      • +
      • cordova-android >= 8.0.0
      • +
      • cordova-ios >= 5.0.0

      If you would integrate this SDK in any other project similar to cordova (like @@ -35,9 +35,8 @@ platform requirements for those projects similar to these.

      - Note : Development on PhoneGap stopped in - 14 Aug 2020. To the best of our knowledge, this SDK should still - be compatible with the final release. + Note : Development on PhoneGap stopped in 14 Aug 2020. To the + best of our knowledge, this SDK should still be compatible with the final release.

      For more information about PhoneGap shut down, @@ -55,7 +54,7 @@ Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

      -
      cd PATH_TO_YOUR_PROJECT
      +
      cd PATH_TO_YOUR_PROJECT
       
       cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
       
      @@ -65,34 +64,34 @@ cordova plugin add countly-sdk-js@20.11.0

      If iOS/Android Platform are already added in your project, first remove them

      -
      cordova platform remove android
      +
      cordova platform remove android
       cordova platform remove ios

      Now add platform of your choice

      -
      cordova platform add android
      +
      cordova platform add android
       cordova platform add ios

      It's important that you make sure you build it with Cordova, as Cordova links folders very well.

      -
      cordova build android
      +
      cordova build android
       ordova build ios

      Now run the application directly for Android,

      -
      cordova run android
      +
      cordova run android

      Or iOS:

      -
      cordova run ios
      +
      cordova run ios

      Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

      - Ionic + Ionic

      Add Countly SDK in your Ionic project using following commands:
      Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

      -
      cd PATH_TO_YOUR_PROJECT
      +
      cd PATH_TO_YOUR_PROJECT
       
       ionic cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
       
      @@ -102,39 +101,39 @@ ionic cordova plugin add countly-sdk-js@20.11.0

      If iOS/Android Platform are already added in your project, first remove them

      -
      ionic cordova platform remove android
      +
      ionic cordova platform remove android
       ionic cordova platform remove ios

      Now add platform of your choice

      -
      ionic cordova platform add android
      +
      ionic cordova platform add android
       ionic cordova platform add ios

      Now prepare the platforms you have added

      -
      ionic cordova prepare android
      +
      ionic cordova prepare android
       ionic cordova prepare ios

      It's important that you make sure you build it with Cordova, as Cordova links folders very well.

      -
      ionic cordova build android
      +
      ionic cordova build android
       ionic cordova build ios

      Now run the application directly for Android,

      -
      ionic cordova run android
      +
      ionic cordova run android

      Or iOS:

      -
      ionic cordova run ios
      +
      ionic cordova run ios

      Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

      In your index.html, use the following lines:

      -
      <script type="text/javascript" src="cordova.js"></script>
      +
      <script type="text/javascript" src="cordova.js"></script>
       <script type="text/javascript" src="Countly.js"></script>
      -

      SDK Integration

      -

      Minimal setup

      +

      SDK Integration

      +

      Minimal setup

      Below you can find necessary code snippets to initialize the SDK for sending data to Countly servers. Where possible, use your server URL instead of try.count.ly in case you have your own server.

      -
      // initialize
      +
      // initialize
       Countly.isInitialized().then((result) => {
                   if(result  != "true") {
                       Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
      @@ -159,7 +158,7 @@ Countly.isInitialized().then((result) => {
           here.
         

      -

      Enable logging

      +

      Enable logging

      If logging is enabled then our sdk will print out debug messages about it's internal state and encountered problems. @@ -167,9 +166,9 @@ Countly.isInitialized().then((result) => {

      When advise doing this while implementing countly features in your application.

      -
      // example for setLoggingEnabled
      +
      // example for setLoggingEnabled
       Countly.setLoggingEnabled();
      -

      Device ID

      +

      Device ID

      When the SDK is initialized for the first time and no device ID is provided, a device ID will be generated by SDK. @@ -181,21 +180,21 @@ Countly.setLoggingEnabled();

      You may provide your own custom device ID when initializing the SDK

      -
      Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
      -

      SDK data storage

      +
      Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
      +

      SDK data storage

      For iOS: SDK data is stored in Application Support Directory in file named "Countly.dat" For Android: SDK data is stored in SharedPreferences. A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them.

      -

      Crash reporting

      +

      Crash reporting

      The Countly SDK has the ability to collect crash reports, which you may examine and resolve later on the server.

      -

      Automatic crash handling

      +

      Automatic crash handling

      With this feature, the Countly SDK will generate a crash report if your application crashes due to an exception and send it to the Countly server for further inspection. @@ -209,15 +208,17 @@ Countly.setLoggingEnabled();

      You will need to call the following method before calling init in order to activate automatic crash reporting.

      -

      - -

      -
      // Using countly crash reports
      +  

      + +
      // Using countly crash reports
       Countly.enableCrashReporting();
       
      -

      Handled exceptions

      +

      Handled exceptions

      You might catch an exception or similar error during your app’s runtime.

      @@ -228,7 +229,7 @@ Countly.enableCrashReporting();

      You can also send a custom crash log to Countly using code below.

      -
      // Send Exception to the server
      +
      // Send Exception to the server
       Countly.logException(["My Customized error message"], true, {"_facebook_version": "0.0.1"});
       Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments);

      @@ -244,7 +245,7 @@ Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments); 1. Manually report handled exception

      -
      // With stackframes
      +
      // With stackframes
       try {
         // your code here...
       } catch (err) {
      @@ -261,7 +262,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true);

      2. Manually report handled exception with segmentation

      -
      // With stackframes
      +
      // With stackframes
       try {
         // your code here...
       } catch (err) {
      @@ -278,7 +279,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true, {"\_facebook_vers
       

      3. Manually report fatal exception

      -
      // With stackframes
      +
      // With stackframes
       try {
         // your code here...
       } catch (err) {
      @@ -295,7 +296,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false);

      4. Manually report fatal exception with segmentation

      -
      // With stackframes
      +
      // With stackframes
       try {
         // your code here...
       } catch (err) {
      @@ -309,17 +310,17 @@ Countly.logException("ERROR_STRING", false, {"\_facebook_version": "0.0.1"});
       
       // With array of strings
       Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false, {"\_facebook_version": "0.0.1"});
      -

      Crash breadcrumbs

      +

      Crash breadcrumbs

      Throughout your app you can leave crash breadcrumbs which would describe previous steps that were taken in your app before the crash. After a crash happens, they will be sent together with the crash report.

      Following the command adds crash breadcrumb:

      -
      // Add crash breadcrumb
      +
      // Add crash breadcrumb
       Countly.addCrashLog("My crash log from JavaScript");
       
      -

      Events

      +

      Events

      An Event is any type of action that you can send to a Countly instance, e.g purchase, settings changed, @@ -330,21 +331,21 @@ Countly.addCrashLog("My crash log from JavaScript"); Here are the detail about properties which we can use with event:

        -
      • +
      • key identifies the event
      • -
      • +
      • count is the number of times this event occurred
      • -
      • +
      • sum is an overall numerical data set tied to an event. For example, total amount of in-app purchase event.
      • -
      • +
      • duration is used to record and track the duration of events.
      • -
      • +
      • segmentation is a key-value pairs, we can use segmentation to track additional information. The only valid data types are: "String", "Integer", "Double" and "Boolean". All other types @@ -352,34 +353,36 @@ Countly.addCrashLog("My crash log from JavaScript");
      - Data passed should be in UTF-8 +

      + Data passed should be in UTF-8 +

      All data passed to Countly server via SDK or API should be in UTF-8.

      -

      Recording events

      +

      Recording events

      We will be recording a purchase event. Here is a quick summary of what information each usage will provide us:

        -
      • +
      • Usage 1: how many times purchase event occurred.
      • -
      • +
      • Usage 2: how many times purchase event occurred + the total amount of those purchases.
      • -
      • +
      • Usage 3: how many times purchase event occurred + which countries and application versions those purchases were made from.
      • -
      • +
      • Usage 4: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions.
      • -
      • +
      • Usage 5: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions + the total duration of those events. @@ -388,33 +391,33 @@ Countly.addCrashLog("My crash log from JavaScript");

        1. Event key and count

        -
        // example for sending basic event
        +
        // example for sending basic event
         var events = {"key":"Basic Event","count":1};
         Countly.recordEvent(events);

        2. Event key, count and sum

        -
        // example for event with sum
        +
        // example for event with sum
         var events = {"key":"Event With Sum","count":1,"sum":"0.99"};
         Countly.recordEvent(events);

        3. Event key and count with segmentation(s)

        -
        // example for event with segment
        +
        // example for event with segment
         var events = {"key":"Event With Segment","count":1};
         events.segments = {"Country" : "Turkey", "Age" : "28"};
         Countly.recordEvent(events);

        4. Event key, count and sum with segmentation(s)

        -
        // example for event with segment and sum
        +
        // example for event with segment and sum
         var events = {"key":"Event With Segment And Sum","count":1,"sum":"0.99"};
         events.segments = {"Country" : "Turkey", "Age" : "28"};
         Countly.recordEvent(events);

        5. Event key, count, sum and duration with segmentation(s)

        -
        var events = {
        +
        var events = {
           "key": "Event With Sum And Segment duration",
           "count": 1,
           "Sum": "0.99",
        @@ -430,11 +433,11 @@ Countly.recordEvent(events);
        those examples and use country, app_version, game_level, time_of_day and any other segmentation that will provide you valuable insights.

        -

        Timed events

        +

        Timed events

        It's possible to create timed events by defining a start and stop moment.

        -
        // Time Event
        +
        // Time Event
         Countly.startEvent("Timed Event");
         setTimeout(function() {
             Countly.endEvent({ "key": "Timed Event");
        @@ -450,7 +453,7 @@ countly.endEvent({"key": "Timed Event With Sum", "sum": "0.99"});
           case, you have to provide segmentation, count and sum. The default values for
           those are "null", 1 and 0.
         

        -
        
        +
        
         // Time Event with segment
         Countly.startEvent("Timed Event With Segment");
         setTimeout(function() {
        @@ -478,28 +481,28 @@ events.segments = {
         };
         Countly.endEvent(events);
         }, 1000);
        -

        Sessions

        -

        Automatic session tracking

        +

        Sessions

        +

        Automatic session tracking

        To start recording an automatic session tracking you would call:

        -
        Countly.start();
        +
        Countly.start();

        Countly.start(); will handle the start session, update session and end session automatically.
        This is how it works:

          -
        • +
        • Start/Begin session Request: It is sent on Countly.start(); call and when the app comes back to the foreground from the background, and it includes basic metrics.
        • -
        • +
        • Update Session Request: It automatically sends a periodical (60 sec by default) update session request while the app is in the foreground.
        • -
        • +
        • End Session Request: It is sent at the end of a session when the app goes to the background or terminates.
        • @@ -507,15 +510,15 @@ Countly.endEvent(events);

          If you want to end automatic session tracking you would call:

          -
          Countly.stop();
          -

          View tracking

          +
          Countly.stop();
          +

          View tracking

          You may track custom views with the following code snippet:

          -
          Countly.recordView("View Name")
          +
          Countly.recordView("View Name")

          While manually tracking views, you may add your custom segmentation to them like this:

          -
          var viewSegmentation = { "Country": "Germany", "Age": "28" };
          +
          var viewSegmentation = { "Country": "Germany", "Age": "28" };
           Countly.recordView("View Name", viewSegmentation);

          To review the resulting data, open the dashboard and go to @@ -524,9 +527,9 @@ Countly.recordView("View Name", viewSegmentation);

          here.

          - 001.png + 001.png
          -

          Device ID management

          +

          Device ID management

          A device ID is a unique identifier for your users. You may specify the device ID yourself or allow the SDK to generate it. When providing one yourself, keep @@ -534,7 +537,7 @@ Countly.recordView("View Name", viewSegmentation);

        an id could be the username, email or some other internal ID used by your other systems.

        -

        Device ID generation

        +

        Device ID generation

        When the SDK is initialized for the first time with no device ID, then SDK will generate a device ID. @@ -546,9 +549,9 @@ Countly.recordView("View Name", viewSegmentation);

        For iOS: the device ID generated by SDK is the Identifier For Vendor (IDFV)
        For Android: the device ID generated by SDK is the OpenUDID

        -

        Changing the Device ID

        +

        Changing the Device ID

        You may configure/change the device ID anytime using:

        -
        Countly.changeDeviceId(DEVICE_ID, ON_SERVER);
        +
        Countly.changeDeviceId(DEVICE_ID, ON_SERVER);

        You may either allow the device to be counted as a new device or merge existing data on the server. If theonServer bool is set to @@ -557,7 +560,7 @@ Countly.recordView("View Name", viewSegmentation);

        Otherwise, if onServer bool is set to false, the device will be counted as a new device on the server.

        -

        Temporary Device ID

        +

        Temporary Device ID

        You may use a temporary device ID mode for keeping all requests on hold until the real device ID is set later. @@ -565,9 +568,9 @@ Countly.recordView("View Name", viewSegmentation);

        You can enable temporary device ID when initializing the SDK:

        -
        Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")
        +
        Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")

        To enable a temporary device ID after init, you would call:

        -
        Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);
        +
        Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);

        Note: When passing TemporaryDeviceID for deviceID parameter, argument for onServerparameter @@ -588,71 +591,75 @@ Countly.recordView("View Name", viewSegmentation);

        which have been kept on hold until that point will start with the real device ID

        -

        Retrieving current device ID

        +

        Retrieving current device ID

        You may want to see what device id Countly is assigning for the specific device. For that you may use the following call:

        -
        // get device id
        +
        // get device id
         Countly.getCurrentDeviceId(function(deviceId){
           console.log(deviceId);
         }, function(getDeviceIDError){
           console.log(getDeviceIDError);
         });
        -

        Push notifications

        -

        Integration

        -

        Android setup

        +

        Push notifications

        +

        Integration

        +

        Android setup

        Here are the steps to make push notifications work on Android:

          -
        1. +
        2. For FCM credentials setup please follow the instruction from this URL https://support.count.ly/hc/en-us/articles/360037754031-Android#getting-fcm-credentials.
        3. -
        4. +
        5. Make sure you have google-services.json from https://firebase.google.com/
        6. -
        7. +
        8. Make sure the app package name and the google-services.json package_name matches.
        9. -
        10. +
        11. Place this google-services.json file under your root project folder. i.e. above www folder.
        12. -
        13. - Put these tags in config.xml file for Android: +
        14. +

          Put these tags in config.xml file for Android:

          -
          <platform name="android">
          +        
          <platform name="android">
              <resource-file src="google-services.json" target="app/google-services.json" />
           </platform>
        15. -
        16. - Put these tags in config.xml file if you are using cordova-android 9.x or - greater: +
        17. +

          + Put these tags in config.xml file if you are using cordova-android 9.x + or greater: +

          -
          <preference name="GradlePluginGoogleServicesEnabled" value="true" />
          +        
          <preference name="GradlePluginGoogleServicesEnabled" value="true" />
           <preference name="GradlePluginGoogleServicesVersion" value="4.2.0" />
        18. -
        19. - Install the google services plugin if you use cordova-android below version - 9 -
          cordova plugin add cordova-support-google-services --save
          +
        20. +

          + Install the google services plugin if you use cordova-android below version + 9 +

          +
          cordova plugin add cordova-support-google-services --save
        21. -
        22. Build your app, and test push notifications.
        23. +
        24. Build your app, and test push notifications.
        -

        iOS setup

        +

        iOS setup

        - By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode. + By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode.

        Screenshot_2022-06-27_at_5.35.43_PM.png @@ -661,25 +668,25 @@ Countly.getCurrentDeviceId(function(deviceId){ There are no additional steps required for iOS,everything is set up for you by the Countly Cordova SDK.

        -

        Enabling push

        +

        Enabling push

        First, when setting up push for the Cordova SDK, you would first select the push token mode. This would allow you to choose either test or production modes, push token mode should be set before init.

        -
        // Set messaging mode for push notifications
        +
        // Set messaging mode for push notifications
         Countly.pushTokenType(Countly.messagingMode.DEVELOPMENT, "Channel Name", "Channel Description");

        When you are finally ready to initialise Countly push, you would call this:

        -
        // This method will ask for permission, enables push notification and send push token to countly server.
        +
        // This method will ask for permission, enables push notification and send push token to countly server.
         Countly.askForNotificationPermission();
        -

        Handling push callbacks

        +

        Handling push callbacks

        To register a Push Notification callback after initializing the SDK, use the method below.

        -
        Countly.registerForNotification(function(theNotification){
        +
        Countly.registerForNotification(function(theNotification){
           console.log(JSON.stringify(theNotification));
         });

        @@ -687,12 +694,13 @@ Countly.askForNotificationPermission();

        code in AppDelegate.m

        Add header files

        -
        #import "CountlyNative.h"
        #import <UserNotifications/UserNotifications.h> +
        #import "CountlyNative.h"
        +#import <UserNotifications/UserNotifications.h>
         

        Before @end add these methods

        -
        // Required for the notification event. You must call the completion handler after handling the remote notification.
        +
        // Required for the notification event. You must call the completion handler after handling the remote notification.
         - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
         {
             [CountlyNative onNotification: userInfo];
        @@ -713,16 +721,49 @@ Countly.askForNotificationPermission();
        [CountlyNative onNotification: notification.request.content.userInfo]; completionHandler(0); }
        -

        Data Structure Received in Push Callbacks

        +

        Data Structure Received in Push Callbacks

        - Here is the example of how data will receive in push callbacks:Screenshot_2022-06-24_at_7.04.23_PM.png
        + Here is the example of how data will receive in push callbacks:Screenshot_2022-06-24_at_7.04.23_PM.png

        Data Received for Android platform:

        -
        {
        "c.e.cc": "TR",
        "c.e.dt": "mobile",
        "Key": "value",
        "c.i": "62b59b979f05a1f5e5592036",
        "c.l": "https:\/\/www.google.com\/",
        "c.m": "https:\/\/count.ly\/images\/logos\/countly-logo-mark.png?v2",
        "c.li": "notify_icon",
        "badge": "1",
        "sound": "custom",
        "title": "title",
        "message": "Message"
        }
        +
        {
        +"c.e.cc": "TR",
        +"c.e.dt": "mobile",
        +"Key": "value",
        +"c.i": "62b59b979f05a1f5e5592036",
        +"c.l": "https:\/\/www.google.com\/",
        +"c.m": "https:\/\/count.ly\/images\/logos\/countly-logo-mark.png?v2",
        +"c.li": "notify_icon",
        +"badge": "1",
        +"sound": "custom",
        +"title": "title",
        +"message": "Message"
        +}

        Data Received for iOS platform:

        -
        {
        Key = value;
        aps = {
        alert = {
        body = Message;
        subtitle = subtitle;
        title = title;
        };
        badge = 1;
        "mutable-content" = 1;
        sound = custom;
        };
        c = {
        a = "https://count.ly/images/logos/countly-logo-mark.png";
        e = {
        cc = TR;
        dt = mobile;
        };
        i = 62b5b945cabedb0870e9f217;
        l = "https://www.google.com/";
        };
        }
        -

        User location

        +
        {
        +Key = value;
        + aps = {
        +  alert = {
        +   body = Message;
        +   subtitle = subtitle;
        +   title = title;
        +  };
        + badge = 1;
        + "mutable-content" = 1;
        + sound = custom;
        + };
        + c = {
        +  a = "https://count.ly/images/logos/countly-logo-mark.png";
        +   e = {
        +    cc = TR;
        +    dt = mobile;
        +   };
        +  i = 62b5b945cabedb0870e9f217;
        +  l = "https://www.google.com/";
        + };
        +}
        +

        User location

        While integrating this SDK into your application, you might want to track your user location. You could use this information to better know your apps user base @@ -730,14 +771,14 @@ completionHandler(0); are 4 fields that can be provided:

          -
        • country code in the 2 letter iso standard
        • -
        • city name (has to be set together with country code)
        • -
        • +
        • country code in the 2 letter iso standard
        • +
        • city name (has to be set together with country code)
        • +
        • Comma separate latitude and longitude values, for example "56.42345,123.45325"
        • -
        • ip address of your user
        • +
        • ip address of your user
        -
        // send user location
        +
        // send user location
         Countly.setLocation("28.006324", "-82.7166183");

        When those values are set, they will be sent every time when initiating a session. @@ -752,13 +793,13 @@ Countly.setLocation("28.006324", "-82.7166183");

        It will erase cached location data from the device and the server.

        -

        Remote Config

        +

        Remote Config

        Remote config allows you to modiffy how your app functions or looks by requesting key-value pairs from your Countly server. The returned values can be modiffied based on the user profile. For more details please see Remote Config documentation.

        -

        Automatic remote config

        +

        Automatic remote config

        There are two ways of acquiring remote config data, by automatic download or manual request. By default, automatic remote config is disabled and therefore @@ -774,7 +815,7 @@ Countly.setLocation("28.006324", "-82.7166183");

        Note: call setRemoteConfigAutomaticDownload method before init

        -
        // Call this method before init
        +
        // Call this method before init
         Countly.setRemoteConfigAutomaticDownload(function(r){
           alert(r)
         }, function(r){
        @@ -791,14 +832,14 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
           instead). It is possible that a previously valid key returns no value after an
           update.
         

        -

        Manual remote config

        +

        Manual remote config

        There are three ways for manually requesting a Remote Config update:

          -
        • Manually updating everything
        • -
        • Manually updating specific keys
        • -
        • Manually updating everything except specific keys
        • +
        • Manually updating everything
        • +
        • Manually updating specific keys
        • +
        • Manually updating everything except specific keys

        Each of these requests also has a callback. If that returns a non-null value, @@ -811,7 +852,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ The advantage is that you can make the request whenever it is desirable for you. It has a callback to let you know when it has finished.

        -
        Countly.remoteConfigUpdate(function(r){
        +
        Countly.remoteConfigUpdate(function(r){
           alert(r)
         }, function(r){
           alert(r);
        @@ -822,7 +863,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
           updated. That list is an array with string values of those keys. It has a callback
           to let you know when the request has finished.
         

        -
        Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
        +
        Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
           alert(r)
         }, function(r){
           alert(r);
        @@ -832,7 +873,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
           updateRemoteConfigExceptKeys. The key list is a array with string values of the
           keys. It has a callback to let you know when the request has finished.
         

        -
        Countly.updateRemoteConfigExceptKeys(["url"], function(r){
        +
        Countly.updateRemoteConfigExceptKeys(["url"], function(r){
           alert(r)
         }, function(r){
           alert(r);
        @@ -843,7 +884,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
           will update all values. This means that it will also erase all keys not returned
           by the server.
         

        -

        Getting Remote Config values

        +

        Getting Remote Config values

        To request a stored value, call getRemoteConfigValueForKey with the specified key. If it returns null then no value was found. The SDK has no @@ -851,22 +892,22 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ needs to cast it to the appropriate type. The returned values can also be a JSONArray, JSONObject or just a simple value like int.

        -
        Countly.getRemoteConfigValueForKey("name", function(r){
        +
        Countly.getRemoteConfigValueForKey("name", function(r){
            alert(r)
          }, function(r){
            alert(r);
          });
        -

        Clearing stored values

        +

        Clearing stored values

        At some point you might want to erase all values downloaded from the server. To achieve that you need to call one function, depicted below:

        -
        Countly.remoteConfigClearValues(function(r){
        +
        Countly.remoteConfigClearValues(function(r){
           alert(r)
         }, function(r){
           alert(r);
         });
        -

        User Feedback

        +

        User Feedback

        There are two ways of getting feedback from your users: Star rating dialog, feedback widget. @@ -875,8 +916,8 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ Star rating dialog allows users to give feedback as a rating from 1 to 5. The feedback widget allows to get the same 1 to 5 rating and also a text comment.

        -

        Ratings

        -

        Star Rating Dialog

        +

        Ratings

        +

        Star Rating Dialog

        Star rating integration provides a dialog for getting user's feedback about the application. It contains a title, simple message explaining what it is for, a @@ -894,17 +935,17 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ either through the init function or the SetStarRatingDialogTexts function. If you don't want to override one of those values, set it to "null".

        -
        // Star Rating
        +
        // Star Rating
         countly.askForStarRating(Function(ratingResult){
           console.log(ratingResult);
         });
        -

        Rating Widget

        +

        Rating Widget

        Feedback widget shows a server configured widget to your user devices.

        - 002.png + 002.png

        It's possible to configure any of the shown text fields and replace with a custom @@ -925,14 +966,14 @@ countly.askForStarRating(Function(ratingResult){ you first have to get the widget ID from your server:

        - 003.png + 003.png

        Using that you can call the function to show the widget popup:

        -
        // Feedback Modal
        +
        // Feedback Modal
         countly.askForFeedback("5e425407975d006a22535fc", "close");
        -

        User Profiles

        +

        User Profiles

        Available with Enterprise Edition, User Profiles is a tool which helps you identify users, their devices, event timeline and application crash information. User @@ -951,7 +992,7 @@ countly.askForFeedback("5e425407975d006a22535fc", "close");

        After you have provided user profile information, you must save it by calling Countly.userData.save().

        -
        / example for setting user data
        +
        / example for setting user data
         var options = {};
         options.name = "Nicola Tesla";
         options.username = "nicola";
        @@ -964,55 +1005,59 @@ options.gender = "Male";
         options.byear = 1919;
         Countly.setUserData(options);

        The keys for predefined user data fields are as follows:

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        KeyTypeDescription
        nameStringUser's full name
        usernameStringUser's nickname
        emailStringUser's email address
        organizationStringUser's organisation name
        phoneStringUser's phone number
        pictureStringURL to avatar or profile picture of the user
        genderStringUser's gender as M for male and F for female
        byearStringUser's year of birth as integer
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        KeyTypeDescription
        nameStringUser's full name
        usernameStringUser's nickname
        emailStringUser's email address
        organizationStringUser's organisation name
        phoneStringUser's phone number
        pictureStringURL to avatar or profile picture of the user
        genderStringUser's gender as M for male and F for female
        byearStringUser's year of birth as integer
        +

        Using "" for strings or a negative number for 'byear' will effectively delete that property. @@ -1022,13 +1067,13 @@ Countly.setUserData(options);

        on your Countly backend. Note: keys with . or $ symbols will have those symbols removed.

        -

        Setting custom values

        +

        Setting custom values

        Additionally you can do different manipulations on your custom data values, like increment current value on server or store a array of values under the same property.

        Below is the list of available methods:

        -
        // example for extra user features
        +
        // example for extra user features
         
         Countly.userData.setProperty("setProperty", "My Property");
         Countly.userData.increment("increment");
        @@ -1043,7 +1088,7 @@ Countly.userData.pullValue("pullValue", "morning");

        In the end always call Countly.userData.save() to send them to the server.

        -

        Application Performance Monitoring

        +

        Application Performance Monitoring

        Performance Monitoring feature allows you to analyze your application's performance on various aspects. For more details please see @@ -1053,20 +1098,20 @@ Countly.userData.pullValue("pullValue", "morning");

        Here is how you can utilize Performance Monitoring feature in your apps:

        First, you need to enable Performance Monitoring feature::

        -
        Countly.enableApm(); 
        +
        Countly.enableApm(); 
         // Enable APM features.

        With this, Countly SDK will start measuring some performance traces automatically. Those include app foreground time, app background time. Additionally, custom traces and network traces can be manually recorded.

        -

        App Start Time

        +

        App Start Time

        For the app start time to be recorded, you need to call the appLoadingFinished method. Make sure this method is called after init.

        -
        // Example of appLoadingFinished
        +
        // Example of appLoadingFinished
         Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
           Countly.appLoadingFinished();
         },(err) => {
        @@ -1081,19 +1126,19 @@ Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
           the app launch time can be recorded only once per app launch. So, the second
           and following calls to this method will be ignored.
         

        -

        Custom traces

        +

        Custom traces

        You may also measure any operation you want and record it using custom traces. First, you need to start a trace by using the startTrace(traceKey) method:

        -
        Countly.startTrace(traceKey);
        +
        Countly.startTrace(traceKey);

        Then you may end it using the endTrace(traceKey, customMetric)method, optionally passing any metrics as key-value pairs:

        -
        String traceKey = "Trace Key"
        +
        String traceKey = "Trace Key"
         ;
         Map<String, int> customMetric = {
           "ABC": 1233,
        @@ -1110,13 +1155,13 @@ Countly.endTrace(traceKey, customMetric);
        You may also cancel any custom trace you started, using cancelTrace(traceKey)method:

        -
        Countly.cancelTrace(traceKey);
        +
        Countly.cancelTrace(traceKey);

        Additionally, if you need you may cancel all custom traces you started, using clearAllTraces()method:

        -
        Countly.clearAllTraces(traceKey);
        -

        Network traces

        +
        Countly.clearAllTraces(traceKey);
        +

        Network traces

        You may record manual network traces using theecordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime) method. @@ -1136,9 +1181,9 @@ Countly.endTrace(traceKey, customMetric);

        time of the request - endTime: UNIX time stamp in milliseconds for the ending time of the request

        -
        Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
        +
        Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
        -

        User Consent

        +

        User Consent

        To be compliant with GDPR, starting from 18.04, Countly provides ways to toggle different Countly features on/off depending on the given consent. @@ -1148,7 +1193,7 @@ Countly.endTrace(traceKey, customMetric);

        By default the requirement for consent is disabled. To enable it, you have to call setRequiresConsent with true, before initializing Countly.

        -
        Countly.setRequiresConsent(true);
        +
        Countly.setRequiresConsent(true);

        By default no consent is given. That means that if no consent is enabled, Countly will not work and no network requests, related to features, will be sent. When @@ -1175,104 +1220,96 @@ Countly.endTrace(traceKey, customMetric);

        The current features are:

          -
        • +
        • sessions - tracking when, how often and how long users use your app
        • -
        • events - allow sending events to server
        • -
        • views - allow tracking which views user visits
        • -
        • location - allow sending location information
        • -
        • crashes - allow tracking crashes, exceptions and errors
        • -
        • +
        • events - allow sending events to server
        • +
        • views - allow tracking which views user visits
        • +
        • location - allow sending location information
        • +
        • crashes - allow tracking crashes, exceptions and errors
        • +
        • attribution - allow tracking from which campaign did user come
        • -
        • +
        • users - allow collecting/providing user information, including custom properties
        • -
        • push - allow push notifications
        • -
        • starRating - allow to send their rating and feedback
        • -
        • apm - allow application performance monitoring
        • -
        • +
        • push - allow push notifications
        • +
        • starRating - allow to send their rating and feedback
        • +
        • apm - allow application performance monitoring
        • +
        • remote-config - allows downloading remote config values from your server
        -

        Changing consent

        +

        Changing consent

        There are 3 ways of changing feature consent:

          -
        • +
        • giveConsentInit - To add consent for a single feature (string parameter) or a subset of features (array of strings parameter). Use this method for giving consent before initializing.
        -
        //giveConsent
        +
        //giveConsent
         Countly.giveConsentInit(["events", "views", "star-rating", "crashes"]);
         
         // removeConsent
         Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
          -
        • +
        • giveConsent/removeConsent - gives or removes consent to a specific feature
        -
        //giveConsent
        +
        //giveConsent
         Countly.giveConsent(["events", "views", "star-rating", "crashes"]);
         
         // removeConsent
         Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
          -
        • +
        • giveAllConsent/removeAllConsent - giveAll or removeAll consent to a specific feature
        -
        //giveAllConsent
        +
        //giveAllConsent
         Countly.giveAllConsent();
         
         //removeAllConsent
         Countly.removeAllConsent();
         
        -

        Security and privacy

        -

        Parameter Tampering Protection

        +

        Security and privacy

        +

        Parameter Tampering Protection

        You can set optional salt to be used for calculating checksum of request data, which will be sent with each request using &checksum field. You need to set exactly the same salt on Countly server. If salt on Countly server is set, all requests would be checked for validity of &checksum field before being processed.

        -
        // sending data with salt
        +
        // sending data with salt
         Countly.enableParameterTamperingProtection("salt");
        -

        Using Proguard

        +

        Using Proguard

        If you are using Countly Messaging in your Android application, it is recommended to obfuscate the Countly Messaging classes using Proguard. To do so, please follow the instructions below:

          -
        1. -

          - Locate the app/proguard-rules.pro file within the /android/app/ folder. -

          -
        2. -
        3. -

          Add the following lines to the file:

          +
        4. + Locate the app/proguard-rules.pro file within the /android/app/ folder.
        5. +
        6. Add the following lines to the file:
        -
        -keep class ly.count.android.sdk.** { *; }
        +
        -keep class ly.count.android.sdk.** { *; }
         
          -
        1. -

          - If Proguard is not yet configured, you must first enable shrinking and - obfuscation in the build file. To do so, locate the build.gradle file - within the /android/app/ folder. -

          -
        2. -
        3. -

          Add the following lines in bold to the build.gradle file:

          +
        4. + If Proguard is not yet configured, you must first enable shrinking and obfuscation + in the build file. To do so, locate the build.gradle file within the /android/app/ + folder.
        5. +
        6. Add the following lines in bold to the build.gradle file:
        -
        ...
        +
        ...
         
         buildTypes {
                 release { // Enables code shrinking, obfuscation, and optimization for only your project's release build type.
        @@ -1287,8 +1324,8 @@ buildTypes {
           By following these steps, the Countly Messaging classes will be obfuscated using
           Proguard and your application will be better protected against reverse engineering.
         

        -

        Other features

        -

        Forcing HTTP POST

        +

        Other features

        +

        Forcing HTTP POST

        If the data sent to the server is short enough, the sdk will use HTTP GET requests. In case you want an override so that HTTP POST is used in all cases, call the @@ -1296,9 +1333,9 @@ buildTypes { to later in the apps life cycle disable the override. This function has to be called every time the app starts.

        -
        Countly.setHttpPostForced(true); // default is false
        +
        Countly.setHttpPostForced(true); // default is false
         
        -

        Optional parameters during initialization

        +

        Optional parameters during initialization

        You can provide optional parameters that will be used during begin_session request. They must be set right after the init function so that they are @@ -1310,13 +1347,13 @@ buildTypes {

        The optional parameters are:

          -
        • Country code: ISO Country code for the user's country
        • -
        • City: Name of the user's city
        • -
        • +
        • Country code: ISO Country code for the user's country
        • +
        • City: Name of the user's city
        • +
        • Location: Comma separate latitude and longitude values, for example "56.42345,123.45325"
        -
        
        +
        
         //setting optional parameters
         Countly.setOptionalParametersForInitialization({
             city: "Tampa",
        diff --git a/legacy_docs/cordova/next.md b/legacy_docs/cordova/next.md
        index 1cf92837..c40d011a 100644
        --- a/legacy_docs/cordova/next.md
        +++ b/legacy_docs/cordova/next.md
        @@ -1,4 +1,4 @@
        -

        +

        This document will guide you through the process of Countly SDK installation and it applies to version 22.09.0
        Countly is an open source SDK, you can take a look at our SDK code in the @@ -19,15 +19,15 @@ Github repo. It should show how most of the functionalities can be used.

        -

        Adding the SDK to the project

        +

        Adding the SDK to the project

        The core of this SDK is developed around Cordova. We have a minimum version requirement for it's core and android, ios modules that have to be satisfied:

          -
        • cordova >= 9.0.0
        • -
        • cordova-android >= 8.0.0
        • -
        • cordova-ios >= 5.0.0
        • +
        • cordova >= 9.0.0
        • +
        • cordova-android >= 8.0.0
        • +
        • cordova-ios >= 5.0.0

        If you would integrate this SDK in any other project similar to cordova (like @@ -35,9 +35,8 @@ platform requirements for those projects similar to these.

        - Note : Development on PhoneGap stopped in - 14 Aug 2020. To the best of our knowledge, this SDK should still - be compatible with the final release. + Note : Development on PhoneGap stopped in 14 Aug 2020. To the + best of our knowledge, this SDK should still be compatible with the final release.

        For more information about PhoneGap shut down, @@ -55,7 +54,7 @@ Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

        -
        cd PATH_TO_YOUR_PROJECT
        +
        cd PATH_TO_YOUR_PROJECT
         
         cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
         
        @@ -65,34 +64,34 @@ cordova plugin add countly-sdk-js@20.11.0

        If iOS/Android Platform are already added in your project, first remove them

        -
        cordova platform remove android
        +
        cordova platform remove android
         cordova platform remove ios

        Now add platform of your choice

        -
        cordova platform add android
        +
        cordova platform add android
         cordova platform add ios

        It's important that you make sure you build it with Cordova, as Cordova links folders very well.

        -
        cordova build android
        +
        cordova build android
         ordova build ios

        Now run the application directly for Android,

        -
        cordova run android
        +
        cordova run android

        Or iOS:

        -
        cordova run ios
        +
        cordova run ios

        Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

        - Ionic + Ionic

        Add Countly SDK in your Ionic project using following commands:
        Note: use the latest SDK version currently available, not specifically the one shown in the sample below.

        -
        cd PATH_TO_YOUR_PROJECT
        +
        cd PATH_TO_YOUR_PROJECT
         
         ionic cordova plugin add https://github.com/Countly/countly-sdk-cordova.git
         
        @@ -102,39 +101,39 @@ ionic cordova plugin add countly-sdk-js@20.11.0

        If iOS/Android Platform are already added in your project, first remove them

        -
        ionic cordova platform remove android
        +
        ionic cordova platform remove android
         ionic cordova platform remove ios

        Now add platform of your choice

        -
        ionic cordova platform add android
        +
        ionic cordova platform add android
         ionic cordova platform add ios

        Now prepare the platforms you have added

        -
        ionic cordova prepare android
        +
        ionic cordova prepare android
         ionic cordova prepare ios

        It's important that you make sure you build it with Cordova, as Cordova links folders very well.

        -
        ionic cordova build android
        +
        ionic cordova build android
         ionic cordova build ios

        Now run the application directly for Android,

        -
        ionic cordova run android
        +
        ionic cordova run android

        Or iOS:

        -
        ionic cordova run ios
        +
        ionic cordova run ios

        Alternatively, you can open the source in Xcode, or Android Studio and move on with further development.

        In your index.html, use the following lines:

        -
        <script type="text/javascript" src="cordova.js"></script>
        +
        <script type="text/javascript" src="cordova.js"></script>
         <script type="text/javascript" src="Countly.js"></script>
        -

        SDK Integration

        -

        Minimal setup

        +

        SDK Integration

        +

        Minimal setup

        Below you can find necessary code snippets to initialize the SDK for sending data to Countly servers. Where possible, use your server URL instead of try.count.ly in case you have your own server.

        -
        // initialize
        +
        // initialize
         Countly.isInitialized().then((result) => {
                     if(result  != "true") {
                         Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
        @@ -159,7 +158,7 @@ Countly.isInitialized().then((result) => {
             here.
           

-

Enable logging

+

Enable logging

If logging is enabled then our sdk will print out debug messages about it's internal state and encountered problems. @@ -167,9 +166,9 @@ Countly.isInitialized().then((result) => {

When advise doing this while implementing countly features in your application.

-
// example for setLoggingEnabled
+
// example for setLoggingEnabled
 Countly.setLoggingEnabled();
-

Device ID

+

Device ID

When the SDK is initialized for the first time and no device ID is provided, a device ID will be generated by SDK. @@ -181,21 +180,21 @@ Countly.setLoggingEnabled();

You may provide your own custom device ID when initializing the SDK

-
Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
-

SDK data storage

+
Countly.init(SERVER_URL, APP_KEY, DEVICE_ID)
+

SDK data storage

For iOS: SDK data is stored in Application Support Directory in file named "Countly.dat" For Android: SDK data is stored in SharedPreferences. A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them.

-

Crash reporting

+

Crash reporting

The Countly SDK has the ability to collect crash reports, which you may examine and resolve later on the server.

-

Automatic crash handling

+

Automatic crash handling

With this feature, the Countly SDK will generate a crash report if your application crashes due to an exception and send it to the Countly server for further inspection. @@ -209,15 +208,17 @@ Countly.setLoggingEnabled();

You will need to call the following method before calling init in order to activate automatic crash reporting.

-

- -

-
// Using countly crash reports
+  

+ +
// Using countly crash reports
 Countly.enableCrashReporting();
 
-

Handled exceptions

+

Handled exceptions

You might catch an exception or similar error during your app’s runtime.

@@ -228,7 +229,7 @@ Countly.enableCrashReporting();

You can also send a custom crash log to Countly using code below.

-
// Send Exception to the server
+
// Send Exception to the server
 Countly.logException(["My Customized error message"], true, {"_facebook_version": "0.0.1"});
 Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments);

@@ -244,7 +245,7 @@ Countly.logException(stackFramesFromStackTraceJS, booleanNonFatal, segments); 1. Manually report handled exception

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -261,7 +262,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true);

2. Manually report handled exception with segmentation

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -278,7 +279,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], true, {"\_facebook_vers
 

3. Manually report fatal exception

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -295,7 +296,7 @@ Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false);

4. Manually report fatal exception with segmentation

-
// With stackframes
+
// With stackframes
 try {
   // your code here...
 } catch (err) {
@@ -309,17 +310,17 @@ Countly.logException("ERROR_STRING", false, {"\_facebook_version": "0.0.1"});
 
 // With array of strings
 Countly.logException(["ERROR_STRING", "ERROR_STRING_2"], false, {"\_facebook_version": "0.0.1"});
-

Crash breadcrumbs

+

Crash breadcrumbs

Throughout your app you can leave crash breadcrumbs which would describe previous steps that were taken in your app before the crash. After a crash happens, they will be sent together with the crash report.

Following the command adds crash breadcrumb:

-
// Add crash breadcrumb
+
// Add crash breadcrumb
 Countly.addCrashLog("My crash log from JavaScript");
 
-

Events

+

Events

An Event is any type of action that you can send to a Countly instance, e.g purchase, settings changed, @@ -330,21 +331,21 @@ Countly.addCrashLog("My crash log from JavaScript"); Here are the detail about properties which we can use with event:

    -
  • - key identifies the event. +
  • + key identifies the event
  • -
  • - count is the number of times this event occurred. +
  • + count is the number of times this event occurred
  • -
  • +
  • sum is an overall numerical data set tied to an event. For example, total amount of in-app purchase event.
  • -
  • +
  • duration is used to record and track the duration of events.
  • -
  • +
  • segmentation is a key-value pairs, we can use segmentation to track additional information. The only valid data types are: "String", "Integer", "Double" and "Boolean". All other types @@ -352,34 +353,36 @@ Countly.addCrashLog("My crash log from JavaScript");
- Data passed should be in UTF-8 +

+ Data passed should be in UTF-8 +

All data passed to Countly server via SDK or API should be in UTF-8.

-

Recording events

+

Recording events

We will be recording a purchase event. Here is a quick summary of what information each usage will provide us:

    -
  • +
  • Usage 1: how many times purchase event occurred.
  • -
  • +
  • Usage 2: how many times purchase event occurred + the total amount of those purchases.
  • -
  • +
  • Usage 3: how many times purchase event occurred + which countries and application versions those purchases were made from.
  • -
  • +
  • Usage 4: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions.
  • -
  • +
  • Usage 5: how many times purchase event occurred + the total amount both of which are also available segmented into countries and application versions + the total duration of those events. @@ -388,33 +391,33 @@ Countly.addCrashLog("My crash log from JavaScript");

    1. Event key and count

    -
    // example for sending basic event
    +
    // example for sending basic event
     var events = {"key":"Basic Event","count":1};
     Countly.recordEvent(events);

    2. Event key, count and sum

    -
    // example for event with sum
    +
    // example for event with sum
     var events = {"key":"Event With Sum","count":1,"sum":"0.99"};
     Countly.recordEvent(events);

    3. Event key and count with segmentation(s)

    -
    // example for event with segment
    +
    // example for event with segment
     var events = {"key":"Event With Segment","count":1};
     events.segments = {"Country" : "Turkey", "Age" : "28"};
     Countly.recordEvent(events);

    4. Event key, count and sum with segmentation(s)

    -
    // example for event with segment and sum
    +
    // example for event with segment and sum
     var events = {"key":"Event With Segment And Sum","count":1,"sum":"0.99"};
     events.segments = {"Country" : "Turkey", "Age" : "28"};
     Countly.recordEvent(events);

    5. Event key, count, sum and duration with segmentation(s)

    -
    var events = {
    +
    var events = {
       "key": "Event With Sum And Segment duration",
       "count": 1,
       "Sum": "0.99",
    @@ -430,11 +433,11 @@ Countly.recordEvent(events);
    those examples and use country, app_version, game_level, time_of_day and any other segmentation that will provide you valuable insights.

    -

    Timed events

    +

    Timed events

    It's possible to create timed events by defining a start and stop moment.

    -
    // Time Event
    +
    // Time Event
     Countly.startEvent("Timed Event");
     setTimeout(function() {
         Countly.endEvent({ "key": "Timed Event");
    @@ -450,7 +453,7 @@ countly.endEvent({"key": "Timed Event With Sum", "sum": "0.99"});
       case, you have to provide segmentation, count and sum. The default values for
       those are "null", 1 and 0.
     

    -
    
    +
    
     // Time Event with segment
     Countly.startEvent("Timed Event With Segment");
     setTimeout(function() {
    @@ -478,28 +481,28 @@ events.segments = {
     };
     Countly.endEvent(events);
     }, 1000);
    -

    Sessions

    -

    Automatic session tracking

    +

    Sessions

    +

    Automatic session tracking

    To start recording an automatic session tracking you would call:

    -
    Countly.start();
    +
    Countly.start();

    Countly.start(); will handle the start session, update session and end session automatically.
    This is how it works:

      -
    • +
    • Start/Begin session Request: It is sent on Countly.start(); call and when the app comes back to the foreground from the background, and it includes basic metrics.
    • -
    • +
    • Update Session Request: It automatically sends a periodical (60 sec by default) update session request while the app is in the foreground.
    • -
    • +
    • End Session Request: It is sent at the end of a session when the app goes to the background or terminates.
    • @@ -507,15 +510,15 @@ Countly.endEvent(events);

      If you want to end automatic session tracking you would call:

      -
      Countly.stop();
      -

      View tracking

      +
      Countly.stop();
      +

      View tracking

      You may track custom views with the following code snippet:

      -
      Countly.recordView("View Name")
      +
      Countly.recordView("View Name")

      While manually tracking views, you may add your custom segmentation to them like this:

      -
      var viewSegmentation = { "Country": "Germany", "Age": "28" };
      +
      var viewSegmentation = { "Country": "Germany", "Age": "28" };
       Countly.recordView("View Name", viewSegmentation);

      To review the resulting data, open the dashboard and go to @@ -524,9 +527,9 @@ Countly.recordView("View Name", viewSegmentation);

      here.

      - 001.png + 001.png
      -

      Device ID management

      +

      Device ID management

      A device ID is a unique identifier for your users. You may specify the device ID yourself or allow the SDK to generate it. When providing one yourself, keep @@ -534,7 +537,7 @@ Countly.recordView("View Name", viewSegmentation);

    an id could be the username, email or some other internal ID used by your other systems.

    -

    Device ID generation

    +

    Device ID generation

    When the SDK is initialized for the first time with no device ID, then SDK will generate a device ID. @@ -546,9 +549,9 @@ Countly.recordView("View Name", viewSegmentation);

    For iOS: the device ID generated by SDK is the Identifier For Vendor (IDFV)
    For Android: the device ID generated by SDK is the OpenUDID

    -

    Changing the Device ID

    +

    Changing the Device ID

    You may configure/change the device ID anytime using:

    -
    Countly.changeDeviceId(DEVICE_ID, ON_SERVER);
    +
    Countly.changeDeviceId(DEVICE_ID, ON_SERVER);

    You may either allow the device to be counted as a new device or merge existing data on the server. If theonServer bool is set to @@ -557,7 +560,7 @@ Countly.recordView("View Name", viewSegmentation);

    Otherwise, if onServer bool is set to false, the device will be counted as a new device on the server.

    -

    Temporary Device ID

    +

    Temporary Device ID

    You may use a temporary device ID mode for keeping all requests on hold until the real device ID is set later. @@ -565,9 +568,9 @@ Countly.recordView("View Name", viewSegmentation);

    You can enable temporary device ID when initializing the SDK:

    -
    Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")
    +
    Countly.init(SERVER_URL, APP_KEY, "TemporaryDeviceID")

    To enable a temporary device ID after init, you would call:

    -
    Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);
    +
    Countly.changeDeviceId("TemporaryDeviceID", ON_SERVER);

    Note: When passing TemporaryDeviceID for deviceID parameter, argument for onServerparameter @@ -586,73 +589,77 @@ Countly.recordView("View Name", viewSegmentation);

    Later, when the real device ID is set using Countly.changeDeviceId(DEVICE_ID, ON_SERVER); method, all requests which have been kept on hold until that point will start with the real device - ID. + ID

    -

    Retrieving current device ID

    +

    Retrieving current device ID

    You may want to see what device id Countly is assigning for the specific device. For that you may use the following call:

    -
    // get device id
    +
    // get device id
     Countly.getCurrentDeviceId(function(deviceId){
       console.log(deviceId);
     }, function(getDeviceIDError){
       console.log(getDeviceIDError);
     });
    -

    Push notifications

    -

    Integration

    -

    Android setup

    +

    Push notifications

    +

    Integration

    +

    Android setup

    Here are the steps to make push notifications work on Android:

      -
    1. +
    2. For FCM credentials setup please follow the instruction from this URL https://support.count.ly/hc/en-us/articles/360037754031-Android#getting-fcm-credentials.
    3. -
    4. +
    5. Make sure you have google-services.json from https://firebase.google.com/
    6. -
    7. +
    8. Make sure the app package name and the google-services.json package_name matches.
    9. -
    10. +
    11. Place this google-services.json file under your root project folder. i.e. above www folder.
    12. -
    13. - Put these tags in config.xml file for Android: +
    14. +

      Put these tags in config.xml file for Android:

      -
      <platform name="android">
      +        
      <platform name="android">
          <resource-file src="google-services.json" target="app/google-services.json" />
       </platform>
    15. -
    16. - Put these tags in config.xml file if you are using cordova-android 9.x or - greater: +
    17. +

      + Put these tags in config.xml file if you are using cordova-android 9.x + or greater: +

      -
      <preference name="GradlePluginGoogleServicesEnabled" value="true" />
      +        
      <preference name="GradlePluginGoogleServicesEnabled" value="true" />
       <preference name="GradlePluginGoogleServicesVersion" value="4.2.0" />
    18. -
    19. - Install the google services plugin if you use cordova-android below version - 9 -
      cordova plugin add cordova-support-google-services --save
      +
    20. +

      + Install the google services plugin if you use cordova-android below version + 9 +

      +
      cordova plugin add cordova-support-google-services --save
    21. -
    22. Build your app, and test push notifications.
    23. +
    24. Build your app, and test push notifications.
    -

    iOS setup

    +

    iOS setup

    - By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode. + By default push notification is enabled for iOS, to disable you need to add the COUNTLY_EXCLUDE_PUSHNOTIFICATIONS=1 flag to the Build Settings > Preprocessor Macros section in Xcode.

    Screenshot_2022-06-27_at_5.35.43_PM.png @@ -661,25 +668,25 @@ Countly.getCurrentDeviceId(function(deviceId){ There are no additional steps required for iOS,everything is set up for you by the Countly Cordova SDK.

    -

    Enabling push

    +

    Enabling push

    - First, when setting up push for the Cordova SDK, you would select the push + First, when setting up push for the Cordova SDK, you would first select the push token mode. This would allow you to choose either test or production modes, push token mode should be set before init.

    -
    // Set messaging mode for push notifications
    +
    // Set messaging mode for push notifications
     Countly.pushTokenType(Countly.messagingMode.DEVELOPMENT, "Channel Name", "Channel Description");

    When you are finally ready to initialise Countly push, you would call this:

    -
    // This method will ask for permission, enables push notification and send push token to countly server.
    +
    // This method will ask for permission, enables push notification and send push token to countly server.
     Countly.askForNotificationPermission();
    -

    Handling push callbacks

    +

    Handling push callbacks

    To register a Push Notification callback after initializing the SDK, use the method below.

    -
    Countly.registerForNotification(function(theNotification){
    +
    Countly.registerForNotification(function(theNotification){
       console.log(JSON.stringify(theNotification));
     });

    @@ -687,12 +694,13 @@ Countly.askForNotificationPermission();

    code in AppDelegate.m

    Add header files

    -
    #import "CountlyNative.h"
    #import <UserNotifications/UserNotifications.h> +
    #import "CountlyNative.h"
    +#import <UserNotifications/UserNotifications.h>
     

    Before @end add these methods

    -
    // Required for the notification event. You must call the completion handler after handling the remote notification.
    +
    // Required for the notification event. You must call the completion handler after handling the remote notification.
     - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
     {
         [CountlyNative onNotification: userInfo];
    @@ -713,16 +721,49 @@ Countly.askForNotificationPermission();
    [CountlyNative onNotification: notification.request.content.userInfo]; completionHandler(0); }
    -

    Data Structure Received in Push Callbacks

    +

    Data Structure Received in Push Callbacks

    - Here is the example of how data will receive in push callbacks:Screenshot_2022-06-24_at_7.04.23_PM.png
    + Here is the example of how data will receive in push callbacks:Screenshot_2022-06-24_at_7.04.23_PM.png

    Data Received for Android platform:

    -
    {
    "c.e.cc": "TR",
    "c.e.dt": "mobile",
    "Key": "value",
    "c.i": "62b59b979f05a1f5e5592036",
    "c.l": "https:\/\/www.google.com\/",
    "c.m": "https:\/\/count.ly\/images\/logos\/countly-logo-mark.png?v2",
    "c.li": "notify_icon",
    "badge": "1",
    "sound": "custom",
    "title": "title",
    "message": "Message"
    }
    +
    {
    +"c.e.cc": "TR",
    +"c.e.dt": "mobile",
    +"Key": "value",
    +"c.i": "62b59b979f05a1f5e5592036",
    +"c.l": "https:\/\/www.google.com\/",
    +"c.m": "https:\/\/count.ly\/images\/logos\/countly-logo-mark.png?v2",
    +"c.li": "notify_icon",
    +"badge": "1",
    +"sound": "custom",
    +"title": "title",
    +"message": "Message"
    +}

    Data Received for iOS platform:

    -
    {
    Key = value;
    aps = {
    alert = {
    body = Message;
    subtitle = subtitle;
    title = title;
    };
    badge = 1;
    "mutable-content" = 1;
    sound = custom;
    };
    c = {
    a = "https://count.ly/images/logos/countly-logo-mark.png";
    e = {
    cc = TR;
    dt = mobile;
    };
    i = 62b5b945cabedb0870e9f217;
    l = "https://www.google.com/";
    };
    }
    -

    User location

    +
    {
    +Key = value;
    + aps = {
    +  alert = {
    +   body = Message;
    +   subtitle = subtitle;
    +   title = title;
    +  };
    + badge = 1;
    + "mutable-content" = 1;
    + sound = custom;
    + };
    + c = {
    +  a = "https://count.ly/images/logos/countly-logo-mark.png";
    +   e = {
    +    cc = TR;
    +    dt = mobile;
    +   };
    +  i = 62b5b945cabedb0870e9f217;
    +  l = "https://www.google.com/";
    + };
    +}
    +

    User location

    While integrating this SDK into your application, you might want to track your user location. You could use this information to better know your apps user base @@ -730,14 +771,14 @@ completionHandler(0); are 4 fields that can be provided:

      -
    • country code in the 2 letter iso standard
    • -
    • city name (has to be set together with country code)
    • -
    • +
    • country code in the 2 letter iso standard
    • +
    • city name (has to be set together with country code)
    • +
    • Comma separate latitude and longitude values, for example "56.42345,123.45325"
    • -
    • ip address of your user
    • +
    • ip address of your user
    -
    // send user location
    +
    // send user location
     Countly.setLocation("28.006324", "-82.7166183");

    When those values are set, they will be sent every time when initiating a session. @@ -752,13 +793,13 @@ Countly.setLocation("28.006324", "-82.7166183");

    It will erase cached location data from the device and the server.

    -

    Remote Config

    +

    Remote Config

    Remote config allows you to modiffy how your app functions or looks by requesting key-value pairs from your Countly server. The returned values can be modiffied based on the user profile. For more details please see Remote Config documentation.

    -

    Automatic remote config

    +

    Automatic remote config

    There are two ways of acquiring remote config data, by automatic download or manual request. By default, automatic remote config is disabled and therefore @@ -774,7 +815,7 @@ Countly.setLocation("28.006324", "-82.7166183");

    Note: call setRemoteConfigAutomaticDownload method before init

    -
    // Call this method before init
    +
    // Call this method before init
     Countly.setRemoteConfigAutomaticDownload(function(r){
       alert(r)
     }, function(r){
    @@ -791,14 +832,14 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       instead). It is possible that a previously valid key returns no value after an
       update.
     

    -

    Manual remote config

    +

    Manual remote config

    There are three ways for manually requesting a Remote Config update:

      -
    • Manually updating everything
    • -
    • Manually updating specific keys
    • -
    • Manually updating everything except specific keys
    • +
    • Manually updating everything
    • +
    • Manually updating specific keys
    • +
    • Manually updating everything except specific keys

    Each of these requests also has a callback. If that returns a non-null value, @@ -811,7 +852,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ The advantage is that you can make the request whenever it is desirable for you. It has a callback to let you know when it has finished.

    -
    Countly.remoteConfigUpdate(function(r){
    +
    Countly.remoteConfigUpdate(function(r){
       alert(r)
     }, function(r){
       alert(r);
    @@ -822,7 +863,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       updated. That list is an array with string values of those keys. It has a callback
       to let you know when the request has finished.
     

    -
    Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
    +
    Countly.updateRemoteConfigForKeysOnly(["name"], function(r){
       alert(r)
     }, function(r){
       alert(r);
    @@ -832,7 +873,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       updateRemoteConfigExceptKeys. The key list is a array with string values of the
       keys. It has a callback to let you know when the request has finished.
     

    -
    Countly.updateRemoteConfigExceptKeys(["url"], function(r){
    +
    Countly.updateRemoteConfigExceptKeys(["url"], function(r){
       alert(r)
     }, function(r){
       alert(r);
    @@ -843,7 +884,7 @@ Countly.setRemoteConfigAutomaticDownload(function(r){
       will update all values. This means that it will also erase all keys not returned
       by the server.
     

    -

    Getting Remote Config values

    +

    Getting Remote Config values

    To request a stored value, call getRemoteConfigValueForKey with the specified key. If it returns null then no value was found. The SDK has no @@ -851,22 +892,22 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ needs to cast it to the appropriate type. The returned values can also be a JSONArray, JSONObject or just a simple value like int.

    -
    Countly.getRemoteConfigValueForKey("name", function(r){
    +
    Countly.getRemoteConfigValueForKey("name", function(r){
        alert(r)
      }, function(r){
        alert(r);
      });
    -

    Clearing stored values

    +

    Clearing stored values

    At some point you might want to erase all values downloaded from the server. To achieve that you need to call one function, depicted below:

    -
    Countly.remoteConfigClearValues(function(r){
    +
    Countly.remoteConfigClearValues(function(r){
       alert(r)
     }, function(r){
       alert(r);
     });
    -

    User Feedback

    +

    User Feedback

    There are two ways of getting feedback from your users: Star rating dialog, feedback widget. @@ -875,8 +916,8 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ Star rating dialog allows users to give feedback as a rating from 1 to 5. The feedback widget allows to get the same 1 to 5 rating and also a text comment.

    -

    Ratings

    -

    Star Rating Dialog

    +

    Ratings

    +

    Star Rating Dialog

    Star rating integration provides a dialog for getting user's feedback about the application. It contains a title, simple message explaining what it is for, a @@ -894,17 +935,17 @@ Countly.setRemoteConfigAutomaticDownload(function(r){ either through the init function or the SetStarRatingDialogTexts function. If you don't want to override one of those values, set it to "null".

    -
    // Star Rating
    +
    // Star Rating
     countly.askForStarRating(Function(ratingResult){
       console.log(ratingResult);
     });
    -

    Rating Widget

    +

    Rating Widget

    Feedback widget shows a server configured widget to your user devices.

    - 002.png + 002.png

    It's possible to configure any of the shown text fields and replace with a custom @@ -925,14 +966,14 @@ countly.askForStarRating(Function(ratingResult){ you first have to get the widget ID from your server:

    - 003.png + 003.png

    Using that you can call the function to show the widget popup:

    -
    // Feedback Modal
    +
    // Feedback Modal
     countly.askForFeedback("5e425407975d006a22535fc", "close");
    -

    User Profiles

    +

    User Profiles

    Available with Enterprise Edition, User Profiles is a tool which helps you identify users, their devices, event timeline and application crash information. User @@ -951,7 +992,7 @@ countly.askForFeedback("5e425407975d006a22535fc", "close");

    After you have provided user profile information, you must save it by calling Countly.userData.save().

    -
    / example for setting user data
    +
    / example for setting user data
     var options = {};
     options.name = "Nicola Tesla";
     options.username = "nicola";
    @@ -964,55 +1005,59 @@ options.gender = "Male";
     options.byear = 1919;
     Countly.setUserData(options);

    The keys for predefined user data fields are as follows:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    KeyTypeDescription
    nameStringUser's full name
    usernameStringUser's nickname
    emailStringUser's email address
    organizationStringUser's organisation name
    phoneStringUser's phone number
    pictureStringURL to avatar or profile picture of the user
    genderStringUser's gender as M for male and F for female
    byearStringUser's year of birth as integer
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyTypeDescription
    nameStringUser's full name
    usernameStringUser's nickname
    emailStringUser's email address
    organizationStringUser's organisation name
    phoneStringUser's phone number
    pictureStringURL to avatar or profile picture of the user
    genderStringUser's gender as M for male and F for female
    byearStringUser's year of birth as integer
    +

    Using "" for strings or a negative number for 'byear' will effectively delete that property. @@ -1022,13 +1067,13 @@ Countly.setUserData(options);

    on your Countly backend. Note: keys with . or $ symbols will have those symbols removed.

    -

    Setting custom values

    +

    Setting custom values

    Additionally you can do different manipulations on your custom data values, like increment current value on server or store a array of values under the same property.

    Below is the list of available methods:

    -
    // example for extra user features
    +
    // example for extra user features
     
     Countly.userData.setProperty("setProperty", "My Property");
     Countly.userData.increment("increment");
    @@ -1043,7 +1088,7 @@ Countly.userData.pullValue("pullValue", "morning");

    In the end always call Countly.userData.save() to send them to the server.

    -

    Application Performance Monitoring

    +

    Application Performance Monitoring

    Performance Monitoring feature allows you to analyze your application's performance on various aspects. For more details please see @@ -1053,20 +1098,20 @@ Countly.userData.pullValue("pullValue", "morning");

    Here is how you can utilize Performance Monitoring feature in your apps:

    First, you need to enable Performance Monitoring feature::

    -
    Countly.enableApm(); 
    +
    Countly.enableApm(); 
     // Enable APM features.

    With this, Countly SDK will start measuring some performance traces automatically. Those include app foreground time, app background time. Additionally, custom traces and network traces can be manually recorded.

    -

    App Start Time

    +

    App Start Time

    For the app start time to be recorded, you need to call the appLoadingFinished method. Make sure this method is called after init.

    -
    // Example of appLoadingFinished
    +
    // Example of appLoadingFinished
     Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
       Countly.appLoadingFinished();
     },(err) => {
    @@ -1081,19 +1126,19 @@ Countly.init("https://try.count.ly", "YOUR_APP_KEY").then((result) => {
       the app launch time can be recorded only once per app launch. So, the second
       and following calls to this method will be ignored.
     

    -

    Custom traces

    +

    Custom traces

    You may also measure any operation you want and record it using custom traces. First, you need to start a trace by using the startTrace(traceKey) method:

    -
    Countly.startTrace(traceKey);
    +
    Countly.startTrace(traceKey);

    Then you may end it using the endTrace(traceKey, customMetric)method, optionally passing any metrics as key-value pairs:

    -
    String traceKey = "Trace Key"
    +
    String traceKey = "Trace Key"
     ;
     Map<String, int> customMetric = {
       "ABC": 1233,
    @@ -1110,13 +1155,13 @@ Countly.endTrace(traceKey, customMetric);
    You may also cancel any custom trace you started, using cancelTrace(traceKey)method:

    -
    Countly.cancelTrace(traceKey);
    +
    Countly.cancelTrace(traceKey);

    Additionally, if you need you may cancel all custom traces you started, using clearAllTraces()method:

    -
    Countly.clearAllTraces(traceKey);
    -

    Network traces

    +
    Countly.clearAllTraces(traceKey);
    +

    Network traces

    You may record manual network traces using theecordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime) method. @@ -1136,9 +1181,9 @@ Countly.endTrace(traceKey, customMetric);

    time of the request - endTime: UNIX time stamp in milliseconds for the ending time of the request

    -
    Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
    +
    Countly.recordNetworkTrace(networkTraceKey, responseCode, requestPayloadSize, responsePayloadSize, startTime, endTime);
    -

    User Consent

    +

    User Consent

    To be compliant with GDPR, starting from 18.04, Countly provides ways to toggle different Countly features on/off depending on the given consent. @@ -1148,7 +1193,7 @@ Countly.endTrace(traceKey, customMetric);

    By default the requirement for consent is disabled. To enable it, you have to call setRequiresConsent with true, before initializing Countly.

    -
    Countly.setRequiresConsent(true);
    +
    Countly.setRequiresConsent(true);

    By default no consent is given. That means that if no consent is enabled, Countly will not work and no network requests, related to features, will be sent. When @@ -1167,7 +1212,7 @@ Countly.endTrace(traceKey, customMetric);

    If consent is removed, but the appropriate function can't be called before the app closes, it should be done at next app start so that any relevant server side - features could be disabled (like reverse geo ip for location). + features could be disabled (like reverse geo ip for location)

    Feature names in the Android SDK are stored as static fields in the class called @@ -1175,104 +1220,96 @@ Countly.endTrace(traceKey, customMetric);

    The current features are:

      -
    • +
    • sessions - tracking when, how often and how long users use your app
    • -
    • events - allow sending events to server
    • -
    • views - allow tracking which views user visits
    • -
    • location - allow sending location information
    • -
    • crashes - allow tracking crashes, exceptions and errors
    • -
    • +
    • events - allow sending events to server
    • +
    • views - allow tracking which views user visits
    • +
    • location - allow sending location information
    • +
    • crashes - allow tracking crashes, exceptions and errors
    • +
    • attribution - allow tracking from which campaign did user come
    • -
    • +
    • users - allow collecting/providing user information, including custom properties
    • -
    • push - allow push notifications
    • -
    • starRating - allow to send their rating and feedback
    • -
    • apm - allow application performance monitoring
    • -
    • +
    • push - allow push notifications
    • +
    • starRating - allow to send their rating and feedback
    • +
    • apm - allow application performance monitoring
    • +
    • remote-config - allows downloading remote config values from your server
    -

    Changing consent

    +

    Changing consent

    There are 3 ways of changing feature consent:

      -
    • +
    • giveConsentInit - To add consent for a single feature (string parameter) or a subset of features (array of strings parameter). Use this method for giving consent before initializing.
    -
    //giveConsent
    +
    //giveConsent
     Countly.giveConsentInit(["events", "views", "star-rating", "crashes"]);
     
     // removeConsent
     Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
      -
    • +
    • giveConsent/removeConsent - gives or removes consent to a specific feature
    -
    //giveConsent
    +
    //giveConsent
     Countly.giveConsent(["events", "views", "star-rating", "crashes"]);
     
     // removeConsent
     Countly.removeConsent(["events", "views", "star-rating", "crashes"]);
      -
    • +
    • giveAllConsent/removeAllConsent - giveAll or removeAll consent to a specific feature
    -
    //giveAllConsent
    +
    //giveAllConsent
     Countly.giveAllConsent();
     
     //removeAllConsent
     Countly.removeAllConsent();
     
    -

    Security and privacy

    -

    Parameter Tampering Protection

    +

    Security and privacy

    +

    Parameter Tampering Protection

    You can set optional salt to be used for calculating checksum of request data, which will be sent with each request using &checksum field. You need to set exactly the same salt on Countly server. If salt on Countly server is set, all requests would be checked for validity of &checksum field before being processed.

    -
    // sending data with salt
    +
    // sending data with salt
     Countly.enableParameterTamperingProtection("salt");
    -

    Using Proguard

    +

    Using Proguard

    If you are using Countly Messaging in your Android application, it is recommended to obfuscate the Countly Messaging classes using Proguard. To do so, please follow the instructions below:

      -
    1. -

      - Locate the app/proguard-rules.pro file within the /android/app/ folder. -

      -
    2. -
    3. -

      Add the following lines to the file:

      +
    4. + Locate the app/proguard-rules.pro file within the /android/app/ folder.
    5. +
    6. Add the following lines to the file:
    -
    -keep class ly.count.android.sdk.** { *; }
    +
    -keep class ly.count.android.sdk.** { *; }
     
      -
    1. -

      - If Proguard is not yet configured, you must first enable shrinking and - obfuscation in the build file. To do so, locate the build.gradle file - within the /android/app/ folder. -

      -
    2. -
    3. -

      Add the following lines in bold to the build.gradle file:

      +
    4. + If Proguard is not yet configured, you must first enable shrinking and obfuscation + in the build file. To do so, locate the build.gradle file within the /android/app/ + folder.
    5. +
    6. Add the following lines in bold to the build.gradle file:
    -
    ...
    +
    ...
     
     buildTypes {
             release { // Enables code shrinking, obfuscation, and optimization for only your project's release build type.
    @@ -1287,8 +1324,8 @@ buildTypes {
       By following these steps, the Countly Messaging classes will be obfuscated using
       Proguard and your application will be better protected against reverse engineering.
     

    -

    Other features

    -

    Forcing HTTP POST

    +

    Other features

    +

    Forcing HTTP POST

    If the data sent to the server is short enough, the sdk will use HTTP GET requests. In case you want an override so that HTTP POST is used in all cases, call the @@ -1296,9 +1333,9 @@ buildTypes { to later in the apps life cycle disable the override. This function has to be called every time the app starts.

    -
    Countly.setHttpPostForced(true); // default is false
    +
    Countly.setHttpPostForced(true); // default is false
     
    -

    Optional parameters during initialization

    +

    Optional parameters during initialization

    You can provide optional parameters that will be used during begin_session request. They must be set right after the init function so that they are @@ -1310,13 +1347,13 @@ buildTypes {

    The optional parameters are:

      -
    • Country code: ISO Country code for the user's country
    • -
    • City: Name of the user's city
    • -
    • +
    • Country code: ISO Country code for the user's country
    • +
    • City: Name of the user's city
    • +
    • Location: Comma separate latitude and longitude values, for example "56.42345,123.45325"
    -
    
    +
    
     //setting optional parameters
     Countly.setOptionalParametersForInitialization({
         city: "Tampa",
    @@ -1327,4 +1364,4 @@ Countly.setOptionalParametersForInitialization({
     });
     
     //and then call the below code
    -Countly.init(this, "https://YOUR_SERVER", "YOUR_APP_KEY", "YOUR_DEVICE_ID")
    +Countly.init(this, "https://YOUR_SERVER", "YOUR_APP_KEY", "YOUR_DEVICE_ID")
    \ No newline at end of file diff --git a/legacy_docs/iot_devices_python/current.md b/legacy_docs/iot_devices_python/current.md index 0de56f6f..e06dcbb8 100644 --- a/legacy_docs/iot_devices_python/current.md +++ b/legacy_docs/iot_devices_python/current.md @@ -1,91 +1,91 @@

    - This documentation shows how to download and use different IoT device SDKs. + This documentation shows how to download and use different IoT device SDKs.

    -

    Installing and Using Countly IoT Raspberry Pi SDK

    +

    Installing and Using Countly IoT Raspberry Pi SDK

    - The Countly Raspberry Pi SDK is one of the Countly iOT SDK families which sends data to the Countly server. After this SDK sends data to Countly, you may visualize it on the dashboard. The server takes care of both storing data and visualizing it for you, so you can get more insights from your devices. + The Countly Raspberry Pi SDK is one of the Countly iOT SDK families which sends data to the Countly server. After this SDK sends data to Countly, you may visualize it on the dashboard. The server takes care of both storing data and visualizing it for you, so you can get more insights from your devices.

    - If a device doesn’t have an internet connection and cannot send data, the SDK stores this data and then sends it to the queue. Items in this queue are then sent one-by-one after an internet connection has been established. + If a device doesn’t have an internet connection and cannot send data, the SDK stores this data and then sends it to the queue. Items in this queue are then sent one-by-one after an internet connection has been established.

    - You may add your Raspberry Pi Python SDK to your project in two different ways. + You may add your Raspberry Pi Python SDK to your project in two different ways.

    1st method: Getting the code from Github

    - The command below copies the SDK from Github directly to your computer. It needs the git command to be available on your operating system. + The command below copies the SDK from Github directly to your computer. It needs the git command to be available on your operating system.

    -
    git clone https://github.com/Countly/countly-sdk-iot.git .
    +
    git clone https://github.com/Countly/countly-sdk-iot.git .

    - Now, you may copy the Countly.py command to your project folder: + Now, you may copy the Countly.py command to your project folder:

    -
    cp raspberry_pi/Raspberry_SDK/Countly.py   your_project_folder
    +
    cp raspberry_pi/Raspberry_SDK/Countly.py   your_project_folder
     

    - In order to import Countly in Python, use this line in your example py file: + In order to import Countly in Python, use this line in your example py file:

    -
    from yourpackage.Countly import Countly
    +
    from yourpackage.Countly import Countly
     

    2nd method: Download using pip, easy Python installer

    - If you have pip command installed on your system, you may run the following command. This easily installs the Countly SDK into your system, so you may directly call it inside your app. + If you have pip command installed on your system, you may run the following command. This easily installs the Countly SDK into your system, so you may directly call it inside your app.

    -
    pip install Raspberry_SDK
    +
    pip install Raspberry_SDK
     

    - In order to use the Countly SDK in your Python app, you may add it as follows: + In order to use the Countly SDK in your Python app, you may add it as follows:

    -
    from Raspberry_SDK.Countly import Countly
    +
    from Raspberry_SDK.Countly import Countly
     
    -

    Using the Countly IoT Raspberry Pi SDK

    +

    Using the Countly IoT Raspberry Pi SDK

    To initiate the SDK without a timer,

    -
    countly = Countly("SERVER_URL", "APP_KEY", 0)
    +
    countly = Countly("SERVER_URL", "APP_KEY", 0)
     

    - where server_URL is the IP or name of the server, and APP_KEY is the application key that you retrieved from the dashboard once you create the application. + where server_URL is the IP or name of the server, and APP_KEY is the application key that you retrieved from the dashboard once you create the application.

    - To initiate the timer with a frequency, use the following: + To initiate the timer with a frequency, use the following:

    -
    countly = Countly("SERVER_URL", "APP_KEY", TIMER_SECOND)
    +
    countly = Countly("SERVER_URL", "APP_KEY", TIMER_SECOND)
     

    - In order to send a specific event, use this command: + In order to send a specific event, use this command:

    -
    countly.event(‘EVENT_NAME’, EVENT_VALUE)
    +
    countly.event(‘EVENT_NAME’, EVENT_VALUE)
     
    -

    Example scenario

    +

    Example scenario

    - The best method for retrieving data from the Raspberry Pi GPIO is to use the Grove interface. Grove is basically a ready-to-use toolset meant to ease the use of SPI, I2C, UART in analog and digital circuits. Prepared by Seeed Studio, it includes several sensors, I/O units, switches, lights, and joysticks. + The best method for retrieving data from the Raspberry Pi GPIO is to use the Grove interface. Grove is basically a ready-to-use toolset meant to ease the use of SPI, I2C, UART in analog and digital circuits. Prepared by Seeed Studio, it includes several sensors, I/O units, switches, lights, and joysticks.

    - Not only does Grove work with Raspberry Pi, it also works with several industrial, well-known development boards, such as Arduino, Intel Edison, and Beagle Bone Green. For more information about Grove, follow this link. To use Grove in Raspberry Pi, a shield-like card called Grove Pi is used. + Not only does Grove work with Raspberry Pi, it also works with several industrial, well-known development boards, such as Arduino, Intel Edison, and Beagle Bone Green. For more information about Grove, follow this link. To use Grove in Raspberry Pi, a shield-like card called Grove Pi is used.

    - In order to use Grove sensors and the Grove Pi shield, create an account on Countly. An App Key will automatically be created for you. We’ll use this key inside the SDK in places where it is relevant. + In order to use Grove sensors and the Grove Pi shield, create an account on Countly. An App Key will automatically be created for you. We’ll use this key inside the SDK in places where it is relevant.

    -

    Raspberry Pi configuration

    +

    Raspberry Pi configuration

    - You may find the necessary configuration regarding how to use Python and Grove with Raspberry Pi. We will need this configuration, so start reading and implementing what is written here. + You may find the necessary configuration regarding how to use Python and Grove with Raspberry Pi. We will need this configuration, so start reading and implementing what is written here.

    - After installing Grove, you may install the Countly SDK: + After installing Grove, you may install the Countly SDK:

    -
    pip install Raspberry_SDK
    +
    pip install Raspberry_SDK

    - In our example scenario, we have a light sensor. This sensor is connected to the Grove input Analog 0. After configuring the Grove Pi and Grove light sensors, the following code may be used to send light sensor data to the Countly servers: + In our example scenario, we have a light sensor. This sensor is connected to the Grove input Analog 0. After configuring the Grove Pi and Grove light sensors, the following code may be used to send light sensor data to the Countly servers:

    -
    import threading
    +
    import threading
     import grovepi 
     from raspberry_pi.Raspberry_SDK.Countly import Countly
      
    @@ -99,5 +99,5 @@ def grove():
      
     grove()

    - You have now finished sending data from Raspberry Pi to your server. + You have now finished sending data from Raspberry Pi to your server.

    \ No newline at end of file diff --git a/legacy_docs/react_native_old/current.md b/legacy_docs/react_native_old/current.md index fcd86b18..d72ebcf6 100644 --- a/legacy_docs/react_native_old/current.md +++ b/legacy_docs/react_native_old/current.md @@ -1,5 +1,5 @@
    -

    This is an unmaintained SDK

    +

    This is an unmaintained SDK

    You are suggested to use React Native (bridge) SDK instead. This SDK will be declared as end-of-life very soon. @@ -10,14 +10,14 @@ It is based on the following:

      -
    • react-native-cli: 2.0.1
    • -
    • react-native: 0.49.1
    • +
    • react-native-cli: 2.0.1
    • +
    • react-native: 0.49.1

    There are other ways to create a react Native application. Our SDK works with all methods, but in this document we are going to show react-native cli.

    -

    Creating a new application

    +

    Creating a new application

    Before creating a new application, please look at the documentation here. @@ -31,7 +31,7 @@ Enter following commands to install react-native-cli and configure your environment.

    -
    npm install -g react-native-cli     # Install React Native
    +
    npm install -g react-native-cli     # Install React Native
     react-native init AwesomeProject    # Create a new project
     
     cd AwesomeProject                   # Go to that directory
    @@ -41,12 +41,12 @@ react-native run-ios                # Run the iOS project
     # New terminal
     adb reverse tcp:8081 tcp:8081       # Link Android port
     npm start                           # Run the build server
    -

    Installing the SDK

    +

    Installing the SDK

    Run the following snippet in the root of your react native project to install the npm dependencies and link the native libraries.

    -
    # Add dependencies
    +
    # Add dependencies
     npm install --save react-native-device-info
     npm i react-native-background-timer --save
     npm i react-native-restart
    @@ -61,11 +61,11 @@ npm install --save countly-sdk-react-native
       and
       for iOS.
     

    -

    SDK Usage

    +

    SDK Usage

    Please see below on how to initialize and start Countly SDK.

    -
    // In your javascript code 
    +
    // In your javascript code 
     
     import Countly from 'countly-sdk-react-native';
     
    @@ -113,7 +113,7 @@ Countly.stop().then((result) => {
       If you want to initialize and start session separately you can do like shown
       below.
     

    -
    // In your javascript code 
    +
    // In your javascript code 
     
     import Countly from 'countly-sdk-react-native';
     
    @@ -142,25 +142,25 @@ Countly.init("https://try.count.ly","app_key","deviceId")
       you provide a deviceID, then it will take that as DeviceId. For example, you
       can use hashed value of user's email as a deviceID.
     

    -

    Sending events

    +

    Sending events

    You can send events with segmentations using following examples.

    Example for sending a basic event:

    -
    var event = {"key":"basic_event","count":1};
    +
    var event = {"key":"basic_event","count":1};
     Countly.recordEvent(event);

    Example for sending event with sum:

    -
    var event = {"key":"event_sum","count":1,"sum":"0.99"};
    +
    var event = {"key":"event_sum","count":1,"sum":"0.99"};
     Countly.recordEvent(event);

    Example for sending event with a segmentation value (in this case, Germany and Age):

    -
    var event = {"key":"event_segment","count":1};
    +
    var event = {"key":"event_segment","count":1};
     event.segmentation = {"Country" : "Germany", "Age" : "28"};
     Countly.recordEvent(event);

    Example for sending event with segmentation value and sum:

    -
    var event = {"key":"event_segment_sum","count":1,"sum":"0.99"};
    +
    var event = {"key":"event_segment_sum","count":1,"sum":"0.99"};
     event.segmentation = {"Country" : "Turkey", "Age" : "28"};
     
     Countly.recordEvent(event);
    @@ -169,13 +169,13 @@ Countly.recordEvent(event);
    to complete. If you send a timed event, then under Countly dashboard you will see its duration (in seconds).

    -
    Countly.startEvent("timedEvent");
    +
    Countly.startEvent("timedEvent");
     Countly.endEvent("timedEvent");

    Duration of the event will be calculated automatically when endEvent method is called.

    -

    Push Notifications

    +

    Push Notifications

    This section requires setting up either APNS (Apple Push Notification Services) or FCM (Firebase Cloud Services). For APNS, you need to get push credentials @@ -186,7 +186,7 @@ Countly.endEvent("timedEvent");

    First, install react-native-firebase plugin to implement push notifications.

    -
    npm install --save react-native-firebase
    +
    npm install --save react-native-firebase
     
     // Link Firebase
     react-native link react-native-firebase
    @@ -195,8 +195,8 @@ react-native link react-native-firebase
    can follow the below given steps to guide you through.

      -
    1. Setup google-services.json
    2. -
    3. +
    4. Setup google-services.json
    5. +
    6. A google-services.json file contains all of the information required by the Firebase Android SDK to connect to your Firebase project. To automatically generate the json file, follow the instructions on the Firebase console to @@ -208,7 +208,7 @@ react-native link react-native-firebase
    In order for Android to parse this file, add the google-services gradle plugin as a dependency to your project in the project level build.gradle file (android/build.gradle):

    -
    buildscript {
    +
    buildscript {
         repositories {
             google()  // < Check this line exists and is above jcenter.
             jcenter()
    @@ -223,10 +223,10 @@ react-native link react-native-firebase

    Now setup gradle dependencies in your android/app/build.gradle file :

    -
    dependencies {
    +
    dependencies {
         ...
         //These should be already present in your gradle file.
    -    implementation project(':react-native-firebase')
    +  	implementation project(':react-native-firebase')
         
         //Add these lines
         implementation "com.google.android.gms:play-services-base:16.0.1"
    @@ -240,7 +240,7 @@ apply plugin: 'com.google.gms.google-services'
     

    Now go to your MainApplication.java and add these imports if not present.

    -
    //add these imports if not present.  
    +
    //add these imports if not present.  
     import io.invertase.firebase.RNFirebasePackage;
     import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; 
     import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage; 
    @@ -258,7 +258,7 @@ protected List getPackages() {
      );                               
     }

    Add these lines to your Android Manifest file

    -
    ...
    +
    ...
      <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
       <uses-permission android:name="android.permission.VIBRATE" />
         <uses-permission android:name="android.permission.INTERNET" />
    @@ -284,13 +284,13 @@ protected List getPackages() {
     </application>
     

    Add these lines in settings.gradle:

    -
    include ':react-native-firebase'                       
    +
    include ':react-native-firebase'                       
     project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
     

    Now go again to your android/app/build.gradle and add this line:

    -
    dependencies {
    +
    dependencies {
       compile project(':react-native-firebase')
       ...
     }
    @@ -299,8 +299,8 @@ project(':react-native-firebase').projectDir = new File(rootProject.projectDir, we proceed please make sure you have generated your certificates properly.

      -
    1. Setup GoogleService-Info.plist
    2. -
    3. +
    4. Setup GoogleService-Info.plist
    5. +
    6. A GoogleService-Info.plist file contains all of the information required by the Firebase iOS SDK to connect to your Firebase project. To automatically generate the plist file, follow the instructions on the Firebase console @@ -312,13 +312,13 @@ project(':react-native-firebase').projectDir = new File(rootProject.projectDir, APP NAME]"…' in XCode.

        -
      1. Initialize Firebase
      2. -
      3. +
      4. Initialize Firebase
      5. +
      6. To initiaize the native SDK in your app, add the following to your ios/[YOUR APP NAME]/AppDelegate.h file:
      -
      //At the begining of your file
      +
      //At the begining of your file
       #import 
       ...
       //At the beginning of the didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method add the following line:
      @@ -330,7 +330,7 @@ project(':react-native-firebase').projectDir = new File(rootProject.projectDir,
         and run command pod init and then add Firebase/Core and Firebase/Messaging
         as shown below:
       

      -
      
      +
      
       # Uncomment the next line to define a global platform for your project
       platform :ios, '9.0'
       
      @@ -353,9 +353,9 @@ end
         Now open your project on Xcode from and goto Capabilities and do the following:
       

        -
      1. Turn on Push Notifications
      2. -
      3. Turn on Background modes
      4. -
      5. Check Remote notifications
      6. +
      7. Turn on Push Notifications
      8. +
      9. Turn on Background modes
      10. +
      11. Check Remote notifications

      Now, go to Build Phases. Click on the “+” under “Link Binary With Libraries” @@ -364,10 +364,10 @@ end Search Path, double click its value and press “+” button. Add following line there.

      -
      $(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase
      +
      $(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase
       

      Go to AppDelegate.h and add those lines:

      -
      #import <UIKit/UIKit.h>
      +
      #import <UIKit/UIKit.h>
       #import <UserNotifications/UserNotifications.h>
       
       @interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
      @@ -376,7 +376,7 @@ end
       
       @end

      Now Add Firebase package in your AppDelegate.m as follows:

      -
      #import "AppDelegate.h"
      +
      #import "AppDelegate.h"
       //Add these lines
       #import 
       #import "RNFirebaseNotifications.h"
      @@ -437,7 +437,7 @@ fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHand
         and follow the instructions to setup push notification action. This step should
         only be performed for iOS project only else it will generate an error.
       

      -
      # For push notifications action support in iOS
      +
      # For push notifications action support in iOS
       
       npm install --save https://github.com/nodexpertsdev/react-native-ios-notification-actions
       react-native link
      @@ -447,7 +447,7 @@ react-native link
       # of the push notification payload
       

      To initialize push notification, use the following:

      -
      // To initialize the push notification.
      +
      // To initialize the push notification.
       // For Android we have two types of users i.e test and production users
       // For test mode use Countly.TEST
       // For production mode use Countly.PRODUCTION
      @@ -496,7 +496,7 @@ constructor(props) {
       

      Add below lines in index.js for enabling background messaging.

      -
      import Countly from 'countly-sdk-react-native';
      +
      import Countly from 'countly-sdk-react-native';
       
       const id = 'your_channel_id';
       
      @@ -504,9 +504,9 @@ const id = 'your_channel_id';
       AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => {
         return message => Countly.bgMessaging(message, id);
       });
      -

      User Profiles

      +

      User Profiles

      -

      Enterprise Edition Feature

      +

      Enterprise Edition Feature

      This feature is only available with Enterprise Edition subscription.

      @@ -516,7 +516,7 @@ AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => { dashboard by recording user details. You can record default and custom properties of user details like this:

      -
      Countly.setUserData({
      +
      Countly.setUserData({
           "name": "Name Surname",
           "username": "xyz",
           "email": "xyz@gmail.com",
      @@ -534,42 +534,42 @@ AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => {
       

      In addition, you can use custom user details modifiers like this:

      -
      Countly.userData.setProperty("setPropertyKey", "setPropertyKeyValue");
      +
      Countly.userData.setProperty("setPropertyKey", "setPropertyKeyValue");
       Countly.userData.increment("incrementKey");
       Countly.userData.incrementBy("incrementByKey", 10);
       Countly.userData.multiply("multiplyKey", 20);
       Countly.userData.saveMax("saveMaxKey", 100);
       Countly.userData.saveMin("saveMinKey", 50);
       Countly.userData.setOnce("setOnceKey", 200);
      -

      Manual Tracking of View (Screen)

      +

      Manual Tracking of View (Screen)

      You can record (track) view as well as the time for which user has visited the particular screen.

      -
      // Example for recording view
      +
      // Example for recording view
       Countly.recordView(ViewName); // ViewName will be your screen name

      You can also track (record) the action performed on the view.

      -
      // To record an action:
      +
      // To record an action:
       Countly.recordViewActions(actionType, touchCoordinate);
       
       // where actionType may be 'touch', 'swipe' etc... and 
       // TouchCoordinate is the x, y axis of touch point.
      -

      Crash Reporting

      +

      Crash Reporting

      Countly can send automated crash reporting to a Countly server. Below you can see how to enable it.

      First, add dependencies to your application:

      -
      npm i react-native-exception-handler --save
      +
      npm i react-native-exception-handler --save
       npm i react-native-restart
       react-native link 

      Then, outside the root component add the following and enable crash reporting feature.

      -
      // Outside the root component add the following line.
      +
      // Outside the root component add the following line.
       // Setting first parameter to true will enable crash 
       // reporting in production mode.
       
      @@ -580,7 +580,7 @@ Countly.enableCrashReporting(true); 
      recommended not to use crash reporting in development mode - it is used to hide the internal error from user and send the issue to the developer.

      -
      Countly.enableCrashReporting(true, true); 
      +
      Countly.enableCrashReporting(true, true); 

      If the crash occurred, SDK sends the crash data to Countly and shows an alert box having the crash message and a Restart button. Restart button will restart @@ -590,7 +590,7 @@ Countly.enableCrashReporting(true);

      If you want to customize the default alert box functionality and message you can do so by changing in config variable as shown below.

      -
      // Config variable to customize default alert box.
      +
      // Config variable to customize default alert box.
       
       Countly.defaultAlert = {
       // default value will be false.
      @@ -609,7 +609,7 @@ Countly.defaultAlert = {
         Further, if you think that you want to create your own custom crash log method
         you can do so by following the below instructions.
       

      -
      // create your custom method
      +
      // create your custom method
       
       const crashMethod = () => {
       // This is optional. If you want to send your custom 
      @@ -629,14 +629,14 @@ const crashMethod = () => {
       // This will disable default crash method and enable your crash method.
       Countly.customCrashLog = crashMethod; 
      -

      Important note

      +

      Important note

      All crash method definition and crash config assignment will be done in root component file of your application (which will be index.js/ index.android.js/ index.ios.js/ App.js) and outside the React class.

      -

      Parameter Tampering

      +

      Parameter Tampering

      This is one of the preventive measures of Countly. If someone in the middle intercepts the request, it would be possible to change the data in the request and make @@ -653,51 +653,51 @@ Countly.customCrashLog = crashMethod;

      of request data, which will be sent with each request using &checksum256 field. You need to set exactly the same secretSalt on Countly under - Management > Applications>"your_app">Salt for checksum. + Management > Applications>"your_app">Salt for checksum. If secretSalt on Countly Server is set, all requests would be checked for validity of &checksum256 field before being processed.

      -
      npm install crypto-js;
      +
      npm install crypto-js;

      and from your app use below lines to set your secret salt

      -
      // set salt in Countly SDK config
      +
      // set salt in Countly SDK config
       Countly.secretSalt = 'XYZ';

      If SALT is not provided, SDK makes ordinary requests without any checksums.

      -

      Star Rating

      +

      Star Rating

      For the rating purpose of your application, you can use star rating component of Countly by implementing steps.

      -
      // Dependency to use Countly Star Rating feature
      +
      // Dependency to use Countly Star Rating feature
       
       npm install --save react-native-modal
       react-native link
       

      For importing star rating component from Countly:

      -
      import { StarRating } from 'countly-sdk-react-native';
      +
      import { StarRating } from 'countly-sdk-react-native';

      Then use star rating component as follows:

      -
       this.setState({isVisible: false})} // required
      +
       this.setState({isVisible: false})} // required
       />
         
       // Default values for optional field:
       // noOfStars = 5
       // message = 'How would you rate the app?'
       // dismissButtonTitle = Dismiss
      -

      Other SDK usage scenarios

      -

      Using custom device ID

      +

      Other SDK usage scenarios

      +

      Using custom device ID

      If you want to use custom device ID, you can change it as follows. Note that once set, device ID will be persistently stored in device on the first launch, and will not change even after app delete and re-install, unless you change it explicitly.

      -
      Countly.changeDeviceId("654321");
      -

      Change DeviceId on server

      +
      Countly.changeDeviceId("654321");
      +

      Change DeviceId on server

      If you want to change the device ID on Countly server, follow steps below.

      -
      // First parameter is onServer
      +
      // First parameter is onServer
       let onServer = ture;
       
       // Then call the setNewDeviceId method to set the new Device Id
      @@ -708,17 +708,17 @@ Countly.setNewDeviceId(onServer, newDeviceId);
       // If onServer is false then current session will be end and the new session starts with new DeviceId.
       
       // If onServer is true than the new session metrics will contain new DeviceId and the old deviceId data will be merged with the new DeviceId.
      -

      Force SDK to make POST request by default

      -
      // Call method setHttpPostForced with parameter true, as shown below
      +

      Force SDK to make POST request by default

      +
      // Call method setHttpPostForced with parameter true, as shown below
       
       Countly.setHttpPostForced(true);
      -

      SSL Certificate Pinning

      +

      SSL Certificate Pinning

      To secure the request from "Man in the Middle" attack, you can implement SSL Certificate Pinning in your application. Below are the steps to implement SSL Certificate Pinning.

      -
      // Install dependencies
      +
      // Install dependencies
       npm i react-native-pinch
       
       // Link the libraries using the following command
      @@ -733,7 +733,7 @@ react-native link react-native-pinch
      Then you need to set the name of the .cer file in Countly.cerFileName config flag as shown below.

      -
      // Notice the file name you should set to the config flag 
      +
      // Notice the file name you should set to the config flag 
       // doesn't have an extension.
       
       Countly.cerFileName = "fileName";
      diff --git a/legacy_docs/unity_previous/current.md b/legacy_docs/unity_previous/current.md new file mode 100644 index 00000000..37675e11 --- /dev/null +++ b/legacy_docs/unity_previous/current.md @@ -0,0 +1,858 @@ +

      + This document explains how to download, setup and use Unity SDK for Countly. + You can + download latest release from Github. +

      +

      + Following are some of the key assumptions being considered while developing the + SDK. Please take into account following considerations before integrating this + SDK: +

      +
        +
      1. This SDK is developed in Unity 2018 2.7f1
      2. +
      3. Scripting version is based on .NET 4.x equivalent
      4. +
      5. API Compatibility Level is based on .NET 4.x
      6. +
      +

      Integration

      +
        +
      1. + Clone/download the source code from github- + https://github.com/Countly/countly-sdk-unity +
      2. +
      3. Unzip the package (if you have downloaded ZIP file).
      4. +
      5. + Look for a folder named “Assets”. Copy all the contents of “Assets” folder + and paste it inside your app’s Assets folder. Unity will import the new assets + now. +
      6. +
      7. + Now, update the following player settings: a. Package Name: App's Bundle + ID b. Scripting Runtime Version: .NET 4x Equivalent +
      8. +
      9. + Create an account on Firebase (firebase.google.com). Go to Firebase Console + (https://console.firebase.google.com/). + Create a new project. +
      10. +
      11. + Add your app (Android/iOS) to the project created in Step 4. Specify the + same package name that you specified in Unity Editor for your app. +
      12. +
      13. + Register your app and download google-services.json for Android + or GoogleService-Info.plist for iOS file, at Step 2 of the registration + process. We do not need to proceed after step 2. So, leave the further steps. +
      14. +
      15. + Place the file downloaded under your app's Assets folder. +
      16. +
      17. + Run Android Resolver in case of Android from + Assets > Play Service Resolver > + Android Resolver => Resolve. For iOS we don’t + need to do anything. +
      18. +
      19. + Attach AppInitScript.cs file to the main scene of your Unity + application. +
      20. +
      +

      + Note that a script named “Testing.cs” under folder “Assets\Scripts\Main\Testing” + contains examples to test all the features of the SDK. You can take reference + from this script to know how to utilize each feature of the SDK. +

      +

      Initializing the SDK

      +

      + To initialize Countly Unity SDK, use following two methods with appropriate parameters. + Note that the following two methods should be added inside your application start + event, in the exact order with method Begin being called before + method SetDefaults. +

      +

      + Begin method +

      +
      Countly.Begin(string serverUrl, string appKey, string deviceId = null);
      +

      + serverUrl: Required Type: string + Description: The URL of the Countly Server where you are going + to post our requests. Example: + https://us-try.count.ly/ +

      +

      + appKey: Required Type: string + Description: The “App Key” for the app that you created on Countly + Server. Example: 124qw3er5u678qwef88d6123456789qwertyui123 +

      +

      + deviceId: Optional Type: string + Description: Your Device ID. It is an optional parameter. + Example: f16e5af2-8a2a-4f37-965d-qwer5678ui98 +

      +

      + If you do not provide device ID during initialization, SDK will generate a Device + ID on its own and use this Device ID for all future requests made to the Countly + server. This Device ID is persisted by the SDK per device. +

      +

      + If you provide a device ID to the SDK and later you are initializing the SDK + again with a different device ID, the old Device ID will be used by the SDK and + not the new one because the priority is as follows: +

      +

      + Cached Device ID > Provided Device ID Upon Initialization > SDK Generated Device ID +

      +
      +

      Which server/host name should I use inside SDK?

      +

      + If you are using Countly Enterprise trial servers, use corresponding server + name, e.g., https://try.count.ly, + https://us-try.count.ly or + https://asia-try.count.ly +

      +

      + If you use Countly Lite and Countly Enterprise, use your own domain name. +

      +
      +

      + SetDefaults +

      +

      + This method takes as input an instance of CountlyConfigModel class. + The constructor for CountlyConfig model takes following list of + parameters (the default values are mentioned alongside each one of them): +

      +
        +
      1. string salt = NULL
      2. +
      3. bool enablePost = false
      4. +
      5. bool enableConsoleErrorLogging = false
      6. +
      7. bool ignoreSessionCooldown = false
      8. +
      9. bool enableManualSessionHandling = false
      10. +
      11. int sessionDuration = 60
      12. +
      13. int eventThreshold = 100
      14. +
      15. int storedRequestLimit = 1000
      16. +
      17. int totalBreadcrumbsAllowed = 100
      18. +
      19. TestMode? notificationMode = NULL
      20. +
      21. bool enableAutomaticCrashReporting = true
      22. +
      +

      Below you can find details of each method.

      +

      + salt: Used to prevent parameter tampering. + Type: string +

      +

      + enablePost: When set to true, all requests made to the Countly + Server will be done using HTTP POST. Otherwise, SDK sends all requests using + HTTP GET method. In some cases, if the data to be sent exceeds 1800 characters + limit, the SDK uses POST method. Type: bool +

      +

      + enableConsoleErrorLogging: This parameter is only useful when + you are debugging your application in Unity Editor. When set to true, it basically + turns on Error Logging on Unity Console window Type: bool +

      +

      + ignoreSessionCooldown: To turn on/off session cooldown behavior + as mentioned in the development-guide Type: bool +

      +

      + enableManualSessionHandling: To turn on/off manual session handling + in the application. Type: bool +

      +

      + sessionDuration: To set the interval (in seconds) after which + the application will automatically extend the session provided manual session + is disabled. This interval is also used to process requests in queue. The default + value is 60 (seconds). Type: bool +

      +

      + eventThreshold: To set a threshold value that limits the number + of events that can be recorded internally by the system before they all can be + sent together in one request. Once the threshold limit is reached, the system + groups all recorded events and send them to the server. The default value is + 100 (events). Type: int +

      +

      + totalBreadcrumbsAllowed: To set a threshold value that limits + the number of requests that can be stored internally by the system. The system + processes these requests after every sessionDuration interval has passed. The + default value is 1000 (requests). Type: int +

      +

      + notificationMode (Optional): When null, SDK disables Push Notification + for the device. Otherwise, when provided an appropriate value from the enum TestMode, + SDK uses the supplied mode for sending Push Notifications. + Type: Enum of type TestMode +

      +

      + enableAutomaticCrashReporting (Optional): This is used to turn + on/off automatic crash reporting. When set to true, SDK will catch exceptions + and automatically report them to the Countly server, otherwise not. + Type: bool +

      +
      var configObj = new CountlyConfigModel(null, false, false, false, false, 60, 100, 1000, 100, TestMode.TestToken, false);
      +await Countly.SetDefaults(configObj);
      +
      +

      Session handling

      +

      + Unity SDK can handle sessions in two ways: Automatic session handling and manual + session handling. If you are in doubt, use automatic session handling. +

      +

      Automatic Session Handling

      +

      + Begin Session: SDK is responsible for automatically handling + Countly session in your app. As soon as you call the initialization methods (Begin + and SetDefaults) in your app start event, SDK will start the session automatically + (only when you set enableManualSessionHandling to true during initialization). +

      +

      + Update Session: SDK is responsible for automatically extending + the session after every 60 seconds (default value). This value is configurable + during initialization using parameter sessionDuration. It cannot be modified + any time after initialization. +

      +

      + Note that in iOS, session will not extend when the app is in background. As soon + as user switches back to the app, session extension will resume. In Android, + session will extend on both occasions: foreground and background. +

      +

      + End Session: SDK is responsible for automatically ending the + session whenever user quits the application. +

      +

      + Session will be ended automatically when user calls Application.Quit() method + available in Unity. +

      +

      Manual Session Handling

      +

      + This is used when you want to start a session on your app manually. +

      +

      + Begin Session: Starts the session manually. You need to call + the following method: +

      +
      Countly.BeginSessionAsync();
      +

      + Update Session: Extends the session manually. You need to call + following method: +

      +
      Countly.ExtendSessionAsync();
      +

      + End Session: Ends the session manually. You need to call the + following method: +

      +
      Countly.EndSessionAsync()
      +

      Optional parameters

      +

      + Countly servers recognize the location of the user’s device from their IP address. + However, you can also specify user’s location manually using the following methods. +

      +

      + Note: You need to use the following methods in conjunction to + specify the exact location manually. Also, IP address can be left out intentionally + when you want to specify a location but don’t have access to user’s IP address. + This is because Countly server gives priority to IP address. So, if you’ve specified + country, city and coordinates of a different location and IP address of a different + location, Countly server will choose the location from the IP address. +

      +

      Setting country code

      +

      + In order set the country, you need to call method SetCountryCode. +

      +

      + Syntax: Countly.SetCountryCode(string country_code); +

      +

      + country_code (required) Type: string Desc: It takes an ISO Country + Code in string format, as parameter. Ex: + Countly.SetCountryCode(“au”); +

      +

      Setting city

      +

      + In order to set the city, you need to call method SetCity. +

      +

      Syntax: Countly.SetCity(string cityname);

      +

      + cityname (required) Type: string Desc: It takes name of the + city in string format, as parameter. Ex: + Countly.SetCity(“Berlin”); +

      +

      Setting location

      +

      + In order to set the coordinates, you need to use method + SetLocation. Syntax: + SetLocation(double latitude, double longitude); +

      +

      There are two parameters, latitude and longitude:

      +

      + latitude and longitude (required) Type: double Ex: + Countly.SetLocation(34.9285,138.6007); +

      +

      Setting IP address

      +

      + You can choose to set (overwrite) the IP address of the user’s device. In order + to set the IP Address, you need to first get user’s device IP Address and then + use method SetIPAddress. +

      +

      + Syntax: Countly.SetIPAddress(string ip_address); +

      +

      + ip_address (required) Type: string Desc: It takes IP address + of the user’s device. Ex: + Countly.SetIPAddress(“SOME_IP_ADDRESS”); +

      +

      Disabling location

      +

      + This will completely remove and disable everything that has been previously set + in context of location like country, city, location and IP address. +

      +

      Parameter(s): None Ex: `Countly.DisableLocation();``

      +

      Events

      +

      + Unity SDK allows you to report custom events. An event can be anything which + is a user action, e.g button click, hover, purchases or level passing information. + You can report any type of events to the Countly server. +

      +

      + Unity SDK helps record as many events as you can (you can set a threshold limit + during initialization), and the system will send them automatically to the server + once the threshold limit is reached. By default, Countly tracks only up to 500 + events, however this is also configurable. +

      +

      + Note: You need to first set the threshold value that decides + the number of events that can be recorded by the system, i.e., + EventSendThreshold value, during initialization. The default value + is 100. Once SDK records this much events, SDK will send all collected events + at once in a single request. +

      +

      Below you can find methods for sending custom events.

      +

      + Recording an event: You can record an event by providing the + event name. The event will not be reported to the Countly server immediately + and will be reported to the server once the threshold limit is reached. +

      +

      + Syntax: Countly.RecordEventAsync(string key); + key: required Type: string Desc: The name of the event. Example: + Countly.RecordEventAsync(“Game_Level_X_Started”); +

      +

      + Recording an event (overload): This is an overload to the method + we defined above. We can provide other information related to the particular + event with this overload method. +

      +

      + Syntax: + Countly.RecordEventAsync(string key, IDictionary<string, object> segmentation, int? count = 1, double? sum = 0, double? duration = null) +

      +

      Parameter(s):

      +

      + key (required) Type: string Desc: The name of the event. +

      +

      + segmentation (optional) Type: IDictionary<string, object> + Desc: Payload data to be sent along with the event +

      +

      + count (optional) Type: integer Desc: Default value is 1 +

      +

      + sum (optional) Type: double Duration: Optional Type: double +

      +

      Example:

      +
      Countly.RecordEventAsync("Game_Level_X_Started",
      +				new Dictionary<string, object>
      +                        { 
      +				{ "Time Spent", "1234455"}, 
      +			{ "Retry Attempts", "10"}
      +			});
      +
      +

      Crash Reporting

      +

      + Unity SDK has the option to send crash reports to your Countly service. This + can be done in two ways, automatic and manual. +

      +

      Automatic crash reporting

      +

      + Countly Unity SDK automatically reports uncaught exceptions/crashes, in the application, + to the Countly server. +

      +

      Manual Crash Reporting

      +

      + Apart from automatically reporting crashes/uncaught exceptions to the Countly + server, the SDK allows you to report your custom errors by using method + SendCrashReportAsync. +

      +

      Syntax:

      +
      Countly.SendCrashReportAsync(string message, string stackTrace, LogType type, IDictionary<string, object> segments = null)
      +
      +

      Parameters:

      +

      + message (required) Type: string Desc: Complete error message. +

      +

      + stackTrace (required) Type: string Desc: Complete stack trace + of the exception. +

      +

      + type (required) Type: A value of enum LogType, defined under + UnityEngine namespace. Desc: You can choose from the various values defined in + the enum LogType. +

      +

      + segments (optional) Type: IDictionary<string, object> + Desc: Custom data in key-value pairs of string and object. This data will be + posted to the Countly server along with the exception details. +

      +

      + Using breadcrumbs +

      +

      + Additionally, SDK allows you to leave breadcrumbs that would be submitted together + with the crash reports. These breadcrumbs are added automatically and sent along + with the crash report (for both automatically caught and manually caught exceptions). +

      +

      + You can add breadcrumbs in the SDK using method AddBreadcrumbs. + A breadcrumb is a string with at most 1000 character and this cannot be modified. + We can add a maximum of 100 breadcrumbs (as it is default value) in the system. + However, we can modify this during initialization with parameter + totalBreadcrumbsAllowed. +

      +

      + Syntax: Countly.AddBreadcrumbs(string breadcrumb); Parameter(s): + breadcrumb: A string value Type: String +

      +

      Setting up views

      +

      Manual View (Screen) Tracking

      +

      + Countly Unity SDK supports manual view (screen) tracking. With this feature, + you can report what views a user did, and for how long. Thus, whenever there + is a screen switch in your app, you can report it to Countly server by using + following method: +

      +

      + Syntax: `Countly.ReportViewAsync(string name, bool hasSessionBegunWithView = + false);`` +

      +

      Parameter(s):

      +

      + name (required) Type: string Desc: The name of the view to be reported. +

      +

      + hasSessionBegunWithView (optional) Type: bool Desc: Set it to true to indicate + that the session started with this view +

      +

      + Ex: Countly.ReportViewAsync(“LoginScreen”); +

      +

      View Actions

      +

      + Additionally, it is possible to report actions taken on views to display on heat + maps or any other purpose. For that, you need to use method ReportActionAsync. +

      +

      + Syntax: + Countly.ReportActionAsync(string type, int x, int y, int width, int height); +

      +

      Parameter(s):

      +

      + type: action type, as click, touch, longpress, etc x: x coordinate of action + y: y coordinate of action width: width of the screen height: height of the screen +

      +

      + Ex: Countly.ReportActionAsync("Touch", 0, 0, 50, 50); +

      +

      Star rating

      +

      + When a user rates your application, you can report it to the Countly server using + method ReportStarRatingAsync. For this, you can optionally set Countly + Unity SDK to automatically ask users for a 1-to-5 star-rating, depending on app + launch count for each version. +

      +

      + Syntax: + Countly.ReportStarRatingAsync(string platform, string app_version, int rating); +

      +

      Parameter(s):

      +

      + platform: platform on which application runs app_version: application's version + number rating: user's 1-to-5 rating +

      +

      + Ex: Countly.ReportStarRatingAsync("android", "0.1", 3); +

      +

      User Profiles

      +

      + Countly Unity SDK allows you to upload specific data related to a user to Countly + server. SDK allows you to set following predefined data for a particular user: +

      +
        +
      1. Name: Full name of the user
      2. +
      3. Username: Username of the user
      4. +
      5. Email: Email address of the user
      6. +
      7. Organization: Organization the user is working in
      8. +
      9. Phone: Phone number
      10. +
      11. Picture Url: Web based Url for user’s profile
      12. +
      13. + Gender: Gender of the user (use only single char like ‘M’ for Male and ‘F’ + for Female) +
      14. +
      15. Birth year: Birth year of the user
      16. +
      +

      + Apart from the above data, you can also add your own custom data for a user. + SDK allows you to upload user details using following methods. You may choose + one of the following methods as per your requirement. +

      +

      Setting user details

      +

      + You can set all the details (specified above) of a user along with some custom + data using method SetUserDetailsAsync. +

      +

      + Syntax: SetUserDetailsAsync(); Parameter(s): None This method is + an instance method and not a static method. It doesn’t take any parameters. You + first need to create an instance of class CountlyUserDetailsModel. + The constructor for this class takes following number of parameters: +

      +
        +
      1. Name: String
      2. +
      3. Username: String
      4. +
      5. Email: String
      6. +
      7. Organization: String
      8. +
      9. Phone: String
      10. +
      11. Gender: String
      12. +
      13. Birth year: String
      14. +
      15. + Custom: String. It is a json string containing key-value pairs. It is used + to send custom data. +
      16. +
      +

      Example:

      +
      var userDetails = new CountlyUserDetailsModel(
      +                                "Full Name", "username", "useremail@email.com", "Organization",
      +                                "222-222-222",              
      +		        "http://webresizer.com/images2/bird1_after.jpg", 
      +        "M", "1986",
      +                                new Dictionary<string, object>
      +                                {
      +                                    { "Hair", "Black" },
      +                                    { "Race", "Asian" },
      +                                });
      +await userDetails.SetUserDetailsAsync();
      +

      Setting custom user details

      +

      + SDK allows you the flexibility to send only custom data to Countly servers when + you don’t want to send other user related data. Similar to the above method, + it is also an instance method and not a static method. So, you first need to + create an instance of class CountlyUserDetailsModel. All the parameters + expected in the constructor remain the same. You can leave all parameters as + NULL and just provide the custom data segment for sending custom data to the + Countly server. +

      +

      + Syntax: SetCustomUserDetailsAsync(); Parameter(s): None +

      +
      var userDetails = new CountlyUserDetailsModel(
      +                                new Dictionary<string, object>
      +                                {  
      +			{ "Nationality", "Indian" },
      +                                    { "Height", "5.8" },
      +                                    { "Mole", "Lower Left Cheek" } 
      +		         });
      +await userDetails.SetCustomUserDetailsAsync();
      +
      +
      +

      Modifying Custom Data Properties

      +

      + Apart from setting user details (SetUserDetailsAsync) and custom + user details (SetCustomUserDetailsAsync), SDK allows you to set/modify + specific custom data properties. The system records multiple properties at once + and reports them (updates to the server) when you want. +

      +

      + Below are some of the methods available in the SDK. All these methods are static + methods and defined in the class CountlyUserDetailsModel. +

      +

      + Set: Sets a value to the provided key. Syntax: + CountlyUserDetailsModel.SetOnce(string key, string value); +

      +

      + Parameter(s): key: Name of the property to be updated + value: Value to be updated with +

      +

      + Example: CountlyUserDetailsModel.Set("Weight", "80"); + CountlyUserDetailsModel.Save(); +

      +

      + SetOnce: Sets value to key, only if property was not defined + before for this user Syntax: + CountlyUserDetailsModel.SetOnce(string key, string value); +

      +

      Parameter(s): Already defined above.

      +

      + Example: CountlyUserDetailsModel.SetOnce("Weight", "90"); + CountlyUserDetailsModel.Save(); +

      +

      + In the above example, Weight will not be updated with value “90” if you’ve already + updated Weight with a certain value. +

      +

      + Increment: To increment value on server by 1 (if no value on + server, assumes it is 0) +

      +

      + Syntax: CountlyUserDetailsModel.Increment(string key); +

      +

      Parameter(s): Already defined above.

      +

      + Example: CountlyUserDetailsModel.Increment("Weight"); + CountlyUserDetailsModel.Save(); +

      +

      + Increment By: To increment value on server by provided value (if no value on + server, assumes it is 0) +

      +

      + Syntax: + CountlyUserDetailsModel.IncrementBy(string key, double value); +

      +

      Parameter(s): Already defined above.

      +

      + Ex: CountlyUserDetailsModel.IncrementBy("Weight", 1); + CountlyUserDetailsModel.Save(); +

      +

      + Multiply: To multiply value on server by provided value (if + no value on server, assumes it is 0) +

      +

      + Syntax: + CountlyUserDetailsModel.Multiply(string key, double value); +

      +

      Parameter(s): Already defined above.

      +

      + Ex: CountlyUserDetailsModel.Multiply("Weight", 2); + CountlyUserDetailsModel.Save(); +

      +

      + Max: To store maximal value from the one on server and provided + value (if no value on server, uses provided value) +

      +

      + Syntax: CountlyUserDetailsModel.Max(string key, double value); +

      +

      Parameter(s): Already defined above.

      +

      + Ex: CountlyUserDetailsModel.Max("Weight", 90); + CountlyUserDetailsModel.Save(); +

      +

      + Min: To store minimal value from the one on server and provided + value (if no value on server, uses provided value). +

      +

      + Syntax: CountlyUserDetailsModel.Min(string key, double value); +

      +

      Parameter(s): Already defined above.

      +

      + Ex: CountlyUserDetailsModel.Min("Weight", 40); + CountlyUserDetailsModel.Save(); +

      +

      + Push: Add one or many values to array property (can have multiple + same values, if property is not array, converts it to array). +

      +

      + Syntax: CountlyUserDetailsModel.Push(string key, string[] value); +

      +

      + Parameter(s): value: A string array containing list of values that you want to + set for the provided key. +

      +

      + Ex: + CountlyUserDetailsModel.Push("Mole", new string[] { "Left Cheek", "Back", "Toe" }); + CountlyUserDetailsModel.Save(); +

      +

      + Push Unique: Add one or many values to array property (will + only store unique values in array, if property is not array, converts it to array). +

      +

      + Syntax: + CountlyUserDetailsModel.PushUnique(string key, string[] value); +

      +

      Parameter(s): Already defined above.

      +

      + Ex: + CountlyUserDetailsModel.PushUnique("Mole", new string[] { "Right Leg", "Right Leg" }); + CountlyUserDetailsModel.Save(); +

      +

      + Pull: Remove one or many values from array property (only removes + value from array properties) +

      +

      + Syntax: CountlyUserDetailsModel.Pull(string key, string[] value); +

      +

      Parameter(s): Already defined above.

      +

      + Ex: + CountlyUserDetailsModel.Pull("Mole", new string[] { "Right Leg", "Back" }); + CountlyUserDetailsModel.Save(); +

      +

      Recording multiple update requests

      +

      + Apart from updating a single property in one request, you can modify multiple + (unique) properties in one single request. This way, you can increment Weight + and multiply Height in the same request. Similarly, you can record N number of + modify requests and Save them all together in one single request instead of multiple + requests. +

      +

      + In order record a “modify custom user detail” request, you just need to call + the particular methods but DO NOT call “Save” method immediately after each method. + CountlyUserDetailsModel.Save() method immediately posts all modify + requests recorded yet. +

      +

      + Note that if you are going to modify multiple properties in one request, make + sure you properties are unique, i.e., a property shouldn’t be modified more than + once in a single request. However, if you record a property more than once, only + the latest modifier will be posted to the server. +

      +

      Example:

      +
      CountlyUserDetailsModel.Max("Weight", 190);
      +CountlyUserDetailsModel.Multiply("Weight", 190);
      +CountlyUserDetailsModel.Min("Height", 5.5);
      +CountlyUserDetailsModel.Push("Mole", new string[] { "Left Cheek", "Back", "Toe" });
      +CountlyUserDetailsModel.Save();
      +

      + You can record N number of modify requests and call “Save” when you want to post + all events recorded before calling “Save” method. +

      +

      + Note: In the above example, you can see Max and Multiply are modifying the same + property “Weight”. Therefore in such a scenario, only Multiply request will pushed + to the server and Max request will not. +

      +

      Push Notifications

      +

      + This section requires setting up either APNS (Apple Push Notification Services) + or FCM (Firebase Cloud Services). For APNS, you need to get push credentials + and upload to Countly. + This document + explains how to retrieve and upload push credentials for APNS. If you are developing + for Android, please + read this documentation + and follow instructions to setup for GCM/FCM. +

      +

      + After setting up push notification credentials, you must initialize Push Notification + for Countly Unity SDK. However, SDK already does it for you so, you don’t have + to initialize it separately. At the beginning of this documentation, go to “initialization” + process (method SetDefaults) where we init the Countly Unity SDK. In that method, + you can see we have a parameter (last one) named TEST_MODE. +

      +
        +
      • + If you don’t want to enable Push Notification for your application, you can + pass NULL to this parameter during initialization. +
      • +
      • + If you want to enable Push Notification for your application, you can provide + any of the suitable value from the enum TestMode under namespace Assets.Scripts.Enums. +
      • +
      +

      + So, the SDK already initializes Push Notification for you. But, if you’ve disabled + Push Notification during initialization and you want to enable anytime after + that, you can do that by using following method EnablePush. +

      +

      + Syntax: Countly.EnablePush(TestMode mode); +

      +

      Parameter(s): Explained above.

      +

      + Key Points: +

      +
        +
      1. + Push Notification with banner image in the background is only supported for + Android platform. Banner image is not supported on iOS platform. +
      2. +
      3. + Push Notifications will only appear when the app is in Foreground. As soon + as user switches to another application and your app is in background, your + session will end and you’ll have to initialize Push Notification again on + your AppStart or OnFocus event, if you haven’t initialized it in the SetDefaults + method of the SDK by passing TestMode parameter. +
      4. +
      5. + For platforms Android and iOS, the notification icon can be set as follows: + For Android, place the notification icons under folder “Assets\Plugins\Android\res” + for different screen densities. The name of the icon must be “notification_icon”. + A sample PNG file is placed under the folder “drawable”. For iOS, iOS platform + will basically pick your app icon as the default push notification icon. + So, you don’t need to do anything for iOS platform. +
      6. +
      +

      Changing Device ID

      +

      + Countly Unity SDK persists Device ID which you provide during initialization + or generates a random ID, if you don’t provide it. This Device ID will be used + persistently for all future requests made from a device until you change that. +

      +

      + The SDK allows you to change the Device ID at any point of time. You can use + following any of the following two methods for changing Device ID, depending + upon your scenario. +

      +

      + Change device ID & end current session: +

      +

      + This method changes the Device ID and does following other operations: +

      +
        +
      1. Ends all the events that have been recorded till now.
      2. +
      3. Ends current session.
      4. +
      5. + Updates Device ID and starts new session with new Device ID. +
      6. +
      +

      + Syntax: + Countly.ChangeDeviceIDAndEndCurrentSessionAsync(string deviceId); +

      +

      + Parameter(s): deviceId: Required + Type: string Desc:** The new device id +

      +

      + Ex: + Countly.ChangeDeviceIDAndEndCurrentSessionAsync(“NEW_DEVICE_ID”); +

      +

      + Change Device ID And Merge Session Data +

      +

      + This method changes the Device ID and merges data for both Device IDs on the + Countly server. +

      +

      + Syntax: + Countly.ChangeDeviceIDAndMergeSessionDataAsync(string deviceId); +

      +

      + Parameter(s): Explained above. Ex: + Countly.ChangeDeviceIDAndMergeSessionDataAsync(“NEW_DEVICE_ID”); +

      \ No newline at end of file