# Koala SDK

## Running locally

To start watching files for changes and run a dev server:

```bash
yarn dev
```

You can now navigate to `127.0.0.1:8080` to test your changes. If you wish to automatically open the html page:

```bash
yarn dev --open
```

## Versions of the SDK

We push two versions of the sdk: the standalone version and the umd version. The "standalone" version is what typically ships to browsers via CDN and self-installs. The umd version attaches to the window object as well (in a browser environment) but must be manually initialized:

```js
// if the umd script is loaded from CDN directly in the browser, you can find the module attached to `window.KoalaSDK`:
window.KoalaSDK.load({ project })

// or if you import it when using a bundler:
import * as KoalaSDK from '@getkoala/browser'
KoalaSDK.load({ project })
```

To test the standalone version, you can `yarn dev` and navigate to `http://localhost:8080/standalone.html?project=cardi-b`

## Deploying the Koala SDK

### Requirements

- `aws` cli - follow the [latest docs](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) on installing the AWS CLI. Once installed, make sure you've configured it via `aws configure`.

The Koala SDK is hosted on S3, and fronted by a Cloudflare Worker that acts as our CDN. To push a new version to S3:

```bash
yarn deploy
```

It will push the latest build into the `koala-sdk/latest` bucket, as well as an immutable bucket associated with the current git sha: e.g. `koala-sdk/e1b323d`
