# @spare.io-organization/sdk

> Tracking tool SDK for the Spare project

Latest version **1.0.2** (published 2022-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @spare.io-organization/sdk
pnpm add @spare.io-organization/sdk
yarn add @spare.io-organization/sdk
bun add @spare.io-organization/sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-06-24 |
| First published | 2022-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | DevimaSolutions |
| Maintainers | devimasolutions-owner, spare.io |
| Keywords | sdk, tracking |

## Links

- npm: https://www.npmjs.com/package/@spare.io-organization/sdk
- Repository: https://github.com/spare-io-organization/sdk
- Homepage: https://github.com/spare-io-organization/sdk/blob/main/README.md
- Issues: https://github.com/spare-io-organization/sdk/issues
- npm.io page: https://npm.io/package/@spare.io-organization/sdk

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-06-24
- 1.0.1 — 2022-06-24
- 0.1.6 — 2022-04-27
- 0.1.5 — 2022-04-26

## README

# @spare.io-organization/sdk
## Usage

### CDN

Put the script into the `head` section of your website:

```html
<script src="https://unpkg.com/@spare.io-organization/sdk@1.0.2/umd/sdk.min.js"></script>
```

The script must be included to all of the pages you specify when creating/editing products on the [spare.io](https://spare.io) platform to be able to track the number of visitors coming from a particular Ad.

To track purchases, call the following script when a purchase occurs:

```js
__spare.purchase({price: 99.99});
```

The price value (eg. `99.99`) is used to properly calculate revenue and other metrics displayed on the Ad Manager page.

You can find an example below that shows how it can look in HTML code of your page:
```html
<h1>Product title</h3>
<button onclick="__spare.purchase({price:99, orderId: 123})">Buy</button>
```

If you are using HTML forms for purchases you need to register `purchaseWithForm` in a head section of your app and specify `id` of the target form as shown below:

```html
<head>
  ...
  <script src="https://unpkg.com/@spare.io-organization/sdk@1.0.2/umd/sdk.min.js"></script>
  <script>
    __spare.purchaseWithForm("buy-form", {price: 1100, orderId: 123});
  </script>
</head>
<body>
  <form id="buy-form" action="/buy" method="post">
    ...
    <button type="submit">Buy</button>
  </form>
</body>
```

### ESM

There is also an option to use the package in ES modules format.

***The `__spare` instance will not be accessible globally from a `window` object when using ES modules***

Install package with npm or yarn

```sh
npm install @spare.io-organization/sdk
```

```ts
import {init} from "@spare.io-organization/sdk";

// Track info about purchase
spare.purchase({
  price: 99.99,
  orderId: 123
});
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

### Live updates with wml

You might need to debug your code if you are going to contribute to this package.

There is a [WML](https://github.com/wix/wml) tool that will allow you to  to perform live mapping of library
into the `node_modules` of the dependent project.

```
# You need to add a link only once
wml add ./ ~/dependent-project/node_modules/@spare.io-organization/sdk

wml start
```

## License

[MIT License](https://github.com/spare-io-organization/sdk/blob/main/LICENCE)

---
_Source: https://npm.io/package/@spare.io-organization/sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
