From f053ca2c9656f41a7003ceef405a6bab7c1edafe Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 17 Apr 2023 16:47:39 +0200 Subject: [PATCH] stopped ab test, removed ab test tracking code --- backend/src/api/controllers/psa.ts | 15 +------------- backend/src/utils/prometheus.ts | 10 ---------- frontend/src/ts/ape/endpoints/psas.ts | 5 +---- frontend/src/ts/controllers/ad-controller.ts | 21 ++++++++++---------- frontend/src/ts/elements/psa.ts | 3 +-- 5 files changed, 14 insertions(+), 40 deletions(-) diff --git a/backend/src/api/controllers/psa.ts b/backend/src/api/controllers/psa.ts index 8d6fe55d7..18a3e31b9 100644 --- a/backend/src/api/controllers/psa.ts +++ b/backend/src/api/controllers/psa.ts @@ -1,20 +1,7 @@ import * as PsaDAL from "../../dal/psa"; import { MonkeyResponse } from "../../utils/monkey-response"; -import { recordAdAbTest } from "../../utils/prometheus"; - -export async function getPsas( - req: MonkeyTypes.Request -): Promise { - const { adChoice: adChoiceRaw } = req.query; - - //ensure adchoice raw is a string and either "pw" or "eg" - const adChoice = - typeof adChoiceRaw === "string" && ["pw", "eg"].includes(adChoiceRaw) - ? adChoiceRaw - : "unknown"; - - recordAdAbTest(adChoice); +export async function getPsas(): Promise { const data = await PsaDAL.get(); return new MonkeyResponse("PSAs retrieved", data); } diff --git a/backend/src/utils/prometheus.ts b/backend/src/utils/prometheus.ts index e0b93ba99..17c250ab7 100644 --- a/backend/src/utils/prometheus.ts +++ b/backend/src/utils/prometheus.ts @@ -322,13 +322,3 @@ export function recordTimeToCompleteJob( timeToCompleteJobTotal.inc({ queueName, jobName }, time); timeToCompleteJobCount.inc({ queueName, jobName }); } - -const adAbTest = new Counter({ - name: "ad_ab_test", - help: "Ad AB test", - labelNames: ["provider"], -}); - -export function recordAdAbTest(provider: string): void { - adAbTest.inc({ provider }); -} diff --git a/frontend/src/ts/ape/endpoints/psas.ts b/frontend/src/ts/ape/endpoints/psas.ts index 8516a4b8b..9e8065bd5 100644 --- a/frontend/src/ts/ape/endpoints/psas.ts +++ b/frontend/src/ts/ape/endpoints/psas.ts @@ -7,14 +7,11 @@ export default class Psas { this.httpClient = httpClient; } - async get(adChoice: string): Ape.EndpointData { + async get(): Ape.EndpointData { return await this.httpClient.get(BASE_PATH, { headers: { "Client-Version": CLIENT_VERSION, }, - searchQuery: { - adChoice, - }, }); } } diff --git a/frontend/src/ts/controllers/ad-controller.ts b/frontend/src/ts/controllers/ad-controller.ts index 6f8a7cc15..4b17f5b88 100644 --- a/frontend/src/ts/controllers/ad-controller.ts +++ b/frontend/src/ts/controllers/ad-controller.ts @@ -18,18 +18,19 @@ let initialised = false; export let adBlock: boolean; export let cookieBlocker: boolean; -export let choice: "eg" | "pw" = Math.random() < 0.5 ? "eg" : "pw"; +// export let choice: "eg" | "pw" = Math.random() < 0.5 ? "eg" : "pw"; +export const choice: "eg" | "pw" = "eg"; -console.log("AB choice: " + choice); +// console.log("AB choice: " + choice); -const adChoiceForce = window.localStorage.getItem("adChoiceForce"); -if (adChoiceForce === "eg") { - choice = "eg"; - console.log("AB choice forced: " + choice); -} else if (adChoiceForce === "pw") { - choice = "pw"; - console.log("AB choice forced: " + choice); -} +// const adChoiceForce = window.localStorage.getItem("adChoiceForce"); +// if (adChoiceForce === "eg") { +// choice = "eg"; +// console.log("AB choice forced: " + choice); +// } else if (adChoiceForce === "pw") { +// choice = "pw"; +// console.log("AB choice forced: " + choice); +// } export function init(): void { if (choice === "eg") { diff --git a/frontend/src/ts/elements/psa.ts b/frontend/src/ts/elements/psa.ts index 4f1bb5cc5..7309597fe 100644 --- a/frontend/src/ts/elements/psa.ts +++ b/frontend/src/ts/elements/psa.ts @@ -3,7 +3,6 @@ import { isLocalhost, secondsToString } from "../utils/misc"; import * as Notifications from "./notifications"; import format from "date-fns/format"; import * as Alerts from "./alerts"; -import { choice } from "../controllers/ad-controller"; function clearMemory(): void { window.localStorage.setItem("confirmedPSAs", JSON.stringify([])); @@ -20,7 +19,7 @@ function setMemory(id: string): void { } async function getLatest(): Promise { - const response = await Ape.psas.get(choice); + const response = await Ape.psas.get(); if (response.status === 500) { if (isLocalhost()) { Notifications.addBanner(