# meta-sdk

# 安装

# 操作说明

```js
import { Monitor } from 'meta-sdk';

Monitor.init({
  report: {
    url: 'http://localhost:3004/api/logger'
  }
});

```

```js
const Monitor = require('meta-sdk');
Monitor.init()
```

```js
<script src=""></script>
```

```js
monitor.on('event', (eventName, emitData) => {
  console.log(eventName, emitData);
});
```

```js
monitor.useVueErrorListener(Vue);
```

# 自定义提交

- 物料操作：拖拽物料到画布
- 页面操作：创建新的页面、导出页面源码
- 工程操作：创建新的工程、导出工程
- 接口操作：导入yapi接口
- --- 以上是b端的

- 模型操作：创建新的模型
- --- 以上是c端的

```js
// 全局导入

// vue2.x
Vue.prototype.$monitor = monitor;
// vue3
app.config.globalProperties.$monitor = monitor;
```

```js
// vue2.x
this.$monitor.customEmits({
  detail: 'some detail',
  path: 'a path',
  level: '' // 默认INFO
})

// vue3
const { proxy } = getCurrentInstance();
proxy.$monitor.customEmits({
  detail: 'some detail',
  path: 'a path',
})
```

# 所有配置

```ts
enum ErrorLevel {
  TRACE = 'TRACE',
  DEBUG = 'DEBUG',
  INFO = 'INFO',
  WARN = 'WARN',
  ERROR = 'ERROR',
  FATAL = 'FATAL',
  MARK = 'MARK',
}

const defaultOptions = {
  env: Env.DEV,
  platform: PlatformType.C,
  report: {
  url: '',
    method: 'POST',
    contentType: 'application/json',
    beforeSend: (data: ErrorCombine) => data,
  },
  data: {},
  http: {
  fetch: true,
    xhr: true,
    watchSuccess: false,
    ignoreRules: [],
  },
  error: {
  watch: true,
    random: 1,
    repeat: 5,
    delay: 1000,
  },
}
```

# Feature

- isSpa
- behavior
- fetch
- performance
- react
- ...
