code: func (a *Agent) UserEvents() []*UserEvent {
  	n := len(a.eventBuf)
  	out := make([]*UserEvent, n)
  	a.eventLock.RLock()
  	defer a.eventLock.RUnlock()
  
  	// Check if the buffer is full
  	if a.eventBuf[a.eventIndex] != nil {
  		if a.eventIndex == 0 {
  			copy(out, a.eventBuf)
  		} else {
  			copy(out, a.eventBuf[a.eventIndex:])
  			copy(out[n-a.eventIndex:], a.eventBuf[:a.eventIndex])
  		}
  	} else {
  		// We haven't filled the buffer yet
  		copy(out, a.eventBuf[:a.eventIndex])
  		out = out[:a.eventIndex]
  	}
  	return out
  }
docs: // UserEvents is used to return a slice of the most recent
  // user events.