gemercheung 3 سال پیش
والد
کامیت
8b0dcdd4c8
10فایلهای تغییر یافته به همراه181 افزوده شده و 164 حذف شده
  1. 158 158
      README.md
  2. 1 1
      packages/core/package.json
  3. 1 1
      packages/types/package.json
  4. 1 1
      packages/utils/package.json
  5. 2 1
      packages/web/package.json
  6. 1 0
      packages/web/src/index.ts
  7. 9 0
      packages/web/src/init.ts
  8. 1 0
      play/package.json
  9. 2 2
      play/src/App.vue
  10. 5 0
      pnpm-lock.yaml

+ 158 - 158
README.md

@@ -1,158 +1,158 @@
-# 埋点 SDK (代号:medici)
-
-> medici,美地奇,指Lorenzo Medici,洛伦佐·美第奇,美地奇家族 文艺复兴时伟大收藏家,亦是现代最大收集/收藏的家族之一。
-
-# browser (浏览器行为)
-
-内置,取 XHR header, userAgent,os, deviceInfo, navigator,location, navigator.connection 等封装。
-
-# Event(全局事件行为类型)
-
-1. click
-2. delete
-3. upload
-
-## PV/UV 内置功能
-
-
-
-
-
-
-
-## SDK 初始化 (monorepo)
-
-<!-- http://120.25.146.52:3090/mock/95/tracking/log/save -->
-
-> 1.普通 es 引包
-
-```js
-import * as medici from "@medici/web";
-medici.init({
-  url: "xxxxxx/tracking/log/save",
-  config: {
-    user: "xxxxxx",
-    version: "xxxxxxxx", //client version
-  },
-});
-```
-
-> 2.小程序 es
-
-```js
-import * as medici from "@medici/miniApp";
-medici.init({
-  url: "xxxxxx/tracking/log/save",
-  config: {
-    user: "xxxxxx",
-    version: "xxxxxxxx", //client version
-  },
-});
-```
-
-> 3.其他 amd 或源引入
-
-```js
-<script src="xxx/xxxx/medici-amd.js"></script>;
-medici.init({
-  url: "xxxxxx/tracking/log/save",
-  config: {
-    user: "xxxxxx",
-    version: "xxxxxxxx", //client version
-  },
-});
-```
-
-> 隐藏带上 SDK version
-
-## 页面(采集)
-
-#### 实现两种方法()
-
-1. 全局注册页面
-
-```js
-medici.setPages([
-  {
-    scene: "/scene",
-    setting: "/setting",
-  },
-]);
-```
-
-> 简单的 key:value, 影射页面采集
-
-2. 接入各 mmvm 的 router(vue-router,react-router) 或原生 history 监控。
-   以 routerName:url, 影射页面采集,
-
-## 点位(采集)
-
-> 主业务事件:eventType
-
-### 一次消费埋点
-
-```js
-medici.track("BuyProduct", {
-  eventType:"click",
-  ProductName: "MacBook Pro",
-  ProductPrice: 123.45,
-  IsAddedToFav: false,
-  ... // 其他自定业务字段
-});
-```
-
-### 二次消费埋点(闭环)
-
-> 开始,主要对接,init startTime,大部分参数等, maxWaitTime 是默认 30s,如果超过这个时间没有冲正 endTrack 的提示 warning.
-
-```js
-medici.startTrack("BuyProduct", {
-  eventType:"click",
-  maxWaitTime: 30000, //可自定义,主要是下载等行为耗时。
-  ProductName: "MacBook Pro",
-  ProductPrice: 123.45,
-  IsAddedToFav: false,
-  ... // 其他自定业务字段
-});
-
-```
-
-> 结束 ,init endTime, 后补参数
-
-```js
-medici.endTrack("BuyProduct", {
-  ... // 后补参数
-});
-
-```
-
----
-
-## API (初定字段)
-
-|     名称     |  类型  | 是否必须 | 默认值 |                    备注                    |
-| :----------: | :----: | :------: | :----: | :----------------------------------------: |
-|   traceId    | string |   必须   |        |                 业务串联码                 |
-| requestType  | string |   必须   |        |   业务:BUSINESS(默认);心跳:HEARTBEAT    |
-|   channel    | string |   必须   |        |         渠道,例如四维看看,指房宝         |
-|    userId    | string |  非必须  |        |                                            |
-|     time     | string |  非必须  |        |                 请求时间戳                 |
-|  requestUrl  | string |  非必须  |        |                                            |
-| requestData  | string |  非必须  |        |         请求数据 ,xhr request data         |
-| TrackingType | string |  非必须  |        | 埋点类型,前端:FRONT(默认),后端:BACKEND |
-|  srcPageUrl  | string |   必须   |        |          发起请求页面 (location)           |
-|  actionType  | string |   必须   |        |                                            |
-|  actionName  | string |   必须   |        |                                            |
-|    userIP    | string |  非必须  |        |                                            |
-| userIpAdress | string |  非必须  |        |                                            |
-|  userAgent   | string |   必须   |        |                     UA                     |
-| networkType  | string |   必须   |        |                                            |
-|  requestId   | string |  非必须  |        |                                            |
-|   duration   | string |  非必须  |        |                                            |
-|    result    | string |  非必须  |        |                                            |
-|   endTime    | string |  非必须  |        |                请求结束时间                |
-
-## 其他问题.
-
-1. 脱敏处理,()crytojs,看加密级别。
-2.
+# 埋点 SDK (代号:medici)
+
+> medici,美地奇,指Lorenzo Medici,洛伦佐·美第奇,美地奇家族 文艺复兴时伟大收藏家,亦是现代最大收集/收藏的家族之一。
+
+# browser (浏览器行为)
+
+内置,取 XHR header, userAgent,os, deviceInfo, navigator,location, navigator.connection 等封装。
+
+# Event(全局事件行为类型)
+
+1. click
+2. delete
+3. upload
+
+## PV/UV 内置功能
+
+
+
+
+
+
+
+## SDK 初始化 (monorepo)
+
+<!-- http://120.25.146.52:3090/mock/95/tracking/log/save -->
+
+> 1.普通 es 引包
+
+```js
+import * as medici from "@medici/web";
+medici.init({
+  url: "xxxxxx/tracking/log/save",
+  config: {
+    user: "xxxxxx",
+    version: "xxxxxxxx", //client version
+  },
+});
+```
+
+> 2.小程序 es
+
+```js
+import * as medici from "@medici/miniApp";
+medici.init({
+  url: "xxxxxx/tracking/log/save",
+  config: {
+    user: "xxxxxx",
+    version: "xxxxxxxx", //client version
+  },
+});
+```
+
+> 3.其他 amd 或源引入
+
+```js
+<script src="xxx/xxxx/medici-amd.js"></script>;
+medici.init({
+  url: "xxxxxx/tracking/log/save",
+  config: {
+    user: "xxxxxx",
+    version: "xxxxxxxx", //client version
+  },
+});
+```
+
+> 隐藏带上 SDK version
+
+## 页面(采集)
+
+#### 实现两种方法()
+
+1. 全局注册页面
+
+```js
+medici.setPages([
+  {
+    scene: "/scene",
+    setting: "/setting",
+  },
+]);
+```
+
+> 简单的 key:value, 影射页面采集
+
+2. 接入各 mmvm 的 router(vue-router,react-router) 或原生 history 监控。
+   以 routerName:url, 影射页面采集,
+
+## 点位(采集)
+
+> 主业务事件:eventType
+
+### 一次消费埋点
+
+```js
+medici.track("BuyProduct", {
+  eventType:"click",
+  ProductName: "MacBook Pro",
+  ProductPrice: 123.45,
+  IsAddedToFav: false,
+  ... // 其他自定业务字段
+});
+```
+
+### 二次消费埋点(闭环)
+
+> 开始,主要对接,init startTime,大部分参数等, maxWaitTime 是默认 30s,如果超过这个时间没有冲正 endTrack 的提示 warning.
+
+```js
+medici.startTrack("BuyProduct", {
+  eventType:"click",
+  maxWaitTime: 30000, //可自定义,主要是下载等行为耗时。
+  ProductName: "MacBook Pro",
+  ProductPrice: 123.45,
+  IsAddedToFav: false,
+  ... // 其他自定业务字段
+});
+
+```
+
+> 结束 ,init endTime, 后补参数
+
+```js
+medici.endTrack("BuyProduct", {
+  ... // 后补参数
+});
+
+```
+
+---
+
+## API (初定字段)
+
+|     名称     |  类型  | 是否必须 | 默认值 |                    备注                    |
+| :----------: | :----: | :------: | :----: | :----------------------------------------: |
+|   traceId    | string |   必须   |        |                 业务串联码                 |
+| requestType  | string |   必须   |        |   业务:BUSINESS(默认);心跳:HEARTBEAT    |
+|   channel    | string |   必须   |        |         渠道,例如四维看看,指房宝         |
+|    userId    | string |  非必须  |        |                                            |
+|     time     | string |  非必须  |        |                 请求时间戳                 |
+|  requestUrl  | string |  非必须  |        |                                            |
+| requestData  | string |  非必须  |        |         请求数据 ,xhr request data         |
+| TrackingType | string |  非必须  |        | 埋点类型,前端:FRONT(默认),后端:BACKEND |
+|  srcPageUrl  | string |   必须   |        |          发起请求页面 (location)           |
+|  actionType  | string |   必须   |        |                                            |
+|  actionName  | string |   必须   |        |                                            |
+|    userIP    | string |  非必须  |        |                                            |
+| userIpAdress | string |  非必须  |        |                                            |
+|  userAgent   | string |   必须   |        |                     UA                     |
+| networkType  | string |   必须   |        |                                            |
+|  requestId   | string |  非必须  |        |                                            |
+|   duration   | string |  非必须  |        |                                            |
+|    result    | string |  非必须  |        |                                            |
+|   endTime    | string |  非必须  |        |                请求结束时间                |
+
+## 其他问题.
+
+1. 脱敏处理,()crytojs,看加密级别。
+2.

+ 1 - 1
packages/core/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/core",
-  "version": "0.0.1",
+  "version": "0.0.2",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 1 - 1
packages/types/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/types",
-  "version": "0.0.1",
+  "version": "0.0.2",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 1 - 1
packages/utils/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/utils",
-  "version": "0.0.1",
+  "version": "0.0.2",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 2 - 1
packages/web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/web",
-  "version": "0.0.1",
+  "version": "0.0.2",
   "main": "dist/index",
   "types": "dist/index",
   "files": [
@@ -17,5 +17,6 @@
     "typescript": "~4.7.4"
   },
   "dependencies": {
+    "@medici/core": "workspace:^0.0.1"
   }
 }

+ 1 - 0
packages/web/src/index.ts

@@ -0,0 +1 @@
+export * from './init';

+ 9 - 0
packages/web/src/init.ts

@@ -0,0 +1,9 @@
+import { SDK, SDKConfigType } from '@medici/core';
+
+export const init = (initParams: SDKConfigType): SDK => {
+    const webParam: SDKConfigType = {
+        ...initParams,
+        platform: 'web',
+    };
+    return new SDK(webParam);
+};

+ 1 - 0
play/package.json

@@ -11,6 +11,7 @@
   "dependencies": {
     "@highlightjs/vue-plugin": "^2.1.0",
     "@medici/core": "workspace:^0.0.1",
+    "@medici/web": "workspace:^0.0.1",
     "highlight.js": "^11.6.0",
     "vue": "^3.2.37",
     "vue-router": "4"

+ 2 - 2
play/src/App.vue

@@ -2,9 +2,9 @@
 // This starter template is using Vue 3 <script setup> SFCs
 // Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
 import HelloWorld from './components/HelloWorld.vue';
-import { SDK } from '@medici/core';
+import * as Medici from '@medici/web';
 
-const medici = new SDK({
+const medici = Medici.init({
     platform: 'web',
     appId: '7b5958d5-1ae6-4ad5-8a87-5fc8a4b92999',
     endPoint: 'http://192.168.0.186:3000/api/collect', //服务器

+ 5 - 0
pnpm-lock.yaml

@@ -75,8 +75,11 @@ importers:
 
   packages/web:
     specifiers:
+      '@medici/core': workspace:^0.0.1
       rimraf: ~3.0.2
       typescript: ~4.7.4
+    dependencies:
+      '@medici/core': link:../core
     devDependencies:
       rimraf: 3.0.2
       typescript: 4.7.4
@@ -85,6 +88,7 @@ importers:
     specifiers:
       '@highlightjs/vue-plugin': ^2.1.0
       '@medici/core': workspace:^0.0.1
+      '@medici/web': workspace:^0.0.1
       '@vitejs/plugin-vue': ^3.0.0
       highlight.js: ^11.6.0
       typescript: ^4.6.4
@@ -95,6 +99,7 @@ importers:
     dependencies:
       '@highlightjs/vue-plugin': 2.1.0_67te4p3ga56i3himeolvr6h3ke
       '@medici/core': link:../packages/core
+      '@medici/web': link:../packages/web
       highlight.js: 11.6.0
       vue: 3.2.37
       vue-router: 4.1.3_vue@3.2.37