@@ -15,6 +15,7 @@ import { useOnce } from '../lib/useOnce';
15
15
import { usePageViewId } from '../lib/usePageViewId' ;
16
16
import { useSignInGateSelector } from '../lib/useSignInGateSelector' ;
17
17
import type { Switches } from '../types/config' ;
18
+ import type { RenderingTarget } from '../types/renderingTarget' ;
18
19
import type { TagType } from '../types/tag' ;
19
20
import { useConfig } from './ConfigContext' ;
20
21
import type { ComponentEventParams } from './SignInGate/componentEventTracking' ;
@@ -453,6 +454,8 @@ interface ShowSignInGateAuxiaProps {
453
454
userTreatment : AuxiaAPIResponseDataUserTreatment ;
454
455
contributionsServiceUrl : string ;
455
456
browserId : string | undefined ;
457
+ treatmentId : string ;
458
+ renderingTarget : RenderingTarget ;
456
459
logTreatmentInteractionCall : (
457
460
interactionType : AuxiaInteractionInteractionType ,
458
461
actionName : AuxiaInteractionActionName ,
@@ -588,6 +591,20 @@ const auxiaLogTreatmentInteraction = async (
588
591
await fetch ( url , params ) ;
589
592
} ;
590
593
594
+ const buildAbTestTrackingAuxiaVariant = (
595
+ treatmentId : string ,
596
+ ) : {
597
+ name : string ;
598
+ variant : string ;
599
+ id : string ;
600
+ } => {
601
+ return {
602
+ name : 'AuxiaSignInGate' ,
603
+ variant : treatmentId ,
604
+ id : treatmentId ,
605
+ } ;
606
+ } ;
607
+
591
608
const SignInGateSelectorAuxia = ( {
592
609
host = 'https://theguardian.com/' ,
593
610
pageId,
@@ -600,20 +617,6 @@ const SignInGateSelectorAuxia = ({
600
617
This function if the Auxia prototype for the SignInGateSelector component.
601
618
*/
602
619
603
- const buildAbTestTrackingAuxiaVariant = (
604
- treatmentId : string ,
605
- ) : {
606
- name : string ;
607
- variant : string ;
608
- id : string ;
609
- } => {
610
- return {
611
- name : 'AuxiaSignInGate' ,
612
- variant : treatmentId ,
613
- id : treatmentId ,
614
- } ;
615
- } ;
616
-
617
620
const authStatus = useAuthStatus ( ) ;
618
621
619
622
const isSignedIn =
@@ -660,21 +663,6 @@ const SignInGateSelectorAuxia = ({
660
663
) ;
661
664
if ( data !== undefined ) {
662
665
setAuxiaGateDisplayData ( data ) ;
663
- if ( data . auxiaData . userTreatment !== undefined ) {
664
- await submitComponentEventTracking (
665
- {
666
- component : {
667
- componentType : 'SIGN_IN_GATE' ,
668
- id : data . auxiaData . userTreatment . treatmentId ,
669
- } ,
670
- action : 'VIEW' ,
671
- abTest : buildAbTestTrackingAuxiaVariant (
672
- data . auxiaData . userTreatment . treatmentId ,
673
- ) ,
674
- } ,
675
- renderingTarget ,
676
- ) ;
677
- }
678
666
}
679
667
} ) ( ) . catch ( ( error ) => {
680
668
console . error ( 'Error fetching Auxia display data:' , error ) ;
@@ -714,6 +702,11 @@ const SignInGateSelectorAuxia = ({
714
702
}
715
703
contributionsServiceUrl = { contributionsServiceUrl }
716
704
browserId = { auxiaGateDisplayData . browserId }
705
+ treatmentId = {
706
+ auxiaGateDisplayData . auxiaData . userTreatment
707
+ . treatmentId
708
+ }
709
+ renderingTarget = { renderingTarget }
717
710
logTreatmentInteractionCall = { async (
718
711
interactionType : AuxiaInteractionInteractionType ,
719
712
actionName : AuxiaInteractionActionName ,
@@ -740,6 +733,8 @@ const ShowSignInGateAuxia = ({
740
733
userTreatment,
741
734
contributionsServiceUrl,
742
735
browserId,
736
+ treatmentId,
737
+ renderingTarget,
743
738
logTreatmentInteractionCall,
744
739
} : ShowSignInGateAuxiaProps ) => {
745
740
const componentId = 'main_variant_5' ;
@@ -755,6 +750,17 @@ const ShowSignInGateAuxia = ({
755
750
'' ,
756
751
browserId ,
757
752
) ;
753
+ await submitComponentEventTracking (
754
+ {
755
+ component : {
756
+ componentType : 'SIGN_IN_GATE' ,
757
+ id : treatmentId ,
758
+ } ,
759
+ action : 'VIEW' ,
760
+ abTest : buildAbTestTrackingAuxiaVariant ( treatmentId ) ,
761
+ } ,
762
+ renderingTarget ,
763
+ ) ;
758
764
} ) ( ) . catch ( ( error ) => {
759
765
console . error ( 'Failed to log treatment interaction:' , error ) ;
760
766
} ) ;
0 commit comments