Skip to content

Commit 6a3d347

Browse files
committed
feat: support promo suppression by path
1 parent d77170b commit 6a3d347

File tree

3 files changed

+79
-66
lines changed

3 files changed

+79
-66
lines changed

src/assets/data/promotions.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type PromoData = {
22
isActive?: boolean;
33
priority?: number;
44
osTargets?: string[];
5+
suppressOnPaths?: string[];
56
message: string;
67
styles?: {
78
container?: string;
@@ -23,20 +24,26 @@ const promoData: Record<string, PromoData> = {
2324
audacity4Alpha: {
2425
isActive: true,
2526
priority: 50,
27+
suppressOnPaths: ["/au4", "/download"],
2628
message: "Want a peek at our next big release?",
2729
cta: {
2830
text: "Try the Audacity 4 Alpha",
2931
link: "/au4",
3032
},
33+
tracking: {
34+
category: "Promo CTA",
35+
action: "Promo CTA button",
36+
name: "Audacity 4 Alpha",
37+
},
3138
styles: {
3239
container: "bg-[#0f004d]",
3340
message: "text-gray-100",
3441
button: "bg-[#ff3254] hover:bg-[#ff1a3c] text-white",
35-
}
42+
},
3643
},
3744
voiceByAuribus: {
3845
isActive: true,
39-
priority: 0,
46+
priority: 50,
4047
osTargets: ["Windows", "OS X"],
4148
message:
4249
"AI powered professional vocals. Transform any track with Voice by Auribus!",

src/components/banner/PromoBanner.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const STATIC_PROMOS: PromoData[] = Object.values(promoData);
2222
const isPromoActive = (promo: PromoData | null | undefined) =>
2323
promo?.isActive ?? true;
2424

25+
const isSuppressedOnPath = (promo: PromoData, path: string | null) => {
26+
if (!path) {
27+
return false;
28+
}
29+
const suppressedPaths = promo.suppressOnPaths ?? [];
30+
return suppressedPaths.includes(path);
31+
};
32+
2533
const getHighestPriorityPromo = (promos: PromoData[]) =>
2634
promos.reduce<PromoData | null>((selected, current) => {
2735
if (!current) {
@@ -74,11 +82,13 @@ const selectWeightedPromo = (promos: PromoData[]) => {
7482
return promos[promos.length - 1] ?? null;
7583
};
7684

77-
const buildPromoList = (): PromoData[] => STATIC_PROMOS;
85+
const buildPromoList = (path: string | null): PromoData[] =>
86+
STATIC_PROMOS.filter((promo) => !isSuppressedOnPath(promo, path));
7887

7988
const PromoBanner: React.FC = () => {
8089
const browserOS = useBrowserOS();
81-
const promos = buildPromoList();
90+
const pathName = typeof window !== "undefined" ? window.location.pathname : null;
91+
const promos = buildPromoList(pathName);
8292
const eligiblePromos = getEligiblePromos(promos, browserOS);
8393
const fallbackPromos = promos.filter((promo) => isPromoActive(promo));
8494
const selectionPool =

src/pages/download.astro

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ const formatCampaignLinkLabel = (
7474
</div>
7575
</section>
7676
<aside class="col-start-2 col-span-10 sm:col-start-8 sm:col-span-3">
77-
<div>
78-
<h2 class="text-sm uppercase font-normal text-gray-600">
79-
Pre-release builds
80-
</h2>
81-
{hasDownloadCampaigns ? (
77+
{hasDownloadCampaigns && (
78+
<div>
79+
<h2 class="text-sm uppercase font-normal text-gray-600">
80+
Pre-release builds
81+
</h2>
8282
<div class="flex flex-col gap-6 mt-2">
8383
{activeDownloadEntries.map((entry) => {
8484
const downloads = entry.downloads;
@@ -89,66 +89,62 @@ const formatCampaignLinkLabel = (
8989

9090
return (
9191
<div class="flex flex-col gap-3">
92-
<h3 class="text-base font-semibold text-gray-900">
93-
{versionLabel}
94-
</h3>
95-
<p class="text-sm text-gray-700">
96-
{entry.summary}
97-
</p>
98-
<ul class="flex flex-col gap-2 text-sm">
99-
{
100-
windowsBuilds.map((build) => (
101-
<li>
102-
<a
103-
class="hyperlink"
104-
href={build.browser_download_url}
105-
>
106-
{formatCampaignLinkLabel(entry, "Windows", build.name)}
107-
</a>
108-
</li>
109-
))
110-
}
111-
{
112-
macBuilds.map((build) => (
113-
<li>
114-
<a
115-
class="hyperlink"
116-
href={build.browser_download_url}
117-
>
118-
{formatCampaignLinkLabel(entry, "macOS", build.name)}
119-
</a>
120-
</li>
121-
))
122-
}
123-
{
124-
linuxBuilds.map((build) => (
125-
<li>
126-
<a
127-
class="hyperlink"
128-
href={build.browser_download_url}
129-
>
130-
{formatCampaignLinkLabel(entry, "Linux", build.name)}
131-
</a>
132-
</li>
133-
))
134-
}
135-
</ul>
136-
<div class="flex items-center gap-1">
137-
<a href={entry.pageHref} class="hyperlink text-sm">
138-
{`Learn more about ${versionLabel}`}
139-
</a>
140-
<span class="align-middle icon icon-share text-blue-600"></span>
141-
</div>
92+
<h3 class="text-base font-semibold text-gray-900">
93+
{versionLabel}
94+
</h3>
95+
<p class="text-sm text-gray-700">
96+
{entry.summary}
97+
</p>
98+
<ul class="flex flex-col gap-2 text-sm">
99+
{
100+
windowsBuilds.map((build) => (
101+
<li>
102+
<a
103+
class="hyperlink"
104+
href={build.browser_download_url}
105+
>
106+
{formatCampaignLinkLabel(entry, "Windows", build.name)}
107+
</a>
108+
</li>
109+
))
110+
}
111+
{
112+
macBuilds.map((build) => (
113+
<li>
114+
<a
115+
class="hyperlink"
116+
href={build.browser_download_url}
117+
>
118+
{formatCampaignLinkLabel(entry, "macOS", build.name)}
119+
</a>
120+
</li>
121+
))
122+
}
123+
{
124+
linuxBuilds.map((build) => (
125+
<li>
126+
<a
127+
class="hyperlink"
128+
href={build.browser_download_url}
129+
>
130+
{formatCampaignLinkLabel(entry, "Linux", build.name)}
131+
</a>
132+
</li>
133+
))
134+
}
135+
</ul>
136+
<div class="flex items-center gap-1">
137+
<a href={entry.pageHref} class="hyperlink text-sm">
138+
{`Learn more about ${versionLabel}`}
139+
</a>
140+
<span class="align-middle icon icon-share text-blue-600"></span>
141+
</div>
142142
</div>
143143
);
144144
})}
145145
</div>
146-
) : (
147-
<p class="text-sm text-gray-700 mt-2">
148-
Pre-release downloads are currently unavailable.
149-
</p>
150-
)}
151-
</div>
146+
</div>
147+
)}
152148
<h2 class="text-sm uppercase font-normal text-gray-600 mt-10">
153149
Additional resources
154150
</h2>
@@ -179,7 +175,7 @@ const formatCampaignLinkLabel = (
179175
<div>
180176
<h3 class="additional-resource-heading">Source code</h3>
181177
<div class="flex flex-col gap-2">
182-
<!-- TODO - Ensure accordions are inclueded in the tab hierarchy -->
178+
<!-- TODO - Ensure accordions are included in the tab hierarchy -->
183179
{primarySourceDownload ? (
184180
<ChecksumAccordion
185181
title={primarySourceDownload.type}

0 commit comments

Comments
 (0)