toothrot / amplitude-api Goto Github PK
View Code? Open in Web Editor NEWA Ruby library for interacting with the Amplitude API
Home Page: http://www.rubydoc.info/gems/amplitude-api/
License: MIT License
A Ruby library for interacting with the Amplitude API
Home Page: http://www.rubydoc.info/gems/amplitude-api/
License: MIT License
Previously in 0.3.3
# config/initializer/amplitude_api.rb
AmplitudeAPI.config.api_key = ENV["AMPLITUDE_TOKEN"]
Now in version 0.4.0
, we need to explicitly load the amplitude_api
library.
# config/initializer/amplitude_api.rb
require "amplitude_api"
AmplitudeAPI.config.api_key = ENV["AMPLITUDE_TOKEN"]
I'm not sure if this is an intentional change.
Please have a look if you have time.
While trying to add a few properties to the default whitelist, I've run into an embarrassing problem. I can't figure out how to set the API key anymore. The
AmplitudeAPI.api_key = 'api_key'
described in the README doesn't work anymore, and I can't figure out how AmplitudeAPI::Config
is supposed to work.
Some help please. :)
Hello,
we are getting frequently this error when using your library. Could you please give us a hint why this could happen?
Thanks,
Johannes
Currently if you pass in options with strings as the keys into the Event
init they will not be properly fetched.
OS: Ubuntu 16.04.6 LTS
Could not open library 'libcurl.so': libcurl.so: cannot open shared object file: No such file or directory.
Could not open library 'libcurl.so.4': libcurl.so.4: cannot open shared object file: No such file or directory
...
/home/ubuntu/.rvm/gems/ruby-2.6.5/gems/ffi-1.9.18/lib/ffi/library.rb:147:in `block in ffi_lib': Could not open library 'libcurl': libcurl: cannot open shared object file: No such file or directory. (LoadError)
Thanks for this gem! It's been super helpful, and I'm looking to pull in the changes that were requested in #54 and just need a bit of clarification:
We're currently pulling in the gem from Rubygems, but it looks like it hasn't been released there for a while (latest version is 0.1.1 there, looks like that's also what's listed in the readme badge).
I'm wondering if there will be a new release to Rubygems?
Thanks for your time!
Hi,
I've set this up, and it appears AmplitudeAPI.config.api_key = ...
doesn't exist, but this works: AmplitudeAPI.api_key = ...
.
But now I send events but I can't see them on the dashboard. Any idea?
Perhaps change the naming of the time parameter to indicate the timestamp will be automatically converted in millisecond.
(I was converting in milliseconds myself before !, so the x1000 multiplication was done twice...)
something like occured_at ?
Hi @AlvaroMaceda, thanks for version 0.4.0. I noticed that in commit a64b0e8a28559d0f2f6a724f2533fbd3fcad8ba7 you removed the lib/amplitude-api.rb
file. That file is used by Rails to autoload the AmplitudeAPI object. Removing the file resulted in this error:
Run bin/rails db:create && bin/rails db:schema:load
rails aborted!
NameError: uninitialized constant AmplitudeAPI
This could easily be fixed by re-adding the deleted file.
If it was your intention to delete the file (i.e. you want us to import the object in a certain way), it might be wise to add a line in the docs for new users on how that should be done. A major version bump / mention in changelog would help people that use the gem as well!
(Copied from @bmo)
There are open issues with using Ethon on macos, e.g. typhoeus/ethon#206
Our developers are not able to use the library on macos w/o disabling the amplitude-api gem, which we need.
Would be nice to use libraries that enjoy more consistent usage (and therefore, fixes) by macos users in the Ruby community, perhaps faraday, HTTParty, rest-client...
Hi! Thanks for the great gem :)
Are you planning to add support for event.time
, so one can send events in the past with specific timestamps?
https://amplitude.zendesk.com/hc/en-us/articles/204771828-HTTP-API
Hey there
It seems that there are quite a few attributes that do not get set on the AmplitudeAPI::Event
model when creating via AmplitudeAPI::Event.new
Given this hash:
{
:event_id=>33785,
:event_type=>"program_stage_viewed",
:event_properties=>{"program_id"=>30, "program_title"=>"Program w/ Stages", "program_stage_id"=>1147, "program_stage_title"=>"Week 4"},
:time=>123123123,
:user_id=>10,
:device_id=>"2b7b68cf-aed7-4387-ad07-6e3338c5fe7e",
:session_id=>457,
:platform=>"smartphone",
:os_name=>"iOS",
:os_version=>"13.2.3",
:device_brand=>"Apple",
:device_model=>"iPhone",
:ip=>"172.19.0.1"
}
The resulting Event object only has the following attributes
#<AmplitudeAPI::Event:0x000055c69aecbcb8
@event_type="program_stage_viewed",
@event_properties={"program_id"=>30, "program_title"=>"Program w/ Stages", "program_stage_id"=>1147, "program_stage_title"=>"Week 4"},
@time=123123123,
@user_id=10,
@device_id="2b7b68cf-aed7-4387-ad07-6e3338c5fe7e",
@platform="smartphone",
@ip="172.19.0.1">
Im just going off the documentation here: https://help.amplitude.com/hc/en-us/articles/360032842391#http-api-v2-events
Any chance this is a bug? Otherwise ill just have to use HTTParty or something
I've setup amplitude-api
within my application and it is currently sending events synchronously. I'd like to move these to a background job in order to free up resources.
Can someone give me an example of how they did this?
I currently have a method in my amplitude.rb
module that looks like the following:
def track(event)
AmplitudeAPI.delay.track(event)
end
For some reason the job is added to the delayed_jobs
table but the logs just show the job as RUNNING and never COMPLETED.
It'd be helpful to see another example of how people are moving event submission to the background.
Hi,
Amplitude just deprecated the v1 of their api.
The gem needs to be updated to handle the http v2 of their API.
https://help.amplitude.com/hc/en-us/articles/204771828-HTTP-API-Deprecated-
AmplitudeAPI.delete(user_ids: [233], ...)
doesn't work. I didn't dig much but passing a single value works fine - AmplitudeAPI.delete(user_ids: 233, ...)
. Not sure what should be fixed - readme or the method. Probably the method
The documentation for amplitude say time is in milliseconds I believe, but the example in the docs shows Time.now which is a time object.
I wanted to make sure this was correct.
Hi,
I'm getting an exception when calling AmplitudeAPI.track
. Here's what I got:
NoMethodError: undefined method `to_h' for []:Array
/Users/abcd/.rvm/gems/ruby-2.0.0-p648/bundler/gems/amplitude-api-40903ce133aa/lib/amplitude_api/event.rb:48:in `optional_properties'
/Users/abcd/.rvm/gems/ruby-2.0.0-p648/bundler/gems/amplitude-api-40903ce133aa/lib/amplitude_api/event.rb:39:in `to_hash'
/Users/abcd/.rvm/gems/ruby-2.0.0-p648/bundler/gems/amplitude-api-40903ce133aa/lib/amplitude_api.rb:69:in `map'
/Users/abcd/.rvm/gems/ruby-2.0.0-p648/bundler/gems/amplitude-api-40903ce133aa/lib/amplitude_api.rb:69:in `track_body'
/Users/abcd/.rvm/gems/ruby-2.0.0-p648/bundler/gems/amplitude-api-40903ce133aa/lib/amplitude_api.rb:87:in `track'
This is what I did:
event = AmplitudeAPI::Event.new({
user_id: "1234",
event_type: "Eat",
event_properties: {
id: 5031,
name: "Burger",
}
})
AmplitudeAPI.track(event)
Thanks for this work!
It took me some time to figure out that README is not for the current version. Seems like the pre-release is 6 months old, maybe it's ready to be released?
I believe this commit broke it: 77c1988
The instructions on the README no longer work:
# Configure your Amplitude API key
AmplitudeAPI.api_key = "abcdef123456"
Will throw:
NoMethodError: undefined method `api_key=' for AmplitudeAPI:Class
Before actually releasing 0.10 you should add back in that initialization option or change the doc to reflect the preferred initialization route.
Switching to:
AmplitudeAPI.config.api_key = "abcdef123456"
will properly initialize the gem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.