@ray-js/robot-data-stream 0.0.12-beta-13 → 0.0.12-beta-15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/api/p2pApi.js CHANGED
@@ -200,7 +200,7 @@ export default class P2pApi {
200
200
  logger('info', {
201
201
  msg: 'p2p downloadStream success'
202
202
  }, this.onLogger);
203
- trace.pointFn('p2p', {
203
+ trace.pointFn({
204
204
  devId: this.devId,
205
205
  eventName: 'downloadStream'
206
206
  });
@@ -212,9 +212,9 @@ export default class P2pApi {
212
212
  msg: 'p2p downloadStream failed===>',
213
213
  params
214
214
  }, this.onLogger);
215
- trace.pointFn('p2pFail', {
215
+ trace.pointFn({
216
216
  devId: this.devId,
217
- eventName: 'downloadStream'
217
+ eventName: 'downloadStreamFailed'
218
218
  });
219
219
  setTimeout(() => {
220
220
  typeof failedCb === 'function' && failedCb();
@@ -251,7 +251,7 @@ export class SweeperP2p extends P2pApi {
251
251
  logger('info', {
252
252
  msg: 'startObserverSweeperDataByP2P ==>'
253
253
  }, this.onLogger);
254
- trace.pointFn('p2p', {
254
+ trace.pointFn({
255
255
  devId,
256
256
  eventName: 'startObserverSweeperDataByP2P'
257
257
  });
@@ -495,7 +495,7 @@ export class SweeperP2p extends P2pApi {
495
495
  logger('info', {
496
496
  msg: `receive first full package, cost time: ${packageTime} ms, fileName: ${fileName}`
497
497
  }, this.onLogger);
498
- trace.pointFn('p2p', {
498
+ trace.pointFn({
499
499
  devId: this.devId,
500
500
  eventName: 'receiveFirstFullPackage'
501
501
  });
package/lib/index.js CHANGED
@@ -8,6 +8,8 @@ import { SweeperP2pInstance } from './api';
8
8
  export * from './mqtt';
9
9
  export * from './mqtt/type/requestType';
10
10
  const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
11
+ const traceId = `${devId}_${Date.now()}`;
12
+ global.robotPanelTraceId = traceId;
11
13
  const {
12
14
  logTag,
13
15
  onReceiveAIPicData,
@@ -62,6 +64,9 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
62
64
  if (logTag) {
63
65
  log4js.setTag(logTag);
64
66
  }
67
+ if (traceId) {
68
+ trace.traceId = traceId;
69
+ }
65
70
  if (isIDE) {
66
71
  logger('warn', {
67
72
  msg: `You are using the IDE environment. To perform P2P and map debugging, please ensure the 'Robot Vacuum Debugger' plugin is installed.`
@@ -84,14 +89,14 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
84
89
  SweeperP2pInstance.onLogger = onLogger;
85
90
  SweeperP2pInstance.initP2pSdk(devId).then(() => {
86
91
  connectP2p();
87
- trace.pointFn('p2p', {
92
+ trace.pointFn({
88
93
  devId,
89
94
  eventName: 'initP2pSdk'
90
95
  });
91
96
  }).catch(() => {
92
- trace.pointFn('p2pFail', {
97
+ trace.pointFn({
93
98
  devId,
94
- eventName: 'initP2pSdk'
99
+ eventName: 'initP2pSdkFail'
95
100
  });
96
101
  });
97
102
  ty.onAppHide(handleAppHide);
@@ -111,22 +116,24 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
111
116
  logger('info', {
112
117
  msg: 'hooks has been started connectP2p'
113
118
  }, onLogger);
119
+ // 开始进行连接时作为整个p2p连接的开始,将trace的开始时间戳记录下来
120
+ trace.initTimeStamps = Date.now();
114
121
  SweeperP2pInstance.connectDevice(() => {
115
- trace.pointFn('p2p', {
122
+ trace.pointFn({
116
123
  devId,
117
- eventName: 'connectDevice'
124
+ eventName: 'connectDeviceSuccess'
118
125
  });
119
126
  isInit.current = true;
120
127
  SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onDefineStructuredMode);
121
128
  offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
122
129
  }, () => {
123
- trace.pointFn('p2pFail', {
130
+ trace.pointFn({
124
131
  devId,
125
- eventName: 'connectDevice'
132
+ eventName: 'connectDeviceFail'
126
133
  });
127
134
  SweeperP2pInstance.reconnectP2p(() => {
128
135
  isInit.current = true;
129
- trace.pointFn('p2p', {
136
+ trace.pointFn({
130
137
  devId,
131
138
  eventName: 'reconnectP2p'
132
139
  });
@@ -1,12 +1,12 @@
1
1
  export declare const PointEventConfig: {
2
2
  p2p: string;
3
- p2pFail: string;
4
3
  };
5
4
  export declare class Trace {
6
5
  initTimeStamps: number;
7
6
  traceId: string;
7
+ devId: string;
8
8
  constructor();
9
- pointFn: (type: 'p2p' | 'p2pFail', options: {
9
+ pointFn: (options: {
10
10
  devId: string;
11
11
  eventName: string;
12
12
  }) => void;
@@ -1,32 +1,33 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- const _excluded = ["devId"];
4
1
  import { event } from '@ray-js/ray';
5
- import { uniqueId } from 'lodash-es';
6
2
 
7
3
  // 事件埋点编码
8
4
  export const PointEventConfig = {
9
- p2p: 'ty_QEsvYl97I7pGNwUlqR2ARB7F8uqTAtht',
10
- p2pFail: 'ty_YB0xgyLYCy3LDCCUh8zykbDDxMMCGWU5'
5
+ p2p: 'ty_MItWO0xACjJhXAxxXuhFLc6QAIzYsL8c'
11
6
  };
12
7
  export class Trace {
13
8
  constructor() {
14
9
  this.initTimeStamps = Date.now();
15
- this.traceId = uniqueId('p2p_trace_');
16
10
  }
17
- pointFn = (type, options) => {
11
+ pointFn = options => {
18
12
  const {
19
- devId
20
- } = options,
21
- rest = _objectWithoutProperties(options, _excluded);
13
+ devId,
14
+ eventName
15
+ } = options;
16
+ console.log('==trace pointFn==', options);
22
17
  event({
23
- eventId: type === 'p2p' ? PointEventConfig.p2p : PointEventConfig.p2pFail,
24
- event: _objectSpread({
25
- devId,
18
+ eventId: PointEventConfig.p2p,
19
+ event: {
20
+ // 设备id
21
+ devId: devId,
22
+ // 事件名称
23
+ eventName,
24
+ // 时间戳
26
25
  timeStamp: Date.now(),
27
- traceId: this.traceId,
28
- costTime: Date.now() - this.initTimeStamps
29
- }, rest)
26
+ // 耗时(当前的时间戳 - initP2PSDK的时间戳)
27
+ costTime: Date.now() - this.initTimeStamps,
28
+ // 追踪id
29
+ traceId: this.traceId || ''
30
+ }
30
31
  });
31
32
  };
32
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.12-beta-13",
3
+ "version": "0.0.12-beta-15",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [