appygram-rails 1.0.1 → 1.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.
@@ -1,10 +1,48 @@
1
1
  require 'appygram'
2
+ require 'json'
2
3
 
3
4
  module AppygramRails
4
5
  class Catcher
5
6
  class << self
7
+
8
+ def extract_http_headers(env)
9
+ headers = {}
10
+ env.select{|k, v| k =~ /^HTTP_/}.each do |name, value|
11
+ proper_name = name.sub(/^HTTP_/, '').split('_').map{|upper_case| upper_case.capitalize}.join('-')
12
+ headers[proper_name] = value
13
+ end
14
+ unless headers['Cookie'].nil?
15
+ headers['Cookie'] = headers['Cookie'].sub(/_session=\S+/, '_session=[FILTERED]')
16
+ end
17
+ headers
18
+ end
19
+
6
20
  def handle_with_controller(exception, controller=nil, request=nil)
7
- Appygram.trace(exception)
21
+ params = {}
22
+ if controller and controller.respond_to?(:current_user)
23
+ cu = controller.current_user
24
+ if cu
25
+ if cu.respond_to?(:email) and cu.email
26
+ params['email'] = cu.email
27
+ end
28
+ if cu.respond_to?(:name) and cu.name
29
+ params['name'] = cu.name
30
+ end
31
+ end
32
+ end
33
+ if request
34
+ o = {
35
+ 'url' => (request.respond_to?(:url) ? request.url : "#{request.protocol}#{request.host}#{request.request_uri}"),
36
+ 'controller' => controller.class.to_s,
37
+ 'action' => (request.respond_to?(:parameters) ? request.parameters['action'] : request.params['action']),
38
+ 'parameters' => (request.respond_to?(:parameters) ? request.parameters : request.params),
39
+ 'request_method' => request.request_method.to_s,
40
+ 'remote_ip' => (request.respond_to?(:remote_ip) ? request.remote_ip : request.ip),
41
+ 'headers' => extract_http_headers(request.env)
42
+ }
43
+ params['app_json'] = JSON o
44
+ end
45
+ Appygram.trace(exception, params)
8
46
  end
9
47
  end
10
48
  end
@@ -1,3 +1,3 @@
1
1
  module AppygramRails
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appygram-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appygram
16
- requirement: &20298560 !ruby/object:Gem::Requirement
16
+ requirement: &70161210414020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 1.0.3
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *20298560
27
+ version_requirements: *70161210414020
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rack
30
- requirement: &20297860 !ruby/object:Gem::Requirement
30
+ requirement: &70161210428320 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *20297860
38
+ version_requirements: *70161210428320
39
39
  description: appygram-rails sends uncaught Rails exceptions as traces to the hosted
40
40
  messaging service at http://www.appygram.com
41
41
  email:
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 1.8.15
78
+ rubygems_version: 1.8.17
79
79
  signing_key:
80
80
  specification_version: 3
81
81
  summary: appygram is a hosted service for sending messages from mobile/web apps