SDKs overview

Keen IO provides a set of Software Development Kits (SDKs) designed to facilitate interaction with its custom analytics platform. These SDKs abstract the direct HTTP requests to the Keen IO API, allowing developers to integrate event tracking and data querying capabilities into their applications using familiar programming languages. The SDKs handle aspects such as authentication, data formatting, and network communication, streamlining the process of sending event data and retrieving analytical results.

The primary function of Keen IO SDKs is to enable the collection of event data from various sources, including web browsers, mobile applications, and server-side processes. Events are typically JSON objects representing user actions, system activities, or other data points relevant for analysis. Once collected, these events can be queried using the SDKs to perform aggregations, filtering, and other analytical operations directly from application code or for custom dashboard creation. Keen IO's approach emphasizes flexibility, allowing developers to define their event schemas and build tailored analytics solutions rather than relying on predefined metrics.

Keen IO maintains official SDKs for several popular programming languages, ensuring broad compatibility across different development environments. In addition to these official offerings, the developer community has contributed various libraries and connectors that extend Keen IO's reach into other frameworks and tools. These community-driven projects can offer specialized integrations or alternative approaches to interacting with the Keen IO platform, complementing the official SDKs.

Official SDKs by language

Keen IO offers official SDKs for a range of programming languages, designed to provide idiomatic interfaces for event collection and querying. Each SDK is maintained by Keen IO and aims to offer a consistent developer experience while adhering to the conventions of its respective language. For comprehensive details on each SDK, developers can refer to the Keen IO documentation portal.

Language Package/Library Installation Command (Example) Maturity
JavaScript keen-js npm install keen-js or yarn add keen-js Stable
Python keen pip install keen Stable
Ruby keen gem install keen Stable
Java keen-java Add to pom.xml (Maven) or build.gradle (Gradle) Stable
PHP keen/keen-client composer require keen/keen-client Stable
Go github.com/keen/go-keen go get github.com/keen/go-keen Stable
Node.js keen-js (server-side usage) npm install keen-js or yarn add keen-js Stable

Installation

Installation for Keen IO SDKs typically follows the standard package management practices for each respective programming language. Below are common installation methods for the officially supported SDKs:

  • JavaScript (Web & Node.js):

    For client-side web applications or server-side Node.js environments, the keen-js package is installed via npm or yarn:

    npm install keen-js
    # or
    yarn add keen-js

    Alternatively, the library can be included directly in HTML via a CDN for browser-based uses:

    <script src="//js.keen.io/3.2.7/keen.min.js" type="text/javascript"></script>
  • Python:

    The Python SDK is available through PyPI and installed using pip:

    pip install keen
  • Ruby:

    The Ruby SDK is published as a gem and installed via the gem command:

    gem install keen
  • Java:

    For Java projects, the SDK is typically managed with Maven or Gradle. Add the following dependency to your pom.xml (Maven):

    <dependency>
        <groupId>io.keen</groupId>
        <artifactId>keen-java</artifactId>
        <version>3.2.0</version> <!-- Check for the latest version -->
    </dependency>

    Or to your build.gradle (Gradle):

    implementation 'io.keen:keen-java:3.2.0' <!-- Check for the latest version -->
  • PHP:

    The PHP SDK uses Composer for dependency management:

    composer require keen/keen-client
  • Go:

    The Go SDK is fetched using the go get command:

    go get github.com/keen/go-keen

It is recommended to always refer to the Keen IO API reference for the most up-to-date installation instructions and version compatibility information.

Quickstart example

This quickstart example demonstrates how to initialize the Keen IO JavaScript SDK and record a simple event. This snippet is suitable for a web browser environment, assuming keen-js has been loaded.

// Initialize the Keen IO client
var client = new Keen({
  projectId: "YOUR_PROJECT_ID",    // Replace with your Keen IO Project ID
  writeKey: "YOUR_WRITE_KEY"       // Replace with your Keen IO Write Key
});

// Define an event to record
var purchaseEvent = {
  item: "Premium Widget",
  price: 29.99,
  currency: "USD",
  quantity: 1,
  user: {
    id: "user-12345",
    email: "[email protected]"
  },
  timestamp: new Date().toISOString()
};

// Record the event to the 'purchases' collection
client.recordEvent("purchases", purchaseEvent, function(err, res){
  if (err) {
    console.log("Error recording event:", err);
  } else {
    console.log("Event recorded successfully:", res);
  }
});

// Example of querying data (Client-side queries might be deprecated or limited for security)
// For server-side queries, use the readKey
/*
var queryClient = new Keen({
  projectId: "YOUR_PROJECT_ID",
  readKey: "YOUR_READ_KEY" // Replace with your Keen IO Read Key
});

queryClient.query("count", {
  event_collection: "purchases",
  timeframe: "this_7_days"
}, function(err, res){
  if (err) {
    console.log("Error running query:", err);
  } else {
    console.log("Query result:", res);
  }
});
*/

This example initializes the Keen IO client with a project ID and write key, then records a purchaseEvent into a collection named purchases. The projectId and writeKey are essential for authenticating requests to your Keen IO project, as detailed in the Keen IO security documentation.

For server-side applications, the process is similar but typically involves using a readKey for querying data. The principles of event definition and collection remain consistent across most SDKs, though the exact method calls and syntax will vary according to the language.

Community libraries

Beyond the officially supported SDKs, the Keen IO ecosystem includes community-contributed libraries and integrations. These resources are developed and maintained by the broader developer community and can offer specialized functionalities, integrations with specific frameworks, or support for additional languages not covered by official SDKs. While not officially supported by Keen IO, they can provide valuable extensions for certain use cases.

Examples of community contributions might include:

  • Connectors for data visualization tools not directly integrated with Keen IO.
  • Libraries for specific web frameworks (e.g., a Django or Rails plugin).
  • Wrappers for niche programming languages or environments.
  • Tools for migrating data to or from Keen IO in specific formats.

Developers seeking community resources should typically explore platforms like GitHub, npm, or PyPI using search terms such as "Keen IO" combined with their desired language or framework. When using community libraries, it is important to review their documentation, community support, and maintenance status to ensure they meet project requirements for stability and security. For instance, developers often consult community forums and shared repositories when integrating with analytics platforms, a practice common across the industry, as noted in general Google developer community guidelines.

While official SDKs are recommended for core integration due to direct vendor support, community libraries can extend the platform's utility, especially for specific development stacks or unique data processing needs. Always verify compatibility and maintenance when relying on third-party integrations.