Skip to content

Commit

Permalink
Merge pull request #968 from brave/master
Browse files Browse the repository at this point in the history
Production Release 2023-11-08
  • Loading branch information
IanKrieger authored Nov 8, 2023
2 parents a2a47b7 + 86cf735 commit fa2da00
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 24 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"highcharts": "11.2.0",
"highcharts-react-official": "3.2.1",
"immer": "10.0.3",
"jwt-decode": "3.1.2",
"lodash": "4.17.21",
"moment": "2.29.4",
"npm-audit-resolver": "3.0.0-RC.0",
Expand Down
15 changes: 14 additions & 1 deletion src/user/adSet/AdSetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,20 @@ export function AdSetList({ campaign, loading, engagements }: Props) {
headerName: "Platforms",
valueGetter: ({ row }) =>
row.oses?.map((o: { name: string }) => o.name).join(", "),
renderCell: ({ row }) => <ChipList items={row.oses} />,
renderCell: ({ row }) => {
if (row.oses?.length === 5) {
return (
<Chip
label="all"
size="small"
variant="outlined"
sx={{ mr: 1, marginY: "4px" }}
/>
);
}

return <ChipList items={row.oses} />;
},
flex: 1,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export function BaseBarChart({
};

const tabs: Option[] = [
{ value: "landingRate", label: "Click to 10s Visit Rate" },
{ value: "landingRate", label: "Click to site visit Rate" },
{ value: "ctr", label: "CTR" },
{ value: "visitRate", label: "10s visit rate" },
{ value: "visitRate", label: "Site visit rate" },
...(extraOptions ?? []),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function BasePieChart({ series, onSetType, extraOptions, type }: Props) {
{ value: "view", label: "Impressions" },
{ value: "conversion", label: "Conversions" },
{ value: "click", label: "Clicks" },
{ value: "landed", label: "10s visits" },
{ value: "landed", label: "Site visits" },
...(extraOptions ?? []),
];

Expand Down
4 changes: 2 additions & 2 deletions src/user/analytics/analyticsOverview/components/LiveFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export default function LiveFeed({ overview, processed }: LiveFeedProps) {
value: `${processed.ctr.toFixed(2)}%`,
},
{
label: "10s visit rate",
label: "Site visit rate",
value: `${processed.visitRate.toFixed(2)}%`,
},
{
label: "Dismissal rate",
value: `${processed.dismissRate.toFixed(2)}%`,
},
{
label: "Click to 10s visit rate",
label: "Click to site visit rate",
value: `${processed.landingRate.toFixed(2)}%`,
},
{ label: "Upvotes", value: `${processed.upvotes}` },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export default function MetricSelect({
{ value: "views", label: "Impressions" },
{ value: "clicks", label: "Clicks" },
{ value: "ctr", label: "CTR" },
{ value: "landings", label: "10s Visits" },
{ value: "landings", label: "Site visits" },
{ value: "conversions", label: "Conversions" },
{ value: "dismissals", label: "Dismissals" },
// { value: "upvotes", label: "Upvotes" },
// { value: "downvotes", label: "Downvotes" },
{ value: "convRate", label: "Conversion Rate" },
{ value: "landingRate", label: "Click to 10s Visit Rate" },
{ value: "visitRate", label: "10s Visit Rate" },
{ value: "dismissRate", label: "Dismissal Rate" },
{ value: "landingRate", label: "Click to site visit rate" },
{ value: "visitRate", label: "Site visit rate" },
{ value: "dismissRate", label: "Dismissal rate" },
{ value: "spend", label: "Spend" },
{ value: "cpa", label: "CPA" },
];
Expand Down
10 changes: 5 additions & 5 deletions src/user/analytics/analyticsOverview/lib/overview.library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ export const decideLabel = (metric: string) => {
case "ctr":
return "CTR";
case "convRate":
return "Conversion Rate";
return "Conversion rate";
case "landingRate":
return "Click to 10s Visit Rate";
return "Click to site visit rate";
case "views":
return "Impressions";
case "cpa":
return "CPA";
case "visitRate":
return "10s visit rate";
return "Site visit rate";
case "dismissRate":
return "Dismissal Rate";
return "Dismissal rate";
case "landings":
return " 10s Visits";
return "Site visits";
default:
return _.capitalize(metric);
}
Expand Down
41 changes: 40 additions & 1 deletion src/user/campaignList/CampaignList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
EngagementOverview,
engagementValue,
renderEngagementCell,
renderStatsCell,
} from "user/analytics/renderers";
import _ from "lodash";
import { uiTextForCampaignFormat } from "user/library";
Expand All @@ -22,6 +23,8 @@ import { DataGrid, GridColDef } from "@mui/x-data-grid";
import { CustomToolbar } from "components/Datagrid/CustomToolbar";
import { CloneCampaign } from "components/Campaigns/CloneCampaign";
import { EditButton } from "user/campaignList/EditButton";
import { calculateMetric } from "user/analytics/analyticsOverview/lib/overview.library";
import { StatsMetric } from "user/analytics/analyticsOverview/types";

interface Props {
advertiser?: AdvertiserCampaignsFragment | null;
Expand All @@ -46,6 +49,22 @@ export function CampaignList({ advertiser }: Props) {
},
});

const getStatFromEngagement = (
row: CampaignSummaryFragment,
k1: keyof EngagementOverview,
k2: keyof EngagementOverview,
m?: Map<string, EngagementOverview>,
) => {
const val1 = m?.get(row.id)?.[k1];
const val2 = m?.get(row.id)?.[k2];

if (typeof val1 !== "number" || typeof val2 !== "number") {
return null;
}

return calculateMetric(true, val1 ?? 0, val2 ?? 0);
};

const columns: GridColDef<CampaignSummaryFragment>[] = [
{
field: "name",
Expand Down Expand Up @@ -124,7 +143,7 @@ export function CampaignList({ advertiser }: Props) {
},
{
field: "landed",
headerName: "10s Visits",
headerName: "Site visits",
valueGetter: ({ row }) =>
engagementData?.get(row.id)?.["landed"] ?? "N/A",
renderCell: ({ row }) =>
Expand All @@ -134,6 +153,26 @@ export function CampaignList({ advertiser }: Props) {
minWidth: 100,
maxWidth: 250,
},
{
field: "ctr",
headerName: "CTR",
valueGetter: ({ row }) =>
getStatFromEngagement(row, "click", "view", engagementData),
renderCell: ({ row }) =>
renderStatsCell(
loading,
"ctr",
{
ctr:
getStatFromEngagement(row, "click", "view", engagementData) ?? 0,
} as StatsMetric,
row.currency,
),
align: "right",
headerAlign: "right",
minWidth: 100,
maxWidth: 250,
},
{
field: "startAt",
headerName: "Start",
Expand Down
2 changes: 1 addition & 1 deletion src/user/views/user/AdDetailTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function AdDetailTable<T extends { id: string }>({
},
{
field: "landed",
headerName: "10s Visits",
headerName: "Site Visits",
valueGetter: ({ row }) => engagements.get(row.id)?.landings,
renderCell: ({ row }) =>
renderStatsCell(loading, "landings", engagements.get(row.id)),
Expand Down

0 comments on commit fa2da00

Please sign in to comment.