mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: make the build not die if window.fetch isn't available.
This commit is contained in:
		
							parent
							
								
									d640a8f8aa
								
							
						
					
					
						commit
						d210fcb05c
					
				| @ -100,7 +100,7 @@ | |||||||
|     "mime": "^2.4.2", |     "mime": "^2.4.2", | ||||||
|     "multer": "^1.4.1", |     "multer": "^1.4.1", | ||||||
|     "mustache": "^4.1.0", |     "mustache": "^4.1.0", | ||||||
|     "node-fetch": "^2.6.7", |     "node-fetch": "^3.2.1", | ||||||
|     "nodemailer": "^6.5.0", |     "nodemailer": "^6.5.0", | ||||||
|     "owasp-password-strength-test": "^1.3.0", |     "owasp-password-strength-test": "^1.3.0", | ||||||
|     "parse-database-url": "^0.3.0", |     "parse-database-url": "^0.3.0", | ||||||
|  | |||||||
| @ -1,39 +0,0 @@ | |||||||
| import React from 'react'; |  | ||||||
| import UserFeedback from '@site/src/components/UserFeedback'; |  | ||||||
| import { UnleashClient } from 'unleash-proxy-client'; |  | ||||||
| import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; |  | ||||||
| 
 |  | ||||||
| // Default implementation, that you can customize
 |  | ||||||
| function Root({ children }) { |  | ||||||
|     const { |  | ||||||
|         siteConfig: { customFields }, |  | ||||||
|     } = useDocusaurusContext(); |  | ||||||
| 
 |  | ||||||
|     const unleashConfig = { |  | ||||||
|         clientKey: customFields.unleashProxyClientKey, |  | ||||||
|         url: customFields.unleashProxyUrl, |  | ||||||
|         refreshInterval: 0, |  | ||||||
|         appName: `docs.getunleash.io-${customFields.environment}`, |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     const [showFeedback, setShowFeedback] = React.useState(false); |  | ||||||
| 
 |  | ||||||
|     try { |  | ||||||
|         const unleash = new UnleashClient(unleashConfig); |  | ||||||
|         unleash.on('ready', () => { |  | ||||||
|             setShowFeedback(unleash.isEnabled('docs-feedback-survey-v1')); |  | ||||||
|         }); |  | ||||||
|         unleash.start(); |  | ||||||
|     } catch (e) { |  | ||||||
|         console.warn('Unable to initialize the Unleash client:', e.message); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return ( |  | ||||||
|         <> |  | ||||||
|             {children} |  | ||||||
|             {showFeedback && <UserFeedback />} |  | ||||||
|         </> |  | ||||||
|     ); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export default Root; |  | ||||||
							
								
								
									
										49
									
								
								website/src/theme/Root.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								website/src/theme/Root.tsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,49 @@ | |||||||
|  | import React from 'react'; | ||||||
|  | import UserFeedback from '@site/src/components/UserFeedback'; | ||||||
|  | import { UnleashClient } from 'unleash-proxy-client'; | ||||||
|  | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||||||
|  | import nodeFetch from 'node-fetch' | ||||||
|  | 
 | ||||||
|  | // Default implementation, that you can customize
 | ||||||
|  | function Root({ children }) { | ||||||
|  |     const { | ||||||
|  |         siteConfig: { customFields }, | ||||||
|  |     } = useDocusaurusContext(); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     const unleashSsrOptions = { | ||||||
|  |         disableMetrics: true, | ||||||
|  |         fetch: nodeFetch | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const unleashConfig = { | ||||||
|  |         clientKey: customFields.unleashProxyClientKey as string, | ||||||
|  |         url: customFields.unleashProxyUrl as string, | ||||||
|  |         disableRefresh: true, | ||||||
|  |         appName: `docs.getunleash.io-${customFields.environment}`, | ||||||
|  |         ...(typeof fetch !=="undefined" ? unleashSsrOptions : {}) | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     const [showFeedback, setShowFeedback] = React.useState(false); | ||||||
|  | 
 | ||||||
|  |     if (typeof fetch !== 'undefined') { | ||||||
|  |         try { | ||||||
|  |             const unleash = new UnleashClient(unleashConfig); | ||||||
|  |             unleash.on('ready', () => { | ||||||
|  |                 setShowFeedback(unleash.isEnabled('docs-feedback-survey-v1')); | ||||||
|  |             }); | ||||||
|  |             unleash.start(); | ||||||
|  |         } catch (e) { | ||||||
|  |             console.warn('Unable to initialize the Unleash client:', e.message); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return ( | ||||||
|  |         <> | ||||||
|  |             {children} | ||||||
|  |             {showFeedback && <UserFeedback />} | ||||||
|  |         </> | ||||||
|  |     ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export default Root; | ||||||
							
								
								
									
										41
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								yarn.lock
									
									
									
									
									
								
							| @ -2557,6 +2557,11 @@ dashdash@^1.12.0: | |||||||
|   dependencies: |   dependencies: | ||||||
|     assert-plus "^1.0.0" |     assert-plus "^1.0.0" | ||||||
| 
 | 
 | ||||||
|  | data-uri-to-buffer@^4.0.0: | ||||||
|  |   version "4.0.0" | ||||||
|  |   resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz#b5db46aea50f6176428ac05b73be39a57701a64b" | ||||||
|  |   integrity sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA== | ||||||
|  | 
 | ||||||
| data-urls@^2.0.0: | data-urls@^2.0.0: | ||||||
|   version "2.0.0" |   version "2.0.0" | ||||||
|   resolved "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz" |   resolved "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz" | ||||||
| @ -3481,6 +3486,14 @@ fb-watchman@^2.0.0: | |||||||
|   dependencies: |   dependencies: | ||||||
|     bser "2.1.1" |     bser "2.1.1" | ||||||
| 
 | 
 | ||||||
|  | fetch-blob@^3.1.2, fetch-blob@^3.1.4: | ||||||
|  |   version "3.1.4" | ||||||
|  |   resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.1.4.tgz#e8c6567f80ad7fc22fd302e7dcb72bafde9c1717" | ||||||
|  |   integrity sha512-Eq5Xv5+VlSrYWEqKrusxY1C3Hm/hjeAsCGVG3ft7pZahlUAChpGZT/Ms1WmSLnEAisEXszjzu/s+ce6HZB2VHA== | ||||||
|  |   dependencies: | ||||||
|  |     node-domexception "^1.0.0" | ||||||
|  |     web-streams-polyfill "^3.0.3" | ||||||
|  | 
 | ||||||
| fetch-mock@9.11.0: | fetch-mock@9.11.0: | ||||||
|   version "9.11.0" |   version "9.11.0" | ||||||
|   resolved "https://registry.npmjs.org/fetch-mock/-/fetch-mock-9.11.0.tgz" |   resolved "https://registry.npmjs.org/fetch-mock/-/fetch-mock-9.11.0.tgz" | ||||||
| @ -3661,6 +3674,13 @@ form-data@~2.3.2: | |||||||
|     combined-stream "^1.0.6" |     combined-stream "^1.0.6" | ||||||
|     mime-types "^2.1.12" |     mime-types "^2.1.12" | ||||||
| 
 | 
 | ||||||
|  | formdata-polyfill@^4.0.10: | ||||||
|  |   version "4.0.10" | ||||||
|  |   resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" | ||||||
|  |   integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== | ||||||
|  |   dependencies: | ||||||
|  |     fetch-blob "^3.1.2" | ||||||
|  | 
 | ||||||
| formidable@^2.0.1: | formidable@^2.0.1: | ||||||
|   version "2.0.1" |   version "2.0.1" | ||||||
|   resolved "https://registry.npmjs.org/formidable/-/formidable-2.0.1.tgz" |   resolved "https://registry.npmjs.org/formidable/-/formidable-2.0.1.tgz" | ||||||
| @ -5727,13 +5747,27 @@ node-cleanup@^2.1.2: | |||||||
|   resolved "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz" |   resolved "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz" | ||||||
|   integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw= |   integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw= | ||||||
| 
 | 
 | ||||||
| node-fetch@2.6.7, node-fetch@^2.6.7: | node-domexception@^1.0.0: | ||||||
|  |   version "1.0.0" | ||||||
|  |   resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" | ||||||
|  |   integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== | ||||||
|  | 
 | ||||||
|  | node-fetch@2.6.7: | ||||||
|   version "2.6.7" |   version "2.6.7" | ||||||
|   resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" |   resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" | ||||||
|   integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== |   integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== | ||||||
|   dependencies: |   dependencies: | ||||||
|     whatwg-url "^5.0.0" |     whatwg-url "^5.0.0" | ||||||
| 
 | 
 | ||||||
|  | node-fetch@^3.2.1: | ||||||
|  |   version "3.2.1" | ||||||
|  |   resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.2.1.tgz#002177382810cfb77858857f69a3621a86c45f26" | ||||||
|  |   integrity sha512-Ef3SPFtRWFCDyhvcwCSvacLpkwmYZcD57mmZzAsMiks9TpHpIghe32U9H06tMICnr+X7YCpzH7WvUlUoml2urA== | ||||||
|  |   dependencies: | ||||||
|  |     data-uri-to-buffer "^4.0.0" | ||||||
|  |     fetch-blob "^3.1.4" | ||||||
|  |     formdata-polyfill "^4.0.10" | ||||||
|  | 
 | ||||||
| node-forge@^1.0.0: | node-forge@^1.0.0: | ||||||
|   version "1.2.1" |   version "1.2.1" | ||||||
|   resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.2.1.tgz#82794919071ef2eb5c509293325cec8afd0fd53c" |   resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.2.1.tgz#82794919071ef2eb5c509293325cec8afd0fd53c" | ||||||
| @ -7886,6 +7920,11 @@ watchpack@^2.3.1: | |||||||
|     glob-to-regexp "^0.4.1" |     glob-to-regexp "^0.4.1" | ||||||
|     graceful-fs "^4.1.2" |     graceful-fs "^4.1.2" | ||||||
| 
 | 
 | ||||||
|  | web-streams-polyfill@^3.0.3: | ||||||
|  |   version "3.2.0" | ||||||
|  |   resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz#a6b74026b38e4885869fb5c589e90b95ccfc7965" | ||||||
|  |   integrity sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA== | ||||||
|  | 
 | ||||||
| webidl-conversions@^3.0.0: | webidl-conversions@^3.0.0: | ||||||
|   version "3.0.1" |   version "3.0.1" | ||||||
|   resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" |   resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user