conversion: more robust fbp, fbc with header-based attempt
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user