react_on_rails 11.0.4 → 11.0.5

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: 55cdca62eaf8c15553635f8255d102728e030761
4
- data.tar.gz: c72e8903805accdf9cf3964162dfdfe4254380ca
3
+ metadata.gz: 1e2e9cfdc5d161ab3706f779c18c8ce1a166b066
4
+ data.tar.gz: 6211ecc33d60cccc7d385ddcc7550a31f1502d43
5
5
  SHA512:
6
- metadata.gz: 74f8c628d2e4ef60422d383483d2828fc70e773ab85a88f2d44a8a43a357cfd61b3213e9016aefe3963371d965b70fbca3f2599f29037d09f2d3218c08cc9d06
7
- data.tar.gz: 8f34bcfa66613559f97ffaa766e676bdd6df69484eb21d1e1f1d34eeaba972910eee058e7347c84e252bee8f87b44e5282d9ae896d467d05c92ddba03a00e3cd
6
+ metadata.gz: 3cac9f496b6163da14528c717ef9c6a87ad15d11f87cab027d3af08ebe48121345f62264cd42dcd2cb64e847a38bc07a2ccb6b5951a98b9ca4737414e1a5afe2
7
+ data.tar.gz: e692554e9375d8c789894624c86639fcc442314ccc024050fca0ee4e371a7f05e047188bed0cf24f6d32497b7ee454ad9cba07fc1d062821c720a0274d4ddd50
@@ -10,6 +10,11 @@ Changes since last non-beta release.
10
10
 
11
11
  *Please add entries here for your pull requests that are not yet released.*
12
12
 
13
+ #### Changed
14
+
15
+ ### [11.0.5] - 2018-05-11
16
+ - More detailed errors for Honeybadger and Sentry. [PR 1081](https://github.com/shakacode/react_on_rails/pull/1081) by [justin808](https://github.com/justin808).
17
+
13
18
  ### [11.0.4] - 2018-05-3
14
19
 
15
20
  #### Changed
@@ -753,7 +758,8 @@ Best done with Object destructing:
753
758
  ##### Fixed
754
759
  - Fix several generator related issues.
755
760
 
756
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.0.4...master
761
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.0.5...master
762
+ [11.0.5]: https://github.com/shakacode/react_on_rails/compare/11.0.4...11.0.5
757
763
  [11.0.4]: https://github.com/shakacode/react_on_rails/compare/11.0.3...11.0.4
758
764
  [11.0.3]: https://github.com/shakacode/react_on_rails/compare/11.0.2...11.0.3
759
765
  [11.0.2]: https://github.com/shakacode/react_on_rails/compare/11.0.1...11.0.2
data/README.md CHANGED
@@ -697,6 +697,10 @@ If you are using [jquery-ujs](https://github.com/rails/jquery-ujs) for AJAX call
697
697
  1. Examples in [spec/dummy/app/views/react_router](./spec/dummy/app/views/react_router) and follow to the JavaScript code in the [spec/dummy/client/app/startup/ServerRouterApp.jsx](spec/dummy/client/app/startup/ServerRouterApp.jsx).
698
698
  1. [Code Splitting docs](./docs/additional-reading/code-splitting.md) for information about how to set up code splitting for server rendered routes.
699
699
 
700
+ ## Error Handling
701
+ * All errors from ReactOnRails will be of type ReactOnRails::Error.
702
+ * Prerendering (server rendering) errors get context information for HoneyBadger and Sentry for easier debugging.
703
+
700
704
  ## Caching and Performance
701
705
  Consider fragment and http caching of pages that contain React on Rails components. See [Caching and Performance](./docs/additional-reading/caching-and-performance.md) for more details.
702
706
 
@@ -5,7 +5,6 @@ Here is the full set of config options. This file is `/config/initializers/react
5
5
 
6
6
  # NOTE: you typically will leave the commented out configurations set to their defaults.
7
7
  # Thus, you only need to pay careful attention to the non-commented settings in this file.
8
-
9
8
  ReactOnRails.configure do |config|
10
9
  # `trace`: General debugging flag.
11
10
  # The default is true for development, off otherwise.
@@ -61,6 +60,9 @@ ReactOnRails.configure do |config|
61
60
  # The default is `%w( manifest.json )` as will be sufficient for most webpacker builds.
62
61
  #
63
62
  config.webpack_generated_files = %w( manifest.json )
63
+
64
+ # You can optionally add values to your rails_context. See example below for RenderingExtension
65
+ # config.rendering_extension = RenderingExtension
64
66
 
65
67
  ################################################################################
66
68
  ################################################################################
@@ -141,3 +143,21 @@ ReactOnRails.configure do |config|
141
143
  end
142
144
 
143
145
  ```
146
+
147
+ Example of a RenderingExtension for custom values in the `rails_context`:
148
+
149
+ ```ruby
150
+ module RenderingExtension
151
+
152
+ # Return a Hash that contains custom values from the view context that will get merged with
153
+ # the standard rails_context values and passed to all calls to generator functions used by the
154
+ # react_component and redux_store view helpers
155
+ def self.custom_context(view_context)
156
+ {
157
+ somethingUseful: view_context.session[:something_useful]
158
+ }
159
+ end
160
+ end
161
+ ```
162
+
163
+
@@ -2,10 +2,34 @@
2
2
 
3
3
  # rubocop:disable: Layout/IndentHeredoc
4
4
  module ReactOnRails
5
- class PrerenderError < StandardError
5
+ class PrerenderError < ::ReactOnRails::Error
6
+ attr_reader :component_name, :err, :props, :js_code, :console_messages
7
+
6
8
  # err might be nil if JS caught the error
7
9
  def initialize(component_name: nil, err: nil, props: nil,
8
10
  js_code: nil, console_messages: nil)
11
+ @component_name = component_name
12
+ @err = err
13
+ @props = props
14
+ @js_code = js_code
15
+ @console_messages = console_messages
16
+
17
+ backtrace, message = calc_message(component_name, console_messages, err, js_code, props)
18
+
19
+ super([message, backtrace].compact.join("\n"))
20
+ end
21
+
22
+ def to_honeybadger_context
23
+ to_error_context
24
+ end
25
+
26
+ def raven_context
27
+ to_error_context
28
+ end
29
+
30
+ private
31
+
32
+ def calc_message(component_name, console_messages, err, js_code, props)
9
33
  message = "ERROR in SERVER PRERENDERING\n".dup
10
34
  if err
11
35
  # rubocop:disable Layout/IndentHeredoc
@@ -33,8 +57,17 @@ console messages:
33
57
  MSG
34
58
  # rubocop:enable Layout/IndentHeredoc
35
59
  end
60
+ [backtrace, message]
61
+ end
36
62
 
37
- super([message, backtrace].compact.join("\n"))
63
+ def to_error_context
64
+ {
65
+ component_name: component_name,
66
+ err: err,
67
+ props: props,
68
+ js_code: js_code,
69
+ console_messages: console_messages
70
+ }
38
71
  end
39
72
  end
40
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "11.0.4".freeze
4
+ VERSION = "11.0.5".freeze
5
5
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "11.0.4",
3
+ "version": "11.0.5",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.4
4
+ version: 11.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-04 00:00:00.000000000 Z
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable