Keen IO, Windows Phone 8.1 and NuGet package creation.

Keen IO, whats that?

We all know what Windows Phone 8.1 is. Read below,

I have developed a game for Windows Phone 8 in February named DotShake, its a very simple game, by shaking your phone, you move a mark ( I call it a ball) up. It had more downloads but many of my friends said the game logic is good but its yet need some functions to call it as a full game. Yes that game does not feature a background music and does not have a leader board. Adding background music is not a great deal. But adding Leaderboard is the big one as I need to buy a online host to store the data but unfortunately I couldnt find any such services for free. Last week Facebook suggested me a page named “Keen IO” and my first thought after seeing it was, “It should be a Node JS library” I went to the page because I am learning Node JS these days so I wanted to know about that library. But (un)fortunately it wasnt a Node JS library but it “lets developers build scalable analytics features directly into their mobile & web apps.” as they claimed in Facebook page and simply it provides “Analytic for developers”.

This Keen IO does not provide you a dedicated server to host your database (and gives the maintenance headache) but simply this provides an API using that you can send all your data – any event, from any source, and as much as you want to their servers and analyze them as your needs. This supports almost all languages and platforms. This is quite simple. This is very quite simple. This is very very quite simple…. This is (n-1)very quite simple. Give AWESOME analytic methods grab exactly the data you need. and the COOL FEATURE IS, THIS GIVES FREEEEEE ACCOUNT FOR DEVELOPERS “”yyyaaaaaayyyyy”” \o/\o/\o/\o/\o/\o/\o/\o/\o/

Developers can add up to 50,000 events per month.

Events? what are them

Events is a (okie, I am copy pasting the description as in Keen IO Docs)

Events are actions that occur at a point in time. These actions can be performed by a user, an admin, a server, a program, etc. Events have properties. Properties are the juicy bits of data that describe what is happening and allow you to do in-depth analysis. When we talk about “event data” we mean events and all the properties that you send along with them.

Events are pretty simple concept. Lets take my game leaderboard example, here I want to post the scores of every user of my game before he exits the game. This is called events, the post action by my game. And it has properties like “Player name”, “UniqueID” and “Score”

Events data is something, which contains properties and thats the data used to occur an event. A good events data example might be

    "keen": {
        "timestamp": "2012-06-06T19:10:39.205000"
    "item": "sophisticated orange turtleneck with deer on it",
    "cost": 469.5,
    "payment_method": "Bank Simple VISA",
    "customer": {
        "name": "Francis Woodbury",
        "age": 28,
    "store": {
        "name": "Yupster Things",
        "city": "San Francisco",
        "address": "467 West Portal Ave",

A pretty simple JSON with properties.

The Problem

Now I am porting by DotShake game to Windows Phone 8.1 with new features. To add the Keen IO to my project I executed

  PM> Install-Package KeenClient

In my Visual Studio 2013 package manager console and got the following error

Install failed. Rolling back...
Install-Package : Could not install package 'Microsoft.Net.Http 2.2.18'. You are trying to install this package into 
a project that targets 'WindowsPhoneApp,Version=v8.1', but the package does not contain any assembly references or 
content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package KeenClient
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

It simply says, one is the dependency package ‘Microsoft.Net.Http 2.2.18’ used by Keen IO 0.2.0 (current version by May 26, 2014) does not support Windows Phone 8.1. 

The solution

Step 1

So I went to Keen IO SDK’s github page, forked it and cloned it to my local repository. There I found the nuspec file “KeenClient.nuspec”, opened it and edited the dependencies with their latest version by today (26th May 2014). The previous file was looked like

<?xml version="1.0"?>
<package xmlns="">
    <authors>David Knaack</authors>
    <owners>Infinity Interactive, Inc.</owners>
	<title>Keen.IO Client - .Net SDK</title>
    <description>Keen IO is an analytics API for modern developers. Track any event: signups, upgrades, impressions, purchases, powerups, errors, shares... Keen IO stores events in arbitrary JSON format, automatically ingesting any new events and rich custom properties you send. Our elegant query APIs make it straightforward to run counts, sums, segmentation, and more.</description>
    <summary>Keen IO is an analytics API that stores events in arbitrary JSON format.</summary>
    <tags> analytics api rest client stats statistics phone wp8</tags>
      <dependency id="Microsoft.Net.Http" version="2.2.18" />
      <dependency id="Newtonsoft.Json" version="6.0.2" />
      <dependency id="Microsoft.Bcl" version="1.1.6" />
      <dependency id="Microsoft.Bcl.Build" version="1.0.13" />
      <dependency id="Microsoft.Bcl.Async" version="1.0.165" />
      <dependency id="PCLStorage" version="0.9.4" />
        <file src="Keen\bin\Release\Keen.dll" target="lib\portable-net45+wp8+win8+monoandroid+monotouch" />
        <file src="Keen\bin\Release\Keen.xml" target="lib\portable-net45+wp8+win8+monoandroid+monotouch" />
        <file src="Keen.Net\bin\Release\Keen*.dll" target="lib\net45" />
        <file src="Keen.Net\bin\Release\Keen*.xml" target="lib\net45" />

and I changed the version to 0.2.1 (<version>0.2.1</version>) and lines 17 to 22 with

      <dependency id="Microsoft.Net.Http" version="2.2.22" />
      <dependency id="Newtonsoft.Json" version="6.0.3" />
      <dependency id="Microsoft.Bcl" version="1.1.9" />
      <dependency id="Microsoft.Bcl.Build" version="1.0.14" />
      <dependency id="Microsoft.Bcl.Async" version="1.0.168" />
      <dependency id="PCLStorage" version="0.9.6" />


Step 2
1) Open the Visual Studio 2013 and open “Keen.sln”

2) The sln file will show  3 folders in solution explorer they are “Keen (portable)” “Keen.Net” and “Keen.NET.Test”

3) Right click on the first folder “Keen (portable)” and select properties. You will get project properties for Keen and there select Library -> click on Change button -> tick “Windows Phone 8.1” -> Click ok



4) Select “Release” solution configuration and Start the solution (you will get error message as there is no UI to start the process. Instead of hit Start, you can build solution with F6)

If you get any error “Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see;. —-> Right click on the solution ‘Solution ‘Keen’ (3projects)’ and select “Enable Nuget package restore”.

5) Do the above step for both other folders “Keen.Net” and “Keen.NET.Test”

Now the Keen client is WP8.1 ready 😉 #WOW

Step 3

Re open ‘KeenClient.nuspec” file and replace 26th and 27th line with

<file src="Keen\bin\Release\Keen.dll" target="lib\portable-net45+wp8+win8+wpa81+monoandroid+monotouch" />
<file src="Keen\bin\Release\Keen.xml" target="lib\portable-net45+wp8+win8+wpa81+monoandroid+monotouch" />

(ie) we are adding wpa81 here, in both of these lines. This indicated the current NuGet package (KeenClient.0.2.1.nupkg) is available for Windows Phone 8.1 as well.

Step 4
Now I have to make a new Nuget Package with the current nuspec file for that I have donwloaded Nuget console from here and pasted it to the current work folder where I have cloned the the Git repo.

After downloading I get the command prompt for the work folder and entered

NuGet Update -self

this command updated the current Nuget.exe to the latest version, and executed

NuGet Pack KeenClient.nuspec

this is the command to make Nuget package (.nupkg) with the .nuspec file. Thus this will create a file “KeenClient.0.2.1.nupkg”

Step 5
Now we have the Nuget package with the latest versions of dependencies. Next step is use the Nuget package in our solution. For this, we have very simple steps

1) Go to the project where you want to add the new nuGet package and Go to Tools -> NuGet package manager -> Package manager settings

2) Select “Package Source”


3)You will get a dialog box like above. In the dialog box, click the “+” button marked in red colour, give the name and give the directory of your work folder as marked in green colour then click Update button. I have given the name as “LocalFeed”. Finally click OK and you ended up with the below


Now click OK to come out.

4) Go to Project -> Manage NuGet packages

5) You can see a category called “LocalFeed” (or whatever you have given as the name in the above step) under “Online” and if you click that. you will see the new Keen IO client (v 0.2.1 with all new dependencies)new nuget client

You can re-check the version (marked with red) and dependencies (marked with green)

6) Now hit ‘INSTALL’

7) It will ask for something there hit “Accept”

It will be installed and thats all .. wow..

keen installed


Finally, The DEVELOPMENT part

Development is simple thing for developers, yes exactly. Just refer link and there, you can see simple steps to integrate this with your app and get services from Keen IO.

I have made all the changed to my Git repo forked from Keenlabs and sent the pull request as well. Thats my first major FOSS contribution.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s