umami/components/forms/TrackingCodeForm.js
Sam Vargas 258e8bb3d6 fix: remove async script attribute
using async and defer on script tags is considered an [antipattern](https://almanac.httparchive.org/en/2022/javascript#async-defer-module-and-nomodule) as defer will be ignored. Defer is the preferred behaviour in most situations.
2023-01-05 12:54:07 +00:00

23 lines
704 B
JavaScript

import useConfig from 'hooks/useConfig';
import { useRef } from 'react';
import { Form, FormRow, TextArea } from 'react-basics';
export default function TrackingCodeForm({ websiteId }) {
const ref = useRef(null);
const { trackerScriptName } = useConfig();
const code = `<script defer src="${trackerScriptName}" data-website-id="${websiteId}"></script>`;
return (
<>
<Form ref={ref}>
<FormRow>
<p>
To track stats for this website, place the following code in the{' '}
<code>&lt;head&gt;</code> section of your HTML.
</p>
<TextArea rows={4} value={code} readOnly allowCopy />
</FormRow>
</Form>
</>
);
}