Title: Quick Start Locale: en URL: https://sensorswave.com/en/docs/feature-gates/quick-start/ Description: Create and use your first Feature Gate This guide will help you quickly create and use your first Feature Gate. Through this example, you'll learn the complete workflow for using Feature Gates. ## Prerequisites Before getting started, make sure you have: - Completed [SDK Integration](../data-integration/client-sdks/javascript.mdx) - Permission to create Feature Gates - Understanding of basic [User Identification](../data-integration/user-identification.mdx) concepts ## Example Scenario Suppose you are developing a new recommendation algorithm for an e-commerce application and want to first open it to internal test users, then gradually expand after verifying stability. ## Step 1: Create a Feature Gate ### 1. Navigate to the Feature Gates Management Page 1. Log in to the Sensors Wave console 2. Click **Feature Gates** in the left menu 3. Click the **Create Feature Gate** button in the upper right corner ### 2. Configure Basic Information Fill in the following information: - **Gate Name**: `new_recommendation_algorithm` - **Display Name**: New Recommendation Algorithm - **Description**: Deep learning-based product recommendation algorithm to improve recommendation accuracy - **Gate Type**: Temporary Gate (will be removed once the feature is stable) - **Default Value**: Disabled (false) > **Tip**: Use lowercase letters and underscores for gate names for easier use in code. ### 3. Configure Targeting Rules Create the first rule to enable the gate for internal test users: 1. Click **Add Rule** 2. Rule name: Internal Test Users 3. Condition settings: - User Property `is_internal_user` **equals** `true` 4. Return value: Enabled (true) 5. Click **Save** ### 4. Save and Launch 1. Verify the configuration is correct 2. Click **Save**, then click **Launch** 3. The Feature Gate takes effect immediately ## Step 2: Use in Code Check the Feature Gate status in your application code: ### JavaScript Example ```javascript // Check if the new recommendation algorithm is enabled const isNewAlgorithmEnabled = await sensorswave.getGateValue( 'new_recommendation_algorithm' ); if (isNewAlgorithmEnabled) { // Use the new recommendation algorithm const recommendations = await getRecommendationsV2(userId); } else { // Use the old recommendation algorithm const recommendations = await getRecommendationsV1(userId); } // Display recommended products displayRecommendations(recommendations); ``` ### Go Example ```go // Check if the new recommendation algorithm is enabled isNewAlgorithmEnabled := client.GetGateValue( "new_recommendation_algorithm", userId, false, // Default value ) var recommendations []Product if isNewAlgorithmEnabled { // Use the new recommendation algorithm recommendations = getRecommendationsV2(userId) } else { // Use the old recommendation algorithm recommendations = getRecommendationsV1(userId) } // Display recommended products displayRecommendations(recommendations) ``` ### Android Example ```kotlin // Check if the new recommendation algorithm is enabled val isNewAlgorithmEnabled = sensorswave.getGateValue( "new_recommendation_algorithm", false // Default value ) val recommendations = if (isNewAlgorithmEnabled) { // Use the new recommendation algorithm getRecommendationsV2(userId) } else { // Use the old recommendation algorithm getRecommendationsV1(userId) } // Display recommended products displayRecommendations(recommendations) ``` ### iOS Example ```swift // Check if the new recommendation algorithm is enabled let isNewAlgorithmEnabled = sensorswave.getGateValue( "new_recommendation_algorithm", defaultValue: false ) let recommendations: [Product] if isNewAlgorithmEnabled { // Use the new recommendation algorithm recommendations = getRecommendationsV2(userId: userId) } else { // Use the old recommendation algorithm recommendations = getRecommendationsV1(userId: userId) } // Display recommended products displayRecommendations(recommendations) ``` ## Step 3: Verify Results ### 1. Test the Feature Gate Log in to the application with an internal test account: 1. Ensure the test account has the `is_internal_user` property set to `true` 2. Refresh the application and check if the new recommendation algorithm is being used 3. Verify that the feature is working properly ### 2. View Usage Data In the Sensors Wave console: 1. Go to the Feature Gate detail page 2. Click the **Usage Analytics** tab 3. Review: - Number of covered users - Number of checks - Rule hit statistics ## Step 4: Expand Rollout Scope After verifying stability, gradually expand the rollout scope: ### 1. Add a 1% Rollout Rule 1. Go to the Feature Gate edit page 2. Click **Add Rule** 3. Rule name: 1% Rollout Users 4. Condition settings: - Percentage rollout: 1% 5. Return value: Enabled (true) 6. Drag the rule to position it after "Internal Test Users" 7. Click **Save**, then click **Launch** ### 2. Monitor Key Metrics Create monitoring charts in [Segmentation](../analytics/event-analysis.mdx): - Click-through rate of the new recommendation algorithm - Conversion rate changes - System performance Metrics - Error rate ### 3. Gradually Expand Scope If Metrics are normal, continue expanding the rollout: - 1% → 10% → 50% → 100% - Observe for 1-2 days after each expansion ### 4. Full Release Once the rollout reaches 100% and is running stably: 1. Remove the rollout rules 2. Change the default value to **Enabled (true)** 3. The feature takes effect for all users ## Step 5: Clean Up the Feature Gate After the feature has been running stably for some time, you can clean up the Feature Gate: ### 1. Remove Gate Checks from Code ```javascript // Remove the Feature Gate check and use the new algorithm directly const recommendations = await getRecommendationsV2(userId); displayRecommendations(recommendations); ``` ### 2. Archive the Feature Gate 1. Go to the Feature Gate detail page in the console 2. Click **Archive** 3. The Feature Gate no longer takes effect, but historical records are preserved ### 3. Remove Old Code ```javascript // You can safely delete the old recommendation algorithm code // const recommendations = await getRecommendationsV1(userId); ``` ## Demo [TODO: Add screenshots] 1. Create Feature Gate interface 2. Configure Targeting Rules 3. Usage analytics panel 4. Gradual rollout process ## Notes ### Gate Naming - Use clear, descriptive names for easy understanding - Use lowercase letters and underscores (snake_case) - Avoid overly short names (e.g., `flag1`, `test`) ### Default Value Settings - For new features, the default value is typically set to **Disabled**; enable gradually through rules - When issues occur in production, the SDK uses the default value as a Fallback ### Rule Priority - Rules are matched from top to bottom - Once a rule is matched, its value is returned without continuing further matching - Place special rules (e.g., internal testing) at the top and general rules (e.g., percentage rollout) at the bottom ### Performance Considerations - The SDK caches Feature Gate configurations locally, avoiding server requests for every check - After configuration changes, the SDK updates the cache within 1 second - It's recommended to preload Feature Gate configurations at application startup ## Common Issues ### Feature Gate Not Taking Effect? Check the following: 1. Confirm that the Feature Gate has been saved and released 2. Verify that the user meets the rule conditions 3. Check that the SDK is properly initialized 4. Check that the network connection is working ### How to Ensure Testing Doesn't Affect Production Data? 1. Use different Projects or environments 2. Distinguish test users from production users via User Properties 3. Filter out test users during data analysis ### Will Feature Gates Affect Performance? - The SDK uses local caching with minimal performance impact - It's recommended to keep the total number of Feature Gates under 100 - Regularly clean up Feature Gates that are no longer in use ## Next Steps Now that you've completed creating and using your first Feature Gate, you can: 1. **[Core Concepts](core-concepts.mdx)**: Dive deeper into how Feature Gates work 2. **[Create and Configure](create-and-configure.mdx)**: Learn more configuration options --- **Last updated**: January 28, 2026