code: function collectEvents(mongoClient, topology) {
    let MongoClient = loadClient();
    const collectedEvents = [];
  
    if (mongoClient instanceof MongoClient) {
      monitoringEvents.forEach(event => {
        topology.on(event, (object1, object2) => {
          if (event === 'open') {
            collectedEvents.push({ event: event, object1: mongoClient });
          } else {
            collectedEvents.push({ event: event, object1: object1, object2: object2 });
          }
        });
      });
    }
  
    return collectedEvents;
  }
docs: Collect all events in order from SDAM