• Random
  • Archive
  • RSS
banner

How to write an SDK for Countly?

Countly is an open source project -both for server and client side code- that is, you can write your own device SDK and benefit from Countly’s infrastructure to collect packages and then analyse outputs. In this post I’ll try to explain the basic rules of writing your own SDK. Of course you can just check Java and Objective-C code samples and understand the innerworkings, but here’s a simple explanation of how an SDK does to send packages to Countly server.

First thing to note - all information sent to server are carried using HTTP GET method. For the initial run, following data is collected and deployed to server: 

  • app_key: App key of the mobile application (as usual)
  • device_id: Device’s UDID (we use openUDID here).
  • sdk_version: Currently not used, but you can put “1” here for a placeholder.
  • begin_session: Use “1” here.
  • metrics: All device specific information JSON data.

An example metrics JSON for Android is as follows: 

  {
   ”_device”:”Galaxy S II”,
   ”_os”:”Android”,
   ”_os_version”:”2.3.3”,
   ”_carrier”:”Vodafone”,
   ”_resolution”:”480x800”,
   ”_locale”:”en_US”,
  }

After sending this first bulk information, device sends the following every 30 seconds to server: 

  • app_key: (same)
  • device_id: (same)
  • session_duration: how many seconds has passed since the last message. This is generally 30 seconds, but you are free to extend or stretch this period.

When the application is terminated, or sent to background, following data ise sent: 

  • app_key: (same)
  • device_id: (same)
  • end_session: “1” (showing that this session has ended)
  • session_duration: How many seconds has passed since the last message. This should be calculated by you.

If the application is sent to background, then you need to send an end_session packet. Likewise, as user puts the information to the foreground again, send a begin_session packet. This ensures highest granularity and eliminates potential miscalculations. 

Now enjoy real-time mobile analytics for your next app! :-)

— Team Countly

    • #mongodb
    • #node.js
    • #nginx
    • #mobile analytics
    • #open source
  • 9 months ago
  • 1
  • Comments
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

1 Notes/ Hide

  1. countly posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Countly is an innovative, real-time mobile analytics application. It collects data from mobile phones, and visualizes this information to analyze mobile application usage and end-user behavior

Help translate Countly

We're looking for translators in Danish, Polish, Portuguese, Hungarian and 10+ other languages. Let's make Countly a truely universal mobile analytics platform for everybody!

Pages

  • Become a guest author

Countly, Elsewhere

  • @gocountly on Twitter
  • Facebook Profile
  • countly on github

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile
Effector Theme by Pixel Union