# howxm-js

> Official NPM wrapper for the howxm JavaScript client

Latest version **0.0.10** (published 2024-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install howxm-js
pnpm add howxm-js
yarn add howxm-js
bun add howxm-js
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2024-09-04 |
| First published | 2023-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | fang.yang |
| Maintainers | zuoshuai, silence717, jposcar |
| Keywords | Howxm |

## Links

- npm: https://www.npmjs.com/package/howxm-js
- Repository: https://github.com/howxm/howxm-js
- Homepage: https://github.com/howxm/howxm-js#readme
- Issues: https://github.com/howxm/howxm-js/issues
- npm.io page: https://npm.io/package/howxm-js

## Recent versions

- 0.0.10 (latest) — 2024-09-04
- 0.0.9 — 2023-12-13
- 0.0.8 — 2023-08-30
- 0.0.7 — 2023-08-08
- 0.0.6 — 2023-05-25
- 0.0.5 — 2023-04-21
- 0.0.4 — 2023-04-18
- 0.0.2 — 2023-04-18

## README

# howxm-js

> Adds [Howxm](https://howxm.com/) capabilities to your project

[![NPM](https://img.shields.io/npm/v/howxm-js.svg)](https://www.npmjs.com/package/howxm-js)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![npm downloads](https://img.shields.io/npm/dt/howxm-js.svg?style=flat-square)](https://www.npmjs.com/package/howxm-js)

## Install

```bash
npm install --save howxm-js
```

## Publish
```bash
git push --follow-tags origin <your version> && npm publish
```

## Usage

- Initializing Howxm

```tsx
import React from 'react'
import { initHowxm } from 'howxm-js'

const myLogger = console.info

const HowxmReadyApp = () => {
  const appId = '<Your App ID>'

  useEffect(() => {
    initHowxm(appId, myLogger)
  }, [])

  return <App />
}
```

- Identifying Customer ([Identify API's rules](https://howxm.com/help/articles/x-sdk-api#part-2ae9459859b8f9f3))

```tsx
import React from 'react'
import { identifyHowxm } from 'howxm-js'

const myLogger = console.info

const MyCustomComponent = () => {
  const customerInfo = {
    uid: '00000001', // 用户唯一ID, 默认字段, 必填，string 类型
  }

  const handleUserInfo = (userInfo) => {
    identifyHowxm(customerInfo)
  }
}
```

- Check Open Campaign ([Check Open API's rules](https://howxm.com/help/articles/web-sdk-intro#4-checkopen))

```tsx
import React from 'react'
import { checkOpenHowxm } from 'howxm-js'

const myLogger = console.info

const MyCustomComponent = () => {
  const campaignId = '<You Campaign ID>'
  const uid = '00000001'

  const handlecCheckOpenCampaign = () => {
    checkOpenHowxm(
      campaignId,
      customerInfo,
      () => {
        myLogger('checkOpenHowxm success')
      },
      (data) => {
        myLogger('checkOpenHowxm faield', data)
      }
    )
  }
}
```

- Open Campaign (Not recommended. [Open API's rules](https://howxm.com/help/articles/web-sdk-intro#3-open))

```tsx
import React from 'react'
import { openHowxm } from 'howxm-js'

const myLogger = console.info

const MyCustomComponent = () => {
  const campaignId = '<You Campaign ID>'
  const customerInfo = {
    uid: '00000001', // 用户唯一ID, 默认字段, 必填，string 类型
  }
  const extra = {
    plan: 'free',
  }

  const handleOpenCampaign = () => {
    openHowxm(campaignId, customerInfo, extra, () => {
      myLogger('openHowxm finished')
    })
  }
}
```

- Send Event ([Event API's rules](https://howxm.com/help/articles/web-sdk-intro#2-event))

```tsx
import React from 'react'
import { eventHowxm } from 'howxm-js'

const myLogger = console.info

const MyCustomComponent = () => {
  const eventCode = '<event code>'
  const eventAttrs = {
    plan: 'free',
    age: 17,
  }

  const handleTriggerEvent = () => {
    eventHowxm(eventCode, eventAttrs, () => {
      myLogger('triggerEvent success')
    })
  }
}
```

## License

MIT © [jinshuju](https://github.com/howxm)

更多信息，请查看我们的[帮助文档](https://howxm.com/help/articles/npm-web-sdk-intro)。

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