Alert.accept() does not accept alert


Within our synthetic, we have an alert popping up from optimizely once the page has loaded. We are trying to use the following code snippet to close the alert

      .wait($driver.until.alertIsPresent(), 10000)
        function (alert) {
          console.log("alert is found - accepting");
        function (erorr) {
          console.log("alert not found");

In our Script logs we can see the alert has been found but following we get an error indicating that the alert has not been accepted - “Script execution failed: UnexpectedAlertOpenError: unexpected alert open”

Is this the correct way to accept an alert or is there another way this can be done?

Thank you.