events.js onRsvpCreated firing twice from dashboard

Hi, I’ve added a function in events.js to create a record in my own table whenever an Event Rsvp is created. If I create the rsvp from Velo Code it creates a single record as I’d expect but if the rsvp is added via the console TWO records are created.
The only difference I can find between them is the memberId field has a null entry and created field isn’t there at all.
Can anyone shed any light on why this might be happening? I don’t know if it might help but here’s the function out of events.js.

export function wixEvents_onRsvpCreated(rsvp) {
let toSave = {
    "rsvpId":       rsvp.rsvpId,
    "eventId":      rsvp.eventId,
    "totalGuests":  rsvp.guests.length,
    "guests":       rsvp.guests,
    "contactId":    rsvp.contactId,
  }

  wixData.insert("EventStatistics", toSave)
    .then( (results) => {
      let item = results;
    } )
    .catch( (err) => {
      console.error(err);
    } );
}

Your help is appreciated

Take a look at this env property of the wixWindow API:

wixWindow Enviroment

Hi Bruno, Thanks for that. I’d discounted that as a cause as it only happens if the RSVP is created from the Wix Dashboard. It doesn’t happen if I call it from Wix Velo code.
Nothing to lose by trying it I guess.