private async makeRequest()

in src/shippers/elastic_v3/browser/src/browser_shipper.ts [143:164]


  private async makeRequest(events: Event[]): Promise<string> {
    const response = await fetch(this.url, {
      method: 'POST',
      body: eventsToNDJSON(events),
      headers: this.buildHeaders(this.clusterUuid, this.options.version, this.licenseId),
      ...(this.options.debug && { query: { debug: true } }),
      // Allow the request to outlive the page in case the tab is closed
      keepalive: true,
    });

    if (this.options.debug) {
      this.initContext.logger.debug(
        `[${ElasticV3BrowserShipper.shipperName}]: ${response.status} - ${await response.text()}`
      );
    }

    if (!response.ok) {
      throw new ErrorWithCode(`${response.status} - ${await response.text()}`, `${response.status}`);
    }

    return `${response.status}`;
  }