Skip to content

Add ReactJs usage instructions#12

Merged
steren merged 1 commit intoGoogleCloudPlatform:masterfrom
oshalygin:feature/add-reactjs-instructions
May 16, 2017
Merged

Add ReactJs usage instructions#12
steren merged 1 commit intoGoogleCloudPlatform:masterfrom
oshalygin:feature/add-reactjs-instructions

Conversation

@oshalygin
Copy link
Contributor

CLA signed:

image

  • There are numerous options to how the library
    can be consumed and used within a ReactJs application
    and the examples/instructions given in the README.md
    are merely examples of how the stackdriver-error-js
    library can be instrumented within a ReactJs
    application.
  • Once the library is published to npm, the instructions
    to import the module will be updated accordingly.

Addresses #11

Copy link
Collaborator

@steren steren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!
Actually, I realize that most of the instructions are not React specific:

  1. and 2. are just the regular setup
  2. and 4. are best practices to have the behavior differ between dev and prod, they would benefit anybody using webpack for example (with or without React)

README.md Outdated
//# sourceMappingURL=http://example.com/path/to/your/sourcemap.map
```

## Setup for ReactJs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Use 'React' or 'ReactJS' (capital S)

README.md Outdated
});
```

3. If using webpack and the `DefinePlugin`, it is advisable to wrap the initialization logic to only occur in your production environment. Otherwise, with local development you will receive 403s if you restricted your API key to your production href(which is _HIGHLY_ recommended). The code for this would look something along these lines:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This advise applies for all framework. I would suggest to move it outside of the React instructions.

README.md Outdated
}
```

4. If you would like to use the logger throughout your application, there are many options that exist within the React ecosystem. The simplest is to pull the initialization logic into its own file and reference it as necessary throughout your application. An example would be as follows:
Copy link
Collaborator

@steren steren May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this is not React specific. I suggest to do a dedicated section with point 3 and 4 about best practices for dev and prod environment.

README.md Outdated
</head>
```

2. You can capture all exceptions with the following logic in your entry point, typically `index.js` with the following code:
Copy link
Collaborator

@steren steren May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. and 2. are not React specific, they are what is already described in the set up instructions. I'd suggest to just say that for React, users need to follow the regular setup instructions.

@ties
Copy link

ties commented May 16, 2017

(Un)fortunately I have experience debugging sporadic, browser-specific errors in React applications.

When recommending an approach for error logging in React please consider how async errors are handled.

Support for error boundaries are being added, but other libraries (redux, react-router) need to be handled differently.

If there is an easy way to listen for "async stacktraces" such as provided by the chrome console, please let me know :-)

@oshalygin
Copy link
Contributor Author

Very good feedback @steren , I'll send an update shortly.

@oshalygin oshalygin force-pushed the feature/add-reactjs-instructions branch 2 times, most recently from 47fbb2b to 81e872e Compare May 16, 2017 17:34
@oshalygin
Copy link
Contributor Author

@steren take a look at the changes and let me know if you have any feedback.

Thanks!!

README.md Outdated

## Best Practices

### Usage with Webpack
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to be more specific in this title. Something like 'Only report in prod environment with Webpack'

## Best Practices

### Usage with Webpack

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to your production href

What is 'href'? Use 'environment'?

- There are numerous options to how the library
  can be consumed and used within a ReactJs application
  and the examples/instructions given in the README.md
  are merely examples of how the stackdriver-error-js
  library can be instrumented within a ReactJs
  application.
- Once the library is published to npm, the instructions
  to import the module will be updated accordingly.
- Additition of a best practices section which helps
  guide users on how the library can be used in conjunction
  with Webpack and as a standalone modular utility.

Addresses GoogleCloudPlatform#11
@oshalygin oshalygin force-pushed the feature/add-reactjs-instructions branch from 81e872e to 7094673 Compare May 16, 2017 20:03
@oshalygin
Copy link
Contributor Author

@steren updated! Let me know what you think :)

@steren steren merged commit 8ad1c1d into GoogleCloudPlatform:master May 16, 2017
@steren
Copy link
Collaborator

steren commented May 16, 2017

Thanks a lot for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants