Merge pull request #1941 from slumbering/website-env-example
website: add environment var to avoid crash issue
This commit is contained in:
commit
76d515464e
@ -15,6 +15,9 @@ module.exports = {
|
|||||||
stylesheets: [
|
stylesheets: [
|
||||||
"https://fonts.googleapis.com/css2?family=Karla&family=Montserrat:wght@700&display=swap",
|
"https://fonts.googleapis.com/css2?family=Karla&family=Montserrat:wght@700&display=swap",
|
||||||
],
|
],
|
||||||
|
customFields: {
|
||||||
|
AMPLITUDE_ID: process.env.REACT_APP_AMPLITUDE_ID
|
||||||
|
},
|
||||||
themeConfig: {
|
themeConfig: {
|
||||||
sidebarCollapsed: false,
|
sidebarCollapsed: false,
|
||||||
prism: {
|
prism: {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
import React, {useState, useEffect, useCallback} from 'react';
|
import React, {useState, useEffect, useCallback} from 'react';
|
||||||
import {MDXProvider} from '@mdx-js/react';
|
import {MDXProvider} from '@mdx-js/react';
|
||||||
import renderRoutes from '@docusaurus/renderRoutes';
|
import renderRoutes from '@docusaurus/renderRoutes';
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
import Layout from '@theme/Layout';
|
import Layout from '@theme/Layout';
|
||||||
import DocSidebar from '@theme/DocSidebar';
|
import DocSidebar from '@theme/DocSidebar';
|
||||||
import MDXComponents from '@theme/MDXComponents';
|
import MDXComponents from '@theme/MDXComponents';
|
||||||
@ -138,12 +139,15 @@ function DocPage(props) {
|
|||||||
matchPath(location.pathname, docRoute),
|
matchPath(location.pathname, docRoute),
|
||||||
);
|
);
|
||||||
|
|
||||||
// DocPage Swizzle
|
// DocPage Swizzle
|
||||||
|
const {siteConfig} = useDocusaurusContext();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
var instance1 = amplitude.getInstance().init(process.env.REACT_APP_AMPLITUDE_ID, null, {
|
if(siteConfig.AMPLITUDE_ID) {
|
||||||
apiEndpoint: `${window.location.hostname}/t`
|
var instance1 = amplitude.getInstance().init(process.env.REACT_APP_AMPLITUDE_ID, null, {
|
||||||
})
|
apiEndpoint: `${window.location.hostname}/t`
|
||||||
amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname });
|
})
|
||||||
|
amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname });
|
||||||
|
}
|
||||||
}, [location.pathname])
|
}, [location.pathname])
|
||||||
// End DocPageSwizzle
|
// End DocPageSwizzle
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user