heap 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +16 -0
- data/Gemfile +11 -8
- data/Gemfile187 +23 -0
- data/LICENSE.txt +2 -2
- data/README.md +120 -0
- data/Rakefile +8 -22
- data/VERSION +1 -1
- data/heap.gemspec +42 -43
- data/lib/heap.rb +10 -23
- data/lib/heap/client.rb +192 -0
- data/lib/heap/errors.rb +18 -0
- data/lib/heap/validations.rb +57 -0
- data/test/client_add_user_properties_test.rb +124 -0
- data/test/client_test.rb +78 -0
- data/test/client_track_test.rb +151 -0
- data/test/heap_test.rb +23 -0
- data/test/helper.rb +4 -17
- metadata +51 -52
- data/CHANGELOG.mdown +0 -18
- data/Gemfile.lock +0 -91
- data/README.mdown +0 -99
- data/lib/generators/heap/install_generator.rb +0 -12
- data/lib/generators/templates/heap.rb +0 -2
- data/lib/heap/events.rb +0 -22
- data/lib/heap/railtie.rb +0 -9
- data/lib/heap/view_helpers.rb +0 -28
- data/test/test_heap.rb +0 -35
- data/test/test_view_helper.rb +0 -47
data/test/helper.rb
CHANGED
@@ -1,16 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
module SimpleCov::Configuration
|
4
|
-
def clean_filters
|
5
|
-
@filters = []
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
SimpleCov.configure do
|
10
|
-
clean_filters
|
11
|
-
load_profile 'test_frameworks'
|
12
|
-
end
|
13
|
-
|
1
|
+
require 'rubygems'
|
14
2
|
require 'bundler'
|
15
3
|
begin
|
16
4
|
Bundler.setup(:default, :development)
|
@@ -19,12 +7,11 @@ rescue Bundler::BundlerError => e
|
|
19
7
|
$stderr.puts "Run `bundle install` to install missing gems"
|
20
8
|
exit e.status_code
|
21
9
|
end
|
10
|
+
require 'minitest/autorun'
|
22
11
|
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
23
14
|
require 'heap'
|
24
|
-
require 'heap/view_helpers'
|
25
|
-
require 'minitest/autorun'
|
26
|
-
require 'shoulda'
|
27
|
-
require 'webmock/minitest'
|
28
15
|
|
29
16
|
class MiniTest::Test
|
30
17
|
end
|
metadata
CHANGED
@@ -1,141 +1,140 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Victor Costan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.8.11
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.8.11
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
33
|
+
version: 0.8.0
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.8.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.8.7.6
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.8.7.6
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '3.12'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '3.12'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '1.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
96
|
+
version: '1.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: jeweler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.0.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
111
|
-
description:
|
112
|
-
email:
|
110
|
+
version: 2.0.1
|
111
|
+
description: Implements Heap's server-side API
|
112
|
+
email: victor@heapanalytics.com
|
113
113
|
executables: []
|
114
114
|
extensions: []
|
115
115
|
extra_rdoc_files:
|
116
|
-
- CHANGELOG.mdown
|
117
116
|
- LICENSE.txt
|
118
|
-
- README.
|
117
|
+
- README.md
|
119
118
|
files:
|
120
119
|
- ".document"
|
121
|
-
-
|
120
|
+
- ".travis.yml"
|
122
121
|
- Gemfile
|
123
|
-
-
|
122
|
+
- Gemfile187
|
124
123
|
- LICENSE.txt
|
125
|
-
- README.
|
124
|
+
- README.md
|
126
125
|
- Rakefile
|
127
126
|
- VERSION
|
128
127
|
- heap.gemspec
|
129
|
-
- lib/generators/heap/install_generator.rb
|
130
|
-
- lib/generators/templates/heap.rb
|
131
128
|
- lib/heap.rb
|
132
|
-
- lib/heap/
|
133
|
-
- lib/heap/
|
134
|
-
- lib/heap/
|
129
|
+
- lib/heap/client.rb
|
130
|
+
- lib/heap/errors.rb
|
131
|
+
- lib/heap/validations.rb
|
132
|
+
- test/client_add_user_properties_test.rb
|
133
|
+
- test/client_test.rb
|
134
|
+
- test/client_track_test.rb
|
135
|
+
- test/heap_test.rb
|
135
136
|
- test/helper.rb
|
136
|
-
|
137
|
-
- test/test_view_helper.rb
|
138
|
-
homepage: https://github.com/HectorMalot/heap
|
137
|
+
homepage: http://github.com/heap/heap-ruby
|
139
138
|
licenses:
|
140
139
|
- MIT
|
141
140
|
metadata: {}
|
@@ -155,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
154
|
version: '0'
|
156
155
|
requirements: []
|
157
156
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.5.1
|
159
158
|
signing_key:
|
160
159
|
specification_version: 4
|
161
|
-
summary:
|
160
|
+
summary: Heap server-side API client
|
162
161
|
test_files: []
|
data/CHANGELOG.mdown
DELETED
@@ -1,18 +0,0 @@
|
|
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/Gemfile.lock
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activesupport (4.1.8)
|
5
|
-
i18n (~> 0.6, >= 0.6.9)
|
6
|
-
json (~> 1.7, >= 1.7.7)
|
7
|
-
minitest (~> 5.1)
|
8
|
-
thread_safe (~> 0.1)
|
9
|
-
tzinfo (~> 1.1)
|
10
|
-
addressable (2.3.6)
|
11
|
-
builder (3.2.2)
|
12
|
-
crack (0.4.2)
|
13
|
-
safe_yaml (~> 1.0.0)
|
14
|
-
descendants_tracker (0.0.4)
|
15
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
16
|
-
docile (1.1.5)
|
17
|
-
faraday (0.9.0)
|
18
|
-
multipart-post (>= 1.2, < 3)
|
19
|
-
git (1.2.8)
|
20
|
-
github_api (0.12.2)
|
21
|
-
addressable (~> 2.3)
|
22
|
-
descendants_tracker (~> 0.0.4)
|
23
|
-
faraday (~> 0.8, < 0.10)
|
24
|
-
hashie (>= 3.3)
|
25
|
-
multi_json (>= 1.7.5, < 2.0)
|
26
|
-
nokogiri (~> 1.6.3)
|
27
|
-
oauth2
|
28
|
-
hashie (3.3.2)
|
29
|
-
highline (1.6.21)
|
30
|
-
httparty (0.13.3)
|
31
|
-
json (~> 1.8)
|
32
|
-
multi_xml (>= 0.5.2)
|
33
|
-
i18n (0.6.11)
|
34
|
-
jeweler (2.0.1)
|
35
|
-
builder
|
36
|
-
bundler (>= 1.0)
|
37
|
-
git (>= 1.2.5)
|
38
|
-
github_api
|
39
|
-
highline (>= 1.6.15)
|
40
|
-
nokogiri (>= 1.5.10)
|
41
|
-
rake
|
42
|
-
rdoc
|
43
|
-
json (1.8.1)
|
44
|
-
jwt (1.2.0)
|
45
|
-
mini_portile (0.6.1)
|
46
|
-
minitest (5.4.3)
|
47
|
-
multi_json (1.10.1)
|
48
|
-
multi_xml (0.5.5)
|
49
|
-
multipart-post (2.0.0)
|
50
|
-
nokogiri (1.6.5)
|
51
|
-
mini_portile (~> 0.6.0)
|
52
|
-
oauth2 (1.0.0)
|
53
|
-
faraday (>= 0.8, < 0.10)
|
54
|
-
jwt (~> 1.0)
|
55
|
-
multi_json (~> 1.3)
|
56
|
-
multi_xml (~> 0.5)
|
57
|
-
rack (~> 1.2)
|
58
|
-
rack (1.5.2)
|
59
|
-
rake (10.4.0)
|
60
|
-
rdoc (3.12.2)
|
61
|
-
json (~> 1.4)
|
62
|
-
safe_yaml (1.0.4)
|
63
|
-
shoulda (3.5.0)
|
64
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
65
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
66
|
-
shoulda-context (1.2.1)
|
67
|
-
shoulda-matchers (2.7.0)
|
68
|
-
activesupport (>= 3.0.0)
|
69
|
-
simplecov (0.9.1)
|
70
|
-
docile (~> 1.1.0)
|
71
|
-
multi_json (~> 1.0)
|
72
|
-
simplecov-html (~> 0.8.0)
|
73
|
-
simplecov-html (0.8.0)
|
74
|
-
thread_safe (0.3.4)
|
75
|
-
tzinfo (1.2.2)
|
76
|
-
thread_safe (~> 0.1)
|
77
|
-
webmock (1.20.4)
|
78
|
-
addressable (>= 2.3.6)
|
79
|
-
crack (>= 0.3.2)
|
80
|
-
|
81
|
-
PLATFORMS
|
82
|
-
ruby
|
83
|
-
|
84
|
-
DEPENDENCIES
|
85
|
-
bundler (~> 1.0)
|
86
|
-
httparty (~> 0.13)
|
87
|
-
jeweler (~> 2.0.1)
|
88
|
-
rdoc (~> 3.12)
|
89
|
-
shoulda
|
90
|
-
simplecov
|
91
|
-
webmock (~> 1.20)
|
data/README.mdown
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# Heap
|
2
|
-
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/heap.svg)](http://badge.fury.io/rb/heap)
|
4
|
-
|
5
|
-
Heap is a simple rubygem that makes is simple to integrate your application with [heap analytics](heapanalytics.com). It provides:
|
6
|
-
|
7
|
-
* Helpers to easily integrate heap into your Rails application
|
8
|
-
* An easy way to submit events to heap directly from your code
|
9
|
-
* The possibility to set additional attributes on your users directly from your app
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
Installation is simple via:
|
14
|
-
|
15
|
-
gem install heap
|
16
|
-
|
17
|
-
For Rails applications, run the following command to add an initiatlizer for your heap `app_id`:
|
18
|
-
|
19
|
-
rails generate heap:install
|
20
|
-
|
21
|
-
To enable the tracking code on your website, place the following in just before the closing `</head>` tag in your layout:
|
22
|
-
|
23
|
-
<%= heap_analytics %>
|
24
|
-
|
25
|
-
## Usage
|
26
|
-
|
27
|
-
After installing, you will have access to `Heap.event` and `Heap.identify` in your ruby code. For Rails, Heap provides 2 helpers to include the tracking code, and to identify individual users.
|
28
|
-
|
29
|
-
Heap needs your application ID to successfully submit data to heapanalytics.com. You can set this directly using `Heap.app_id = 123`, or in Rails, by using the provided generator to generate an initializer at config/initializers/heap.rb
|
30
|
-
|
31
|
-
### Identifying your users
|
32
|
-
|
33
|
-
The `heap_identify` view helper can be used to supply heap with attributes for your users. The helper takes 2 arguments:
|
34
|
-
|
35
|
-
* [String] email: The e-mail address used to identify your visitor in Heap
|
36
|
-
* [Hash, optional] properties: A hash containing additional properties for your users (Hashes with multiple levels are currently not supported)
|
37
|
-
|
38
|
-
Example:
|
39
|
-
|
40
|
-
<%= heap_identify(current_user.email, name: current_user.name, role: current_user.role) if signed_in? %>
|
41
|
-
|
42
|
-
If you wish to use a different handle type, only `handle`/`email` are supported at the time of writing, you can set it using `Heap.default_handle_type = 'handle'`.
|
43
|
-
|
44
|
-
Default is set to `email`.
|
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
|
-
|
52
|
-
### Tracking server-side events
|
53
|
-
|
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
|
-
|
56
|
-
* [String] event: A description of the event
|
57
|
-
* [String] identity: The e-mail address used to identify your user
|
58
|
-
* [Hash, optional] properties: A hash containing additional properties for the event (Hashes with multiple levels are currently not supported)
|
59
|
-
|
60
|
-
Example:
|
61
|
-
|
62
|
-
Heap.event("Welcome e-mail sent", "user@example.com", promotion:'second gem free', segment:'ruby developers')
|
63
|
-
|
64
|
-
### Adding server-side user attributes
|
65
|
-
|
66
|
-
To update or set properties on your users directly from your application, use `Heap.identify`. `Heap.identify` takes 2 arguments:
|
67
|
-
|
68
|
-
* [String] identity: The e-mail address used to identify your user
|
69
|
-
* [Hash] properties: A hash containing additional properties for your users (Hashes with multiple levels are currently not supported)
|
70
|
-
|
71
|
-
Example:
|
72
|
-
|
73
|
-
Heap.identify("user@example.com", segment:'ruby developers', age: 25)
|
74
|
-
|
75
|
-
### Advanced load configuration
|
76
|
-
|
77
|
-
When calling 'heap_analytics', you may set additional advanced configuration options (such as secure cookies, enabling SSL, and disabling text capture). The helper takes an optional argument:
|
78
|
-
|
79
|
-
* [Hash, optional] properties: A hash containing additional configuration options (Hashes with multiple levels are currently not supported)
|
80
|
-
|
81
|
-
Example:
|
82
|
-
|
83
|
-
<%= heap_analytics(forceSSL: true, secureCookie: true, disableTextCapture: true) %>
|
84
|
-
|
85
|
-
## Contributing to Heap
|
86
|
-
|
87
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
88
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
89
|
-
* Fork the project.
|
90
|
-
* Start a feature/bugfix branch.
|
91
|
-
* Commit and push until you are happy with your contribution.
|
92
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
93
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
94
|
-
|
95
|
-
## Copyright
|
96
|
-
|
97
|
-
The Heap gem is licensed under the MIT license. Copyright (c) 2014 Dennis de Reus. See LICENSE.txt for further details.
|
98
|
-
|
99
|
-
The Heap gem is a personal project and not affiliated to heapanalytics.com
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
|
3
|
-
class Heap
|
4
|
-
module Generators
|
5
|
-
class InstallGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path("../../templates", __FILE__)
|
7
|
-
def copy_initializer
|
8
|
-
template "heap.rb", "config/initializers/heap.rb"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|