Git Product home page Git Product logo

km's Introduction

Documentation

The original km Ruby gem is not thread safe. We have released a new gem, kmts, that is threadsafe.

We are hosting our documentation for our Ruby API here: support.kissmetrics.io/reference#ruby

kmts version 1.0.2

Version 1.0.2 of the kmts gem had an issue where it was found to not actually be thread safe. If you were using version 1.0.2 of the kmts gem, you were likely using non thread-safe code. In this case, you will want to either switch to using the non thread-safe km gem, or update your code to use the thread-safe kmts gem version >= 2.0.0.

km version 1.3.0

This version uses the ‘trk.kissmetrics.io` tracking server domain.

Installation

gem install km

SaaS

This gem includes SaaS calls. For more information please refer to: support.kissmetrics.io/docs/saas-essentials

For the methods used, see the rdoc for SaaS

km's People

Contributors

bcluca avatar dcrec1 avatar derrickko avatar duncanbeevers avatar eskfung avatar masone avatar mstump avatar nateklaiber avatar nathanielwroblewski avatar percyhanna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

km's Issues

README for kmts is wrong

Hi, I noticed that the documentation says that syntax like KM.record('[email protected]', 'Viewed Homepage') is acceptable, but reading through the code, it seems like this is not the case. The correct syntax is:

KM.identify('[email protected]')
KM.record('Viewed Homepage')

I could submit a pull request fixing this, but it seems just as simple to open a PR making the code behave as documented (which I prefer). Is this an actual issue?

Requiring the kmts gem doesn't work

Unfortunately, the documented way how to include and require the kmts gem doesn't work. The following line in the Gemfile throws an error ('km' not found)

gem 'kmts', '~> 1.0.0', require: "km"

KM Gem replacing spaces with "+"

Hi there, we're posting in something like Michael Leung, and when we run reports in the KM admin it shows as Michael+Leung. Any insight would be great. We've tried it with the JavaScript API and it doesn't seem to gsub the space. Thanks!

Simpler alternative

Hi KM,

I had a few issues with your gem and eventually decided it was easier to create my own code to interface with Kissmetrics and would like to share it with you what the problems were and what I came up with.

The first problem was around environments and the use of logs and cron and I had to work around the fact that the code executes differently in production. I would recommend that rather than hardcode behavior around environments to make this configurable instead. For example, I use an environment called 'staging' which should behave exactly like production, except it has a different name.

Also, as you may know, Heroku only allows hourly cron jobs so that meant the stats were not instant. And then I didn't see a distinct advantage to holding the logs in a file since they are sent one-by-one anyway. Finally, using the file system, in particular the tmp dir for storing the log posed the potential problem of logs possibly being deleted by automatic cleanup processes.

Because Heroku works well with delayed_job, that was my preferred method for sending metrics.

So please find my version of the KM class in the gist below. It's a bit of a work in progress since it only does what I need but so far it works well for me.

https://gist.github.com/1170061 (required: delayed_job and httparty gems)

Thanks,
Vincent

KM Isn't Threadsafe

The use of mutable class instance variables means that KM is not threadsafe. Class instance variables are shared between threads. This is particularly troublesome for the @id variable, which is mutated by KM.identify(). Here's an example that demonstrates the problem:

KM.init("1234", log_dir: ".")

10.times.map do |n| 
  Thread.new(n) do |thread_id|
    KM.identify(thread_id)
    sleep(1)
    KM.record("Test")
  end
end.each(&:join)

After running that, I would expect to see 10 unique URLs in kissmetrics_development_sent.log. Instead, I see 10 URLs with the same _p parameter:

/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179
/e?_n=Test&_p=9&_k=1234&_t=1346454179

Need a rubygems.org release for development testing

The currently published gem contains an early exit when sending requests if the environment is not production.

From: /Users/jroes/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/km-1.1.2/lib/km.rb @ line 214 KM.send_query:

    214: def send_query(line)
    215:   if @env != 'production'
 => 216:     log_sent(line)
    217:     return
    218:   end

This leads to confusion when testing in the development environment as requests don't actually make it to the KISSmetrics Live panel.

Don't rescue Exception

This library rescues Exception all over the place, oftentimes not re-raising it. This is problematic since it'll swallow interrupts and prevent threads from exiting properly. You should really only rescue StandardError unless you intend on re-raising the exception.

'kmts' gem yanked ? what's the alternative?

I woke up this morning to see all our builds fail and deploy impossible because kmts has been yanked. see here http://rubygems.org/gems/kmts - what's the alternative? is the january release of the km gem thread-safe? this is a big headache for me, and there seems to be no documentation on the yank or the alternative that I can find.

uninitialized constant ApplicationController::KM for kmts gem (kmts gem doesn't work)

  1. Add KM.init('KM_KEY') to a before_filter in application controller

  2. Add km gem to gemfile

  3. bundle

  4. run server, visit localhost
    Notice: Page loads as expected

  5. Change 'km' to 'kmts' in gemfile

  6. bundle

  7. run server, visit localhost

  • ERROR: uninitialized constant ApplicationController::KMTS

It appears that including the kmts gem does not work at all; does the documentation need updated or the gem have an issue?

License

Hey,

Could you please add a license to the km gem?

Thanks.

Why rename?

Hey

I was wondering why did you rename the gem to kmts instead of increasing version number of km?

Connection times out when get request too large

Hi,

Today we encountered an issue with lengthy parameters data.

In one of our reports to KM we send one of the parameters we get on our API. At some point we started seing large timeouts. After some careful evaluation we found these on the logs:

<Mon Nov 19 12:29:12 2012> End of file reached for host trk.kissmetrics.com:80

This was due to the fact that kissmetrics send metrics via get request and as such all parameters are sent on the URL. URL's have a length limit http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url

Is there anyway around this?

Thank you.

Sending events not related to the browsing user is not possible

Hi.

I have a very simple setup where I have a before_filter in ApplicationController that sets up KM.identify based on cookies/deviceId.

Users can 'like' something which would trigger email notifications which I would like to mark as sent. In this setup I want to do something like KM.record_with_identity(identity, 'Sent notification email') without affecting the KM that was initialized in the ApplicationController.

Here is a function that makes this work, sorry for not forking/requesting commit.

def record_with_identity(id,action,props={})
  temp_id = @id
  @id = id
  record(action, props)
  @id = temp_id
end

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.