32 lines
667 B
TypeScript
32 lines
667 B
TypeScript
export function getTrackingCookiesForRedirect() {
|
|
const cookieObj = Object.fromEntries(
|
|
document.cookie.split("; ").map((c) => c.split("="))
|
|
);
|
|
|
|
const result = Object.entries(cookieObj).filter(([key]) => {
|
|
return (
|
|
[
|
|
"_fbc",
|
|
"_fbp",
|
|
"_ym_uid",
|
|
"_ym_d",
|
|
"_ym_isad",
|
|
"_ym_visorc",
|
|
"yandexuid",
|
|
"ymex",
|
|
].includes(key) ||
|
|
key.startsWith("_ga") ||
|
|
key.startsWith("_gid")
|
|
);
|
|
});
|
|
|
|
const queryString = result
|
|
.map(
|
|
([key, value]) =>
|
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
)
|
|
.join("&");
|
|
|
|
return queryString;
|
|
}
|