# tracking-wallet

> Tracking wallet ======================== ## v5.5.1 - add the properties in camelCase to the events, keeping the old ones.

Latest version **5.5.3** (published 2022-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install tracking-wallet
pnpm add tracking-wallet
yarn add tracking-wallet
bun add tracking-wallet
```

## 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 | 5.5.3 |
| Published | 2022-04-08 |
| First published | 2018-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 121 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | coverwallet-dev |

## Links

- npm: https://www.npmjs.com/package/tracking-wallet
- Repository: https://github.com/coverwallet/tracking-wallet
- Homepage: https://github.com/coverwallet/tracking-wallet#readme
- Issues: https://github.com/coverwallet/tracking-wallet/issues
- npm.io page: https://npm.io/package/tracking-wallet

## Dependencies (2)

- [js-cookie](https://npm.io/package/js-cookie.md) ^2.2.1
- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.21

## Recent versions

- 5.5.3 (latest) — 2022-04-08
- 5.5.2 — 2022-03-25
- 5.5.2-rc.0 — 2022-03-23
- 3.6.0 — 2022-03-23
- 5.5.1 — 2022-02-28
- 5.5.0 — 2022-02-28
- 5.5.0-rc.0 — 2022-02-24
- 5.4.0 — 2022-02-04
- 5.4.1-rc.0 — 2022-02-04
- 5.3.6 — 2021-12-07
- 5.3.5 — 2021-12-06
- 5.3.4 — 2021-12-03
- 5.3.3 — 2021-10-19
- 5.3.3-rc.0 — 2021-10-19
- 5.3.2 — 2021-10-15
- … 27 more at https://npm.io/package/tracking-wallet/versions

## README

Tracking wallet
========================
## v5.5.1
- add the properties in camelCase to the events, keeping the old ones.

## v5.4.0
- added dynamic props to page method under TrackingWallet class
- each page view / Loaded a page event now can be customized with new properties by passing in argument

## v5
- removes `jquery` from the bundle. This may introduce some breaking changes in the projects which still rely on it. 
- support for Server Side Rendering (only uses `window` if it's available)
- recovered agent identification functionality from v4
- `userRole` tracking property automatically detected from session + cookies for one of the following values:
    - insured
    - agent
    - CW Internal User
    - CW test
- Simplified `alias` logic. Only sends an alias call to Segment/Mixpanel if the `userRole` is NOT `agent`
- NO event is sent to Segment if the `userRole` is `CW Test` (internal automated tests)

Migrate from v4 to v5
--------------
- `extractDataForm` method deprecated. JQuery is removed from the library, tracking-wallet is no longer in charge of gathering the data from hidden inputs: each host project will provide the data for the event methods in their own way.
- `init` method deprecated and with it, the `skipPageViewEvents` option is deprecated too. Tracking-wallet will no longer emit a custom event for page views. For a page view event just use `trackingWallet.page()`. To start using the library, it is enough just to instantiate it:
```js
import TrackingWallet from "tracking-wallet"
const tracker = new TrackingWallet();
tracker.track();
```
- `preserveUTMTags` method deprecated. Just remove it's calls.
- `getUserId` method deprecated. Use the following instead:
```js
const id = trackingWallet.getAnalyticsUser().userId;
```


Migrate from v3 to v4
--------------
- Remove calls to `timeEvent` method. The calls can stay but will fall back to an additional track event for the same event name ended in `_TIME_EVENT`
- Remove all references to `window.mixpanel` from the project

## Usage
ES6 Module:
```javascript
import TrackingWallet from 'tracking-wallet';

const trackingWallet = new TrackingWallet();
trackingWallet.identify('userId', { /* User traits */ });
trackingWallet.track({ /* Event */}, { /* Event options */});
```
or use the bundled version:

```html
<script type="text/javascript" src="<path>/dist/tracking-wallet.min.js"></script>
<script type="text/javascript">
    var trackingWallet = new window.TrackingWallet();
    trackingWallet.identify('userId', { /* User traits */ });
    trackingWallet.track({ /* Event */}, { /* Event options */});
</script>
```

- If `window.analytics` object is not ready before event is sent this event is stored in the queue and gets processed as soon as `window.analytics` is ready.

## Developement
You don't need to run a separate script to bundle the minified version of the code. It will be done automatically and added to your commit when you make changes in the `src` directory.

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