public async recordPerf()

in src/performance/index.ts [43:69]


  public async recordPerf(options: CustomOptionsType) {
    let fmp: { fmpTime: number | undefined } = { fmpTime: undefined };
    if (options.autoTracePerf && options.useFmp) {
      fmp = await new FMP();
    }
    // auto report pv and perf data
    setTimeout(() => {
      if (options.autoTracePerf) {
        this.perfConfig.perfDetail = new pagePerf().getPerfTiming();
      }
      const perfDetail = options.autoTracePerf
        ? {
            ...this.perfConfig.perfDetail,
            fmpTime: options.useFmp ? parseInt(String(fmp.fmpTime), 10) : undefined,
          }
        : undefined;
      const perfInfo = {
        ...perfDetail,
        pagePath: options.pagePath,
        serviceVersion: options.serviceVersion,
        service: options.service,
      };
      new Report('PERF', options.collector).sendByXhr(perfInfo);
      // clear perf data
      this.clearPerf();
    }, 6000);
  }