hyperfocal 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -18
- data/bin/hyperfocal +3 -0
- data/lib/hyperfocal/commands.rb +68 -0
- data/lib/hyperfocal/record.rb +2 -0
- data/lib/hyperfocal/transmitter.rb +17 -0
- data/lib/hyperfocal/version.rb +1 -1
- data/lib/hyperfocal.rb +55 -1
- metadata +26 -16
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/hyperfocal.gemspec +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c47d9b331310563355dcb8b4bb2c1b7aa2e9534
|
4
|
+
data.tar.gz: e576d76d0078155f23cdb3b803df78a4f8dba3ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61f9f5ad2fee2b3cccd81f3a9f9e0919b4a3825e4d5ce4a8b930544a8bd3f558bbe1823190ede5a9337178173dfcfbea1f668bda99042207fe6d17eab413ce41
|
7
|
+
data.tar.gz: 5af1ccb7e298781fce47c09349f7eb6783f9b991b23cceacb294417ff4523086bddd7cba6d0bac7eb86fb91c1cd3c405c3534ef10df9d1640c0749744f795897
|
data/README.md
CHANGED
@@ -1,39 +1,52 @@
|
|
1
1
|
# Hyperfocal
|
2
2
|
|
3
|
-
|
3
|
+
## Installation
|
4
4
|
|
5
|
-
|
5
|
+
Visit [hyperfocal.io](http://hyperfocal.io) to set up an account, and find installation instructions
|
6
6
|
|
7
|
-
##
|
7
|
+
## Usage
|
8
8
|
|
9
|
-
|
9
|
+
After making sure you have an account on Hyperfocal, you can use the following
|
10
|
+
in your application.
|
10
11
|
|
11
|
-
|
12
|
-
gem 'hyperfocal'
|
13
|
-
```
|
12
|
+
### Event Tracking
|
14
13
|
|
15
|
-
|
14
|
+
To track an event, simply use this line in your application
|
15
|
+
`Hyperfocal.event('event_name', other_attributes_as_hash)`
|
16
16
|
|
17
|
-
|
17
|
+
Optional (but helpful) attributes to include
|
18
18
|
|
19
|
-
|
19
|
+
```
|
20
|
+
user_id: Used to filter events by user/unique user
|
21
|
+
```
|
20
22
|
|
21
|
-
|
23
|
+
This will send an event to Hyperfocal
|
22
24
|
|
23
|
-
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
### Metric Tracking
|
27
|
+
|
28
|
+
Hyperfocal allows you to report metrics to the system. You can view them,
|
29
|
+
as averages, mins, or maxs.
|
30
|
+
|
31
|
+
To track a metric, use the following code in your application
|
32
|
+
`Hyperfocal.metric('metric_name', 'metric_value', other_attributes_as_hash)`
|
26
33
|
|
27
|
-
|
34
|
+
The supported metric values are strings, and integers. If you report the metrics
|
35
|
+
as integers, you can use the average, min, and max reporting type in Hyperfocal
|
28
36
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
37
|
|
31
|
-
|
38
|
+
### User Tracking
|
32
39
|
|
33
|
-
|
40
|
+
If you'd like to see more detailed information about your users in Hyperfocal,
|
41
|
+
you can report the User information to Hyperfocal.
|
34
42
|
|
35
|
-
|
43
|
+
To report a user to Hyperfocal, simply use the following
|
44
|
+
`Hyperfocal.user(attributes_as_hash)`.
|
36
45
|
|
46
|
+
The only required field for a user, is whatever unique identifier is used by
|
47
|
+
your application. This is required to be unique for all your users,
|
48
|
+
as if you report two differnet users with the same ID. We will overwrite the
|
49
|
+
previous information, as the reported information is taken as gospel.
|
37
50
|
|
38
51
|
## License
|
39
52
|
|
data/bin/hyperfocal
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'hyperfocal'
|
2
|
+
require 'net/http'
|
3
|
+
require 'thor'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Hyperfocal
|
7
|
+
class Commands < Thor
|
8
|
+
desc :setup, 'Set up Hyperfocal'
|
9
|
+
def setup(token=nil)
|
10
|
+
return say('A token is required. Please visit http://hyperfocal.io to get a setup token', :red) if token.nil?
|
11
|
+
return say('Invalid app token, please make sure you have it correct', :red) unless valid_token?(token)
|
12
|
+
|
13
|
+
if File.exists?(initializer_path)
|
14
|
+
say('Initializer already exists', :red)
|
15
|
+
say('You can view your app at http://hyperfocal.io or remove config/initializers/hyperfocal.rb and set it up as a new app', :red)
|
16
|
+
else
|
17
|
+
write_initializer(token)
|
18
|
+
activate_app(token)
|
19
|
+
say('Congratulations, your app is ready to send events to Hyperfocal', :green)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc :uninstall, 'Uninstall Hyperfocal'
|
24
|
+
def uninstall
|
25
|
+
if File.exists?(initializer_path)
|
26
|
+
File.delete(initializer_path)
|
27
|
+
say('The Hyperfocal initializer has been removed.')
|
28
|
+
say('Removing the gem from your Gemfile, and code from your app will complete the installation')
|
29
|
+
say("We're sad to see you go, if there's anything we can do, drop us a line at support@hyperfocal.io")
|
30
|
+
else
|
31
|
+
say('Hyperfocal does not have a configuration file, there is nothing to uninstall', :red)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def initializer_path
|
38
|
+
File.expand_path(relative_initializer_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def relative_initializer_path
|
42
|
+
'config/initializers/hyperfocal.rb'
|
43
|
+
end
|
44
|
+
|
45
|
+
def write_initializer(token)
|
46
|
+
FileUtils.mkdir_p(File.dirname(initializer_path))
|
47
|
+
|
48
|
+
File.open(initializer_path, 'w') do |f|
|
49
|
+
f.puts <<-CONF
|
50
|
+
Hyperfocal.configure do |config|
|
51
|
+
config.app_id = #{token}
|
52
|
+
end
|
53
|
+
CONF
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def activate_app(token)
|
58
|
+
uri = URI('http://api.hyperfocal.io/activate')
|
59
|
+
req = Net::HTTP.post_form(uri, { token: token })
|
60
|
+
end
|
61
|
+
|
62
|
+
def valid_token?(token)
|
63
|
+
req = Net::HTTP.get("api.hyperfocal.io", "/validate?token=#{token}")
|
64
|
+
return JSON.parse(req.to_s)['valid']
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hyperfocal
|
2
|
+
module Transmitter
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def send(type, params)
|
6
|
+
url = URI(url_for(type))
|
7
|
+
Net::HTTP.post_form(url, params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def url_for(type)
|
11
|
+
raise 'Unknown Tracking Type' unless %w[ event metric user ].include?(type)
|
12
|
+
|
13
|
+
host = Hyperfocal.host
|
14
|
+
return "#{host}/#{type}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/hyperfocal/version.rb
CHANGED
data/lib/hyperfocal.rb
CHANGED
@@ -1,5 +1,59 @@
|
|
1
|
+
require "yaml"
|
1
2
|
require "hyperfocal/version"
|
3
|
+
require "hyperfocal/transmitter"
|
2
4
|
|
3
5
|
module Hyperfocal
|
4
|
-
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration
|
8
|
+
|
9
|
+
def configure
|
10
|
+
self.configuration ||= Configuration.new
|
11
|
+
yield(configuration)
|
12
|
+
configuration.host = 'https://api.hyperfocal.io'
|
13
|
+
end
|
14
|
+
|
15
|
+
def host
|
16
|
+
raise 'App ID Not Set' if configuration.app_id.nil?
|
17
|
+
|
18
|
+
configuration.host + '/track/' + configuration.app_id
|
19
|
+
end
|
20
|
+
|
21
|
+
def event(event, attrs = {})
|
22
|
+
send_request do
|
23
|
+
event_params = { event: attrs.merge(title: event) }
|
24
|
+
Transmitter.send('event', event_params)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def metric(metric, value, attrs = {})
|
29
|
+
send_request do
|
30
|
+
metric_params = { metric: attrs.merge(title: metric, value: value) }
|
31
|
+
Transmitter.send('metric', metric_params)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def user(attrs)
|
36
|
+
send_request do
|
37
|
+
user_params = { user: attrs }
|
38
|
+
Transmitter.send('user', user_params)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def send_request(&block)
|
43
|
+
thr = Thread.new do
|
44
|
+
yield
|
45
|
+
end
|
46
|
+
thr.join
|
47
|
+
thr.exit
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Configuration
|
52
|
+
attr_accessor :app_id
|
53
|
+
attr_reader :host
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
@host = 'https://api.hyperfocal.io'
|
57
|
+
end
|
58
|
+
end
|
5
59
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperfocal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Pineworks Inc.
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,22 +68,18 @@ dependencies:
|
|
54
68
|
version: '3.0'
|
55
69
|
description:
|
56
70
|
email:
|
57
|
-
-
|
58
|
-
executables:
|
71
|
+
- support@pineworks.io
|
72
|
+
executables:
|
73
|
+
- hyperfocal
|
59
74
|
extensions: []
|
60
75
|
extra_rdoc_files: []
|
61
76
|
files:
|
62
|
-
- ".gitignore"
|
63
|
-
- ".rspec"
|
64
|
-
- ".travis.yml"
|
65
|
-
- Gemfile
|
66
|
-
- LICENSE.txt
|
67
77
|
- README.md
|
68
|
-
-
|
69
|
-
- bin/console
|
70
|
-
- bin/setup
|
71
|
-
- hyperfocal.gemspec
|
78
|
+
- bin/hyperfocal
|
72
79
|
- lib/hyperfocal.rb
|
80
|
+
- lib/hyperfocal/commands.rb
|
81
|
+
- lib/hyperfocal/record.rb
|
82
|
+
- lib/hyperfocal/transmitter.rb
|
73
83
|
- lib/hyperfocal/version.rb
|
74
84
|
homepage: http://hyperfocal.io
|
75
85
|
licenses:
|
@@ -95,5 +105,5 @@ rubyforge_project:
|
|
95
105
|
rubygems_version: 2.5.1
|
96
106
|
signing_key:
|
97
107
|
specification_version: 4
|
98
|
-
summary:
|
108
|
+
summary: An event reporting app for Ruby
|
99
109
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016 Aaron Miler
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "hyperfocal"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/hyperfocal.gemspec
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'hyperfocal/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "hyperfocal"
|
8
|
-
spec.version = Hyperfocal::VERSION
|
9
|
-
spec.authors = ["Aaron Miler"]
|
10
|
-
spec.email = ["aaron@pineworks.io"]
|
11
|
-
|
12
|
-
spec.summary = %q{A Ruby gem for reporting to hyperfocal.io}
|
13
|
-
spec.homepage = "http://hyperfocal.io"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
if spec.respond_to?(:metadata)
|
19
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
-
else
|
21
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
-
"public gem pushes."
|
23
|
-
end
|
24
|
-
|
25
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
-
f.match(%r{^(test|spec|features)/})
|
27
|
-
end
|
28
|
-
|
29
|
-
spec.bindir = "exe"
|
30
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = ["lib"]
|
32
|
-
|
33
|
-
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
-
end
|