-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished support for JavaScript, Java and Python code examples, inclu…
…ding substituting into the sample code the application, experiment and/or page names, as well as the correct protocol (HTTP or HTTPS) and host name (including port) of the server, where appearing in the sample code.
- Loading branch information
Showing
27 changed files
with
483 additions
and
213 deletions.
There are no files selected for viewing
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
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
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
49 changes: 49 additions & 0 deletions
49
modules/ui/app/resources/samplecode/javascript/action.js.html
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,49 @@ | ||
<div class="displaySourceCode"> | ||
<p> | ||
This example is taken from the Hello World example in the contrib folder of Wasabi. That example uses the | ||
wasabi.js library that is available from the same server as this Admin UI. In order to use the library, | ||
you would add the following to your index.html (or equivalent initial load page): | ||
</p> | ||
<pre> | ||
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> | ||
<script src='{{webServingUrl}}scripts/wasabi.js'></script> | ||
</pre> | ||
<p> | ||
Of course, you can choose whatever version of jQuery works for you and your Wasabi server may be running on | ||
a different host or port. | ||
</p> | ||
<p> | ||
In order to record an action for a user for an experiment using the library, you would make a call like this: | ||
</p> | ||
<pre> | ||
// Set up properties that will be the same on all Wasabi calls. | ||
WASABI.setOptions({ | ||
'applicationName': '{{experiment.applicationName}}', | ||
'experimentName': '{{experiment.label}}', | ||
'protocol': '{{serverProtocol}}', | ||
'host': '{{serverHostAndPort}}' | ||
}); | ||
|
||
// Check Wasabi to record an action for this user. | ||
WASABI.postAction( | ||
'MyEventName', | ||
'{\\\"myPayloadKey1\\\":\\\"payloadKey1Value\\\"}', | ||
{ | ||
'userID': 'UserName' | ||
} | ||
).then( | ||
function(response) { | ||
console.log('postAction: success'); | ||
// Note: there is no response from posting an Action. | ||
}, | ||
function(error) { | ||
console.log('postAction: error'); | ||
} | ||
); | ||
</pre> | ||
<p> | ||
In order to see and run locally a working example using JavaScript, AngularJS and node, go to:<br/> | ||
<a href="https://github.com/intuit/wasabi/tree/develop/contrib/hello-world" target="_blank">https://github.com/intuit/wasabi/tree/develop/contrib/hello-world</a> | ||
</p> | ||
</div> | ||
|
49 changes: 49 additions & 0 deletions
49
modules/ui/app/resources/samplecode/javascript/assignment.js.html
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,49 @@ | ||
<div class="displaySourceCode"> | ||
<p> | ||
This example is taken from the Hello World example in the contrib folder of Wasabi. That example uses the | ||
wasabi.js library that is available from the same server as this Admin UI. In order to use the library, | ||
you would add the following to your index.html (or equivalent initial load page): | ||
</p> | ||
<pre> | ||
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> | ||
<script src='{{webServingUrl}}scripts/wasabi.js'></script> | ||
</pre> | ||
<p> | ||
Of course, you can choose whatever version of jQuery works for you and your Wasabi server may be running on | ||
a different host or port. | ||
</p> | ||
<p> | ||
In order to retrieve an assignment for an experiment using the library, you would make a call like this: | ||
</p> | ||
<pre> | ||
// Set up properties that will be the same on all Wasabi calls. | ||
WASABI.setOptions({ | ||
'applicationName': '{{experiment.applicationName}}', | ||
'experimentName': '{{experiment.label}}', | ||
'protocol': '{{serverProtocol}}', | ||
'host': '{{serverHostAndPort}}' | ||
}); | ||
|
||
// Check Wasabi to see if this user should be in the test and which bucket. | ||
WASABI.getAssignment({ | ||
'userID': 'UserName' | ||
}).then( | ||
function(response) { | ||
console.log('getAssignment: success'); | ||
console.log(JSON.stringify(response)); | ||
// This object will include the assignment made and the status, which might tell you the experiment | ||
// has not been started, etc. | ||
// Note that if the experiment doesn't exist or hasn't been started, response.assignment is undefined, which is OK. | ||
console.log(response.assignment); | ||
}, | ||
function(error) { | ||
console.log('getAssignment: error'); | ||
} | ||
); | ||
</pre> | ||
<p> | ||
In order to see and run locally a working example using JavaScript, AngularJS and node, go to:<br/> | ||
<a href="https://github.com/intuit/wasabi/tree/develop/contrib/hello-world" target="_blank">https://github.com/intuit/wasabi/tree/develop/contrib/hello-world</a> | ||
</p> | ||
</div> | ||
|
57 changes: 57 additions & 0 deletions
57
modules/ui/app/resources/samplecode/javascript/assignment_with_seg.js.html
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,57 @@ | ||
<div class="displaySourceCode"> | ||
<p> | ||
This example is taken from the Hello World example in the contrib folder of Wasabi. That example uses the | ||
wasabi.js library that is available from the same server as this Admin UI. In order to use the library, | ||
you would add the following to your index.html (or equivalent initial load page): | ||
</p> | ||
<pre> | ||
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> | ||
<script src='{{webServingUrl}}scripts/wasabi.js'></script> | ||
</pre> | ||
<p> | ||
Of course, you can choose whatever version of jQuery works for you and your Wasabi server may be running on | ||
a different host or port. | ||
</p> | ||
<p> | ||
In order to retrieve an assignment for an experiment passing | ||
a profile for use in evaluating a segmentation rule using the library, you would make a call like this: | ||
</p> | ||
<pre> | ||
// Set up properties that will be the same on all Wasabi calls. | ||
WASABI.setOptions({ | ||
'applicationName': '{{experiment.applicationName}}', | ||
'experimentName': '{{experiment.label}}', | ||
'protocol': '{{serverProtocol}}', | ||
'host': '{{serverHostAndPort}}' | ||
}); | ||
|
||
// Check Wasabi to see if this user should be in the test and which bucket. | ||
WASABI.getAssignmentWithSegmentation( | ||
'{\ | ||
"profile": {\ | ||
"platform": "mac"\ | ||
}\ | ||
}', | ||
{ | ||
'userID': 'UserName' | ||
} | ||
).then( | ||
function(response) { | ||
console.log('getAssignmentWithSegmentation: success'); | ||
console.log(JSON.stringify(response)); | ||
// This object will include the assignment made and the status, which might tell you the experiment | ||
// has not been started, etc. | ||
// Note that if the experiment doesn't exist or hasn't been started, response.assignment is undefined, which is OK. | ||
console.log(response.assignment); | ||
}, | ||
function(error) { | ||
console.log('getAssignmentWithSegmentation: error'); | ||
} | ||
); | ||
</pre> | ||
<p> | ||
In order to see and run locally a working example using JavaScript, AngularJS and node, go to:<br/> | ||
<a href="https://github.com/intuit/wasabi/tree/develop/contrib/hello-world" target="_blank">https://github.com/intuit/wasabi/tree/develop/contrib/hello-world</a> | ||
</p> | ||
</div> | ||
|
Oops, something went wrong.