Skip to content

Commit

Permalink
added default envs to the serverside rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
andrezimpel authored Jul 25, 2019
1 parent 03689b7 commit 1cf4514
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import React from 'react';

const defaultOptions = {
environments: ['production'],
googleAnalytics: {
anonymize: true
}
}

exports.onRenderBody = ({ setHeadComponents }, pluginOptions = {}) => {
const currentEnvironment = process.env.ENV || process.env.NODE_ENV || "development";
const options = Object.assign(defaultOptions, pluginOptions);

// add the facebook pixel script by default to the page - it does not initialize or track anything to this point. :-)
if (pluginOptions.environments.includes(currentEnvironment)) {
if (options.environments.includes(currentEnvironment)) {
return setHeadComponents([
<script
key={`gatsby-plugin-gdpr-cookies`}
Expand Down

0 comments on commit 1cf4514

Please sign in to comment.