Skip to content

[DW] Updated terms and SDK versions #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Example Demo Page to show Split JS Browser SDK
## Example Demo Page to show Split JavaScript SDK and JavaScript Browser SDK

These are two single pages that show how to set up the [JavaScript SDK](https://github.com/splitio/javascript-client) and the [JavaScript Browser SDK](https://github.com/splitio/javascript-browser-client). Follow the instructions below to make the changes needed using the information obtained from Split user interface.

This is a single page that shows how to set up the [JS Browser SDK](https://github.com/splitio/javascript-browser-client). Follow the instructions below to make the changes needed using the information obtained from Split UI.

### Get started

* Log in to Split Web console, go to the "Admin Tab", copy an API token of type "Client-side", and assign it to the `authorizationKey` config param in the `index.html`.
* [Create a Split](CREATESPLIT.md) and assign its name to the variable `featureName` in the `index.html`.
* Open `index.html` in your browser.
* Log in to the Split user interface, go to the "Admin Tab", copy an SDK key of type "Client-side", and assign it to the `authorizationKey` config param in either the `index-js-sdk.html` file or `index-js-browser-sdk.html` file, in order to try the JavaScript SDK or JavaScript Browser SDK respectively.
* [Create a feature flag](CREATE_FEATURE_FLAG.md) and assign its name to the variable `featureFlagName` in the HTML file.
* Open the HTML file in your browser.
18 changes: 8 additions & 10 deletions index.html → index-js-browser-sdk.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<meta charset="utf-8">
<title>Hello Split</title>
<!-- For other bundle versions check our documentation at https://help.split.io/hc/en-us/articles/360058730852 -->
<script src="https://cdn.split.io/sdk/split-browser-0.1.0.min.js"></script>
<script src="https://cdn.split.io/sdk/split-browser-0.9.4.min.js"></script>
</head>
<body>
<script>

// CHANGE THIS: Copy and paste the feature name from Split web console.
var featureName = "My_Feature_Name";
// Change this with the name of your feature flag, that you can find in the Split user interface
var featureFlagName = "my_feature_flag_name";

// Change this to represent your user or account id. (usually a dynamic value)
// Change this to represent your user or account id
var userKey = 'userId-1';

var div = document.createElement("div");
Expand All @@ -21,20 +21,18 @@

sdk = splitio.SplitFactory({
core: {
authorizationKey: '<CHANGE_ME>',
// Change this with your SDK key of type client-side
authorizationKey: '<YOUR_SDK_KEY>',
key: userKey
},
startup: {
readyTimeout: 2
}
});

var client = sdk.client();

function onReady() {
var treatment = client.getTreatment(featureName);
var treatment = client.getTreatment(featureFlagName);

console.log("Treatment for feature: " + featureName + " is: " + treatment);
console.log("Treatment for feature flag " + featureFlagName + " is " + treatment);
div.replaceChild(document.createTextNode(treatment), div.firstChild);
}

Expand Down
43 changes: 43 additions & 0 deletions index-js-sdk.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">
<title>Hello Split</title>
<script src="https://cdn.split.io/sdk/split-10.22.4.min.js"></script>
</head>
<body>
<script>

// Change this with the name of your feature flag, that you can find in the Split user interface
var featureFlagName = "my_feature_flag_name";

// Change this to represent your user or account id
var userKey = 'userId-1';

var div = document.createElement("div");
document.body.appendChild(div);
div.appendChild(document.createTextNode('clickMe'));

sdk = splitio({
core: {
// Change this with your SDK key of type client-side
authorizationKey: '<YOUR_SDK_KEY>',
key: userKey
}
});

var client = sdk.client();

function onReady() {
var treatment = client.getTreatment(featureFlagName);

console.log("Treatment for feature flag " + featureFlagName + " is " + treatment);
div.replaceChild(document.createTextNode(treatment), div.firstChild);
}

// Evaluate treatment when the SDK is ready to operate.
client.on(client.Event.SDK_READY, onReady);

</script>
</body>
</html>