game_analytics 0.0.1 → 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94d50722665774ca90d5e42edb9e727a931fbdff
4
+ data.tar.gz: 0a62b5479e0ad7db5d251d727f9e53a78668e3ca
5
+ SHA512:
6
+ metadata.gz: 32d4129191048cba941f9c61a707df6c2847607b5eecedd4c3ec3759d1b81bf72a981e1f08399cbb70998faede16249c3ddd3efbac17eaf14fc27dc22a7f1a1d
7
+ data.tar.gz: 27c13be5e2e3484d5b285d1c080c9078a1f44d8c0180cab2913b3bacf8671923cc72248ed9a39e21b262d3f50a6df00ee4e8a8b927f92bdc48ed1c349eb7145f
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ /.idea/
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 William Lipa
1
+ Copyright (c) 2013 William Lipa, Niklas Bichinger
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -41,7 +41,14 @@ In your application, create Metric objects of the appropriate GameAnalytics type
41
41
  m = GameAnalytics::Metric::Business.new(:user_id => '-100', :session_id => '-100',
42
42
  :build => 'development', :message => 'test')
43
43
  GameAnalytics.client.enqueue m
44
-
44
+
45
+ GameAnalytics uses the submitting ip to determine the country the user resides in. If you are submitting events
46
+ in the name of the user (e.g. client) from another machine (e.g. server), you can pass the original ip using `new_with_ip`:
47
+
48
+ m = GameAnalytics::Metric::Business.new_with_ip('123.123.123.123', :user_id => '-100', :session_id => '-100',
49
+ :build => 'development', :message => 'test')
50
+ GameAnalytics.client.enqueue m
51
+
45
52
  You can also send arrays of objects in a single service request:
46
53
 
47
54
  GameAnalytics.client.enqueue [m1, m2]
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'game_analytics/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "game_analytics"
7
+ spec.name = 'game_analytics'
8
8
  spec.version = GameAnalytics::VERSION
9
- spec.authors = ["wlipa"]
10
- spec.email = ["dojo@masterleep.com"]
11
- spec.description = %q{Lightweight and non-disruptive interface to save metrics data to gameanalytics.com}
12
- spec.summary = %q{saves metrics data to gameanalytics.com}
13
- spec.homepage = ""
14
- spec.license = "MIT"
9
+ spec.description = %q{Lightweight and non-disruptive interface to save metrics data to gameanalytics.com using its REST API}
10
+ spec.summary = %q{Interface to the REST API of the metrics collection service gameanalytics.com}
11
+ spec.homepage = 'https://github.com/bichinger/game_analytics'
12
+ spec.license = 'MIT'
13
+ spec.authors = ['wlipa','gr8bit']
14
+ spec.email = ['niklas@bichinger.de']
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ spec.files = `git ls-files`.split("\n")
18
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency('httpclient')
22
22
  spec.add_dependency('rails')
@@ -2,8 +2,15 @@ module GameAnalytics
2
2
  class Metric
3
3
 
4
4
  include Common
5
-
6
-
5
+
6
+ attr_accessor :origin_ip
7
+
8
+ def self.new_with_ip(ip, data={})
9
+ metric = self.new(data)
10
+ metric.origin_ip = ip
11
+ metric
12
+ end
13
+
7
14
  def initialize(data={})
8
15
  @data = data
9
16
  needs = required_keys - data.keys
@@ -36,6 +43,5 @@ class Metric
36
43
  class Quality < Metric
37
44
  end
38
45
 
39
-
40
46
  end
41
47
  end
@@ -1,5 +1,5 @@
1
1
  module GameAnalytics
2
2
 
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
 
5
5
  end
@@ -14,13 +14,16 @@ class Worker
14
14
  end
15
15
 
16
16
  def process(unit)
17
- klass = unit.is_a?(Array) ? unit.first.class : unit.class
18
- category = klass.name.demodulize.downcase
17
+ metric = unit.is_a?(Array) ? unit.first : unit
18
+ klass = metric.class
19
+
19
20
  json_data = unit.to_json
20
- hd = Digest::MD5.hexdigest(json_data + options[:secret_key])
21
+ header = {'Authorization' => Digest::MD5.hexdigest(json_data + options[:secret_key])}
22
+ header['X-Forwarded-For'] = metric.origin_ip if metric.origin_ip
23
+ category = klass.name.demodulize.downcase
21
24
  url = "#{@url_base}/#{category}"
22
- logger.info "GameAnalytics <: #{url} #{json_data} #{hd}"
23
- resp = @http.post(url, :body => json_data, :header => { 'Authorization' => hd })
25
+ logger.info "GameAnalytics <: #{url} #{json_data} #{header.inspect}"
26
+ resp = @http.post(url, :body => json_data, :header => header)
24
27
  logger.info "GameAnalytics >: #{resp.content} (#{resp.status})"
25
28
  end
26
29
 
metadata CHANGED
@@ -1,88 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: game_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - wlipa
8
+ - gr8bit
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2015-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ! '>='
18
+ - - ">="
20
19
  - !ruby/object:Gem::Version
21
20
  version: '0'
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ! '>='
25
+ - - ">="
28
26
  - !ruby/object:Gem::Version
29
27
  version: '0'
30
28
  - !ruby/object:Gem::Dependency
31
29
  name: rails
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ! '>='
32
+ - - ">="
36
33
  - !ruby/object:Gem::Version
37
34
  version: '0'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
- - - ! '>='
39
+ - - ">="
44
40
  - !ruby/object:Gem::Version
45
41
  version: '0'
46
42
  - !ruby/object:Gem::Dependency
47
43
  name: bundler
48
44
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ~>
46
+ - - "~>"
52
47
  - !ruby/object:Gem::Version
53
48
  version: '1.3'
54
49
  type: :development
55
50
  prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
- - - ~>
53
+ - - "~>"
60
54
  - !ruby/object:Gem::Version
61
55
  version: '1.3'
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: rake
64
58
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
59
  requirements:
67
- - - ! '>='
60
+ - - ">="
68
61
  - !ruby/object:Gem::Version
69
62
  version: '0'
70
63
  type: :development
71
64
  prerelease: false
72
65
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
- - - ! '>='
67
+ - - ">="
76
68
  - !ruby/object:Gem::Version
77
69
  version: '0'
78
70
  description: Lightweight and non-disruptive interface to save metrics data to gameanalytics.com
71
+ using its REST API
79
72
  email:
80
- - dojo@masterleep.com
73
+ - niklas@bichinger.de
81
74
  executables: []
82
75
  extensions: []
83
76
  extra_rdoc_files: []
84
77
  files:
85
- - .gitignore
78
+ - ".gitignore"
86
79
  - Gemfile
87
80
  - LICENSE.txt
88
81
  - README.md
@@ -94,29 +87,28 @@ files:
94
87
  - lib/game_analytics/metric.rb
95
88
  - lib/game_analytics/version.rb
96
89
  - lib/game_analytics/worker.rb
97
- homepage: ''
90
+ homepage: https://github.com/bichinger/game_analytics
98
91
  licenses:
99
92
  - MIT
93
+ metadata: {}
100
94
  post_install_message:
101
95
  rdoc_options: []
102
96
  require_paths:
103
97
  - lib
104
98
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
99
  requirements:
107
- - - ! '>='
100
+ - - ">="
108
101
  - !ruby/object:Gem::Version
109
102
  version: '0'
110
103
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
104
  requirements:
113
- - - ! '>='
105
+ - - ">="
114
106
  - !ruby/object:Gem::Version
115
107
  version: '0'
116
108
  requirements: []
117
109
  rubyforge_project:
118
- rubygems_version: 1.8.25
110
+ rubygems_version: 2.4.5
119
111
  signing_key:
120
- specification_version: 3
121
- summary: saves metrics data to gameanalytics.com
112
+ specification_version: 4
113
+ summary: Interface to the REST API of the metrics collection service gameanalytics.com
122
114
  test_files: []