Skip to content

Commit

Permalink
add loops ab test id
Browse files Browse the repository at this point in the history
  • Loading branch information
elie222 committed Dec 24, 2024
1 parent bc9a14b commit 2111ba8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/loops/src/loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export async function createContact(
}> {
const loops = getLoopsClient();
if (!loops) return { success: false };
const resp = await loops.createContact(email, firstName ? { firstName } : {});
// so we can run a/b tests with 2-6 groups easily
const abTestId = getRandomInt(60);
const resp = await loops.createContact(
email,
firstName ? { firstName, abTestId } : { abTestId },
);
return resp;
}

Expand Down Expand Up @@ -62,3 +67,7 @@ export async function cancelledPremium(
});
return resp;
}

function getRandomInt(max: number) {
return Math.ceil(Math.random() * max);
}

1 comment on commit 2111ba8

@vercel
Copy link

@vercel vercel bot commented on 2111ba8 Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.