Git Product home page Git Product logo

analytics-clj's Introduction

analytics-clj

Idiomatic Clojure wrapper for the Segment.io 2.x Java client

For full documentation on the Segment.io 2.x Java client, see analytics-java.

Build Status

CircleCI

Installation

[circleci/analytics-clj "0.8.0"]

Usage

View the full API.

Initialize an analytics client

(use '[circleci.analytics-clj.core])
(def analytics (initialize "<writeKey>"))

With logging:

(defn logger []
  (reify com.segment.analytics.Log
    (print [this level format args]
      (println (str (java.util.Date.) "\t" level "\t" args)))
    (print [this level error format args]
      (println error))))

(def analytics (initialize "<writeKey>" {:log (logger)}))

Messages

All of the message types can take options. See Spec: Common Fields for a list of common fields between all message types.

Identify

(identify analytics "user-id")

With traits:

(identify analytics "user-id" {:email "[email protected]"})

Track

(track analytics "user-id" "signup")

With properties:

(track analytics "user-id" "signup" {:company "Acme Inc."})

A full example:

(track analytics (:id user) "signup" {:company "Acme Inc."} {:context {:language "en-us"}
                                                             :integrations {"AdRoll" false}
                                                             :integration-options {"Amplitude" {:session-id (:id session)}}})

Screen

(screen analytics "1234" "Login Screen")

With properties:

(screen analytics "1234" "Login Screen" {:path "/users/login"})

Page

(page analytics "1234" "Login Page")

With properties:

(page analytics "1234" "Login Page" {:path "/users/login"})

Group

(group analytics "1234" "group-5678")

With traits:

(group analytics "1234" "group-5678" {:name "Segment"})

Alias

(alias analytics "anonymous_user" "5678")

Did we miss something?

We provided a top level enqueue function to allow you to do the following:

(enqueue analytics (doto (YourMessageType/builder)
                         (.userId "user-id")
                         (.properties {"company" "Acme Inc."})))

License

Copyright © 2019 CircleCI

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

analytics-clj's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.