-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update docs #1012
Merged
Merged
Update docs #1012
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,5 @@ | ||
# Analytics | ||
|
||
The application supports tracking page views with pluggable analytics handlers. | ||
Documentation moved to the Flex Docs site: | ||
|
||
## Google Analytics | ||
|
||
Google Analytics (GA) is supported by default. The enable GA, set the GA tracker ID to the | ||
environment variable `REACT_APP_GOOGLE_ANALYTICS_ID`; | ||
|
||
## Custom analytics handler | ||
|
||
If you want to add a new analytics library, you can do as follows: | ||
|
||
1. Add the analytics library script | ||
|
||
If the analytics library has an external script, add the library script tag to the | ||
[src/public/index.html](../public/index.html) file. If you need more control, see how the GA | ||
script is added in [server/renderer.js](../server/renderer.js). | ||
|
||
1. Create a handler | ||
|
||
To track page views, create a custom handler e.g. in | ||
[src/analytics/handlers.js](../src/analytics/handlers.js). The handler should be a class that | ||
implements a `trackPageView(url)` method. | ||
|
||
Note that the `url` parameter might not be the same as in the URL bar of the browser. It is the | ||
canonical form of the URL. For example, in the listing page it doesn't have the dynamic title | ||
slug in the middle. This allows unified analytics and correct tracking of pages that can be | ||
accessed from multiple different URLs. | ||
|
||
If you analytics library takes the page URL from the browser, you might need to override that | ||
behavior to use the canonical URL that is given to the method. | ||
|
||
1. Initialise the handler | ||
|
||
Initialise the handler in the `setupAnalyticsHandlers()` function in | ||
[src/index.js](../src/index.js). | ||
https://www.sharetribe.com/docs/guides/how-to-set-up-analytics-for-ftw/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,5 @@ | ||
# Content Security Policy (CSP) | ||
|
||
According to [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP): | ||
Documentation moved to the Flex Docs site: | ||
|
||
> Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate | ||
> certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These | ||
> attacks are used for everything from data theft to site defacement or distribution of malware. | ||
|
||
This document describes how to use a CSP with the Flex template app. By default the CSP is disabled. | ||
By turning it on, the default whitelist in [server/csp.js](../server/csp.js) works with the all the | ||
URLs and tools that come with the application. | ||
|
||
## Setup | ||
|
||
The CSP is configured using the `REACT_APP_CSP` environment variable. | ||
|
||
Possible values: | ||
|
||
- not set: disabled | ||
- `REACT_APP_CSP=report`: Enabled, but policy violations are only reported | ||
- `REACT_APP_CSP=block`: Enabled. Policy violations are reported and requests that violate the | ||
policy are blocked | ||
|
||
If error logging with Sentry is enabled (See [Error logging with Sentry](sentry.md)), the reports | ||
are sent to Sentry. Otherwise the reports are just logged in the backend. | ||
|
||
## Extending the policy | ||
|
||
If you want to whitelist new sources (for example adding a new external analytics service) and keep | ||
the CSP enabled, you should add the domains to the white list in [server/csp.js](../server/csp.js). | ||
|
||
The easiest way to do this is to first turn on the policy in report mode and then see what policy | ||
violations are logged to the browser developer console or to the backend policy violation report | ||
URL. | ||
|
||
## Resources | ||
|
||
To understand what CSP is and how browsers work, here are some resources: | ||
|
||
- https://content-security-policy.com/ | ||
- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | ||
- https://ponyfoo.com/articles/content-security-policy-in-express-apps | ||
- https://helmetjs.github.io/docs/csp/ | ||
https://www.sharetribe.com/docs/guides/how-to-set-up-csp-for-ftw/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the same format as the other changelog updates