async writeToDatabase_() {
    this.beginWrite_();
    try {
      await this.addEventsHandler(this.inProgress[this.inProgress.length - 1]);
      this.endWrite_(true);
    } catch {
      this.endWrite_(false);
      throw Error('Failed to write to database.');
    }
  }
Trigger an API call to write events to the database.
@throws Throws an error if the write was not successful.
@private