Skip to content
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

Split.io integration #714

Merged
merged 7 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ module.exports = {
contentPadding: '2rem',
maxWidth: '1700px',
},
splitio: {
core: {
authorizationKey: process.env.SPLITIO_AUTH_KEY,
},
env: {
development: {
features: {
'developer-website_global-header-gh-buttons': 'on',
},
core: {
authorizationKey: process.env.SPLITIO_AUTH_KEY || 'localhost',
},
},
},
},
newrelic: {
configs: {
production: {
Expand Down
8 changes: 7 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ exports.onCreateNode = ({ node, actions }) => {
}
};

exports.onCreateWebpackConfig = ({ actions }) => {
exports.onCreateWebpackConfig = ({ actions, plugins }) => {
actions.setWebpackConfig({
// The `debug` library is causing issues when building the site by including
// invalid JS. This ensures the module resolves to the browser-capatible
// source instead of the node source. See the following issue for this
// recommendation:
// https://github.com/escaladesports/legacy-gatsby-plugin-prefetch-google-fonts/issues/18
plugins: [plugins.normalModuleReplacement(/^\.\/node\.js/, './browser.js')],
externals: {
tessen: 'Tessen',
},
Expand Down
154 changes: 137 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"@emotion/styled": "^10.0.27",
"@mdx-js/mdx": "^1.6.16",
"@mdx-js/react": "^1.6.16",
"@newrelic/gatsby-theme-newrelic": "^1.7.3",
"@newrelic/gatsby-theme-newrelic": "^1.8.1",
"@splitsoftware/splitio-react": "^1.2.0",
"classnames": "^2.2.6",
"date-fns": "^2.15.0",
"eslint-plugin-react-hooks": "^4.0.8",
Expand Down
15 changes: 13 additions & 2 deletions src/layouts/MainLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,39 @@ import MobileHeader from '../components/MobileHeader';
import Sidebar from '../components/Sidebar';
import CookieApprovalDialog from '../components/CookieApprovalDialog';
import '../components/styles.scss';
import usePageContext from '../hooks/usePageContext';
import { useLocation } from '@reach/router';

const gaTrackingId = 'UA-3047412-33';
const gdprConsentCookieName = 'newrelic-gdpr-consent';

const MainLayout = ({ children }) => {
const {
site: { layout },
site: { layout, siteMetadata },
} = useStaticQuery(graphql`
query {
site {
layout {
contentPadding
maxWidth
}
siteMetadata {
repository
}
}
}
`);

const location = useLocation();
const { fileRelativePath } = usePageContext();
const [cookieConsent, setCookieConsent] = useState(false);
const [isMobileNavOpen, setIsMobileNavOpen] = useState(false);
const isComponentDoc = fileRelativePath.includes(
'src/markdown-pages/components'
);
const editUrl = isComponentDoc
? null
: `${siteMetadata.repository}/blob/main/${fileRelativePath}`;

useEffect(() => {
const consentValue = Cookies.get(gdprConsentCookieName) === 'true';
Expand Down Expand Up @@ -68,7 +79,7 @@ const MainLayout = ({ children }) => {
</script>
) : null}
</Helmet>
<GlobalHeader search />
<GlobalHeader editUrl={editUrl} />
<MobileHeader
css={css`
@media (min-width: 761px) {
Expand Down