ข้ามไปยังเนื้อหา

Targeting & Rollouts

ทุก 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 ทำงานอย่างไรตั้งแต่ต้นจนจบ
2Targeting Attributesการกำหนดและส่ง attribute ของผู้ใช้ให้ SDK
3Targeting Conditionsการกรองผู้ใช้ตามค่าของ attribute ใน rule
4Percentage Rolloutsการค่อย ๆ ปล่อย flag ให้ผู้ใช้ทีละเปอร์เซ็นต์
5Forced 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 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');
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');
GrowthBook มี rule สองตัวบน flag หนึ่ง: rule A (เจาะกลุ่มผู้ใช้ beta) และ rule B (rollout 50%) อยู่ด้านล่าง เมื่อผู้ใช้ beta เข้ามา rule ไหนจะถูกนำมาใช้?
GrowthBook คืนค่าอะไรเมื่อไม่มี rule ใดบน feature ที่ match กับผู้ใช้คนปัจจุบัน?
`gb.setAttributes(...)` ทำหน้าที่อะไร?