Feature Flags
Endpoint pubblico per valutare flag con sticky bucketing: lo stesso utente riceve sempre la stessa decisione.
JavaScript / fetch
js
const res = await fetch(
"https://project--YOUR_PROJECT.lovable.app/api/public/flags/YOUR_PROJECT_ID",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
userId: "user-123", // sticky bucketing key
flags: ["new_checkout", "dark_mode_v2"],
attributes: { plan: "pro", country: "IT" }
})
}
);
const { flags } = await res.json();
// => { new_checkout: true, dark_mode_v2: false }cURL
bash
curl -X POST \
https://project--YOUR_PROJECT.lovable.app/api/public/flags/YOUR_PROJECT_ID \
-H "Content-Type: application/json" \
-d '{"userId":"user-123","flags":["new_checkout"]}'Performance
L'endpoint risponde tipicamente in <50ms. Per scenari ad alta frequenza, considera l'SDK Node con caching locale.
Attributi richiesti
userId— chiave di bucketing (stringa, obbligatorio)flags— array di slug di flag da valutareattributes— proprietà per regole di targeting (opzionale)