Skip to content
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

Improve readme and add contributing.md #25

Merged
merged 8 commits into from
Feb 8, 2021
Merged
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Contributing

## Testing

Unit tests are written in [Jest](https://jestjs.io/) and can be run with `npm test`.

Integration tests are written in [Mocha](https://mochajs.org/) and can be run from a local webserver using `npm run test:webserver`. They can also be run in [Chromium](https://www.chromium.org/), [WebKit](https://webkit.org/), and [Firefox](https://t.co/uiLRlFZnpI?amp=1) using `npm run test:playwright`.

## Code Quality

JavaScript/TypeScript code is:

- linted using [ESLint](https://eslint.org/), by running `npm run lint`, checking that all relevant files pass the linting rules
- formatted using [Prettier](https://prettier.io/), by running `npm run check-formatting`, checking that all relevant files are formatted correctly

## Assembly

The project is built using [webpack](https://webpack.js.org/). You can build the project using `npm run build`. This will create a [minified](https://en.wikipedia.org/wiki/Minification_(programming)) JS bundle at `dist/main.js`.
65 changes: 46 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Ably Asset Tracking SDK for JavaScript
# Ably Asset Tracking SDK for JavaScript

![.github/workflows/check.yml](https://github.com/ably/ably-asset-tracking-js/workflows/.github/workflows/check.yml/badge.svg)

### Overview
## Overview

Ably Asset Tracking SDKs provide an easy way to track multiple assets with realtime location updates powered by [Ably](https://ably.io/) realtime network.
Ably Asset Tracking SDKs provide an easy way to track multiple assets with realtime location updates powered by [Ably](https://ably.io/) realtime network and Mapbox [Navigation SDK](https://docs.mapbox.com/android/navigation/overview/) with location enhancement.

**Status:** this is a preview version of the SDK. That means that it contains a subset of the final SDK functionality, and the APIs are subject to change.
**Status:** this is a preview version of the SDK. That means that it contains a subset of the final SDK functionality, and the APIs are subject to change. The latest release of this SDK is available in the [Released section](https://github.com/ably/ably-asset-tracking-js/releases) of this repository.

Ably Asset Tracking is:

Expand All @@ -20,39 +20,66 @@ Ably Asset Tracking is:

This repository contains the Asset Subscribing SDK for Web.

## Example App

This repository also contains an example app that showcases how the Ably Asset Tracking SDK can be used:

- the [Asset Subscribing example app](examples/subscribing-example-app/)
## Usage

### Usage
Here is an example of how the SDK can be used:

```ts
import AblyAssetTracking from 'ably-asset-tracking';
import { AssetSubscriber, Accuracy } from 'ably-asset-tracking';

const ablyOptions = {
key: '',
clientId: '',
key: ABLY_API_KEY,
clientId: CLIENT_ID,
};

const trackingId: '';

// Define a callback to be notified when a location update is recieved.
const onLocationUpdate = (locationUpdate) => {
console.log(`Location update: ${locationUpdate}`);
console.log(`Location update recieved. Coordinates: ${locationUpdate.location.geometry.coordinates}`);
};

// Define a callback to be notified when the asset online status is updated.
const onStatusUpdate = (isOnline) => {
console.log(`Status update: Publisher is now ${isOnline ? 'online' : 'offline'}`);
};

const assetSubscriber = new AblyAssetTrackingAssetSubscriber({
// Request a specific resolution to be considered by the publisher.
const resolution = {
accuracy: Accuracy.High,
desiredInterval: 1000,
minimumDisplacement: 1,
};

// Initialise the subscriber.
const subscriber = new AssetSubscriber({
ablyOptions,
onLocationUpdate,
onStatusUpdate,
});

assetSubscriber.start(trackingId);
const trackingId = '<some application defined asset tracking identifier>';

(async () => {
// Start tracking an asset using its tracking identifier.
await subscriber.start(trackingId);

assetSubscriber.stop();
// Request a new resolution to be considered by the publisher.
await subscriber.sendChangeRequest({
accuracy: Accuracy.Low,
desiredInterval: 3000,
minimumDisplacement: 5,
});

// Stop tracking the asset.
await subscriber.stop();
})();
```

## Example App

This repository also contains an example app that showcases how the Ably Asset Tracking SDK can be used:

- the [Asset Subscribing example app](examples/subscribing-example-app/)

## Development

see [Contributing](CONTRIBUTING.md).