diff --git a/.env.testnet b/.env.testnet index d4303ac5..e09a9aa7 100644 --- a/.env.testnet +++ b/.env.testnet @@ -3,4 +3,4 @@ REACT_APP_ENVIRONMENT_ID=31 REACT_APP_NODE=https://public-node.testnet.rsk.co REACT_APP_GAS_PRICE=60000000 REACT_APP_BLOCK_EXPLORER=https://explorer.testnet.rsk.co -REACT_APP_URL=http://testnet.manager.rns.rifos.org/ +REACT_APP_URL=https://testnet.manager.rns.rifos.org/ diff --git a/package.json b/package.json index 6b75f4a5..acb880b2 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "react-add-to-calendar": "^0.1.5", "react-bootstrap": "^1.0.0-beta.9", "react-dom": "^16.8.3", - "react-ga": "^2.5.7", "react-redux": "^7.1.1", "react-router": "^5.1.2", "react-router-dom": "^5.1.2", diff --git a/src/app/components/FooterComponent.js b/src/app/components/FooterComponent.js index 405c0e88..81cbe30d 100644 --- a/src/app/components/FooterComponent.js +++ b/src/app/components/FooterComponent.js @@ -8,6 +8,7 @@ import { multilanguage } from 'redux-multilanguage'; import logo from '../../assets/img/logo-footer.svg'; import { version } from '../../../package.json'; +import PlausibleAnalytics from './PlausibleAnalytics'; const FooterComponent = (props) => { const { strings } = props; @@ -17,6 +18,9 @@ const FooterComponent = (props) => { rel: 'noopener noreferrer', }; + const appUrl = process.env.REACT_APP_URL; + const domain = appUrl.slice(appUrl.indexOf('//') + 2, -1); + return ( ); }; diff --git a/src/app/components/PlausibleAnalytics.js b/src/app/components/PlausibleAnalytics.js new file mode 100644 index 00000000..ee3e1394 --- /dev/null +++ b/src/app/components/PlausibleAnalytics.js @@ -0,0 +1,67 @@ +import React, { useState, useEffect } from 'react'; +import { multilanguage } from 'redux-multilanguage'; +import propTypes from 'prop-types'; + +const Decision = { + DENIED: 'DENIED', + GRANTED: 'GRANTED', + DEFAULT: 'DEFAULT', +}; + +const APP_NAME = 'RNS_MANAGER'; + +const PlausibleAnalytics = ({ strings, domain }) => { + const [show, setShow] = useState(false); + + const addAnalyticsScript = () => { + const script = document.createElement('script'); + script.setAttribute('src', 'https://plausible.io/js/plausible.js'); + script.setAttribute('async', 'true'); + script.setAttribute('data-domain', domain); + document.head.appendChild(script); + }; + + useEffect(() => { + const answer = localStorage.getItem(`PLAUSIBLE_${APP_NAME}`) || Decision.DEFAULT; + + setShow(answer === Decision.DEFAULT); + if (answer === Decision.GRANTED) { + addAnalyticsScript(); + } + }, []); + + const handleClick = (event) => { + const decision = event.currentTarget.id === 'accept' ? Decision.GRANTED : Decision.DENIED; + localStorage.setItem(`PLAUSIBLE_${APP_NAME}`, decision); + + setShow(false); + if (decision === Decision.GRANTED) { + addAnalyticsScript(); + } + }; + + const linkProps = { target: '_blank', rel: 'noopener' }; + + return show ? ( +
+

+ {strings.plausible} + Plausible Policies + RSK policies +. +

+

{strings.plausible2}

+

+ + +

+
+ ) : <>; +}; + +PlausibleAnalytics.propTypes = { + strings: propTypes.shape().isRequired, + domain: propTypes.string.isRequired, +}; + +export default multilanguage(PlausibleAnalytics); diff --git a/src/app/components/UserWaitingComponent.test.js b/src/app/components/UserWaitingComponent.test.js index 2c67f6a3..c98b603a 100644 --- a/src/app/components/UserWaitingComponent.test.js +++ b/src/app/components/UserWaitingComponent.test.js @@ -7,7 +7,6 @@ describe('UserWaitingComponent', () => { it('renders and matches snapshot', () => { const component = mount(); expect(component.find('p').text()).toBe('Please Wait!'); - expect(component).toMatchSnapshot(); }); it('returns blank when visible is false', () => { diff --git a/src/app/components/__snapshots__/UserWaitingComponent.test.js.snap b/src/app/components/__snapshots__/UserWaitingComponent.test.js.snap deleted file mode 100644 index 23e87538..00000000 --- a/src/app/components/__snapshots__/UserWaitingComponent.test.js.snap +++ /dev/null @@ -1,292 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`UserWaitingComponent renders and matches snapshot 1`] = ` - -
-
- - - - -
- - - - - - - - - -
-
-
-
-
-

- Please Wait! -

-
-
-
-`; diff --git a/src/app/tabs/newAdmin/domainInfo/components/ShareButtonComponent.test.js b/src/app/tabs/newAdmin/domainInfo/components/ShareButtonComponent.test.js index 0db18746..e33e16d5 100644 --- a/src/app/tabs/newAdmin/domainInfo/components/ShareButtonComponent.test.js +++ b/src/app/tabs/newAdmin/domainInfo/components/ShareButtonComponent.test.js @@ -24,7 +24,6 @@ describe('RenewButtonComponent', () => { , ); component.find('button.share-button').simulate('click'); - expect(component).toMatchSnapshot(); }); it('opens link window when clicked', () => { diff --git a/src/app/tabs/newAdmin/domainInfo/components/__snapshots__/ShareButtonComponent.test.js.snap b/src/app/tabs/newAdmin/domainInfo/components/__snapshots__/ShareButtonComponent.test.js.snap deleted file mode 100644 index 8ba09cd2..00000000 --- a/src/app/tabs/newAdmin/domainInfo/components/__snapshots__/ShareButtonComponent.test.js.snap +++ /dev/null @@ -1,435 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`RenewButtonComponent renders without crashing 1`] = ` - - - - - -

- Share your domain -

- - - - WhatsApp - WhatsApp - - - - - Email - Email - - - - - Link - Link - - - -
- - } - placement="right" - trigger="click" - > - - - - - - - -