"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.FedopsReporter = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
class FedopsReporter {
  constructor(params) {
    (0, _defineProperty2.default)(this, "componentName", void 0);
    (0, _defineProperty2.default)(this, "collection", void 0);
    (0, _defineProperty2.default)(this, "internalMonitor", void 0);
    this.componentName = params.componentName;
    this.collection = params.collection;
    this.internalMonitor = params.internalMonitor;
    const {
      internalMonitor,
      componentName,
      collection
    } = this;
    internalMonitor.reportInteractionStart(componentName, 'initial-load');
    internalMonitor.reportInteractionStart(componentName, 'e2e');
    collection.hooks.once('beforeInitialFetch', ({
      isStale
    }) => {
      const customProps = {
        cached: !isStale
      };
      internalMonitor.reportInteractionEnd(componentName, 'initial-load');
      internalMonitor.reportInteractionStart(componentName, 'initial-fetch-data', customProps);
      collection.emitter.once('ready', () => {
        internalMonitor.reportInteractionEnd(componentName, 'initial-fetch-data', customProps);
      });
    });
  }
  onFullRenderStart() {
    const {
      internalMonitor,
      componentName
    } = this;
    internalMonitor.reportInteractionStart(componentName, 'initial-full-render');
    return () => {
      internalMonitor.reportInteractionEnd(componentName, 'initial-full-render');
      internalMonitor.reportInteractionEnd(componentName, 'e2e');
    };
  }
}
exports.FedopsReporter = FedopsReporter;
//# sourceMappingURL=FedopsReporter.js.map