diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/flutter/sample.dart b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/flutter/SDK_V3/sample.dart similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/flutter/sample.dart rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/flutter/SDK_V3/sample.dart diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/flutter/SDK_V4/sample.dart b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/flutter/SDK_V4/sample.dart new file mode 100644 index 00000000..87164c04 --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/flutter/SDK_V4/sample.dart @@ -0,0 +1,18 @@ +import 'package:flagship/flagship.dart'; + +// Step 1 - Start the Flagship sdk with default configuration. +Flagship.start("_ENV_ID_", "_API_KEY_"); + +// Step 2 - Create visitor with context "isVip" : true +var visitor = Flagship.newVisitor(visitorId: "visitorId", hasConsented: true) + .withContext({"isVip": true}).build(); + +// Step 3 - Fetch flags + visitor.fetchFlags().whenComplete(() { + // Step 4 - Get Flag key + var flag = v.getFlag("displayVipFeature"); + // Step 5 - Read Flag value + var value = flag.value(false); + var value1 = v.getFlag("backgroundColor").value("red"); + var value1 = v.getFlag("backgroundSize").value(1); + }); \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/go/SDK_V2/sample.go b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/go/SDK_V2/sample.go similarity index 50% rename from cmd/feature-experimentation/analyze/code-samples/flagship/go/SDK_V2/sample.go rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/go/SDK_V2/sample.go index 7304cd24..02c33a05 100644 --- a/cmd/feature-experimentation/analyze/code-samples/flagship/go/SDK_V2/sample.go +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/go/SDK_V2/sample.go @@ -2,10 +2,10 @@ package SDK_V2 func main() { // Using the Decision API (default) - fsClient, _ := flagship.Start("environmentID", "apiKey") + fsClient, err := flagship.Start(environmentID, apiKey) // Using the Bucketing mode - fsClient, _ = flagship.Start("environmentID", "apiKey", client.WithBucketing()) + fsClient, err := flagship.Start(environmentID, apiKey, client.WithBucketing()) // Create visitor context context := map[string]interface{}{ @@ -14,11 +14,11 @@ func main() { "name": "visitor", } // Create a visitor - fsVisitor, _ := fsClient.NewVisitor("visitor_id", context) + fsVisitor, err := fsClient.NewVisitor("visitor_id", context) // Update a single key fsVisitor.UpdateContextKey("vipUser", true) - fsVisitor.UpdateContextKey("age", 30) + fsVisitor.UpdateContextLey("age", 30) // Update the whole context newContext := map[string]interface{}{ @@ -32,9 +32,6 @@ func main() { discountName, err := fsVisitor.GetModificationNumber("btnSize", 13, true) discountName, err := fsVisitor.GetModificationBool("showBtn", false, true) - // these flags will be analyzed using the custom-regex file example-regex.json - // try the command: flagship analyze flag list --custom-regex-json ./cmd/analyze/flag/example-regex.json --directory ./cmd/analyze/code-samples/abtasty-cli/go/ - flagValue, _ := example.BoolVariation("my-boolean-flag", false) - flagValue1, _ := example.StringVariation("my-string-flag", "defaltVal") - flagValue2, _ := example.Float64Variation("my-numbers-flag", 13.6) + // If there is not error (and if there is, your value will still be set to defaut), you can use your modification value in your business logic + discountValue := getDiscountFromDB(discountName) } diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V2/sample.m b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V2/sample.m similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V2/sample.m rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V2/sample.m diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V2/sample.swift b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V2/sample.swift similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V2/sample.swift rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V2/sample.swift diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V3/sample.m b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V3/sample.m similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V3/sample.m rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V3/sample.m diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V3/sample.swift b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V3/sample.swift similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/ios/SDK_V3/sample.swift rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V3/sample.swift diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V4/sample.swift b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V4/sample.swift new file mode 100644 index 00000000..69efc3fa --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V4/sample.swift @@ -0,0 +1,30 @@ +import Flagship + +// Step 1 - Start the Flagship sdk with default configuration. +Flagship.sharedInstance.start(envId: "_ENV_ID_", apiKey: "_API_KEY_") + +// Step 2 - Create visitor with context "isVip" : true +let visitor = Flagship.sharedInstance.newVisitor(visitorId: "visitorId", hasConsented: true) + .withContext(context: ["isVip": true]) + .build() + +// Step 3 - Fetch flags +visitor.fetchFlags { + + // Fetch completed + + // Step 4 - Get Flag key + let flag = visitor.getFlag(key: "btnColor") + + // Step 5 - Read Flag value + let value = flag.value(defaultValue: "red") + + let value = visitor.getFlag(key: "displayVipFeature").value(defaultValue: false) + + // Step 4 - Get Flag key + let flag2 = visitor.getFlag(key: "vipFeature") + + // Step 5 - Read Flag value + let value = flag2.value(defaultValue: 16) + +} \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V2/sample.java b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V2/sample.java similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V2/sample.java rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V2/sample.java diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V2/sample.kt b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V2/sample.kt similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V2/sample.kt rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V2/sample.kt diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V3/sample.java b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V3/sample.java similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V3/sample.java rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V3/sample.java diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V3/sample.kt b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V3/sample.kt similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/java/SDK_V3/sample.kt rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V3/sample.kt diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V4/sample.kt b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V4/sample.kt new file mode 100644 index 00000000..fe74255f --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V4/sample.kt @@ -0,0 +1,9 @@ +val flagRank = visitor.getFlag("btnColor"); +val flagRankValue = flagRank.value("red"); + +val flagRankValue2 = visitor.getFlag("backgroundSize").value(1); + +val flagRank1 = visitor.getFlag("showBackground"); +val flagRankValue = flagRank1.value(true); + +val flagRank12 = visitor.getFlag("showBackground1"); \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V2/sample.js b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V2/sample.js similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V2/sample.js rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V2/sample.js diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V2/sample.ts b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V2/sample.ts similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V2/sample.ts rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V2/sample.ts diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V3/sample.js b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V3/sample.js similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V3/sample.js rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V3/sample.js diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V3/sample.ts b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V3/sample.ts similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/js/SDK_V3/sample.ts rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V3/sample.ts diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.js b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.js new file mode 100644 index 00000000..67dfb302 --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.js @@ -0,0 +1,75 @@ +//start demo +// Usage: node demo/index.js +const express = require("express"); +const { Flagship, HitType, EventCategory } = require("@flagship.io/js-sdk"); + +const app = express(); +app.use(express.json()); + +const visitorId = "visitor-id"; + +// Step 1: Start the Flagship SDK by providing the environment ID and API key +Flagship.start("", "", { + fetchNow: false, +}); + +// Endpoint to get an item +app.get("/item", async (req, res) => { + + // Step 2: Create a new visitor with a visitor ID and consent status + const visitor = Flagship.newVisitor({ + visitorId, + hasConsented: true, + context: { + fs_is_vip: true, + }, + }); + + // Step 3: Fetch the flags for the visitor + await visitor.fetchFlags(); + + // fe:flag:fs_disable_coupon, string + const fsDisableCoupon = visitor.getFlag("fs_disable_coupon"); + + // Step 4: Get the values of the flags for the visitor + const fsEnableDiscount = visitor.getFlag("fs_enable_discount"); + const fsAddToCartBtnColor = visitor.getFlag("fs_add_to_cart_btn_color"); + + const fsEnableDiscountValue = fsEnableDiscount.getValue(false); + const fsAddToCartBtnColorValue = fsAddToCartBtnColor.getValue("blue"); + + res.json({ + item: { + name: "Flagship T-shirt", + price: 20, + }, + fsEnableDiscount: fsEnableDiscountValue, + fsAddToCartBtnColor: fsAddToCartBtnColorValue, + }); +}); + +// Endpoint to add an item to the cart +app.post("/add-to-cart", async (req, res) => { + + const visitor = Flagship.newVisitor({ + visitorId, + hasConsented: true + }); + + // Step 5: Send a hit to track an action + visitor.sendHit({ + type: HitType.EVENT, + category: EventCategory.ACTION_TRACKING, + action: "add-to-cart-clicked", + }); + + res.json(null); +}); + +const port = 3000; + +app.listen(port, () => { + console.log(`Server running on port ${port}`); +}); + +//end demo \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.ts b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.ts new file mode 100644 index 00000000..76a54daf --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.ts @@ -0,0 +1,29 @@ +import { Flagship } from "@flagship.io/js-sdk"; + +Flagship.start("your_env_id", "your_api_key"); + +const visitor = Flagship.newVisitor({ + visitorId: "your_visitor_id", + context: { isVip: true }, +}); + +visitor.fetchFlags(); + +const variableKey = visitor.getFlag("flagKey"); +const boxSizeFlagDefaultValue = variableKey.getValue("flagDefaultValue"); + +const variableKey1: any = visitor.getFlag("flagKey1"); + +const variableKey3: any = visitor.getFlag("flagKey3"); +const boxSizeFlagDefaultValue1 = variableKey3.getValue(16); + +const variableKey4: any = visitor.getFlag("flagKey4"); + +const variableKey5: any = visitor.getFlag("flagKey5").getValue(false); + +// fe:flag: flagKey6, true +const variable6: any = visitor.getFlag("flagKey6"); + +visitor.getFlag("flagKey5").getValue(false); + +visitor.getFlagValue("FlagKey5", false); diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V1/sample.cs b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V1/sample.cs similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V1/sample.cs rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V1/sample.cs diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V1/sample.fs b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V1/sample.fs similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V1/sample.fs rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V1/sample.fs diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V1/sample.vb b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V1/sample.vb similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V1/sample.vb rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V1/sample.vb diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V3/sample.cs b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V3/sample.cs similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V3/sample.cs rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V3/sample.cs diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V3/sample.fs b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V3/sample.fs similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V3/sample.fs rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V3/sample.fs diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V3/sample.vb b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V3/sample.vb similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/net/SDK_V3/sample.vb rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V3/sample.vb diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.cs b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.cs new file mode 100644 index 00000000..a9eaaecc --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.cs @@ -0,0 +1,24 @@ +using Flagship.Main; + +//Step 2: Create a visitor +var visitor = Fs.NewVisitor("", true) + .SetContext(new Dictionary(){["isVip"] = true}) + .Build(); + + +//Step 3: Fetch flag from the Flagship platform +await visitor.FetchFlags(); + +/* Step 4: Retrieves a flag named "displayVipFeature", + */ +var flag = visitor.GetFlag("showBtn"); + +//Step 5: get the flag value and if the flag does not exist, it returns the default value "false" +var flagValue = flag.GetValue(false); + +var flag_ = visitor.GetFlag("btnSize").GetValue(15); + +var flag1 = visitor.GetFlag("btnColor"); +var flagValue = flag1.GetValue("red"); + +Console.WriteLine($"Flag {flagValue}"); \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.fs b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.fs new file mode 100644 index 00000000..d0df0065 --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.fs @@ -0,0 +1,20 @@ +open System.Collections.Generic +open Flagship + +let client = FlagshipBuilder.Start("ENV_ID","API_KEY"); + +let context = new Dictionary(); +context.Add("key", "value"); + +let visitor = client.NewVisitor("visitor_id", context); + +visitor.FetchFlags(); + +let btnColorFlag = visitor.GetFlag("btnColor"); +let btnColorFlagValue = btnColorFlag.GetValue('red'); + +let flag = visitor.GetFlag("btnSize"); +let flagValue = flag.GetValue(13); + +let showBtnFlag = visitor.GetFlag("showBtn"); +let showBtnFlagValue = showBtnFlag.GetValue(true); \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/php/SDK_V1/sample.php b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V1/sample.php similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/php/SDK_V1/sample.php rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V1/sample.php diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/php/SDK_V2/sample.php b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V2/sample.php similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/php/SDK_V2/sample.php rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V2/sample.php diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/php/SDK_V3/sample.php b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V3/sample.php similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/php/SDK_V3/sample.php rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V3/sample.php diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V4/sample.php b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V4/sample.php new file mode 100644 index 00000000..05b87bd3 --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V4/sample.php @@ -0,0 +1,25 @@ +use Flagship\Flagship; + +// Step 1: start the SDK +Flagship::start("", ""); + + //Step 2: Create a visitor + $visitor = Flagship::newVisitor("", true) + ->setContext(["isVip" => true]) + ->build(); + + //Step 3: Fetch flag from the Flagship platform + $visitor->fetchFlags(); + + //Step 4: Retrieves a flag named "displayVipFeature" + $flag = $visitor->getFlag("displayVipFeature"); + + //Step 5: Returns the flag value ,or if the flag does not exist, it returns the default value "false" + echo "flag value:". $flag->getValue(false); + + $flag1 = $visitor->getFlag("vipFeatureSize")->getValue(15); + + $flag1 = $visitor->getFlag("vipFeatureColor")->getValue("red"); + + //Step 6: Batch all the collected hits and send them + Flagship::close(); \ No newline at end of file diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/python/SDK_V2/sample.py b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/python/SDK_V2/sample.py similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/python/SDK_V2/sample.py rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/python/SDK_V2/sample.py diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/react/SDK_V2/sample.jsx b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V2/sample.jsx similarity index 100% rename from cmd/feature-experimentation/analyze/code-samples/flagship/react/SDK_V2/sample.jsx rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V2/sample.jsx diff --git a/cmd/feature-experimentation/analyze/code-samples/flagship/react/SDK_V3/sample.jsx b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V3/sample.jsx similarity index 91% rename from cmd/feature-experimentation/analyze/code-samples/flagship/react/SDK_V3/sample.jsx rename to cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V3/sample.jsx index f9859160..41634710 100644 --- a/cmd/feature-experimentation/analyze/code-samples/flagship/react/SDK_V3/sample.jsx +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V3/sample.jsx @@ -4,7 +4,7 @@ import {useFsFlag} from "@flagship.io/react-sdk"; export const MyReactComponent = () => { const backgroundColorFlag = useFsFlag("backgroundColor", "green") const btnColorFlag = useFsFlag("btnColor", "red") - const backgroundSize = useFsFlag("backgroundColor", 16) + const backgroundSize = useFsFlag("backgroundSize", 16) const showBtn = useFsFlag("showBtn", true) return ( diff --git a/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V4/sample.jsx b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V4/sample.jsx new file mode 100644 index 00000000..7ac18b7e --- /dev/null +++ b/cmd/feature-experimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V4/sample.jsx @@ -0,0 +1,28 @@ +import React from "react"; +import { useFsFlag } from "@flagship.io/react-sdk"; + +export const MyReactComponent = () => { + ///Step 2: Retrieves a flag named "backgroundColor" + const flag = useFsFlag("backgroundColor") + + //Step 3: Returns the value of the flag or if the flag does not exist, it returns the default value "green" + const flagValue = flag.getValue("green") + + + const flag_ = useFsFlag("btnSize").getValue(16) + + const flag1 = useFsFlag("showBtn") + const flagValue_ = flag1.getValue(true) + + return ( + + ); +}; \ No newline at end of file diff --git a/go.mod b/go.mod index 5bd01806..a0f93b39 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/d5/tengo/v2 v2.13.0 - github.com/flagship-io/codebase-analyzer v0.8.0 + github.com/flagship-io/codebase-analyzer v0.9.3 github.com/kyokomi/emoji/v2 v2.2.12 github.com/rodaine/table v1.1.0 github.com/sirupsen/logrus v1.9.0 diff --git a/go.sum b/go.sum index e5cd6d1c..8b4465c9 100644 --- a/go.sum +++ b/go.sum @@ -61,8 +61,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= -github.com/flagship-io/codebase-analyzer v0.8.0 h1:/aTkBm3W2c1XGnwIde2DtrGYUJbIVYkm5+TXgQDmYro= -github.com/flagship-io/codebase-analyzer v0.8.0/go.mod h1:6+KRy0IPSkhxBv9CZf6Xjh+AfJFjJxWH6zGuT8a6x0c= +github.com/flagship-io/codebase-analyzer v0.9.3 h1:c7SQ8Zu5dO5e8JxymggTRTGGnCGaoQLbme1k2oGJbJI= +github.com/flagship-io/codebase-analyzer v0.9.3/go.mod h1:6+KRy0IPSkhxBv9CZf6Xjh+AfJFjJxWH6zGuT8a6x0c= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=