keen 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -1
- data/lib/keen.rb +1 -1
- data/lib/keen/client/publishing_methods.rb +16 -0
- data/lib/keen/version.rb +1 -1
- data/spec/keen/client/publishing_methods_spec.rb +7 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Keen IO Official Ruby Client Library
|
2
2
|
|
3
|
-
[](http://travis-ci.org/keenlabs/keen-gem)
|
3
|
+
[](http://travis-ci.org/keenlabs/keen-gem) [](https://codeclimate.com/github/keenlabs/keen-gem)
|
4
4
|
|
5
5
|
keen-gem is the official Ruby Client for the [Keen IO](https://keen.io/) API. The
|
6
6
|
Keen IO API lets developers build analytics features directly into their apps.
|
@@ -224,6 +224,17 @@ Keen.beacon_url("sign_ups", :recipient => "foo@foo.com")
|
|
224
224
|
|
225
225
|
To track email opens, simply add an image to your email template that points to this URL.
|
226
226
|
|
227
|
+
#### Redirect URL's
|
228
|
+
Redirect URL's are just like image beacon URL's with the addition of a `redirect` query parameter. This parameter is used
|
229
|
+
to issue a redirect to a certain URL after an event is recorded.
|
230
|
+
|
231
|
+
```
|
232
|
+
Keen.redirect_url("sign_ups", { :recipient => "foo@foo.com" }, "http://foo.com")
|
233
|
+
# => "https://api.keen.io/3.0/projects/xxxxxx/events/email_opens?api_key=yyyyyy&data=eyJyZWNpcGllbnQiOiJmb29AZm9vLmNvbSJ9&redirect=http://foo.com"
|
234
|
+
```
|
235
|
+
|
236
|
+
This is helpful for tracking email clickthroughs.
|
237
|
+
|
227
238
|
### Changelog
|
228
239
|
|
229
240
|
##### 0.7.7
|
data/lib/keen.rb
CHANGED
@@ -113,6 +113,22 @@ module Keen
|
|
113
113
|
"#{self.api_url}#{api_event_collection_resource_path(event_collection)}?api_key=#{self.write_key}&data=#{data}"
|
114
114
|
end
|
115
115
|
|
116
|
+
# Returns an encoded URL that will record an event and then redirect. Useful in email situations.
|
117
|
+
# See detailed documentation here
|
118
|
+
# https://keen.io/docs/api/reference/#event-collection-resource
|
119
|
+
#
|
120
|
+
# @param event_collection
|
121
|
+
# @param [Hash] event properties
|
122
|
+
#
|
123
|
+
# @return a URL that will track an event when hit
|
124
|
+
def redirect_url(event_collection, properties, redirect_url)
|
125
|
+
require 'open-uri'
|
126
|
+
encoded_url = URI::encode(redirect_url)
|
127
|
+
json = MultiJson.encode(properties)
|
128
|
+
data = [json].pack("m0").tr("+/", "-_").gsub("\n", "")
|
129
|
+
"#{self.api_url}#{api_event_collection_resource_path(event_collection)}?api_key=#{self.write_key}&data=#{data}&redirect=#{encoded_url}"
|
130
|
+
end
|
131
|
+
|
116
132
|
private
|
117
133
|
|
118
134
|
def publish_body(path, body, error_method)
|
data/lib/keen/version.rb
CHANGED
@@ -230,4 +230,11 @@ describe Keen::Client::PublishingMethods do
|
|
230
230
|
"#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0="
|
231
231
|
end
|
232
232
|
end
|
233
|
+
|
234
|
+
describe "redirect_url" do
|
235
|
+
it "should return a url with a base-64 encoded json param and an encoded redirect url" do
|
236
|
+
client.redirect_url("sign_ups", { :name => "Bob" }, "http://keen.io/?foo=bar&bar=baz").should ==
|
237
|
+
"#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0=&redirect=http://keen.io/?foo=bar&bar=baz"
|
238
|
+
end
|
239
|
+
end
|
233
240
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: multi_json
|