heap 0.1.3 → 0.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.mdown +18 -0
- data/README.mdown +9 -3
- data/VERSION +1 -1
- data/heap.gemspec +4 -3
- data/lib/heap/view_helpers.rb +16 -8
- data/test/test_view_helper.rb +28 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d744f1219db0c3007df69dd94f39c0b1850638bc
|
4
|
+
data.tar.gz: 51dbfcc6932734701355ce03ae8e75dbbaa171d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fee957cce4f2c73d599457071c86a0a1bdc7d71f60cab29768c7390910d9222e51eb4c102284f8e685eee548fa84eb367f5d72f3744fd831302d4eeddf8530f
|
7
|
+
data.tar.gz: a5eb712028103a1143b477d97115e9fb66c759dd2eed4f5fb0cbff5c6fa8f694b78560519e05168eaca5bbab592f1a1e97b7b1763b59cc8ca9ae9702a1254dfd
|
data/CHANGELOG.mdown
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
<!-- ## [Unreleased][unreleased] -->
|
6
|
+
|
7
|
+
## [0.1.3] - 2015-02-05
|
8
|
+
### Changed
|
9
|
+
- Updated to new JS snippet from heap
|
10
|
+
|
11
|
+
## [0.1.2] - 2014-12-21
|
12
|
+
### Added
|
13
|
+
- Heap now gives you the option to use another user handle instead of e-mail
|
14
|
+
|
15
|
+
[unreleased]: https://github.com/hectormalot/heap/compare/v0.1.3...HEAD
|
16
|
+
[0.1.3]: https://github.com/hectormalot/heap/compare/v0.1.3...v0.1.2
|
17
|
+
[0.1.2]: https://github.com/hectormalot/heap/compare/v0.1.2...v0.1.1
|
18
|
+
[0.1.1]: https://github.com/hectormalot/heap/compare/v0.1.1...v0.1.0
|
data/README.mdown
CHANGED
@@ -30,7 +30,7 @@ Heap needs your application ID to successfully submit data to heapanalytics.com.
|
|
30
30
|
|
31
31
|
### Identifying your users
|
32
32
|
|
33
|
-
The `heap_identify` view helper can be used to supply heap with attributes for your users. The helper takes 2 arguments:
|
33
|
+
The `heap_identify` view helper can be used to supply heap with attributes for your users. The helper takes 2 arguments:
|
34
34
|
|
35
35
|
* [String] email: The e-mail address used to identify your visitor in Heap
|
36
36
|
* [Hash, optional] properties: A hash containing additional properties for your users (Hashes with multiple levels are currently not supported)
|
@@ -43,6 +43,12 @@ If you wish to use a different handle type, only `handle`/`email` are supported
|
|
43
43
|
|
44
44
|
Default is set to `email`.
|
45
45
|
|
46
|
+
### Adding custom event properties
|
47
|
+
|
48
|
+
With `heap_set_event_properties`, you can specify key-value pairs to associate with all of a user's subsequent events. This helper takes one argument:
|
49
|
+
|
50
|
+
* [Hash] properties: A hash containing all of the properties you want to attach to the user's events
|
51
|
+
|
46
52
|
### Tracking server-side events
|
47
53
|
|
48
54
|
In case you want to track server-side events -- for example when sending a welcome e-mail to a new user --, you can do so using `Heap.event`. `Heap.event` takes 3 arguments:
|
@@ -55,7 +61,7 @@ Example:
|
|
55
61
|
|
56
62
|
Heap.event("Welcome e-mail sent", "user@example.com", promotion:'second gem free', segment:'ruby developers')
|
57
63
|
|
58
|
-
### Adding server-side user attributes
|
64
|
+
### Adding server-side user attributes
|
59
65
|
|
60
66
|
To update or set properties on your users directly from your application, use `Heap.identify`. `Heap.identify` takes 2 arguments:
|
61
67
|
|
@@ -67,7 +73,7 @@ Example:
|
|
67
73
|
Heap.identify("user@example.com", segment:'ruby developers', age: 25)
|
68
74
|
|
69
75
|
## Contributing to Heap
|
70
|
-
|
76
|
+
|
71
77
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
72
78
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
73
79
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/heap.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: heap 0.
|
5
|
+
# stub: heap 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "heap"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Dennis de Reus"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-04-04"
|
15
15
|
s.description = "Easy integration of heapanalytics into your ruby app"
|
16
16
|
s.email = "dennisdereus@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
+
"CHANGELOG.mdown",
|
23
24
|
"Gemfile",
|
24
25
|
"Gemfile.lock",
|
25
26
|
"LICENSE.txt",
|
data/lib/heap/view_helpers.rb
CHANGED
@@ -1,18 +1,26 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
class Heap
|
2
4
|
module ViewHelpers
|
3
5
|
def heap_analytics
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}.html_safe
|
9
|
-
end
|
6
|
+
heap_js_block %Q{
|
7
|
+
window.heap=window.heap||[],heap.load=function(t,e){window.heap.appid=t,window.heap.config=e;var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.heapanalytics.com/js/heap-"+t+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(t){return function(){heap.push([t].concat(Array.prototype.slice.call(arguments,0)))}},p=["clearEventProperties","identify","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=o(p[c])};
|
8
|
+
heap.load("#{Heap.app_id}");
|
9
|
+
}
|
10
10
|
end
|
11
11
|
|
12
12
|
def heap_identify(handle, properties = nil)
|
13
13
|
body = properties.map {|k,v| ", #{k}: \"#{v}\""}.join if properties.is_a? Hash
|
14
|
-
|
15
|
-
|
14
|
+
heap_js_block %Q{heap.identify({#{Heap.default_handle_type}: "#{handle}" #{body}});}
|
15
|
+
end
|
16
|
+
|
17
|
+
def heap_set_event_properties(properties = {})
|
18
|
+
heap_js_block %Q{heap.setEventProperties(#{properties.to_json});}
|
19
|
+
end
|
20
|
+
|
21
|
+
def heap_js_block(content)
|
22
|
+
javascript_tag :type => "text/javascript" do
|
23
|
+
raw content.html_safe
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
data/test/test_view_helper.rb
CHANGED
@@ -1,10 +1,34 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
+
class String
|
4
|
+
def html_safe
|
5
|
+
self
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
class HeapHelperTest < MiniTest::Test
|
4
10
|
include Heap::ViewHelpers
|
5
11
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
12
|
+
def javascript_tag(options = {})
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
|
16
|
+
def raw(js)
|
17
|
+
js
|
18
|
+
end
|
19
|
+
|
20
|
+
should "produce correct identify handle type" do
|
21
|
+
handle = '123'
|
22
|
+
assert_equal heap_identify(handle), "heap.identify({email: \"#{handle}\" });"
|
23
|
+
end
|
24
|
+
|
25
|
+
should "set event properties from arbitrary key-value pairs" do
|
26
|
+
js = heap_set_event_properties({
|
27
|
+
:first => "first value",
|
28
|
+
"second" => 2,
|
29
|
+
:third => true
|
30
|
+
})
|
31
|
+
|
32
|
+
assert_equal js, %Q/heap.setEventProperties({"first":"first value","second":2,"third":true});/
|
33
|
+
end
|
10
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis de Reus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -117,6 +117,7 @@ extra_rdoc_files:
|
|
117
117
|
- README.mdown
|
118
118
|
files:
|
119
119
|
- ".document"
|
120
|
+
- CHANGELOG.mdown
|
120
121
|
- Gemfile
|
121
122
|
- Gemfile.lock
|
122
123
|
- LICENSE.txt
|