1+ export type PromoType = "banner" | "video" ;
2+
13export type PromoData = {
4+ type ?: PromoType ;
25 isActive ?: boolean ;
36 priority ?: number ;
47 osTargets ?: string [ ] ;
@@ -18,10 +21,61 @@ export type PromoData = {
1821 text : string ;
1922 link : string ;
2023 } ;
24+ // Video-specific properties
25+ video ?: {
26+ placeholderImage : string ;
27+ imageAltText : string ;
28+ videoURL : string ;
29+ } ;
30+ } ;
31+
32+ export type FilterOptions = {
33+ type ?: PromoType ;
34+ os ?: string | null ;
35+ path ?: string | null ;
36+ } ;
37+
38+ /** Get all promos matching the filter criteria, sorted by priority (highest first) */
39+ export const getFilteredPromos = (
40+ promos : PromoData [ ] ,
41+ options : FilterOptions = { }
42+ ) : PromoData [ ] => {
43+ const { type, os, path } = options ;
44+
45+ return promos
46+ . filter ( ( promo ) => {
47+ // Check if active
48+ if ( promo . isActive === false ) return false ;
49+
50+ // Check type match
51+ if ( type && promo . type !== type ) return false ;
52+
53+ // Check path suppression
54+ if ( path && promo . suppressOnPaths ?. includes ( path ) ) return false ;
55+
56+ // Check OS targeting
57+ if ( promo . osTargets && promo . osTargets . length > 0 ) {
58+ if ( ! os || ! promo . osTargets . includes ( os ) ) return false ;
59+ }
60+
61+ return true ;
62+ } )
63+ . sort ( ( a , b ) => ( b . priority ?? 0 ) - ( a . priority ?? 0 ) ) ;
64+ } ;
65+
66+ /** Get the top N promos matching the filter criteria */
67+ export const getTopPromos = (
68+ promos : PromoData [ ] ,
69+ count : number ,
70+ options : FilterOptions = { }
71+ ) : PromoData [ ] => {
72+ return getFilteredPromos ( promos , options ) . slice ( 0 , count ) ;
2173} ;
2274
2375const promoData : Record < string , PromoData > = {
76+ // === BANNER PROMOS ===
2477 audacity4Alpha : {
78+ type : "banner" ,
2579 isActive : false ,
2680 priority : 50 ,
2781 suppressOnPaths : [ "/next" , "/download" ] ,
@@ -42,6 +96,7 @@ const promoData: Record<string, PromoData> = {
4296 } ,
4397 } ,
4498 voiceByAuribus : {
99+ type : "banner" ,
45100 isActive : false ,
46101 priority : 50 ,
47102 osTargets : [ "Windows" , "OS X" ] ,
@@ -63,6 +118,7 @@ const promoData: Record<string, PromoData> = {
63118 } ,
64119 } ,
65120 soapVoiceCleaner : {
121+ type : "banner" ,
66122 isActive : true ,
67123 priority : 50 ,
68124 osTargets : [ "Windows" , "OS X" ] ,
@@ -85,6 +141,7 @@ const promoData: Record<string, PromoData> = {
85141 } ,
86142 } ,
87143 ampknob : {
144+ type : "banner" ,
88145 isActive : false ,
89146 osTargets : [ "Windows" , "OS X" ] ,
90147 message : "Heavy guitar tone in seconds. One knob, no distractions." ,
@@ -105,6 +162,7 @@ const promoData: Record<string, PromoData> = {
105162 } ,
106163 } ,
107164 survey : {
165+ type : "banner" ,
108166 isActive : false ,
109167 message : "3 minute survey:\nHelp us understand what features you want next" ,
110168 styles : {
@@ -123,6 +181,44 @@ const promoData: Record<string, PromoData> = {
123181 link : "https://docs.google.com/forms/d/e/1FAIpQLScxH_f64JPCWt5nwqa8MTPXfmi453mqYwy1xZFPF_mx9mYkNw/viewform" ,
124182 } ,
125183 } ,
184+
185+ // === VIDEO PROMOS ===
186+ audacity4Video : {
187+ type : "video" ,
188+ isActive : true ,
189+ priority : 100 ,
190+ message : "How we're building Audacity 4" ,
191+ tracking : {
192+ category : "Video embed" ,
193+ action : "Watch release video" ,
194+ name : "How we're building Audacity 4" ,
195+ } ,
196+ video : {
197+ placeholderImage : "https://i.ytimg.com/vi/QYM3TWf_G38/maxresdefault.jpg" ,
198+ imageAltText : "Video thumbnail: How we're building Audacity 4" ,
199+ videoURL : "https://www.youtube-nocookie.com/embed/QYM3TWf_G38?autoplay=1" ,
200+ } ,
201+ } ,
202+ playgrndFxVideo : {
203+ type : "video" ,
204+ isActive : true ,
205+ priority : 90 ,
206+ message : "Install once. Access tons of powerful plugins. Blend for infinite creativity." ,
207+ cta : {
208+ text : "Get it on MuseHub" ,
209+ link : "https://www.musehub.com/plugin/playgrnd-fx?utm_source=au-web&utm_medium=mh-web-cta&utm_campaign=au-web-mh-web-playgrnd-fx" ,
210+ } ,
211+ tracking : {
212+ category : "Video embed" ,
213+ action : "Watch release video" ,
214+ name : "PLAYGRND FX" ,
215+ } ,
216+ video : {
217+ placeholderImage : "https://i.ytimg.com/vi/UGiJCTu67Ak/maxresdefault.jpg" ,
218+ imageAltText : "Video thumbnail: PLAYGRND FX" ,
219+ videoURL : "https://www.youtube-nocookie.com/embed/UGiJCTu67Ak?autoplay=1" ,
220+ } ,
221+ } ,
126222} ;
127223
128224export default promoData ;
0 commit comments