# react-native-topmind-sdk

> react-native sdk for Topmind

Latest version **1.0.12** (published 2021-07-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-topmind-sdk
pnpm add react-native-topmind-sdk
yarn add react-native-topmind-sdk
bun add react-native-topmind-sdk
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2021-07-30 |
| First published | 2019-08-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kirill Gudkov |
| Maintainers | talenttech |
| Keywords | react-native, topmind |

## Links

- npm: https://www.npmjs.com/package/react-native-topmind-sdk
- Repository: https://github.com/severgroup-tt/topmind-react-native
- Homepage: https://github.com/severgroup-tt/topmind-react-native#readme
- Issues: https://github.com/severgroup-tt/topmind-react-native/issues
- npm.io page: https://npm.io/package/react-native-topmind-sdk

## Recent versions

- 1.0.12 (latest) — 2021-07-30
- 1.0.11 — 2020-04-01
- 1.0.10 — 2019-10-21
- 1.0.9 — 2019-10-21
- 1.0.8 — 2019-08-19
- 1.0.7 — 2019-08-19
- 1.0.6 — 2019-08-08
- 1.0.5 — 2019-08-08
- 1.0.4 — 2019-08-01
- 1.0.3 — 2019-08-01
- 1.0.2 — 2019-08-01
- 1.0.1 — 2019-08-01
- 1.0.0 — 2019-08-01

## README

# react-native-topmind-sdk

[![npm version](https://badge.fury.io/js/react-native-topmind-sdk.svg)](https://badge.fury.io/js/react-native-topmind-sdk)

## Getting started

Run `yarn add react-native-topmind-sdk` or `npm install react-native-topmind-sdk --save`

Then run `react-native link react-native-topmind-sdk`

### Android setup
Add your GitHub credentials(`GITHUB_USER` and `GITHUB_PERSONAL_ACCESS_TOKEN`([instruction](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)))
into environment variables

Then add maven repo in build.gradle
```groovy
allprojects {
    repositories {
        maven {
            name = "GithubPackages"
            url = uri("https://maven.pkg.github.com/severgroup-tt/topmind-sdk-android")
            credentials {
                username = System.getenv('GITHUB_USER')
                password = System.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')
            }
        }
    }
}
```

Add
```
<string name="TopmindClientId">your_client_id</string>
<string name="TopmindApiKey">your_api_key</string>
```
to `res/values/strings.xml` and
```
<meta-data android:name="TopmindApiKey" android:value="@string/TopmindApiKey" />
<meta-data android:name="TopmindClientId" android:value="@string/TopmindClientId" />
```

to your `AndroidManifest.xml`

### iOS setup

Add
```
<key>TopMindClientId</key>
<string>your_client_id</string>
<key>TopMindApiKey</key>
<string>your_api_key</string>
```
to `info.plist`

and run `cd ios && pod install`

## Usage
```typescript
import { RNTopmind } from 'react-native-topmind-sdk';

  /**
   * Required to call before any other calls
   */
  RNTopmind.initialize();

  /**
   * Use it to send event to TopMind.
   * @param name event's name: "menu click" e.g
   * @param eventData Map with data
   * {
   *   foo: {
   *      bar: "someString"
   *    }
   * }
   */
  static logEvent(name: string, eventData: {[key: string]: object} ): void;

  /**
   * Use it to persist user identifier
   * It will be passed through all events as userId property
   * @param userId your user id
   */
  RNTopmind.setUserId(userId: string): void;

  /**
   * It removes all persisted TopMind data (userId e.g)
   */
  RNTopmind.logout(): void;

  /**
   * Sends event that app has started
   */
  RNTopmind.applicationStarted(): void;

  /**
   * Returns the current install id. The id is generated by the app at first run
   * App persists the id through the whole app lifetime.
   *
   * Will be deleted if you clear the application data
   */
  RNTopmind.getInstallId(): Promise<string>;
  
  /**
   * Returns the current sid_long. The id is generated and returned by TopMind at first event response
   * App persist the id through the whole app lifetime and passes it through each event
   *
   * Will be deleted if you clear the application data
   */
  RNTopmind.getSidLong(): Promise<string>;


  /**
   * Returns true if the application was launched for the first time
   */
  RNTopmind.isFirstRun(): Promise<boolean>;
```

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