@@ -60,51 +60,12 @@ export default function Advert({
60
60
} ) {
61
61
if ( process . env . NEXT_PUBLIC_REMOVE_ADVERTS === "1" ) return null ;
62
62
63
- // Handle a server-friendly execution path. We will handle the client-side
64
- // logic in effects.
65
- const [ cta , setCta ] = useState ( ( ) => {
66
- // Handle the selected promotion.
67
- const selectedPromotion = marketingData . promotions [ instanceGroup ] ;
68
- for ( const promotion of selectedPromotion || [ ] ) {
69
- if ( promotion . if ) {
70
- if ( promotion . if . gpu && gpu ) {
71
- return marketingData . ctas [ promotion . cta ] ;
72
- }
73
- } else {
74
- return marketingData . ctas [ promotion . cta ] ;
75
- }
76
- }
77
-
78
- // Try with the generic promotion.
79
- const genericPromotion = marketingData . promotions . generic ;
80
- for ( const promotion of genericPromotion || [ ] ) {
81
- if ( promotion . if ) {
82
- if ( promotion . if . ab ) continue ;
83
- if ( promotion . if . gpu && gpu ) {
84
- return marketingData . ctas [ promotion . cta ] ;
85
- }
86
- } else {
87
- return marketingData . ctas [ promotion . cta ] ;
88
- }
89
- }
90
-
91
- // If no promotion was found, handle it differently depending on if this
92
- // is the server (if this is the server, scream!).
93
- if ( typeof window === "undefined" ) {
94
- throw new Error ( "No promotion found" ) ;
95
- } else {
96
- setTimeout ( ( ) => {
97
- throw new Error ( "No promotion found" ) ;
98
- } , 0 ) ;
99
- }
100
-
101
- // Return a generic promotion.
102
- const cta = Object . keys ( marketingData . ctas ) [ 0 ] ;
103
- if ( cta ) {
104
- return marketingData . ctas [ cta ] ;
105
- }
106
- return null ;
107
- } ) ;
63
+ // Get the cta.
64
+ const [ cta , setCta ] = useState < {
65
+ title : string ;
66
+ cta_text : string ;
67
+ cta_url : string ;
68
+ } | null > ( null ) ;
108
69
109
70
// Make an ab group.
110
71
const [ abGroup , setAbGroup ] = useState ( false ) ;
@@ -191,29 +152,23 @@ export default function Advert({
191
152
}
192
153
193
154
// Throw if no promotion was found.
194
- throw new Error ( "No promotion found" ) ;
155
+ setTimeout ( ( ) => {
156
+ throw new Error ( "No promotion found" ) ;
157
+ } , 0 ) ;
195
158
} , [ gpu , abGroup , loadedMarketingData ] ) ;
196
159
197
- const handledCta =
198
- cta ||
199
- ( ( ) => {
200
- if ( typeof window === "undefined" ) {
201
- throw new Error ( "No CTA found" ) ;
202
- } else {
203
- setTimeout ( ( ) => {
204
- throw new Error ( "No CTA found" ) ;
205
- } , 0 ) ;
206
- }
207
- return {
208
- title : "Get a demo" ,
209
- cta_text : "Get a demo of Vantage from a FinOps expert." ,
210
- cta_url :
211
- "https://vantage.sh/lp/aws-instances-demo?utm_campaign=Instances%20Blog%20Clicks&utm_source=aws-banner" ,
212
- } ;
213
- } ) ( ) ;
160
+ // By default, show the banner with no context.
161
+ if ( ! cta ) {
162
+ return (
163
+ < div className = "h-[2.5em]" style = { style } >
164
+ < div className = "flex items-center justify-center h-full" > </ div >
165
+ </ div >
166
+ ) ;
167
+ }
214
168
169
+ // Return when the cta is found.
215
170
return (
216
- < a href = { handledCta . cta_url } target = "_blank" >
171
+ < a href = { cta . cta_url } target = "_blank" >
217
172
< div className = "h-[2.5em]" style = { style } >
218
173
< div className = "flex items-center justify-center h-full" >
219
174
< img
@@ -222,8 +177,8 @@ export default function Advert({
222
177
className = "h-4 mr-1.5"
223
178
/>
224
179
< p >
225
- { handledCta . title } { " " }
226
- < span className = "font-bold" > { handledCta . cta_text } </ span >
180
+ { cta . title } { " " }
181
+ < span className = "font-bold" > { cta . cta_text } </ span >
227
182
</ p >
228
183
</ div >
229
184
</ div >
0 commit comments