Report parameters.

This commit is contained in:
Mike Cao 2023-06-14 23:48:11 -07:00
parent b10b490088
commit e7fef80d79
4 changed files with 9 additions and 17 deletions

View File

@ -25,8 +25,8 @@ export function ReportHeader({ icon }) {
if (!report.id) { if (!report.id) {
create(report, { create(report, {
onSuccess: async ({ id }) => { onSuccess: async ({ id }) => {
router.push(`/reports/${id}`, null, { shallow: true });
showToast({ message: formatMessage(messages.saved), variant: 'success' }); showToast({ message: formatMessage(messages.saved), variant: 'success' });
router.push(`/reports/${id}`, null, { shallow: true });
}, },
}); });
} else { } else {

View File

@ -5,6 +5,7 @@ import { ReportContext } from 'components/pages/reports/Report';
import NoData from 'components/common/NoData'; import NoData from 'components/common/NoData';
import styles from './EventDataParameters.module.css'; import styles from './EventDataParameters.module.css';
import { DATA_TYPES } from 'lib/constants'; import { DATA_TYPES } from 'lib/constants';
import BaseParameters from '../BaseParameters';
function useFields(websiteId, startDate, endDate) { function useFields(websiteId, startDate, endDate) {
const { get, useQuery } = useApi(); const { get, useQuery } = useApi();
@ -31,16 +32,9 @@ export function EventDataParameters() {
runReport(values); runReport(values);
}; };
if (!websiteId || !dateRange) {
return null;
}
if (isLoading) {
return <Loading icon="dots" />;
}
return ( return (
<Form ref={ref} values={parameters} error={error} onSubmit={handleSubmit}> <Form ref={ref} values={parameters} error={error} onSubmit={handleSubmit}>
<BaseParameters />
<FormRow label={formatMessage(labels.fields)}> <FormRow label={formatMessage(labels.fields)}>
<div className={styles.fields}> <div className={styles.fields}>
{!data?.length && <NoData />} {!data?.length && <NoData />}

View File

@ -1,4 +1,4 @@
import { useContext, useRef, useState } from 'react'; import { useContext, useRef } from 'react';
import { useMessages } from 'hooks'; import { useMessages } from 'hooks';
import { import {
Icon, Icon,

View File

@ -61,7 +61,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
return forbidden(res); return forbidden(res);
} }
const { url, referrer, name: eventName, data: dynamicData, title: pageTitle } = payload; const { url, referrer, name: eventName, data: eventData, title: pageTitle } = payload;
await useSession(req, res); await useSession(req, res);
@ -96,18 +96,18 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
referrerDomain, referrerDomain,
pageTitle, pageTitle,
eventName, eventName,
eventData: dynamicData, eventData,
...session, ...session,
sessionId: session.id, sessionId: session.id,
}); });
} }
if (type === COLLECTION_TYPE.identify) { if (type === COLLECTION_TYPE.identify) {
if (!dynamicData) { if (!eventData) {
return badRequest(res, 'Data required.'); return badRequest(res, 'Data required.');
} }
await saveSessionData({ ...session, sessionData: dynamicData, sessionId: session.id }); await saveSessionData({ ...session, sessionData: eventData, sessionId: session.id });
} }
const token = createToken(session, secret()); const token = createToken(session, secret());
@ -153,7 +153,7 @@ async function hasBlockedIp(req: NextApiRequestCollect) {
const clientIp = getIpAddress(req); const clientIp = getIpAddress(req);
const blocked = ips.find(ip => { return ips.find(ip => {
if (ip === clientIp) return true; if (ip === clientIp) return true;
// CIDR notation // CIDR notation
@ -166,7 +166,5 @@ async function hasBlockedIp(req: NextApiRequestCollect) {
return false; return false;
}); });
return blocked;
} }
} }