You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Official [GrowthBook](https://www.growthbook.io/) SDK for Roku/BrightScript applications. Add feature flags and A/B testing to your Roku channels with a simple, lightweight SDK.
|`decryptionKey`| string | Decrypt encrypted feature payloads (Roku OS 9.2+)|
622
625
|`attributes`| object | User attributes for targeting (e.g., `{id: "user-123", premium: true}`) |
623
626
|`trackingCallback`| function | Callback fired when user is placed in an experiment |
624
627
|`onFeatureUsage`| function | Callback fired on every feature evaluation |
628
+
|`stickyBucketService`| object | Sticky bucket storage service (in-memory or registry-based) |
625
629
|`enableDevMode`| boolean | Enable verbose logging for debugging |
626
630
627
631
### Core Methods
@@ -667,6 +671,28 @@ gb.setAttributes({
667
671
})
668
672
```
669
673
674
+
#### `refreshFeatures() as boolean`
675
+
676
+
Re-fetch features from the GrowthBook API. Useful for long-running apps.
677
+
678
+
```brightscript
679
+
if gb.refreshFeatures()
680
+
print "Features refreshed"
681
+
end if
682
+
```
683
+
684
+
#### `registerTrackingPlugin(plugin as object)`
685
+
686
+
Register a tracking plugin to receive experiment and feature usage events.
687
+
688
+
```brightscript
689
+
plugin = GrowthBookTrackingPlugin({
690
+
ingestorHost: "https://analytics.example.com",
691
+
clientKey: "sdk_YOUR_KEY"
692
+
})
693
+
gb.registerTrackingPlugin(plugin)
694
+
```
695
+
670
696
#### `evalFeature(featureKey as string) as object`
671
697
672
698
Get detailed feature evaluation result.
@@ -681,16 +707,71 @@ print result.ruleId ' ID of the matching rule
681
707
682
708
### Advanced Targeting
683
709
684
-
The SDK version 1.3.1+ supports all GrowthBook advanced targeting rules:
710
+
The SDK v2.0.0 supports all GrowthBook advanced targeting rules:
685
711
686
712
-**Filters**: Complex user segmentation using hash-based filtering.
687
-
-**Ranges (Intervals)**: Precise traffic control for experiments and rollouts (v1.1.0+).
713
+
-**Ranges (Intervals)**: Precise traffic control for experiments and rollouts.
688
714
-**Namespaces**: Mutually exclusive experiments to prevent overlap.
689
715
-**Prerequisites**: Dependent feature flags (flag A requires flag B).
690
716
-**Forced Variations**: Global variation overrides for testing.
717
+
-**Sticky Bucketing**: Persistent variation assignments across sessions.
691
718
692
719
These are handled automatically by the SDK based on your GrowthBook configuration.
693
720
721
+
### Encrypted Features
722
+
723
+
Decrypt encrypted feature payloads from the GrowthBook API. Requires Roku OS 9.2+.
724
+
725
+
```brightscript
726
+
gb = GrowthBook({
727
+
clientKey: "sdk_YOUR_KEY",
728
+
decryptionKey: "your-base64-decryption-key",
729
+
attributes: { id: "user-123" }
730
+
})
731
+
gb.init() ' Encrypted features are decrypted automatically
732
+
```
733
+
734
+
### Sticky Bucketing
735
+
736
+
Persist experiment assignments so users always see the same variation, even across sessions or after attribute changes.
737
+
738
+
```brightscript
739
+
' In-memory (for testing or single-session use)
740
+
sbs = GrowthBookInMemoryStickyBucketService()
741
+
742
+
' Registry-based (persists across app restarts)
743
+
sbs = GrowthBookRegistryStickyBucketService()
744
+
745
+
gb = GrowthBook({
746
+
clientKey: "sdk_YOUR_KEY",
747
+
attributes: { id: "user-123" },
748
+
stickyBucketService: sbs
749
+
})
750
+
gb.init()
751
+
```
752
+
753
+
### Tracking Plugins
754
+
755
+
Register plugins to receive experiment and feature usage events. The built-in `GrowthBookTrackingPlugin` sends batched events to a configurable HTTP endpoint.
756
+
757
+
```brightscript
758
+
plugin = GrowthBookTrackingPlugin({
759
+
ingestorHost: "https://analytics.example.com",
760
+
clientKey: "sdk_YOUR_KEY",
761
+
batchSize: 10
762
+
})
763
+
764
+
gb = GrowthBook({
765
+
clientKey: "sdk_YOUR_KEY",
766
+
attributes: { id: "user-123" }
767
+
})
768
+
gb.init()
769
+
gb.registerTrackingPlugin(plugin)
770
+
771
+
' Events are batched and sent automatically
772
+
if gb.isOn("new-feature") then doSomething()
773
+
```
774
+
694
775
## Examples
695
776
696
777
See the `examples/` directory for complete working examples:
@@ -769,8 +850,8 @@ Minimum Roku OS: 9.0+
769
850
770
851
- No Server-Sent Events (SSE) streaming support (Roku limitation)
771
852
- No Visual Editor experiments (SceneGraph only)
772
-
-AES decryption requires`roEVPCipher` component (Roku OS 9.2+)
773
-
- Network requests are asynchronous only
853
+
-Encrypted features require`roEVPCipher` component (Roku OS 9.2+)
854
+
- Network requests are synchronous (no background polling)
0 commit comments