From cd9007fed977f018e5092de1f9f72222c20329ee Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 3 Sep 2020 13:00:32 -0700 Subject: [PATCH] feat: load treatments from split for contribute buttons --- .../RelatedContentModules/Contribute.js | 22 +++++++++++++++++-- src/data/constants.js | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/RelatedContentModules/Contribute.js b/src/components/RelatedContentModules/Contribute.js index 3bb6234fa..1cb70653c 100644 --- a/src/components/RelatedContentModules/Contribute.js +++ b/src/components/RelatedContentModules/Contribute.js @@ -3,6 +3,9 @@ import PropTypes from 'prop-types'; import { css } from '@emotion/core'; import { Button, ExternalLink, Icon } from '@newrelic/gatsby-theme-newrelic'; import { graphql, useStaticQuery } from 'gatsby'; +import useTreatment from '../../hooks/useTreatment'; +import { useTrack } from '@splitsoftware/splitio-react'; +import { SPLITS } from '../../data/constants'; import Section from './Section'; const Contribute = ({ pageContext }) => { @@ -16,6 +19,9 @@ const Contribute = ({ pageContext }) => { } `); + const { treatment, config } = useTreatment(SPLITS.CONTRIBUTE_BUTTONS); + const track = useTrack(); + const { fileRelativePath } = pageContext; const { @@ -35,8 +41,14 @@ const Contribute = ({ pageContext }) => { css={css` margin-right: 0.5rem; `} - variant={Button.VARIANT.PRIMARY} + disabled={treatment === 'control'} + variant={config?.issues || Button.VARIANT.NORMAL} size={Button.SIZE.SMALL} + onClick={() => + track('related_content.contribute_action_clicked', null, { + button: 'issues', + }) + } > {