# datalabs-trx-react

> Internal Tracking React Helper

Latest version **1.0.1** (published 2022-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install datalabs-trx-react
pnpm add datalabs-trx-react
yarn add datalabs-trx-react
bun add datalabs-trx-react
```

## 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.1 |
| Published | 2022-01-06 |
| First published | 2021-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jethro Guzman |
| Maintainers | jethro-smdatalabs, rap.sepnio |
| Keywords | react-native |

## Links

- npm: https://www.npmjs.com/package/datalabs-trx-react
- Repository: https://github.com/smic-datalabs/datalabs-trx-react
- Homepage: https://github.com/smic-datalabs/datalabs-trx-react#readme
- Issues: https://github.com/smic-datalabs/datalabs-trx-react/issues
- npm.io page: https://npm.io/package/datalabs-trx-react

## Recent versions

- 1.0.1 (latest) — 2022-01-06
- 1.0.0 — 2021-12-31

## README

# datalabs-trx-react

## Getting started

`$ npm install datalabs-trx-react --save`

### Mostly automatic installation

`$ react-native link datalabs-trx-react`

## Quick Usage
```javascript
import TrxReact from 'datalabs-trx-react';

const trx = new TrxReact();
trx.init('https://trx-sample-domain.com/', 'TRX-SAMPLEUNIQUECODE');

// tag this page
trx.tag("pageType", "sample-page");  // tag this page as a sample page

// add multiple tags for different type of information as needed
trx.tag('userID', '100');

// send event to tracker with simple dataset
trx.send('loaded', {pagename: 'sample'});

```


## Methods
### `init`
Initialize the tracker by setting the tracking service URL and the site/application identity.

Usage: `init(<trackerURL>, <siteIdentifier>)`

#### Parameters:
1. url - URL of tracker service. URL is removed from public package for privacy/security concerns.
1. site identifier - A unique site/application identifier that is provided by tracking service admins.

<hr/>

### `tag`
Tags the user or page being viewed. This tag will persist throughout the lifetime of the class instance. Using the same tagName multiple times overwrites the old values assigned to that tag. 

Usage: `tag(<tagName>, <tagValue>)`



#### Parameters

1. tagName - Any key you want to tracker to keep track of. This could be page/view related information or user related information. Examples: userID, sessionID, pageType, pageID.
1. tagValue - Any value for the tag names specified.

<hr/>

### `send`
Sends the data to the tracking service. Should be triggered by events.

Usage: `send(<eventName>, <eventDetails>)`

#### Parameters
1. eventName - name of the event that triggered this send function. Examples: pageView, cartCheckedOut, addedWishlist
1. eventDetails - javascript object/hash map that provides contextual information  about the event that triggered this function. Examples: `{pageID: 199, pageURL: 'someURL'}` or `{transactionID: 839}`



## Development
```shell
# login to user account that has access to the npm module
npm login

# publish the package
npm publish
```

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