feat: invite codes

This commit is contained in:
2023-12-02 21:27:46 +00:00
parent 6f8e8eca0f
commit f26155ddd8
18 changed files with 5609 additions and 22 deletions

View File

@ -536,3 +536,29 @@ export function getCountry() {
export function trackEvent(event: string) {
window.plausible?.(event);
}
export function storeRefCode() {
const ref = getCurrentRefCode();
if (ref) {
window.localStorage.setItem("ref", ref);
}
}
export function getCurrentRefCode() {
if (window.location.search) {
const q = new URLSearchParams(window.location.search);
const ref = q.get("ref");
if (ref) {
return ref;
}
}
}
export function getRefCode() {
const r = window.localStorage.getItem("ref");
if (r) return r;
}
export function deleteRefCode() {
window.localStorage.removeItem("ref");
}