@@ -33,7 +33,6 @@ type Props = {
3333 idUrl ?: string ;
3434 contributionsServiceUrl : string ;
3535 auxiaGateDisplayData ?: AuxiaGateDisplayData | undefined ;
36- signInGateVersion ?: AuxiaGateVersion ;
3736} ;
3837
3938// function to generate the profile.theguardian.com url with tracking params
@@ -87,12 +86,15 @@ export const SignInGateSelector = ({
8786 idUrl = 'https://profile.theguardian.com' ,
8887 contributionsServiceUrl,
8988 auxiaGateDisplayData,
90- signInGateVersion,
9189} : Props ) => {
9290 if ( ! pageIdIsAllowedForGating ( pageId ) ) {
9391 return < > </ > ;
9492 }
9593
94+ const signInGateVersion = getAuxiaGateVersion (
95+ auxiaGateDisplayData ?. auxiaData . userTreatment ,
96+ ) ;
97+
9698 return (
9799 < SignInGateSelectorAuxia
98100 host = { host }
@@ -138,7 +140,7 @@ type PropsAuxia = {
138140 isPreview : boolean ;
139141 isPaidContent : boolean ;
140142 auxiaGateDisplayData ?: AuxiaGateDisplayData ;
141- signInGateVersion ? : AuxiaGateVersion ;
143+ signInGateVersion : AuxiaGateVersion ;
142144} ;
143145
144146// [1] If true, it indicates that we are using the component for the regular Auxia share of the Audience
@@ -158,7 +160,7 @@ interface ShowSignInGateAuxiaProps {
158160 interactionType : AuxiaInteractionInteractionType ,
159161 actionName ?: AuxiaInteractionActionName ,
160162 ) => Promise < void > ;
161- signInGateVersion ? : AuxiaGateVersion ;
163+ signInGateVersion : AuxiaGateVersion ;
162164}
163165
164166const incrementGateDisplayCount = ( ) => {
@@ -243,22 +245,21 @@ const buildAbTestTrackingAuxiaVariant = (
243245 } ;
244246} ;
245247
248+ /**
249+ * Determines the gate version based on one of 2 things:
250+ * 1. url query parameter
251+ * 2. treatmentType
252+ */
246253export const getAuxiaGateVersion = (
247- signInGateVersion ?: AuxiaGateVersion ,
248254 userTreatment ?: AuxiaAPIResponseDataUserTreatment ,
249255) : AuxiaGateVersion => {
250- if ( signInGateVersion ) {
251- return signInGateVersion ;
252- }
253-
254256 const params = new URLSearchParams ( window . location . search ) ;
255257 const version = params . get ( 'auxia_gate_version' ) ;
256258
257259 if (
258260 String ( version ) . toLowerCase ( ) . endsWith ( 'v2' ) ||
259- String ( userTreatment ?. treatmentType )
260- . toLowerCase ( )
261- . endsWith ( 'POPUP' )
261+ userTreatment ?. treatmentType === 'DISMISSABLE_SIGN_IN_GATE_POPUP' ||
262+ userTreatment ?. treatmentType === 'NONDISMISSIBLE_SIGN_IN_GATE_POPUP'
262263 ) {
263264 return 'v2' ;
264265 }
@@ -300,6 +301,13 @@ const SignInGateSelectorAuxia = ({
300301 document . dispatchEvent (
301302 new CustomEvent ( 'article:sign-in-gate-dismissed' ) ,
302303 ) ;
304+
305+ // Emit event for use by ad slots
306+ document . dispatchEvent (
307+ new CustomEvent (
308+ `article:sign-in-gate-${ signInGateVersion } -dismissed` ,
309+ ) ,
310+ ) ;
303311 }
304312 } , [ isGateDismissed ] ) ;
305313
@@ -397,7 +405,7 @@ const ShowSignInGateAuxia = ({
397405 const personaliseSignInGateAfterCheckoutSwitch = undefined ;
398406
399407 // Get the gate version configuration
400- const gateVersion = getAuxiaGateVersion ( signInGateVersion , userTreatment ) ;
408+ // const gateVersion = getAuxiaGateVersion(signInGateVersion, userTreatment);
401409
402410 const [ signInGatePlaceholder , setSignInGatePlaceholder ] =
403411 useState < HTMLElement | null > ( null ) ;
@@ -417,6 +425,7 @@ const ShowSignInGateAuxia = ({
417425
418426 useEffect ( ( ) => {
419427 if ( hasBeenSeen ) {
428+ // Tell Auxia
420429 void auxiaLogTreatmentInteraction (
421430 contributionsServiceUrl ,
422431 userTreatment ,
@@ -436,6 +445,7 @@ const ShowSignInGateAuxia = ({
436445 ) ;
437446 } ) ;
438447
448+ // Tell Ophan
439449 void submitComponentEventTracking (
440450 {
441451 component : {
@@ -451,6 +461,13 @@ const ShowSignInGateAuxia = ({
451461 // Once the gate is being displayed we need to update
452462 // the tracking of the number of times the gate has been displayed
453463 incrementGateDisplayCount ( ) ;
464+
465+ // Emit event for use by ad slots
466+ document . dispatchEvent (
467+ new CustomEvent (
468+ `article:sign-in-gate-${ signInGateVersion } -viewed` ,
469+ ) ,
470+ ) ;
454471 }
455472 } , [
456473 componentId ,
@@ -460,7 +477,7 @@ const ShowSignInGateAuxia = ({
460477 renderingTarget ,
461478 treatmentId ,
462479 userTreatment ,
463- gateVersion ,
480+ signInGateVersion ,
464481 ] ) ;
465482
466483 const commonProps = {
@@ -498,7 +515,7 @@ const ShowSignInGateAuxia = ({
498515 aria-hidden = "true"
499516 style = { { height : 1 , marginTop : - 1 } }
500517 />
501- { gateVersion === 'v2' ? (
518+ { signInGateVersion === 'v2' ? (
502519 shouldShowV2Gate && < SignInGateAuxiaV2 { ...commonProps } />
503520 ) : (
504521 < SignInGateAuxiaV1 { ...commonProps } />
0 commit comments