You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
I think that’s a valid point, and it would be better to keep @guardian/libs dependency-free. Any idea where it might live instead?
I’ve been thinking recently about creating a better abstraction around this anyways, and we could possibly move the core-vitals dependencies back to the consumers.
Just so I get it outside my brain, I was thinking something like below, where the init function returns a method you can call to register sending the metrics at page unload:
/** List of collecting functions to run at page unload */constcollectors=newMap<string,()=>void>();/** Initialiser logger */constinit=({ label, collector }: {label: string;collector: ()=>void;})=>({/** Call this function to schedule collection at page unload */schedule: (consent: boolean)=>{if(!consent){console.warn(`No consent for “${label}” logging`);return;}if(collectors.has(label)){console.warn(`Overriding “${label}” logging`);}collectors.set(label,collector);},/** Call this function to stop collection at page unload */remove: ()=>{console.warn(`Removing “${label}” logging`);collectors.delete(label);},});
main reason being it turns the google package into a peerDep of
libs
regardless of what you're using from it.i'm getting warnings about it being missing when using
libs
in another node module.i don't want to add it to keep that warning quiet.
maybe anything that has a peerDep should not be included in
libs
?any thoughts?
cc @mxdvl @guardian/client-side-infra
The text was updated successfully, but these errors were encountered: