From 78445cc3e8edbb74e139ba84ad51a3e5bb58aacb Mon Sep 17 00:00:00 2001 From: IvoPaunov Date: Mon, 16 Dec 2024 11:41:42 +0200 Subject: [PATCH 1/3] add dsp stats data, action and admin tab --- src/components/AdminPanel/AdminPanel.tsx | 6 +++ src/components/AdminPanel/DspStats.tsx | 15 +++++++ src/contexts/AdminContext/AdminContext.tsx | 46 +++++++++++++++++++++- src/types/dspStats.ts | 17 ++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/components/AdminPanel/DspStats.tsx create mode 100644 src/types/dspStats.ts diff --git a/src/components/AdminPanel/AdminPanel.tsx b/src/components/AdminPanel/AdminPanel.tsx index d31bf23f..b9f2c4fa 100644 --- a/src/components/AdminPanel/AdminPanel.tsx +++ b/src/components/AdminPanel/AdminPanel.tsx @@ -7,6 +7,7 @@ import Invoices from 'components/Billing/Invoices' import AdminAnalytics from './AdminAnalytics' import Accounts from './Accounts' import SSPsAnalytics from './SSPsAnalytics' +import DspStats from './DspStats' // import { AccountDetails } from './AccountDetails' const AdminPanel = () => { @@ -28,6 +29,7 @@ const AdminPanel = () => { Invoices Validator Analytics SSPs Analytics + DSP stats Accounts Account details @@ -51,6 +53,10 @@ const AdminPanel = () => { + + + + diff --git a/src/components/AdminPanel/DspStats.tsx b/src/components/AdminPanel/DspStats.tsx new file mode 100644 index 00000000..695184aa --- /dev/null +++ b/src/components/AdminPanel/DspStats.tsx @@ -0,0 +1,15 @@ +import { Stack } from '@mantine/core' +import useAdmin from 'hooks/useAdmin' +import { useEffect } from 'react' + +const DspStats = () => { + const { dspStats, getDspStats } = useAdmin() + + useEffect(() => { + getDspStats() + }, []) + + return {JSON.stringify(dspStats, null, 2)} +} + +export default DspStats diff --git a/src/contexts/AdminContext/AdminContext.tsx b/src/contexts/AdminContext/AdminContext.tsx index 1c7a0c7c..b5c5f977 100644 --- a/src/contexts/AdminContext/AdminContext.tsx +++ b/src/contexts/AdminContext/AdminContext.tsx @@ -2,10 +2,13 @@ import { createContext, FC, PropsWithChildren, useMemo, useState, useCallback } import { Account, AdminTransfer, AdminTransferType } from 'types' import { useAdExApi } from 'hooks/useAdexServices' import { removeOptionalEmptyStringProps } from 'helpers' +import { DspStats } from 'types/dspStats' interface IAdminContext { accounts: Map getAllAccounts: () => void + dspStats: DspStats + getDspStats: () => void initialDataLoading: boolean makeTransfer: ( values: AdminTransfer, @@ -20,12 +23,25 @@ interface IAdminContext { ) => Promise } +const dspStatsDefault = { + totalRequests: 0, + ortbRequests: 0, + throttledRequests: 0, + ortbRequestsPerSecond: 0, + throttledRequestsPerSecond: 0, + bidRequestsWithNoBids: 0, + bidRequestsBidsInTime: 0, + bidRequestsWithBidsLate: 0, + ssp: [] +} + const AdminContext = createContext(null) const AdminProvider: FC = ({ children }) => { const { adexServicesRequest } = useAdExApi() const [initialDataLoading, setLoading] = useState(true) const [accounts, setAccounts] = useState>(new Map()) + const [dspStats, setDspStats] = useState(dspStatsDefault) const getAllAccounts = useCallback(async () => { try { @@ -131,15 +147,43 @@ const AdminProvider: FC = ({ children }) => { [adexServicesRequest] ) + const getDspStats = useCallback(async () => { + try { + const res = await adexServicesRequest('backend', { + route: '/dsp/admin/sysinfo', + method: 'GET', + headers: { + 'content-type': 'application/json' + } + }) + + if (res) { + setDspStats(res) + } + } catch (err) { + console.log({ err }) + } + }, [adexServicesRequest]) + const contextValue = useMemo( () => ({ accounts, getAllAccounts, + getDspStats, + dspStats, initialDataLoading, makeTransfer, updateAccountInfo }), - [accounts, initialDataLoading, makeTransfer, getAllAccounts, updateAccountInfo] + [ + accounts, + getAllAccounts, + getDspStats, + dspStats, + initialDataLoading, + makeTransfer, + updateAccountInfo + ] ) return {children} diff --git a/src/types/dspStats.ts b/src/types/dspStats.ts new file mode 100644 index 00000000..1a7bfa9e --- /dev/null +++ b/src/types/dspStats.ts @@ -0,0 +1,17 @@ +export type SSPQPSStats = { + name: string + qpsConfig?: number + qpsCurrent: number + qpsDropped: number +} +export type DspStats = { + totalRequests: number + ortbRequests: number + throttledRequests: number + ortbRequestsPerSecond: number + throttledRequestsPerSecond: number + bidRequestsWithNoBids: number + bidRequestsBidsInTime: number + bidRequestsWithBidsLate: number + ssp: SSPQPSStats[] +} From c68c9e155a16b10fd120424a076f39d0ee46bf5d Mon Sep 17 00:00:00 2001 From: IvoPaunov Date: Mon, 16 Dec 2024 12:02:22 +0200 Subject: [PATCH 2/3] rename campaign details row to details row --- .../CreateCampaign/CampaignSummary.tsx | 40 ++++++------------- .../CreateCampaign/StepFour/StepFour.tsx | 4 +- .../common/CampainDetailsRow/index.ts | 3 -- .../DetailsRow.tsx} | 8 ++-- src/components/common/DetailsRow/index.ts | 3 ++ 5 files changed, 22 insertions(+), 36 deletions(-) delete mode 100644 src/components/common/CampainDetailsRow/index.ts rename src/components/common/{CampainDetailsRow/CampaignDetailsRow.tsx => DetailsRow/DetailsRow.tsx} (86%) create mode 100644 src/components/common/DetailsRow/index.ts diff --git a/src/components/CreateCampaign/CampaignSummary.tsx b/src/components/CreateCampaign/CampaignSummary.tsx index 92ec661a..2fcec032 100644 --- a/src/components/CreateCampaign/CampaignSummary.tsx +++ b/src/components/CreateCampaign/CampaignSummary.tsx @@ -3,7 +3,7 @@ import { Button, Group, Stack, Text } from '@mantine/core' import useCreateCampaignContext from 'hooks/useCreateCampaignContext' import LeftArrowIcon from 'resources/icons/LeftArrow' import useCreateCampaignData from 'hooks/useCreateCampaignData/useCreateCampaignData' -import CampaignDetailsRow from 'components/common/CampainDetailsRow' +import DetailsRow from 'components/common/DetailsRow' import { UtmInfo } from './CreateCampaignCommon' const CampaignSummary = ({ onLaunchClick }: { onLaunchClick: () => void }) => { @@ -39,51 +39,41 @@ const CampaignSummary = ({ onLaunchClick }: { onLaunchClick: () => void }) => { return ( - - - + + {placement === 'site' && ( - + )} - - - - + + + - - - void }) => { noBorder mb="xs" /> - + {step === 3 ? (