Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4f6ccb6
Add support for feature-specific config payloads
pavkam Jan 10, 2025
7b3a4af
Refactor flag evaluation logic and update SDK version.
pavkam Jan 13, 2025
70f2393
Add feature configuration support and enhance fallback features
pavkam Jan 13, 2025
2e30def
Merge remote-tracking branch 'origin/main' into buc-3198-extend-the-w…
pavkam Jan 13, 2025
d2e9de6
Bump version to 0.4.0
pavkam Jan 13, 2025
5af7fd3
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 22, 2025
340fc9c
feat(browser-sdk): add format script, improve README formatting, and …
pavkam Jan 22, 2025
a6c6678
feat(browser-sdk): update feature configuration handling and improve …
pavkam Jan 22, 2025
f5f250e
feat(react-sdk): enhance feature handling in useFeature hook
pavkam Jan 22, 2025
66f661a
feat(browser-sdk, react-sdk, openfeature-browser-sdk): enhance featur…
pavkam Jan 22, 2025
38975e1
feat(openfeature-browser-provider): revert changes to openfeature ada…
pavkam Jan 24, 2025
f2ba839
chore(browser-sdk, react-sdk): Respond to comments
pavkam Jan 24, 2025
f1383e6
fix(browser-sdk): update README to reflect changes in feature configu…
pavkam Jan 24, 2025
cd276f4
feat(openfeature-browser-provider): update browser-sdk dependency and…
pavkam Jan 24, 2025
5f02bb8
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 27, 2025
295f05d
fix(browser-sdk): update feature remote config type definition
pavkam Jan 27, 2025
0dd5757
chore(react-sdk): remove unused import from index.tsx
pavkam Jan 27, 2025
7173423
feat(browser-sdk): enhance fallback feature configuration handling
pavkam Jan 27, 2025
862df25
test(browser-sdk): remove .only from features test
pavkam Jan 27, 2025
2326f86
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 27, 2025
e22475b
test(browser-sdk): update feature test expectations
pavkam Jan 27, 2025
b6d7b9a
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 27, 2025
31ee556
refactor(react-sdk): simplify feature config retrieval
pavkam Jan 27, 2025
2e62475
refactor(react-sdk): simplify feature config access and reduce payload
pavkam Jan 27, 2025
4b09505
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 27, 2025
13f5f2f
test(browser-sdk): improve test coverage and error handling for flag …
pavkam Jan 27, 2025
2f74252
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 28, 2025
fa735d8
docs(browser-sdk,react-sdk): clarify remote config documentation
pavkam Jan 28, 2025
a6eb451
Merge remote-tracking branch 'origin/main' into buc-3198-extend-the-w…
pavkam Jan 28, 2025
ff3e85a
Merge remote-tracking branch 'origin/buc-3198-extend-the-web-sdks-to-…
pavkam Jan 28, 2025
f986feb
feat(browser-sdk): export FallbackFeatureOverride type
pavkam Jan 28, 2025
7c6c47c
chore(release): bump browser-sdk and react-sdk to 3.0.0-alpha.1
pavkam Jan 28, 2025
352a462
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 28, 2025
931cf96
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 28, 2025
a75eec8
chore(deps): upgrade @bucketco/browser-sdk to 3.0.0-alpha.0
pavkam Jan 28, 2025
9d89947
chore(deps): upgrade @bucketco/browser-sdk to 3.0.0-alpha.1
pavkam Jan 28, 2025
9faa1ac
Merge branch 'main' into buc-3250-extend-the-openfeature-web-sdk-to-u…
pavkam Jan 29, 2025
91a7ae0
chore(deps): upgrade @bucketco/browser-sdk to 3.0.0-alpha.1
pavkam Jan 29, 2025
aee63d5
fix(node-sdk): update Feature type to support undefined config
pavkam Feb 4, 2025
2029f91
chore(node-sdk): bump version to 1.6.0-alpha.3
pavkam Feb 5, 2025
f7f90c1
Merge branch 'node-1.6.alpha' into buc-3250-extend-the-openfeature-we…
pavkam Feb 5, 2025
dc93f93
feat(openfeature-browser-provider): Enhance provider with improved fe…
pavkam Feb 8, 2025
02779b3
feat(openfeature-node-provider): Enhance provider with improved featu…
pavkam Feb 8, 2025
4dd9dea
fix(openfeature-providers): Ensure consistent type conversion for use…
pavkam Feb 8, 2025
6ba06c7
Merge branch 'browser-react-3.0.alpha' into buc-3250-extend-the-openf…
pavkam Feb 8, 2025
98734c4
fix(openfeature-providers): Improve type checking and payload resolut…
pavkam Feb 8, 2025
5fd4280
feat(node-sdk): improved flag events (#307)
pavkam Feb 12, 2025
8c79bd8
Merge branch 'main' into node-1.6.alpha
pavkam Feb 12, 2025
0277ffa
Merge branch 'node-1.6.alpha' into buc-3250-extend-the-openfeature-no…
pavkam Feb 12, 2025
7b4afbb
chore: revert browser changes
pavkam Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,46 @@ typedoc
# We can fix this by removing the number at the end of the anchor.
SEDCOMMAND='s/globals.md#(.*)-[0-9]+/globals.md#\1/g'

FILES=$(find dist/docs/@bucketco -name "globals.md")
# Find all markdown files including globals.md
FILES=$(find dist/docs/@bucketco -name "*.md")

echo "Processing markdown files..."
for file in $FILES
do
sed -r $SEDCOMMAND $file > $file.fixed
rm $file
mv $file.fixed $file
echo "Processing $file..."

# Fix anchor links in globals.md files
if [[ "$file" == *"globals.md" ]]; then
sed -r "$SEDCOMMAND" "$file" > "$file.fixed"
rm "$file"
mv "$file.fixed" "$file"
fi

# Create a temporary file for processing
tmp_file="${file}.tmp"

# Process NOTE blocks - handle multi-line
awk '
BEGIN { in_block = 0; content = ""; }
/^> \[!NOTE\]/ { in_block = 1; print "{% hint style=\"info\" %}"; next; }
/^> \[!TIP\]/ { in_block = 1; print "{% hint style=\"success\" %}"; next; }
/^> \[!IMPORTANT\]/ { in_block = 1; print "{% hint style=\"warning\" %}"; next; }
/^> \[!WARNING\]/ { in_block = 1; print "{% hint style=\"warning\" %}"; next; }
/^> \[!CAUTION\]/ { in_block = 1; print "{% hint style=\"danger\" %}"; next; }
in_block && /^>/ {
content = content substr($0, 3) "\n";
next;
}
in_block && !/^>/ {
printf "%s", content;
print "{% endhint %}";
in_block = 0;
content = "";
}
!in_block { print; }
' "$file" > "$tmp_file"

mv "$tmp_file" "$file"
done

echo "Processing complete!"
47 changes: 4 additions & 43 deletions packages/browser-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,19 @@ const bucketClient = new BucketClient({ publishableKey, user, company });

await bucketClient.initialize();

const {
isEnabled,
config: { payload: question },
track,
requestFeedback,
} = bucketClient.getFeature("huddle");
const { isEnabled, track, requestFeedback } = bucketClient.getFeature("huddle");

if (isEnabled) {
// Show feature. When retrieving `isEnabled` the client automatically
// show feature. When retrieving `isEnabled` the client automatically
// sends a "check" event for the "huddle" feature which is shown in the
// Bucket UI.

// On usage, call `track` to let Bucket know that a user interacted with the feature
track();

// The `payload` is a user-supplied JSON in Bucket that is dynamically picked
// out depending on the user/company.
const question = payload?.question ?? "Tell us what you think of Huddles";

// Use `requestFeedback` to create "Send feedback" buttons easily for specific
// features. This is not related to `track` and you can call them individually.
requestFeedback({ title: question });
requestFeedback({ title: "Tell us what you think of Huddles" });
}

// `track` just calls `bucketClient.track(<featureKey>)` to send an event using the same feature key
Expand Down Expand Up @@ -147,7 +138,6 @@ To retrieve features along with their targeting information, use `getFeature(key
const huddle = bucketClient.getFeature("huddle");
// {
// isEnabled: true,
// config: { key: "zoom", payload: { ... } },
// track: () => Promise<Response>
// requestFeedback: (options: RequestFeedbackData) => void
// }
Expand All @@ -161,7 +151,6 @@ const features = bucketClient.getFeatures();
// huddle: {
// isEnabled: true,
// targetingVersion: 42,
// config: ...
// }
// }
```
Expand All @@ -170,35 +159,7 @@ const features = bucketClient.getFeatures();
by down-stream clients, like the React SDK.

Note that accessing `isEnabled` on the object returned by `getFeatures` does not automatically
generate a `check` event, contrary to the `isEnabled` property on the object returned by `getFeature`.

### Remote config

Similar to `isEnabled`, each feature has a `config` property. This configuration is managed from within Bucket.
It is managed similar to the way access to features is managed, but instead of the binary `isEnabled` you can have
multiple configuration values which are given to different user/companies.

```ts
const features = bucketClient.getFeatures();
// {
// huddle: {
// isEnabled: true,
// targetingVersion: 42,
// config: {
// key: "gpt-3.5",
// payload: { maxTokens: 10000, model: "gpt-3.5-beta1" }
// }
// }
// }
```

The `key` is always present while the `payload` is a optional JSON value for arbitrary configuration needs.
If feature has no configuration or, no configuration value was matched against the context, the `config` object
will be empty, thus, `key` will be `undefined`. Make sure to check against this case when trying to use the
configuration in your application.

Just as `isEnabled`, accessing `config` on the object returned by `getFeatures` does not automatically
generate a `check` event, contrary to the `config` property on the object returned by `getFeature`.
generate a `check` event, contrary to the `isEnabled` property on the object return from `getFeature`.

### Tracking feature usage

Expand Down
43 changes: 43 additions & 0 deletions packages/browser-sdk/example/browser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bucket feature management</title>
</head>
<body>
<span id="loading">Loading...</span>

<script>
const urlParams = new URLSearchParams(window.location.search);
const publishableKey = urlParams.get("publishableKey");
const featureKey = urlParams.get("featureKey") ?? "huddles";
</script>
<div id="start-huddle" style="display: none">
<button onClick="bucket.track(featureKey)">Click me</button>
<button onClick="bucket.requestFeedback({featureKey})">
Give feedback!
</button>
</div>

<script src="../dist/bucket-browser-sdk.umd.js"></script>
<script>
const bucket = new BucketBrowserSDK.BucketClient({
publishableKey,
user: { id: "42" },
company: { id: "1" },
});

bucket.initialize().then(() => {
console.log("Bucket initialized");
document.getElementById("loading").style.display = "none";
const { isEnabled, track, requestFeedback } =
bucket.getFeature("huddles");
if (isEnabled) {
// show the start-huddle button
document.getElementById("start-huddle").style.display = "block";
}
});
</script>
</body>
</html>
51 changes: 0 additions & 51 deletions packages/browser-sdk/example/typescript/app.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/browser-sdk/example/typescript/index.html

This file was deleted.

71 changes: 0 additions & 71 deletions packages/browser-sdk/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion packages/browser-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bucketco/browser-sdk",
"version": "3.0.0-alpha.2",
"version": "2.5.2",
"packageManager": "yarn@4.1.1",
"license": "MIT",
"repository": {
Expand Down
Loading
Loading