public reportEvents()

in src/shippers/elastic_v3/server/src/server_shipper.ts [135:154]


  public reportEvents(events: Event[]) {
    // If opted out OR offline for longer than 24 hours, skip processing any events.
    if (this.isOptedIn$.value === false || (this.firstTimeOffline && Date.now() - this.firstTimeOffline > 24 * HOUR)) {
      return;
    }

    const freeSpace = MAX_NUMBER_OF_EVENTS_IN_INTERNAL_QUEUE - this.internalQueue.length;

    // As per design, we only want store up-to 1000 events at a time. Drop anything that goes beyond that limit
    if (freeSpace < events.length) {
      const toDrop = events.length - freeSpace;
      const droppedEvents = events.splice(-toDrop, toDrop);
      this.reportTelemetryCounters(droppedEvents, {
        type: 'dropped',
        code: 'queue_full',
      });
    }

    this.internalQueue.push(...events);
  }