wu-sheng commented on a change in pull request #6: Feat: add performance data URL: https://github.com/apache/skywalking-client-js/pull/6#discussion_r376883708
########## File path: src/performance/index.ts ########## @@ -0,0 +1,55 @@ + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CustomPerfOptionsType } from '../types'; +import Report from '../services/report'; +import pagePerf from './perf'; + +class TracePerf { + private isPerf: boolean = true; + private perfConfig = { + resources: [], + perfDetail: {}, + } as any; + + public recordPerf(options: CustomPerfOptionsType) { + if (this.isPerf) { + this.perfConfig.performance = pagePerf.getPerfTiming(); + } + const perfInfo = { + perfDetail: this.perfConfig.perfDetail, + resources: this.perfConfig.resources, + ...options, + }; + new Report(options.reportUrl).sendByXhr(perfInfo); + this.clearPerf(); Review comment: I set the question for a wrong line, sorry. I mean for `#sendByXhr`. According to the protocol, https://github.com/apache/skywalking-data-collect-protocol/blob/master/browser/BrowserPerf.proto#L39-L41, the report data should include service id and version id. But I can't see the check and buffer(if not registered yet). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
