wat_catcher 0.2.4 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 059ab5a6a7d7fe37b117e3290bd8825ca7f5399a
4
- data.tar.gz: 14a467fa7a3e62c0e742836116f4ebfa18f4f96b
3
+ metadata.gz: 5fb2129c1a2999ffff9869cd6803a44160f2016a
4
+ data.tar.gz: 4b2cfcbce4bf60f45ae5f0ac1b74e946e1cb9168
5
5
  SHA512:
6
- metadata.gz: 740d9b19ed9a47d036150be2d9c811d444499482c256acf7742e319a2d3269dad96c3b5983c0ede7a06233253d7bcea8d53b2442e6defe0366ba88ae202356be
7
- data.tar.gz: 9a947a3a0dc5e8f0e58423e8b514ab857c8111dc0e50ca2c3f48d4ea481ba416f140f72b2c65a83f97985b0627fc0e07d751db9dfac976a55fbb5036a00c7742
6
+ metadata.gz: 2ebe816f36becb10568d1f2282a13df1eb609d157555dbed7cd42ac39780cd5baf25fd1830f2c3bf94b904c772b3397d16ba610c014f838d1751027d05cd6c09
7
+ data.tar.gz: 50e29d28ff2bb387eaa07cef80cc2d5d2c8f63cde8b39232be25503a6aacf3f4326050a21a868633e9b24acef8da040d00239481e7bd2d3d17d5d7ed7e3a2463
@@ -0,0 +1,10 @@
1
+ module WatCatcher
2
+ class WatsController < ApplicationController
3
+ skip_before_filter :verify_authenticity_token, only: :create
4
+
5
+ def create
6
+ Report.new(nil, request: request)
7
+ head :ok
8
+ end
9
+ end
10
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ WatCatcher::Engine.routes.draw do
2
+ resources :wats, only: :create, module: "wat_catcher"
3
+ end
@@ -1,7 +1,6 @@
1
1
  module WatCatcher
2
- module Rails
3
- class Engine < ::Rails::Engine
4
- # Get rails to add app, lib, vendor to load path
5
- end
2
+ class Engine < ::Rails::Engine
3
+ engine_name "wat_catcher"
6
4
  end
7
- end
5
+ end
6
+
@@ -14,11 +14,21 @@ module WatCatcher
14
14
  end
15
15
 
16
16
  def params
17
- { wat: exception_description.merge(request_description).merge(worker_description) }
17
+ { wat: exception_description.merge(request_description).merge(worker_description).merge(param_exception_description) }
18
18
  end
19
19
 
20
+ def param_exception_description
21
+ return {} if exception || request.blank?
22
+ wat_params = request.params[:wat]
23
+ {
24
+ backtrace: wat_params[:backtrace],
25
+ page_url: wat_params[:page_url],
26
+ request_params: nil
27
+ }
28
+ end
20
29
 
21
30
  def exception_description
31
+ return {} unless exception
22
32
  {
23
33
  backtrace: exception.backtrace.to_a,
24
34
  message: exception.message,
@@ -1,3 +1,3 @@
1
1
  module WatCatcher
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,7 +1,9 @@
1
1
  module WatCatcher
2
2
  module Helper
3
3
  def javascript_wat_catcher
4
- javascript_include_tag "wat_catcher", "data-host" => WatCatcher.configuration.host, "data-app_env" => ::Rails.env, "data-app_name" => ::Rails.application.class.parent_name
4
+ javascript_include_tag "wat_catcher",
5
+ "data-route" => wat_catcher.wats_path,
6
+ "data-app_name" => ::Rails.application.class.parent_name
5
7
  end
6
8
  end
7
9
  end
data/lib/wat_catcher.rb CHANGED
@@ -7,7 +7,6 @@ require "wat_catcher/wattle_helper"
7
7
  require "wat_catcher/sidekiq_middleware"
8
8
  require "wat_catcher/sidekiq_poster"
9
9
 
10
-
11
10
  require "wat_catcher/railtie" if defined?(Rails::Railtie)
12
11
  module WatCatcher
13
12
  class << self
@@ -1,19 +1,13 @@
1
1
  #Send the error to the same host that served this file (I think)
2
2
  class @WatCatcher
3
-
4
-
5
3
  constructor: (target=window) ->
6
4
  scripts = document.getElementsByTagName("script");
7
5
  node = scripts[scripts.length - 1];
6
+ @attrs = {}
8
7
  for attr in node.attributes
9
- if attr.nodeName == 'data-host'
10
- @host = attr.nodeValue
11
- if attr.nodeName == 'data-app_env'
12
- @appEnv = attr.nodeValue
13
- if attr.nodeName == 'data-app_name'
14
- @appName = attr.nodeValue
15
- if @appEnv? && @host? && @appName?
16
- break
8
+ attrs = /data-(.*)/.exec(attr.nodeName)
9
+ if attrs?
10
+ @attrs[attrs[1]] = attr.nodeValue
17
11
 
18
12
  @oldErrorHandler = target.onerror
19
13
  target.onerror = @watHandler
@@ -43,17 +37,24 @@ class @WatCatcher
43
37
  page_url: window.location.toString()
44
38
  message: msg
45
39
  backtrace: [url+":"+line]
46
- app_env: @appEnv
47
- app_name: @appName
40
+ app_env: @attrs.appEnv
41
+ app_name: @attrs.appName
48
42
  }
49
43
  }
50
44
 
51
- img = new Image()
52
- img.src = "#{@host}/create/wat?#{@toQuery(params)}"
53
- catch error
45
+ xmlhttp = if window.XMLHttpRequest
46
+ new XMLHttpRequest()
47
+ else
48
+ new ActiveXObject("Microsoft.XMLHTTP")
49
+
50
+ xmlhttp.open("POST", @attrs.route, true);
51
+ xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
52
+ xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
53
+ xmlhttp.send(@toQuery(params));
54
54
 
55
- if typeof @oldErrorHandler == 'function'
56
- @oldErrorHandler(arguments...)
55
+ catch error
56
+ if typeof @oldErrorHandler == 'function'
57
+ @oldErrorHandler(arguments...)
57
58
 
58
59
 
59
60
  window.watCatcher = new WatCatcher()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wat_catcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Constantine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-20 00:00:00.000000000 Z
11
+ date: 2013-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,6 +137,8 @@ files:
137
137
  - LICENSE.txt
138
138
  - README.md
139
139
  - Rakefile
140
+ - app/controllers/wat_catcher/wats_controller.rb
141
+ - config/routes.rb
140
142
  - lib/wat_catcher.rb
141
143
  - lib/wat_catcher/engine.rb
142
144
  - lib/wat_catcher/middleware.rb