@ray-js/robot-data-stream 0.0.12-beta-14 → 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
@@ -74,8 +74,6 @@ export default class P2pApi {
74
74
  initP2pSdk = async devId => {
75
75
  return new Promise((resolve, reject) => {
76
76
  try {
77
- // 初始化p2pSDK时,将trace的开始时间戳记录下来
78
- trace.initTimeStamps = Date.now();
79
77
  this.devId = devId;
80
78
  p2p.P2PSDKInit({
81
79
  success: () => {
@@ -216,7 +214,7 @@ export default class P2pApi {
216
214
  }, this.onLogger);
217
215
  trace.pointFn({
218
216
  devId: this.devId,
219
- eventName: 'downloadStream'
217
+ eventName: 'downloadStreamFailed'
220
218
  });
221
219
  setTimeout(() => {
222
220
  typeof failedCb === 'function' && failedCb();
package/lib/index.d.ts CHANGED
@@ -7,7 +7,6 @@ declare const useP2PDataStream: (devId: string, onReceiveMapData: (data: string)
7
7
  onReceiveAIPicHDData?: ((data: string) => void) | undefined;
8
8
  onLogger?: TOnLogger | undefined;
9
9
  onDefineStructuredMode?: ((isStructured: boolean) => void) | undefined;
10
- traceId?: string | undefined;
11
10
  } | undefined) => {
12
11
  appendDownloadStreamDuringTask: (files: Array<string>, successCb?: () => void, failedCb?: () => void) => Promise<boolean> | void;
13
12
  };
package/lib/index.js CHANGED
@@ -8,13 +8,14 @@ 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,
14
16
  onReceiveAIPicHDData,
15
17
  onLogger,
16
- onDefineStructuredMode,
17
- traceId
18
+ onDefineStructuredMode
18
19
  } = opt || {};
19
20
  const isInit = useRef(false);
20
21
  const offSessionStatusChange = useRef(null);
@@ -115,10 +116,12 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
115
116
  logger('info', {
116
117
  msg: 'hooks has been started connectP2p'
117
118
  }, onLogger);
119
+ // 开始进行连接时作为整个p2p连接的开始,将trace的开始时间戳记录下来
120
+ trace.initTimeStamps = Date.now();
118
121
  SweeperP2pInstance.connectDevice(() => {
119
122
  trace.pointFn({
120
123
  devId,
121
- eventName: 'connectDevice'
124
+ eventName: 'connectDeviceSuccess'
122
125
  });
123
126
  isInit.current = true;
124
127
  SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onDefineStructuredMode);
@@ -4,6 +4,7 @@ export declare const PointEventConfig: {
4
4
  export declare class Trace {
5
5
  initTimeStamps: number;
6
6
  traceId: string;
7
+ devId: string;
7
8
  constructor();
8
9
  pointFn: (options: {
9
10
  devId: string;
@@ -2,7 +2,7 @@ import { event } from '@ray-js/ray';
2
2
 
3
3
  // 事件埋点编码
4
4
  export const PointEventConfig = {
5
- p2p: 'ty_QEsvYl97I7pGNwUlqR2ARB7F8uqTAtht'
5
+ p2p: 'ty_MItWO0xACjJhXAxxXuhFLc6QAIzYsL8c'
6
6
  };
7
7
  export class Trace {
8
8
  constructor() {
@@ -13,19 +13,20 @@ export class Trace {
13
13
  devId,
14
14
  eventName
15
15
  } = options;
16
+ console.log('==trace pointFn==', options);
16
17
  event({
17
18
  eventId: PointEventConfig.p2p,
18
19
  event: {
19
20
  // 设备id
20
- devId,
21
+ devId: devId,
22
+ // 事件名称
23
+ eventName,
21
24
  // 时间戳
22
- time: Date.now(),
23
- // 追踪id
24
- traceId: this.traceId || '',
25
+ timeStamp: Date.now(),
25
26
  // 耗时(当前的时间戳 - initP2PSDK的时间戳)
26
27
  costTime: Date.now() - this.initTimeStamps,
27
- // 事件名称
28
- eventName
28
+ // 追踪id
29
+ traceId: this.traceId || ''
29
30
  }
30
31
  });
31
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.12-beta-14",
3
+ "version": "0.0.12-beta-15",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [