|
| 1 | +import { Box, CircularProgress } from '@mui/material' |
| 2 | +import Paper from '@mui/material/Paper' |
| 3 | +import Typography from '@mui/material/Typography' |
| 4 | +import { FunctionComponent, useEffect, useState } from 'react' |
| 5 | +import { ContentTrackingMethods } from '../components/ContentTracking/ContentTrackingMethods' |
| 6 | +import { ContentTrackingForm } from '../components/ContentTrackingForm/ContentTrackingForm' |
| 7 | + |
| 8 | +const ContentTrackingPage: FunctionComponent = () => { |
| 9 | + const [isLoading, setIsLoading] = useState(true) |
| 10 | + |
| 11 | + useEffect(() => { |
| 12 | + document.title = 'Content Tracking' |
| 13 | + }, []) |
| 14 | + |
| 15 | + useEffect(() => { |
| 16 | + const timeout = setTimeout(() => { |
| 17 | + setIsLoading(false) |
| 18 | + }, 3000) |
| 19 | + |
| 20 | + return () => { |
| 21 | + clearTimeout(timeout) |
| 22 | + } |
| 23 | + }, []) |
| 24 | + |
| 25 | + return ( |
| 26 | + <Paper |
| 27 | + sx={{ |
| 28 | + p: 2, |
| 29 | + display: 'flex', |
| 30 | + flexDirection: 'column' |
| 31 | + }} |
| 32 | + > |
| 33 | + <Typography component='h1' variant='h4' align='center'> |
| 34 | + Content Tracking Example |
| 35 | + </Typography> |
| 36 | + |
| 37 | + <Box> |
| 38 | + <Paper sx={{ p: 5, mt: 5 }}> |
| 39 | + <Typography |
| 40 | + data-track-content |
| 41 | + data-content-name='block' |
| 42 | + data-content-piece='paragraph' |
| 43 | + data-content-target='target' |
| 44 | + > |
| 45 | + This element will be tracked automatically if it's present in DOM |
| 46 | + before tracking script is loaded and `Interactions with popups and |
| 47 | + content` setting is turned on in the administration panel |
| 48 | + </Typography> |
| 49 | + </Paper> |
| 50 | + |
| 51 | + <Paper sx={{ mt: 5, p: 3 }}> |
| 52 | + <Typography> |
| 53 | + For content that will appear later in the DOM, like modals or |
| 54 | + components that are waiting for data to be loaded, use{' '} |
| 55 | + <b>ContentTracking</b> module |
| 56 | + </Typography> |
| 57 | + |
| 58 | + <Box sx={{ py: 5 }}> |
| 59 | + {isLoading ? <CircularProgress /> : <ContentTrackingMethods />} |
| 60 | + </Box> |
| 61 | + </Paper> |
| 62 | + |
| 63 | + <Paper sx={{ mt: 3 }}> |
| 64 | + <ContentTrackingForm /> |
| 65 | + </Paper> |
| 66 | + </Box> |
| 67 | + </Paper> |
| 68 | + ) |
| 69 | +} |
| 70 | + |
| 71 | +export default ContentTrackingPage |
0 commit comments