-
Notifications
You must be signed in to change notification settings - Fork 83
docs(README): List supported environments, add badges, and more #136
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
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
83724bb
docs(README): Update
spencerwilson-optimizely 260b780
theoiaw
spencerwilson-optimizely d4266fd
Add npm workaround
spencerwilson-optimizely a183ea9
Use complete sentences
spencerwilson-optimizely a4c16a1
Fix travis yml link, hopefully
spencerwilson-optimizely e50ba3a
Use 0.10.44
spencerwilson-optimizely b083826
Add Coveralls badge
spencerwilson-optimizely 818aaa1
Give a better link to Travis encrypted env var docs
spencerwilson-optimizely c866753
Fix badge link in root readme
spencerwilson-optimizely 2aff7da
Use right package name
spencerwilson-optimizely d3bb631
Add blurb to root readme
spencerwilson-optimizely 724d1d5
Clarify Lerna usage
spencerwilson-optimizely 09b5afd
Add license badge
spencerwilson-optimizely 67cfbf6
refactor(scripts): Use Karma CLI rather than grunt
spencerwilson-optimizely 22a353b
s/run/start/
spencerwilson-optimizely 17d396f
Merge branch 'sw/drop-grunt' into sw/readme
spencerwilson-optimizely 23dc790
feat(ci): Only run xbrowser-tests with the latest Node.js release
spencerwilson-optimizely 3049c92
Merge branch 'sw/xbrowser-once' into sw/readme
spencerwilson-optimizely e98687e
Try adding braces
spencerwilson-optimizely fe7a196
heck the logging
spencerwilson-optimizely 8467cb2
Merge branch 'sw/xbrowser-once' into sw/readme
spencerwilson-optimizely fae9d22
Update readme
spencerwilson-optimizely b4d981c
Drop note that says node < 4 is unsupported
spencerwilson-optimizely 268c76e
beyond...
spencerwilson-optimizely 2a6cd9a
Au revoir, 0.10.44
spencerwilson-optimizely 0aa5b7c
s/url/landing page/
spencerwilson-optimizely a72af3f
Merge branch 'master' into sw/readme
spencerwilson-optimizely a626342
Options first, like a sane person
spencerwilson-optimizely 115e025
Merge remote-tracking branch 'origin/master' into sw/readme
spencerwilson-optimizely 7758b77
Merge remote-tracking branch 'origin/sw/readme' into sw/readme
spencerwilson-optimizely 40013e3
grammar around EOL date
spencerwilson-optimizely 8d95f8b
Delineate officially-support and other environments
spencerwilson-optimizely cedffb5
Merge branch 'master' into sw/readme
spencerwilson-optimizely 964a869
Add PWAs, WebViews, and hybrid mobile apps
spencerwilson-optimizely 7956534
Merge remote-tracking branch 'origin/sw/readme' into sw/readme
spencerwilson-optimizely File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,68 +1,69 @@ | ||
# Optimizely JavaScript SDK | ||
# JavaScript SDK for Optimizely X Full Stack | ||
[](https://www.npmjs.com/package/@optimizely/optimizely-sdk) | ||
[](https://www.npmjs.com/package/@optimizely/optimizely-sdk) | ||
[](https://travis-ci.org/optimizely/javascript-sdk) | ||
[](https://coveralls.io/github/optimizely/javascript-sdk) | ||
[](https://choosealicense.com/licenses/apache-2.0/) | ||
|
||
This repository houses the JavaScript SDK for Optimizely X Full Stack. | ||
|
||
Optimizely X Full Stack is A/B testing and feature management for product development teams. Experiment in any application. Make every feature on your roadmap an opportunity to learn. Learn more at the [landing page](https://www.optimizely.com/products/full-stack/), or see the [documentation](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=node). | ||
|
||
This directory contains the source code for the JavaScript SDK, which is usable in Node.js, browsers, and beyond. | ||
|
||
## Getting Started | ||
|
||
### Installing the SDK | ||
### Prerequisites | ||
|
||
Ensure the SDK supports all of the platforms you're targeting. In particular, the SDK targets any ES5-compliant JavaScript environment. We officially support: | ||
- Node.js >= 4.0.0. By extension, environments like AWS Lambda, Google Cloud Functions, and Auth0 Webtasks are supported as well. Older Node.js releases likely work too (try `npm test` to validate for yourself), but are not formally supported. | ||
- [Web browsers](https://caniuse.com/#feat=es5) | ||
|
||
Other environments likely are compatible, too, but note that we don't officially support them: | ||
- Progressive Web Apps, WebViews, and hybrid mobile apps like those built with React Native and Apache Cordova. | ||
- [Cloudflare Workers](https://developers.cloudflare.com/workers/) and [Fly](https://fly.io/), both of which are powered by recent releases of V8. | ||
- Anywhere else you can think of that might embed a JavaScript engine. The sky is the limit; experiment everywhere! 🚀 | ||
|
||
The SDK is available through [npm](https://npmjs.com/package/optimizely-sdk). To install: | ||
Once you've validated that the SDK supports the platforms you're targeting, fetch the package from [NPM](https://www.npmjs.com/package/@optimizely/optimizely-sdk). Using `npm`: | ||
|
||
``` | ||
npm install @optimizely/optimizely-sdk --save | ||
npm install --save @optimizely/optimizely-sdk | ||
``` | ||
|
||
Or to use in a non CommonJS fashion in the Browser: | ||
### Usage | ||
See the Optimizely X Full Stack [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK. | ||
|
||
1. Run `npm run build` | ||
2. Pull in `dist/optimizely.browser.umd.min.js` as a `<script>` | ||
3. Use as global variable `window.optimizelyClient` | ||
Regarding `EventDispatcher`s: In Node.js and browser environments, the default `EventDispatcher` is powered by the [`http/s`](https://nodejs.org/api/http.html) modules and by [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Browser_compatibility), respectively. In all other environments, you must supply your own `EventDispatcher`. | ||
|
||
### Migrating from 1.x.x | ||
|
||
This version represents a major version change and, as such, introduces some breaking changes: | ||
|
||
- The Node SDK is now combined with the JavaScript SDK so that we have one `optimizely-sdk` package that works across both server + browser environments. | ||
- The Node.js SDK is now combined with the JavaScript SDK. We now have just one package, `@optimizely/optimizely-sdk`, that works in many JavaScript environments. | ||
|
||
- We no longer support legacy Node versions (under 4.0). | ||
- We no longer support Node.js < 4.0.0, which collectively [reached end-of-life](https://github.com/nodejs/Release#end-of-life-releases) on 2016-12-31. | ||
|
||
- You will no longer be able to pass in `revenue` value as a stand-alone argument to the `track` call. Instead you will need to pass it as an entry in the [`eventTags`](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=javascript#event-tags). | ||
|
||
### Feature Management Access | ||
|
||
To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive. | ||
|
||
### Using the SDK | ||
See the Optimizely X Full Stack testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK. | ||
|
||
## Development | ||
### Feature Management access | ||
|
||
### Installing dependencies | ||
To access Feature Management in the Optimizely web application, please contact your Optimizely account executive. | ||
|
||
```npm install``` | ||
## Contributing | ||
This information is relevant only if you plan on contributing to the SDK itself. | ||
|
||
### Unit tests | ||
```sh | ||
# Prerequisite: Install dependencies. | ||
npm install | ||
|
||
You can run all unit tests with: | ||
``` | ||
# Run unit tests with mocha. | ||
npm test | ||
``` | ||
|
||
### Build distribution packages | ||
|
||
``` | ||
npm run build | ||
# Run unit tests in many browsers, currently via BrowserStack. | ||
# For this to work, the following environment variables must be set: | ||
# - BROWSER_STACK_USERNAME | ||
# - BROWSER_STACK_PASSWORD | ||
npm run test-xbrowser | ||
``` | ||
|
||
This command will build several distribution bundles under the `dist` directory: | ||
1. optimizely.browser.cjs.js - This is the main entry point for browser/client-side bundles | ||
2. optimizely.browser.umd.js - This is used when not packaging the optimizely-sdk with your own JS bundles. Instead you would load this script as a `<script>` tag and reference it via the global var `optimizelyClient` | ||
3. optimizely.node.js - This is the main entry point for Node apps | ||
|
||
The browser bundles also come with a minified / production-ready version. | ||
|
||
### Environment Variables | ||
|
||
The .yml of this project contains environment vairables for ```BROWSER_STACK_USERNAME``` and ```BROWSER_STACK_ACCESS_KEY```. | ||
[.travis.yml](/.travis.yml) contains the definitions for `BROWSER_STACK_USERNAME` and `BROWSER_STACK_ACCESS_KEY` used in CI. These values are Optimizely's BrowserStack credentials, encrypted with our Travis CI public key. These creds can be rotated by following [these docs](https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml). | ||
|
||
These variables, created in BrowserStack, are encrypted by the Travis CI public key. This is done directly with the Travis CI command line tools; for additional information see travis encrypt-file. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth mentioning hybrid mobile environments like Cordova (+ Phonegap) and others like React Native?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh good call, will add