howxm-js
v0.0.10
Published
Official NPM wrapper for the howxm JavaScript client
Downloads
74
Readme
howxm-js
Adds Howxm capabilities to your project
Install
npm install --save howxm-js
Publish
git push --follow-tags origin <your version> && npm publish
Usage
- Initializing Howxm
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)
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)
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)
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)
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
更多信息,请查看我们的帮助文档。