Skip to content

Commit

Permalink
Merge pull request #324 from AmbireTech/dsp-stats
Browse files Browse the repository at this point in the history
Dsp stats
  • Loading branch information
ivopaunov authored Dec 16, 2024
2 parents c083196 + dfaabb7 commit 31cf7e7
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 54 deletions.
6 changes: 6 additions & 0 deletions src/components/AdminPanel/AdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -28,6 +29,7 @@ const AdminPanel = () => {
<Tabs.Tab value="invoices">Invoices</Tabs.Tab>
<Tabs.Tab value="validatorAnalytics">Validator Analytics</Tabs.Tab>
<Tabs.Tab value="sspAnalytics">SSPs Analytics</Tabs.Tab>
<Tabs.Tab value="dspStats">DSP info</Tabs.Tab>
<Tabs.Tab value="accounts">Accounts</Tabs.Tab>
<Tabs.Tab value="user-account" disabled>
Account details
Expand All @@ -51,6 +53,10 @@ const AdminPanel = () => {
<SSPsAnalytics />
</Tabs.Panel>

<Tabs.Panel value="dspStats" pt="xs">
<DspStats />
</Tabs.Panel>

<Tabs.Panel value="accounts" pt="xs">
<Accounts />
</Tabs.Panel>
Expand Down
74 changes: 74 additions & 0 deletions src/components/AdminPanel/DspStats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { NumberFormatter, Stack, Divider, Space } from '@mantine/core'
import DetailsRow from 'components/common/DetailsRow'
import useAdmin from 'hooks/useAdmin'
import { useEffect } from 'react'

const DspStats = () => {
const { dspStats, getDspStats } = useAdmin()

useEffect(() => {
getDspStats()
}, [])

return (
<Stack maw={420} gap="xs">
<DetailsRow
title="Total ORTB requests"
value={<NumberFormatter thousandSeparator value={dspStats.ortbRequests} />}
/>
<DetailsRow
title="Bid requests with no bids"
value={<NumberFormatter thousandSeparator value={dspStats.bidRequestsWithNoBids} />}
/>
<DetailsRow
title="Bid requests in time"
value={<NumberFormatter thousandSeparator value={dspStats.bidRequestsBidsInTime} />}
/>
<DetailsRow
title="Bid requests with late bids"
value={<NumberFormatter thousandSeparator value={dspStats.bidRequestsWithBidsLate} />}
/>
<DetailsRow
title="Total Bid requests per second"
value={<NumberFormatter thousandSeparator value={dspStats.ortbRequestsPerSecond} />}
/>
<DetailsRow
title="Total requests"
value={<NumberFormatter thousandSeparator value={dspStats.totalRequests} />}
/>
<DetailsRow
title="Throttled requests"
value={<NumberFormatter thousandSeparator value={dspStats.throttledRequests} />}
/>
<DetailsRow
title="Throttled requests per second"
value={<NumberFormatter thousandSeparator value={dspStats.throttledRequestsPerSecond} />}
/>
<Space />
{dspStats.ssp.map((ssp) => (
<Stack gap={0}>
<DetailsRow id={ssp.name} title="ssp" value={ssp.name} />
<DetailsRow
id={ssp.name}
title="qps cfg"
value={<NumberFormatter thousandSeparator value={ssp.qpsConfig} />}
/>
<DetailsRow
id={ssp.name}
title="qps current"
value={<NumberFormatter thousandSeparator value={ssp.qpsCurrent} />}
/>
<DetailsRow
id={ssp.name}
title="qps dropped"
value={<NumberFormatter thousandSeparator value={ssp.qpsDropped} />}
noBorder
/>
<Divider size="xl" />
</Stack>
))}
</Stack>
)
}

export default DspStats
34 changes: 17 additions & 17 deletions src/components/CampaignDetails/CampaignDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AdUnit, CampaignStatus } from 'adex-common/dist/types'
import MediaThumb from 'components/common/MediaThumb'
import { formatDateTime } from 'helpers/formatters'
import GoBack from 'components/common/GoBack'
import CampaignDetailsRow from 'components/common/CampainDetailsRow/CampaignDetailsRow'
import DetailsRow from 'components/common/DetailsRow/DetailsRow'
import { useCampaignsData } from 'hooks/useCampaignsData'
import ActiveIcon from 'resources/icons/Active'
import StopIcon from 'resources/icons/Stop'
Expand Down Expand Up @@ -275,7 +275,7 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
<Paper bg="lightBackground" p="md" withBorder>
<Stack gap="xs">
{isAdminPanel && (
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Owner"
value={
Expand All @@ -290,9 +290,9 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
}
/>
)}
<CampaignDetailsRow textSize="sm" title="Title" value={campaign?.title} />
<CampaignDetailsRow textSize="sm" title="Id" value={campaign?.id} />
<CampaignDetailsRow
<DetailsRow textSize="sm" title="Title" value={campaign?.title} />
<DetailsRow textSize="sm" title="Id" value={campaign?.id} />
<DetailsRow
textSize="sm"
title="Status"
value={
Expand All @@ -304,14 +304,14 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
}
/>
{/* TODO: Add data for it */}
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Served"
// value={campaignData?.share}
value=""
/>
{/* TODO: Add data for it */}
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Budget"
value={
Expand All @@ -323,11 +323,11 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
/>
}
/>
<CampaignDetailsRow
<DetailsRow
title="Created"
value={formatDateTime(new Date(Number(campaign.created)))}
/>
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Starts"
value={
Expand All @@ -336,7 +336,7 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
: 'N/A'
}
/>
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Ends"
value={
Expand All @@ -345,7 +345,7 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
: 'N/A'
}
/>
<CampaignDetailsRow
<DetailsRow
title="CPM min"
value={
campaign.pricingBounds.IMPRESSION?.min && (
Expand All @@ -359,7 +359,7 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
)
}
/>
<CampaignDetailsRow
<DetailsRow
title="CPM max"
value={
campaign.pricingBounds.IMPRESSION?.max && (
Expand All @@ -373,7 +373,7 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
)
}
/>
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Limit average daily spending"
value={
Expand All @@ -382,19 +382,19 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
: 'No'
}
/>
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Aggressive bidding"
value={
campaign.targetingInput.inputs.advanced.aggressiveBidding ? 'Yes' : 'No'
}
/>
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Loose source bidding"
value={campaign.targetingInput.inputs.advanced.looseSourceCTR ? 'Yes' : 'No'}
/>
<CampaignDetailsRow
<DetailsRow
textSize="sm"
title="Last modified by"
noBorder
Expand Down Expand Up @@ -443,7 +443,7 @@ const CampaignDetails = ({ isAdminPanel }: { isAdminPanel?: boolean }) => {
{campaign.adUnits.map((item: AdUnit, index: number) => {
const isLast = index === campaign.adUnits.length - 1
return (
<CampaignDetailsRow
<DetailsRow
key={item.id}
textSize="sm"
title={`${item.banner?.format.w}x${item.banner?.format.h}`}
Expand Down
40 changes: 13 additions & 27 deletions src/components/CreateCampaign/CampaignSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -39,51 +39,41 @@ const CampaignSummary = ({ onLaunchClick }: { onLaunchClick: () => void }) => {

return (
<Stack gap="xs">
<CampaignDetailsRow
lighterColor
title="Budget"
value={campaignBudgetFormatted}
textSize="sm"
/>
<CampaignDetailsRow lighterColor title="CPM" value={priceBoundsFormatted} textSize="sm" />
<CampaignDetailsRow
<DetailsRow lighterColor title="Budget" value={campaignBudgetFormatted} textSize="sm" />
<DetailsRow lighterColor title="CPM" value={priceBoundsFormatted} textSize="sm" />
<DetailsRow
lighterColor
title="Placement"
value={placement === 'site' ? 'Website' : 'App'}
textSize="sm"
/>
{placement === 'site' && (
<CampaignDetailsRow
lighterColor
title="Device"
textSize="sm"
value={formattedSelectedDevice}
/>
<DetailsRow lighterColor title="Device" textSize="sm" value={formattedSelectedDevice} />
)}
<CampaignDetailsRow lighterColor title="Ad Format" value={adFormats} textSize="sm" />
<CampaignDetailsRow lighterColor title="Categories" value={formattedCats} textSize="sm" />
<CampaignDetailsRow lighterColor title="Countries" value={formattedLocs} textSize="sm" />
<CampaignDetailsRow
<DetailsRow lighterColor title="Ad Format" value={adFormats} textSize="sm" />
<DetailsRow lighterColor title="Categories" value={formattedCats} textSize="sm" />
<DetailsRow lighterColor title="Countries" value={formattedLocs} textSize="sm" />
<DetailsRow
lighterColor
title="Limit average daily spending"
value={advancedTargeInput.limitDailyAverageSpending ? 'Yes' : 'No'}
textSize="sm"
/>
<CampaignDetailsRow
<DetailsRow
lighterColor
title="Aggressive bidding"
value={advancedTargeInput.aggressiveBidding ? 'Yes' : 'No'}
textSize="sm"
/>

<CampaignDetailsRow
<DetailsRow
lighterColor
title="Loose source bidding"
value={advancedTargeInput.looseSourceCTR ? 'Yes' : 'No'}
textSize="sm"
/>

<CampaignDetailsRow
<DetailsRow
lighterColor
title="Auto UTM tracking"
value={
Expand All @@ -98,11 +88,7 @@ const CampaignSummary = ({ onLaunchClick }: { onLaunchClick: () => void }) => {
noBorder
mb="xs"
/>
<CampaignDetailsRow
title="Estimated Impressions"
value={estimatedImpressions}
textSize="sm"
/>
<DetailsRow title="Estimated Impressions" value={estimatedImpressions} textSize="sm" />
<Stack align="stretch" justify="space-between" gap="sm" mt="xl" px="md">
{step === 3 ? (
<Button onClick={onLaunchClick} size="lg" variant="filled">
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreateCampaign/StepFour/StepFour.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Paper, Stack } from '@mantine/core'
import CampaignDetailsRow from 'components/common/CampainDetailsRow/CampaignDetailsRow'
import DetailsRow from 'components/common/DetailsRow/DetailsRow'
import useCreateCampaignData from 'hooks/useCreateCampaignData/useCreateCampaignData'
import { useMemo } from 'react'
import { CreateCampaignOverview } from 'types'
Expand Down Expand Up @@ -68,7 +68,7 @@ const StepFour = () => {
const fullTitle = `${item.title}`

return (
<CampaignDetailsRow
<DetailsRow
key={fullTitle}
lighterColor
title={fullTitle}
Expand Down
3 changes: 0 additions & 3 deletions src/components/common/CampainDetailsRow/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Divider, Flex, Text, FlexProps, MantineFontSize } from '@mantine/core'

export type CampaignDetailsRowProps = FlexProps & {
export type DetailsRowProps = FlexProps & {
title: string
value: any | undefined
lighterColor?: boolean | undefined
Expand All @@ -9,15 +9,15 @@ export type CampaignDetailsRowProps = FlexProps & {
column?: boolean
}

const CampaignDetailsRow = ({
const DetailsRow = ({
title,
value,
lighterColor,
textSize = 'md',
noBorder = false,
column = false,
...flexProps
}: CampaignDetailsRowProps) => {
}: DetailsRowProps) => {
return (
<>
<Flex
Expand All @@ -44,4 +44,4 @@ const CampaignDetailsRow = ({
)
}

export default CampaignDetailsRow
export default DetailsRow
3 changes: 3 additions & 0 deletions src/components/common/DetailsRow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DetailsRow from './DetailsRow'

export default DetailsRow
Loading

0 comments on commit 31cf7e7

Please sign in to comment.