stopped ab test, removed ab test tracking code

This commit is contained in:
Miodec 2023-04-17 16:47:39 +02:00
parent efef1bce85
commit f053ca2c96
5 changed files with 14 additions and 40 deletions

View file

@ -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<MonkeyResponse> {
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<MonkeyResponse> {
const data = await PsaDAL.get();
return new MonkeyResponse("PSAs retrieved", data);
}

View file

@ -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 });
}

View file

@ -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,
},
});
}
}

View file

@ -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") {

View file

@ -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<MonkeyTypes.PSA[] | null> {
const response = await Ape.psas.get(choice);
const response = await Ape.psas.get();
if (response.status === 500) {
if (isLocalhost()) {
Notifications.addBanner(