# cordova-plugin-dmhub

> Cordova Plugin for DMHub SDK

Latest version **2.0.8** (published 2024-04-28) · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-dmhub
pnpm add cordova-plugin-dmhub
yarn add cordova-plugin-dmhub
bun add cordova-plugin-dmhub
```

## 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 | 2.0.8 |
| Published | 2024-04-28 |
| First published | 2021-03-18 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | clab, abwbw |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-dmhub
- npm.io page: https://npm.io/package/cordova-plugin-dmhub

## Recent versions

- 2.0.8 (latest) — 2024-04-28
- 2.0.7 — 2022-09-02
- 2.0.6 — 2021-10-28
- 2.0.5 — 2021-10-13
- 2.0.4 — 2021-09-22
- 2.0.3 — 2021-08-30
- 2.0.2 — 2021-03-18

## README

## DMHub cordova plugin

## 安装步骤

    cordova plugin add cordova-plugin-dmhub

## 配置
> Android

打开 platforms/android/app/src/main/AndroidManifest.xml
修改

```
<meta-data android:name="com.convertlab.dmhubsdk.config.DMHubSDKAppId" android:value="[配置appid]" />
<meta-data android:name="com.convertlab.dmhubsdk.config.Endpoint" android:value="[配置服务器地址]" />
<meta-data android:name="com.convertlab.dmhubsdk.config.EnableDebugLogging" android:comment="是否启用调试，默认false"  android:value="false"/>
<meta-data android:name="com.convertlab.dmhubsdk.config.FlushInterval" android:comment="上传数据的时间间隔（单位：秒），默认值：30000ms" android:value="30000"/>
<meta-data android:name="com.convertlab.dmhubsdk.config.BulkUploadLimit" android:comment="事件队列长度，默认是40"  android:value="40"/>
<meta-data android:name="com.convertlab.dmhubsdk.config.UploadOnlyWifi" android:comment="是否自动记录进入、离开视图事件，默认值：" android:value="false"/>
<meta-data android:name="com.convertlab.dmhubsdk.config.MaximumBackgroundDuration" android:comment="App退到后台，重新打开，被认为重新开启的阈值，默认30000ms" android:value="30000"/>
```
第二行到第七行，如果无需配置，可以采用默认值，建议删除。

> iOS

打开Staging/config.xml

修改appid，以及endpoint配置服务器地址
```
<preference name="DMHUB_SDK_APP_ID" value="[配置appid]" />
<preference name="DMHUB_SDK_ENDPOINT" value="[配置服务器地址]" />
<preference name="DMHUB_SDK_AUTO_TRACK" value="YES" />
<preference name="DMHUB_SDK_FLUSH_INTERVAL" value="60"/>
```

如果不需要配置服务器地址，则删除第二行
如果不需要自动埋点，则删除第三行
如果不需要调整默认30秒的埋点刷新时间，则删除第四行

## 调用方式
### 1. 启动SDK
>接口
```
DMHubCDVPlugin.initSdk()
```

### 2. 设置客户身份
>接口
```
DMHubCDVPlugin.setIdentity(identityType: string, identityValue: string);
```

>例子
```
DMHubCDVPlugin.setIdentity('email', 'global@gmail.com');
```

### 3. 获取当前客户身份
>接口
```
DMHubCDVPlugin.currentIdentity(success: function, failed: function);

```

>例子
```
DMHubCDVPlugin.currentIdentity(function(result){
    if(result){
        document.getElementById('identity').innerText = result.type + ' ' + result.value;
    }else{
        document.getElementById('identity').innerText = '';
    }
}, function (result) {
    document.getElementById('identity').innerText = '';
});
```

### 4. 清除客户身份
>接口
```
DMHubCDVPlugin.clearIdentity()
```

### 5. 跟踪自定义客户事件
>接口
```
DMHubCDVPlugin.trackMap(eventId: string, properties: object);
```

>例子
```
DMHubCDVPlugin.trackMap('add-to-cart', {
            'name': 'juice',
            'price': 12.00
        });
```

### 6. 跟踪自定义客户事件
>接口
```
DMHubCDVPlugin.trackMap(eventId: string);
```

>例子
```
DMHubCDVPlugin.track('add-to-cart');
```

### 7. 跟踪进入视图事件
>接口
```
DMHubCDVPlugin.trackOpenView(viewName: string);
```

>例子
```
DMHubCDVPlugin.trackOpenView('menuPage');
```

### 8. 跟踪离开视图事件
>接口
```
DMHubCDVPlugin.trackExitView(viewName: string);
```

>例子
```
DMHubCDVPlugin.trackExitView('productPage');
```

### 9. 禁用采集信息行为
默认以下所有信息将进行采集，可支持配置选项有：
android: 
* imei
* bluetooth
* mac
* location
* androidId

iOS: 
* idfa
* location

注意：同一个配置项将同时影响 iOS、Android 两端
>接口
```
DMHubCDVPlugin.disableCollect(names: Array<string>);
```

>例子
```
DMHubCDVPlugin.disableCollect(['imei','idfs','location']);
```


### 10. 启用采集信息行为
默认以下所有信息将进行采集，不需要进行启用：
android: 
* imei
* bluetooth
* mac
* location
* androidId

iOS: 
* idfa
* location

注意：同一个配置项将同时影响 iOS、Android 两端
>接口
```
DMHubCDVPlugin.enableCollect(names: Array<string>);
```

>例子
```
DMHubCDVPlugin.enableCollect(['imei','idfs','location']);
```

### Supported Platforms

- Android
- iOS

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