Targeting & Rollouts
GrowthBook ประเมินค่าของ Flag อย่างไร
หัวข้อที่มีชื่อว่า “GrowthBook ประเมินค่าของ Flag อย่างไร”ทุก Feature ใน GrowthBook จะมีชุดของ Rules แยกตาม environment (เช่น dev, production) เมื่อ SDK เรียก isOn() หรือ getFeatureValue() GrowthBook จะไล่ดู rule เหล่านั้นจากบนลงล่าง rule แรกที่ targeting condition ตรงกับ attribute ของผู้ใช้คนปัจจุบันจะถูกนำมาใช้ และคืนค่าของ rule นั้น หากไม่มี rule ใด match เลย ระบบจะคืน default value ของ Feature นั้น
โมเดลแบบบนลงล่างและเลือกตัวที่ match ตัวแรกนี้ให้คุณควบคุมได้อย่างแม่นยำ คุณสามารถบังคับค่าให้ผู้ใช้ภายในองค์กร แล้วทำ percentage rollout ให้ผู้ใช้ที่เหลือ โดยที่ rule ทั้งสองจะไม่รบกวนกัน
บทเรียนในโมดูลนี้
หัวข้อที่มีชื่อว่า “บทเรียนในโมดูลนี้”| # | บทเรียน | สิ่งที่คุณจะได้เรียนรู้ |
|---|---|---|
| 1 | ภาพรวม (หน้านี้) | การประเมิน rule ทำงานอย่างไรตั้งแต่ต้นจนจบ |
| 2 | Targeting Attributes | การกำหนดและส่ง attribute ของผู้ใช้ให้ SDK |
| 3 | Targeting Conditions | การกรองผู้ใช้ตามค่าของ attribute ใน rule |
| 4 | Percentage Rollouts | การค่อย ๆ ปล่อย flag ให้ผู้ใช้ทีละเปอร์เซ็นต์ |
| 5 | Forced Values & Saved Groups | การบังคับค่าเฉพาะและการนำกลุ่มผู้ใช้กลับมาใช้ซ้ำ |
import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({ apiHost: 'https://cdn.growthbook.io', clientKey: 'sdk-YOUR_DEV_KEY',});
await gb.init({ timeout: 2000 });
// Tell GrowthBook who the current user isgb.setAttributes({ id: 'user-123', country: 'TH', plan: 'pro',});
// Boolean flagconst showBanner = gb.isOn('promo-banner');
// Flag with a typed defaultconst checkoutVersion = gb.getFeatureValue('checkout-version', 'v1');import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'sdk-YOUR_DEV_KEY',
});
await gb.init({ timeout: 2000 });
// Tell GrowthBook who the current user is
gb.setAttributes({
id: 'user-123',
country: 'TH',
plan: 'pro',
});
// Boolean flag
const showBanner = gb.isOn('promo-banner');
// Flag with a typed default
const checkoutVersion = gb.getFeatureValue('checkout-version', 'v1');