Skip to content

Commit 1d8270e

Browse files
use early return
1 parent df2c83a commit 1d8270e

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

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

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,37 +90,38 @@ const handleMeasureDetectedEvent = (
9090
'whitelisted' in e &&
9191
'subscribed' in e;
9292

93-
if (isMeasureDetectedEvent(event)) {
94-
if (event.adblocking) {
95-
log(
96-
'commercial',
97-
'🛡️ Admiral - user has an adblocker and it is enabled',
98-
);
99-
recordAdmiralOphanEvent(ab, { action: 'DETECT', value: 'blocked' });
100-
}
101-
if (event.whitelisted) {
102-
log(
103-
'commercial',
104-
'🛡️ Admiral - user has seen Engage and subsequently disabled their adblocker',
105-
);
106-
recordAdmiralOphanEvent(ab, {
107-
action: 'DETECT',
108-
value: 'whitelisted',
109-
});
110-
}
111-
if (event.subscribed) {
112-
log(
113-
'commercial',
114-
'🛡️ Admiral - user has an active subscription to a transact plan',
115-
);
116-
}
117-
} else {
93+
if (!isMeasureDetectedEvent(event)) {
11894
log(
11995
'commercial',
12096
`🛡️ Admiral - Event is not of expected format of measure.detected ${JSON.stringify(
12197
event,
12298
)}`,
12399
);
100+
return;
101+
}
102+
103+
if (event.adblocking) {
104+
log(
105+
'commercial',
106+
'🛡️ Admiral - user has an adblocker and it is enabled',
107+
);
108+
recordAdmiralOphanEvent(ab, { action: 'DETECT', value: 'blocked' });
109+
}
110+
if (event.whitelisted) {
111+
log(
112+
'commercial',
113+
'🛡️ Admiral - user has seen Engage and subsequently disabled their adblocker',
114+
);
115+
recordAdmiralOphanEvent(ab, {
116+
action: 'DETECT',
117+
value: 'whitelisted',
118+
});
119+
}
120+
if (event.subscribed) {
121+
log(
122+
'commercial',
123+
'🛡️ Admiral - user has an active subscription to a transact plan',
124+
);
124125
}
125126
};
126127

0 commit comments

Comments
 (0)