2020-08-08 05:36:57 +02:00
|
|
|
import React, { useRef } from 'react';
|
2020-09-06 02:27:01 +02:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2020-08-08 05:36:57 +02:00
|
|
|
import Button from 'components/common/Button';
|
|
|
|
import FormLayout, { FormButtons, FormRow } from 'components/layout/FormLayout';
|
|
|
|
import CopyButton from '../common/CopyButton';
|
|
|
|
|
2020-08-15 10:17:15 +02:00
|
|
|
export default function TrackingCodeForm({ values, onClose }) {
|
2020-08-08 05:36:57 +02:00
|
|
|
const ref = useRef();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormLayout>
|
|
|
|
<p>
|
2020-09-06 02:27:01 +02:00
|
|
|
<FormattedMessage
|
|
|
|
id="message.track-stats"
|
|
|
|
defaultMessage="To track stats for {target}, place the following code in the {head} section of your website."
|
|
|
|
values={{ head: '<head>', target: <b>{values.name}</b> }}
|
|
|
|
/>
|
2020-08-08 05:36:57 +02:00
|
|
|
</p>
|
|
|
|
<FormRow>
|
2020-09-15 13:54:35 +02:00
|
|
|
{/* Run `npm run build-snippet, and copy paste here the content of public/snippet.js */}
|
|
|
|
{/* TODO: use webpack importing function to import the content of the file here ? */}
|
2020-08-08 05:36:57 +02:00
|
|
|
<textarea
|
|
|
|
ref={ref}
|
|
|
|
rows={3}
|
|
|
|
cols={60}
|
2020-08-17 06:28:54 +02:00
|
|
|
spellCheck={false}
|
2020-09-15 13:54:35 +02:00
|
|
|
defaultValue={`!function(){"use strict";!function(e){var t=e.umami=e.umami||[];if(!t.registerAutoEvents)if(t.invoked)e.console&&console.error&&console.error("Umami snippet included twice.");else{t.invoked=!0,t.calls=[],t.methods=["registerAutoEvents","event","pageView"],t.factory=function(e){return function(){var r=Array.prototype.slice.call(arguments);return r.unshift(e),t.calls.push(r),t}};for(var r=0;r<t.methods.length;r++){var i=t.methods[r];t[i]=t.factory(i)}t.load=function(e,t,r,i){var o=document.createElement("script");o.type="text/javascript",o.defer=!0,o.async=!0,o.setAttribute("data-website-id",t),r&&o.setAttribute("data-skip-auto","true"),i&&o.setAttribute("data-debug","true"),o.src=e;var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)},t.load("${document.location.origin}/umami.js","${values.website_uuid}",!1,!1)}}(window)}();
|
|
|
|
`}
|
2020-08-08 05:36:57 +02:00
|
|
|
readOnly
|
|
|
|
/>
|
|
|
|
</FormRow>
|
|
|
|
<FormButtons>
|
|
|
|
<CopyButton type="submit" variant="action" element={ref} />
|
2020-09-06 02:27:01 +02:00
|
|
|
<Button onClick={onClose}>
|
|
|
|
<FormattedMessage id="button.cancel" defaultMessage="Cancel" />
|
|
|
|
</Button>
|
2020-08-08 05:36:57 +02:00
|
|
|
</FormButtons>
|
|
|
|
</FormLayout>
|
|
|
|
);
|
|
|
|
}
|