Skip to content

Commit bec8a32

Browse files
authored
Merge pull request #13524 from guardian/ph-20250305-0905-auxia
auxia experiment: move ophan view notification
2 parents a3bc91c + 50ee0ad commit bec8a32

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

dotcom-rendering/src/components/SignInGateSelector.importable.tsx

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useOnce } from '../lib/useOnce';
1515
import { usePageViewId } from '../lib/usePageViewId';
1616
import { useSignInGateSelector } from '../lib/useSignInGateSelector';
1717
import type { Switches } from '../types/config';
18+
import type { RenderingTarget } from '../types/renderingTarget';
1819
import type { TagType } from '../types/tag';
1920
import { useConfig } from './ConfigContext';
2021
import type { ComponentEventParams } from './SignInGate/componentEventTracking';
@@ -453,6 +454,8 @@ interface ShowSignInGateAuxiaProps {
453454
userTreatment: AuxiaAPIResponseDataUserTreatment;
454455
contributionsServiceUrl: string;
455456
browserId: string | undefined;
457+
treatmentId: string;
458+
renderingTarget: RenderingTarget;
456459
logTreatmentInteractionCall: (
457460
interactionType: AuxiaInteractionInteractionType,
458461
actionName: AuxiaInteractionActionName,
@@ -588,6 +591,20 @@ const auxiaLogTreatmentInteraction = async (
588591
await fetch(url, params);
589592
};
590593

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+
591608
const SignInGateSelectorAuxia = ({
592609
host = 'https://theguardian.com/',
593610
pageId,
@@ -600,20 +617,6 @@ const SignInGateSelectorAuxia = ({
600617
This function if the Auxia prototype for the SignInGateSelector component.
601618
*/
602619

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-
617620
const authStatus = useAuthStatus();
618621

619622
const isSignedIn =
@@ -660,21 +663,6 @@ const SignInGateSelectorAuxia = ({
660663
);
661664
if (data !== undefined) {
662665
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-
}
678666
}
679667
})().catch((error) => {
680668
console.error('Error fetching Auxia display data:', error);
@@ -714,6 +702,11 @@ const SignInGateSelectorAuxia = ({
714702
}
715703
contributionsServiceUrl={contributionsServiceUrl}
716704
browserId={auxiaGateDisplayData.browserId}
705+
treatmentId={
706+
auxiaGateDisplayData.auxiaData.userTreatment
707+
.treatmentId
708+
}
709+
renderingTarget={renderingTarget}
717710
logTreatmentInteractionCall={async (
718711
interactionType: AuxiaInteractionInteractionType,
719712
actionName: AuxiaInteractionActionName,
@@ -740,6 +733,8 @@ const ShowSignInGateAuxia = ({
740733
userTreatment,
741734
contributionsServiceUrl,
742735
browserId,
736+
treatmentId,
737+
renderingTarget,
743738
logTreatmentInteractionCall,
744739
}: ShowSignInGateAuxiaProps) => {
745740
const componentId = 'main_variant_5';
@@ -755,6 +750,17 @@ const ShowSignInGateAuxia = ({
755750
'',
756751
browserId,
757752
);
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+
);
758764
})().catch((error) => {
759765
console.error('Failed to log treatment interaction:', error);
760766
});

0 commit comments

Comments
 (0)