Alert.accept() does not accept alert

Hello,

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

$browser
      .wait($driver.until.alertIsPresent(), 10000)
      .then(
        function (alert) {
          console.log("alert is found - accepting");
          alert.accept();
        },
        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.