wat_catcher 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
data/lib/wat_catcher/railtie.rb
CHANGED
@@ -13,7 +13,12 @@ module WatCatcher
|
|
13
13
|
config_file = ::Rails.root.join("config", "wat_catcher.yml")
|
14
14
|
config = YAML.load_file(config_file) if File.exists?(config_file)
|
15
15
|
WatCatcher.configure(config[::Rails.env] ? config[::Rails.env] : config) if config
|
16
|
+
|
17
|
+
end
|
18
|
+
initializer "wat_catcher.view_helpers" do |app|
|
19
|
+
ActionView::Base.send :include, ::WatCatcher::Helper
|
16
20
|
end
|
21
|
+
|
17
22
|
end
|
18
23
|
|
19
24
|
end
|
data/lib/wat_catcher/version.rb
CHANGED
data/lib/wat_catcher.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
#Send the error to the same host that served this file (I think)
|
2
|
+
class @WatCatcher
|
3
|
+
|
4
|
+
|
5
|
+
constructor: (target=window) ->
|
6
|
+
scripts = document.getElementsByTagName("script");
|
7
|
+
node = scripts[scripts.length - 1];
|
8
|
+
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 @appEnv? && @host?
|
14
|
+
break
|
15
|
+
|
16
|
+
@oldErrorHandler = target.onerror
|
17
|
+
target.onerror = @watHandler
|
18
|
+
|
19
|
+
toQuery: (params, prefix="") ->
|
20
|
+
query = ""
|
21
|
+
|
22
|
+
unless params instanceof Object
|
23
|
+
return "#{prefix}=#{params}&"
|
24
|
+
|
25
|
+
for k, v of params
|
26
|
+
k = encodeURIComponent(k)
|
27
|
+
k = if prefix == "" then k else "#{prefix}[#{k}]"
|
28
|
+
if v instanceof Array
|
29
|
+
for i in v
|
30
|
+
query += @toQuery(i, "#{k}[]")
|
31
|
+
else if v instanceof Object
|
32
|
+
query += "#{@toQuery(v, k)}"
|
33
|
+
else
|
34
|
+
query += "#{k}=#{encodeURIComponent(v)}&"
|
35
|
+
query
|
36
|
+
|
37
|
+
watHandler: (msg, url, line) =>
|
38
|
+
try
|
39
|
+
params = {
|
40
|
+
wat: {
|
41
|
+
page_url: window.location.toString()
|
42
|
+
message: msg
|
43
|
+
backtrace: [url+":"+line]
|
44
|
+
app_env: @appEnv
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
img = new Image()
|
49
|
+
img.src = "#{@host}/create/wat?#{@toQuery(params)}"
|
50
|
+
catch error
|
51
|
+
|
52
|
+
if typeof @oldErrorHandler == 'function'
|
53
|
+
@oldErrorHandler(arguments...)
|
54
|
+
|
55
|
+
|
56
|
+
window.watCatcher = new WatCatcher()
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wat_catcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -128,9 +128,10 @@ files:
|
|
128
128
|
- lib/wat_catcher/middleware.rb
|
129
129
|
- lib/wat_catcher/railtie.rb
|
130
130
|
- lib/wat_catcher/version.rb
|
131
|
+
- lib/wat_catcher/wattle_helper.rb
|
131
132
|
- spec/javascripts/support/jasmine.yml
|
132
133
|
- spec/javascripts/wat_catcher_spec.coffee
|
133
|
-
- vendor/assets/javascripts/wat_catcher.coffee
|
134
|
+
- vendor/assets/javascripts/wat_catcher.coffee
|
134
135
|
- wat_catcher.gemspec
|
135
136
|
homepage: ''
|
136
137
|
licenses:
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#Send the error to the same host that served this file (I think)
|
2
|
-
class @WatCatcher
|
3
|
-
|
4
|
-
constructor: (target=window) ->
|
5
|
-
@oldErrorHandler = target.onerror
|
6
|
-
target.onerror = @watHandler
|
7
|
-
|
8
|
-
watHandler: (msg, url, line) =>
|
9
|
-
xmlhttp = if window.XMLHttpRequest
|
10
|
-
new XMLHttpRequest()
|
11
|
-
else
|
12
|
-
new ActiveXObject("Microsoft.XMLHTTP")
|
13
|
-
|
14
|
-
params = "wat[page_url]=#{escape(window.location.toString())}"
|
15
|
-
params += "&wat[message]=#{escape(msg)}"
|
16
|
-
params += "&wat[backtrace][]=#{escape(url+":"+line)}"
|
17
|
-
params += "&wat[app_env]=#{escape(@appEnv)}"
|
18
|
-
xmlhttp.open("POST", "<%= WatCatcher.configuration.host %>/wats", true);
|
19
|
-
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
20
|
-
xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
21
|
-
xmlhttp.send(params);
|
22
|
-
|
23
|
-
if typeof @oldErrorHandler == 'function'
|
24
|
-
@oldErrorHandler(msg, url, line)
|
25
|
-
|
26
|
-
window.watCatcher = new WatCatcher()
|