# Nonstop Javascript SDK

## Initialization

Initialize the Nonstop SDK on any pages of the website where you want to use it.

### Initialization

The initialize method takes an object with several configuration properties:

* `environment` - The SDK needs to know which Nonstop API Environment to use - this should be passed as the first parameter
* `platform` - The SDK needs to know which platform it is being run on - both for reporting to Nonstop and also for reporting to Amplitude. Valid values are `web`, `tizen` and `chromecast`.
* `cdnUrl` - The path to the directory where the Nonstop SDK JS files are hosted (see [Installation](Installation.md))

### Example

```javascript
    ready(function() {
        Nonstop.default.initialize({
            environment: 'prod',
            platform: 'web',
            cdnUrl: 'https://nonstop.azureedge.net/js-sdk/1.5.0/dist/'
        });
    });

    function ready(fn) {
        if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") {
            fn();
        } else {
            document.addEventListener('DOMContentLoaded', fn);
        }
    }
```

#### Environments

The Environments parameter controls which APIs the SDK will hit, and thus which Nonstop Admin and ShowMS Environment is tied to them. Developers should be conscious of this and match their Nonstop Environment to their ShowMS environment for the given build.

* **Dev**
  * Admin - https://dev.admin.nonstopapp.co/
  * Client API - https://dev.api.nonstopapp.co/swagger/index.html
  * ShowMS Web - http://dev.showms.freeform.go.com/
  * ShowMS Admin - http://dev.admin.freeform.showms.com/
  * ShowMS API - https://dev.api.showms.com/swagger/ui/index
* **Staging**
  * Admin - https://staging.admin.nonstopapp.co/
  * Client API - https://staging.api.nonstopapp.co/swagger/index.html
  * ShowMS Web - http://staging.showms.freeform.go.com/
  * ShowMS Admin - http://staging.admin.freeform.showms.com/
  * ShowMS API - https://staging.api.showms.com/swagger/ui/index
* **QA**
  * Admin - https://qa.admin.nonstopapp.co/
  * Client API - https://qa.api.nonstopapp.co/swagger/index.html
  * ShowMS Web - http://qa.showms.freeform.go.com/
  * ShowMS Admin - http://qa.admin.freeform.showms.com/
  * ShowMS API - https://qa.api.showms.com/swagger/ui/index
* **Production**
  * Admin - https://admin.nonstopapp.co/
  * Client API - https://api.nonstopapp.co/swagger/index.html
  * ShowMS Web - http://freeform.go.com/
  * ShowMS Admin - http://admin.showms.com/
  * ShowMS API - https://api.showms.com/swagger/ui/index

#### Reward Animations

Note: The Nonstop SDK will asynchronously preload reward animations on initialize for improved performance when they are required so you will see this network call on calling the initialize method. These are loaded once per tab instance and stored in Session Storage.