Skip to content

Commit

Permalink
Merge pull request #421 from newrelic/ru/upgrade-gatsby-38
Browse files Browse the repository at this point in the history
chore: upgrade gatsby to v3.8
  • Loading branch information
rudouglas committed Jul 2, 2021
2 parents 13fb282 + d8be290 commit a7cefd1
Show file tree
Hide file tree
Showing 13 changed files with 2,525 additions and 1,591 deletions.
14 changes: 7 additions & 7 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"@mdx-js/mdx": "^1.6.16",
"@mdx-js/react": "^1.6.16",
"@newrelic/gatsby-theme-newrelic": "^1.1.10",
"gatsby": "^3.4.0-next.3",
"gatsby-plugin-mdx": "^2.3.0",
"gatsby-plugin-sharp": "^3.3.0",
"gatsby-remark-autolink-headers": "^4.0.0",
"gatsby-remark-images": "^5.0.0",
"gatsby-source-filesystem": "^3.3.0",
"gatsby-transformer-sharp": "^3.3.0",
"gatsby": "^3.8.1",
"gatsby-plugin-mdx": "^2.8.0",
"gatsby-plugin-sharp": "^3.8.0",
"gatsby-remark-autolink-headers": "^4.5.0",
"gatsby-remark-images": "^5.5.0",
"gatsby-source-filesystem": "^3.8.0",
"gatsby-transformer-sharp": "^3.8.0",
"github-slugger": "^1.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion demo/src/templates/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ BasicTemplate.propTypes = {
};

export const pageQuery = graphql`
query($slug: String!) {
query ($slug: String!) {
mdx(slug: { eq: $slug }) {
body
mdxAST
Expand Down
8 changes: 2 additions & 6 deletions packages/gatsby-theme-newrelic/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ exports.onPreBootstrap = ({ reporter, store }, themeOptions) => {
});

if (themeOptions.i18n) {
const {
locales,
i18nextOptions,
translationsPath,
themeNamespace,
} = getI18nConfig(themeOptions);
const { locales, i18nextOptions, translationsPath, themeNamespace } =
getI18nConfig(themeOptions);

locales.forEach(({ locale }) => {
i18nextOptions.ns
Expand Down
20 changes: 10 additions & 10 deletions packages/gatsby-theme-newrelic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"@mdx-js/mdx": "^1.6.16",
"@mdx-js/react": "^1.6.16",
"@splitsoftware/splitio-react": "^1.2.0",
"gatsby": "^3.4.0-next.3",
"gatsby-plugin-mdx": "^2.3.0",
"gatsby": "^3.8.1",
"gatsby-plugin-mdx": "^2.8.0",
"i18next-parser": "^3.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand All @@ -53,16 +53,16 @@
"@xstate/react": "^1.3.1",
"babel-plugin-prismjs": "^2.0.1",
"date-fns": "^2.21.0",
"gatsby-plugin-emotion": "^6.3.0",
"gatsby-plugin-layout": "^2.3.0",
"gatsby-plugin-emotion": "^6.8.0",
"gatsby-plugin-layout": "^2.8.0",
"gatsby-plugin-newrelic": "^2.0.0",
"gatsby-plugin-react-helmet": "^4.3.0",
"gatsby-plugin-robots-txt": "^1.5.5",
"gatsby-plugin-sharp": "^3.3.0",
"gatsby-plugin-sitemap": "^4.1.0-next.1",
"gatsby-plugin-react-helmet": "^4.8.0",
"gatsby-plugin-robots-txt": "^1.6.8",
"gatsby-plugin-sharp": "^3.8.0",
"gatsby-plugin-sitemap": "^4.4.0",
"gatsby-plugin-use-dark-mode": "^1.3.0",
"gatsby-source-filesystem": "^3.3.0",
"gatsby-transformer-sharp": "^3.3.0",
"gatsby-source-filesystem": "^3.8.0",
"gatsby-transformer-sharp": "^3.8.0",
"html-react-parser": "^1.2.5",
"i18next": "^20.2.1",
"js-cookie": "^2.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ const AnnouncementBanner = () => {
const announcement = findCurrentAnnouncement(allMdx.nodes);
const announcementId = announcement ? createContentHash(announcement) : null;

const [
lastAnnouncementDismissed,
setLastAnnouncementDismissed,
] = useLastAnnouncementDismissed(null);
const [lastAnnouncementDismissed, setLastAnnouncementDismissed] =
useLastAnnouncementDismissed(null);

const [visible, setVisible] = useState(
lastAnnouncementDismissed !== announcementId
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby-theme-newrelic/src/components/NavItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const NavItem = ({ page, __parent: parent, __depth: depth = 0 }) => {
new RegExp(`\\/${locale.locale}(?=\\/)`),
''
);
const containsCurrentPage = useMemo(() => containsPage(page, pathname), [
page,
pathname,
]);
const containsCurrentPage = useMemo(
() => containsPage(page, pathname),
[page, pathname]
);
const isCurrentPage = page.url === pathname;
const shouldExpand = isCurrentPage || containsCurrentPage;
const hasChangedPage = pathname !== usePrevious(pathname);
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby-theme-newrelic/src/hooks/useQueryParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const toQueryString = (queryParams) =>
const useQueryParams = () => {
const location = useLocation();

const queryParams = useMemo(() => new URLSearchParams(location.search), [
location.search,
]);
const queryParams = useMemo(
() => new URLSearchParams(location.search),
[location.search]
);

const setQueryParam = useCallback(
(key, value) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/gatsby-theme-newrelic/src/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ const withPrefix = (prefix, icons) =>
// with the changes to the `Icon` component, while allowing the old
// implementation to be used simultaneously. These new changes allow the Icon
// component to use multiple icon sources instead of just feather icons.
const wrapFeatherIcon = (icon) => (props) => (
<FeatherSVG {...props}>{icon}</FeatherSVG>
);
const wrapFeatherIcon = (icon) => (props) =>
<FeatherSVG {...props}>{icon}</FeatherSVG>;

const wrapFeatherIcons = (icons) =>
Object.fromEntries(
Expand Down
8 changes: 5 additions & 3 deletions packages/gatsby-theme-newrelic/src/utils/composeHandlers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const composeHandlers = (...fns) => (...args) => {
fns.filter(Boolean).forEach((fn) => fn(...args));
};
const composeHandlers =
(...fns) =>
(...args) => {
fns.filter(Boolean).forEach((fn) => fn(...args));
};

export default composeHandlers;
27 changes: 13 additions & 14 deletions packages/gatsby-theme-newrelic/src/utils/configBuilder.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
const { merge, omit } = require('lodash');
const getResolvedEnv = require('./config/resolvedEnv');

const buildConfigGetter = (
configKey,
{ defaults = {}, envOptions = false } = {}
) => (themeOptions) => {
const config = themeOptions[configKey];
const buildConfigGetter =
(configKey, { defaults = {}, envOptions = false } = {}) =>
(themeOptions) => {
const config = themeOptions[configKey];

if (!config) {
return null;
}
if (!config) {
return null;
}

return merge(
defaults,
omit(config, ['env']),
envOptions && config.env ? config.env[getResolvedEnv(themeOptions)] : {}
);
};
return merge(
defaults,
omit(config, ['env']),
envOptions && config.env ? config.env[getResolvedEnv(themeOptions)] : {}
);
};

module.exports = { buildConfigGetter };
64 changes: 33 additions & 31 deletions packages/gatsby-theme-newrelic/src/utils/createTessen.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,43 @@ const warnAboutNoop = ({ config, action, name, category }) => {
const canSendAction = ({ config, name, category }) =>
name && category && config && config.product && config.subproduct;

const tessenAction = (action, config) => (name, category, properties = {}) => {
if (!canSendAction({ config, name, category })) {
return warnAboutNoop({ config, action, name, category });
}
const tessenAction =
(action, config) =>
(name, category, properties = {}) => {
if (!canSendAction({ config, name, category })) {
return warnAboutNoop({ config, action, name, category });
}

if (!window.Tessen) {
return warning(
false,
`tessen.${name}: You are attempting to use a Tessen action, but Tessen is not available on 'window'. Calls to '${name}' will result in a noop.`
);
}
if (!window.Tessen) {
return warning(
false,
`tessen.${name}: You are attempting to use a Tessen action, but Tessen is not available on 'window'. Calls to '${name}' will result in a noop.`
);
}

const customerId = Cookies.get('ajs_user_id') || '';
const customerId = Cookies.get('ajs_user_id') || '';

if (canTrack()) {
window.Tessen[action](
name,
{
...properties,
category,
nr_product: config.product,
nr_subproduct: config.subproduct,
location: 'Public',
customer_user_id: customerId,
},
{
Segment: {
integrations: {
All: true,
},
if (canTrack()) {
window.Tessen[action](
name,
{
...properties,
category,
nr_product: config.product,
nr_subproduct: config.subproduct,
location: 'Public',
customer_user_id: customerId,
},
}
);
}
};
{
Segment: {
integrations: {
All: true,
},
},
}
);
}
};

const createTessen = (config) => ({
page: tessenAction('page', config),
Expand Down
36 changes: 18 additions & 18 deletions packages/gatsby-theme-newrelic/src/utils/page-tracking/tessen.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ const trackPageView = ({ config, env, location }) => {
});
};

const initializeTessenTracking = ({ config, env, location }) => (
options = {}
) => {
if (canTrack() && !initialized) {
initialized = true;
const { segmentWriteKey } = config;
window.Tessen.load(['Segment', 'NewRelic'], {
Segment: {
identifiable: true,
writeKey: segmentWriteKey,
},
});

window.Tessen.identify({});

options.trackPageView && trackPageView({ config, env, location });
}
};
const initializeTessenTracking =
({ config, env, location }) =>
(options = {}) => {
if (canTrack() && !initialized) {
initialized = true;
const { segmentWriteKey } = config;
window.Tessen.load(['Segment', 'NewRelic'], {
Segment: {
identifiable: true,
writeKey: segmentWriteKey,
},
});

window.Tessen.identify({});

options.trackPageView && trackPageView({ config, env, location });
}
};

export default trackViaTessen;
Loading

0 comments on commit a7cefd1

Please sign in to comment.