From b008b17d02863287339e8a6d19735eaf33bc8d01 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:11:59 -0500 Subject: [PATCH 1/2] chore(deps): update dependency jwt-decode to v4 (#963) * chore(deps): update dependency jwt-decode to v4 * chore(deps): remove jwt decode --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ian Krieger --- package-lock.json | 6 ------ package.json | 1 - 2 files changed, 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b1495df..cc2720ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,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", @@ -8676,11 +8675,6 @@ "node": ">=4.0" } }, - "node_modules/jwt-decode": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz", - "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==" - }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", diff --git a/package.json b/package.json index 525c4536..977dd98d 100644 --- a/package.json +++ b/package.json @@ -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", From 86cf735d55326990573f3aa399eb1b92e8601254 Mon Sep 17 00:00:00 2001 From: Ian Krieger <48930920+IanKrieger@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:26:02 -0500 Subject: [PATCH 2/2] feat: rename columns, add CTR to campaign view (#967) --- src/user/adSet/AdSetList.tsx | 15 ++++++- .../components/BaseBarChart.tsx | 4 +- .../components/BasePieChart.tsx | 2 +- .../analyticsOverview/components/LiveFeed.tsx | 4 +- .../components/MetricSelect.tsx | 8 ++-- .../analyticsOverview/lib/overview.library.ts | 10 ++--- src/user/campaignList/CampaignList.tsx | 41 ++++++++++++++++++- src/user/views/user/AdDetailTable.tsx | 2 +- 8 files changed, 69 insertions(+), 17 deletions(-) diff --git a/src/user/adSet/AdSetList.tsx b/src/user/adSet/AdSetList.tsx index 06c5cee6..dfc4fd4e 100644 --- a/src/user/adSet/AdSetList.tsx +++ b/src/user/adSet/AdSetList.tsx @@ -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 }) => , + renderCell: ({ row }) => { + if (row.oses?.length === 5) { + return ( + + ); + } + + return ; + }, flex: 1, }, { diff --git a/src/user/analytics/analyticsOverview/components/BaseBarChart.tsx b/src/user/analytics/analyticsOverview/components/BaseBarChart.tsx index 044334dd..040931de 100644 --- a/src/user/analytics/analyticsOverview/components/BaseBarChart.tsx +++ b/src/user/analytics/analyticsOverview/components/BaseBarChart.tsx @@ -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 ?? []), ]; diff --git a/src/user/analytics/analyticsOverview/components/BasePieChart.tsx b/src/user/analytics/analyticsOverview/components/BasePieChart.tsx index 8c79f26f..b491fe98 100644 --- a/src/user/analytics/analyticsOverview/components/BasePieChart.tsx +++ b/src/user/analytics/analyticsOverview/components/BasePieChart.tsx @@ -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 ?? []), ]; diff --git a/src/user/analytics/analyticsOverview/components/LiveFeed.tsx b/src/user/analytics/analyticsOverview/components/LiveFeed.tsx index daa3e7ab..b6a69349 100644 --- a/src/user/analytics/analyticsOverview/components/LiveFeed.tsx +++ b/src/user/analytics/analyticsOverview/components/LiveFeed.tsx @@ -26,7 +26,7 @@ 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)}%`, }, { @@ -34,7 +34,7 @@ export default function LiveFeed({ overview, processed }: LiveFeedProps) { 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}` }, diff --git a/src/user/analytics/analyticsOverview/components/MetricSelect.tsx b/src/user/analytics/analyticsOverview/components/MetricSelect.tsx index c16b4e50..92d5a466 100644 --- a/src/user/analytics/analyticsOverview/components/MetricSelect.tsx +++ b/src/user/analytics/analyticsOverview/components/MetricSelect.tsx @@ -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" }, ]; diff --git a/src/user/analytics/analyticsOverview/lib/overview.library.ts b/src/user/analytics/analyticsOverview/lib/overview.library.ts index 27a64b16..4a23f967 100644 --- a/src/user/analytics/analyticsOverview/lib/overview.library.ts +++ b/src/user/analytics/analyticsOverview/lib/overview.library.ts @@ -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); } diff --git a/src/user/campaignList/CampaignList.tsx b/src/user/campaignList/CampaignList.tsx index b4f3b149..8badba39 100644 --- a/src/user/campaignList/CampaignList.tsx +++ b/src/user/campaignList/CampaignList.tsx @@ -14,6 +14,7 @@ import { EngagementOverview, engagementValue, renderEngagementCell, + renderStatsCell, } from "user/analytics/renderers"; import _ from "lodash"; import { uiTextForCampaignFormat } from "user/library"; @@ -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; @@ -46,6 +49,22 @@ export function CampaignList({ advertiser }: Props) { }, }); + const getStatFromEngagement = ( + row: CampaignSummaryFragment, + k1: keyof EngagementOverview, + k2: keyof EngagementOverview, + m?: Map, + ) => { + 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[] = [ { field: "name", @@ -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 }) => @@ -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", diff --git a/src/user/views/user/AdDetailTable.tsx b/src/user/views/user/AdDetailTable.tsx index a57e442c..cd70f70d 100644 --- a/src/user/views/user/AdDetailTable.tsx +++ b/src/user/views/user/AdDetailTable.tsx @@ -63,7 +63,7 @@ export function AdDetailTable({ }, { field: "landed", - headerName: "10s Visits", + headerName: "Site Visits", valueGetter: ({ row }) => engagements.get(row.id)?.landings, renderCell: ({ row }) => renderStatsCell(loading, "landings", engagements.get(row.id)),