mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-23 00:16:25 +01:00
feat: plausible for events export (#7868)
Plausible for events exports. And small cleanup.
This commit is contained in:
parent
585eb30730
commit
778413d4c0
@ -12,6 +12,7 @@ import {
|
|||||||
import FileDownload from '@mui/icons-material/FileDownload';
|
import FileDownload from '@mui/icons-material/FileDownload';
|
||||||
import type { EventSchema } from '../../../openapi';
|
import type { EventSchema } from '../../../openapi';
|
||||||
import { json2csv } from 'json-2-csv';
|
import { json2csv } from 'json-2-csv';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const StyledActions = styled('div')(({ theme }) => ({
|
const StyledActions = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -29,6 +30,7 @@ interface IEventActions {
|
|||||||
|
|
||||||
export const EventActions: FC<IEventActions> = ({ events }) => {
|
export const EventActions: FC<IEventActions> = ({ events }) => {
|
||||||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
const open = Boolean(anchorEl);
|
const open = Boolean(anchorEl);
|
||||||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
@ -53,6 +55,12 @@ export const EventActions: FC<IEventActions> = ({ events }) => {
|
|||||||
|
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
|
|
||||||
|
trackEvent('events-exported', {
|
||||||
|
props: {
|
||||||
|
eventType: 'json',
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportCsv = () => {
|
const exportCsv = () => {
|
||||||
@ -68,13 +76,16 @@ export const EventActions: FC<IEventActions> = ({ events }) => {
|
|||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = fileName;
|
a.download = fileName;
|
||||||
a.style.display = 'none';
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
|
||||||
|
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
|
|
||||||
|
trackEvent('events-exported', {
|
||||||
|
props: {
|
||||||
|
eventType: 'csv',
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -65,7 +65,8 @@ export type CustomEvents =
|
|||||||
| 'command-bar'
|
| 'command-bar'
|
||||||
| 'new-in-unleash-click'
|
| 'new-in-unleash-click'
|
||||||
| 'new-in-unleash-dismiss'
|
| 'new-in-unleash-dismiss'
|
||||||
| 'search-opened';
|
| 'search-opened'
|
||||||
|
| 'events-exported';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user