conversion: more robust fbp, fbc with header-based attempt

This commit is contained in:
Elijah Duffy
2025-12-18 22:06:23 -08:00
parent 764da5db2e
commit 0e1a449cb6
2 changed files with 19 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import type { Cookies } from '@sveltejs/kit';
import log from 'loglevel';
export type EnsureFbcOptions = {
@@ -79,10 +80,19 @@ export function ensureFbc(options: EnsureFbcOptions = {}) {
}
/**
* Helper to read both _fbp and _fbc for your CAPI payload.
* Helper to read both _fbp and _fbc for your CAPI payload from browser cookies.
*/
export function getFbpFbc(): { fbp?: string; fbc?: string } {
const fbp = getCookie('_fbp');
const fbc = getCookie('_fbc');
return { fbp, fbc };
}
/**
* Helper to read both _fbp and _fbc for your CAPI payload from cookies object.
*/
export function getFbpFbcFromCookies(cookies: Cookies): { fbp?: string; fbc?: string } {
const fbp = cookies.get('_fbp') || undefined;
const fbc = cookies.get('_fbc') || undefined;
return { fbp, fbc };
}