-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/update codebase analyzer v0.9.2 (#4)
* feat: update codebase-analyzer library * chore(GOMOD): Update go mod with new codebase analyzer version * chore(SDK example): Add SDK V4 examples
- Loading branch information
Showing
37 changed files
with
268 additions
and
13 deletions.
There are no files selected for viewing
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
...mentation/analyze/code-samples/abtasty-feature-experimentation/flutter/SDK_V4/sample.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
...erimentation/analyze/code-samples/abtasty-feature-experimentation/ios/SDK_V4/sample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
...xperimentation/analyze/code-samples/abtasty-feature-experimentation/java/SDK_V4/sample.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions
75
...-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<ENV_ID>", "<API_KEY>", { | ||
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 |
29 changes: 29 additions & 0 deletions
29
...-experimentation/analyze/code-samples/abtasty-feature-experimentation/js/SDK_V4/sample.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
...experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Flagship.Main; | ||
|
||
//Step 2: Create a visitor | ||
var visitor = Fs.NewVisitor("<VISITOR_ID>", true) | ||
.SetContext(new Dictionary<string, object>(){["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}"); |
20 changes: 20 additions & 0 deletions
20
...experimentation/analyze/code-samples/abtasty-feature-experimentation/net/SDK_V4/sample.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
open System.Collections.Generic | ||
open Flagship | ||
|
||
let client = FlagshipBuilder.Start("ENV_ID","API_KEY"); | ||
|
||
let context = new Dictionary<string, obj>(); | ||
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); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
...xperimentation/analyze/code-samples/abtasty-feature-experimentation/php/SDK_V4/sample.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use Flagship\Flagship; | ||
|
||
// Step 1: start the SDK | ||
Flagship::start("<ENV_ID>", "<API_KEY>"); | ||
|
||
//Step 2: Create a visitor | ||
$visitor = Flagship::newVisitor("<VISITOR_ID>", 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(); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...erimentation/analyze/code-samples/abtasty-feature-experimentation/react/SDK_V4/sample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<button | ||
style={{ | ||
height: "200px", | ||
width: "200px", | ||
backgroundColor: flagValue, | ||
}} | ||
> | ||
{"I'm a square with color=" + flagValue} | ||
</button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters