Documentation
¶
Overview ¶
Package auditlog is a package to send audit logs events to WorkOS.
Example:
func main() { auditlog.SetAPIKey("my_api_key") // Wherever you need to publish an audit log event: err := auditlog.Publish(context.Background(), auditlog.Event{ Action: "document.viewed", ActionType: auditlog.Create, ActorName: "Jairo Kunde", ActorID: "user_01DGZ0FAXN978HCET66Q98QMTQ", Group: "abstract.com", Location: "55.27.223.26", OccurredAt: time.Now(), TargetName: "central.class", TargetID: "doc_01DGZ0FAXP4HA4X0BVFKS0ZH4Y", }) if err != nil { // Handle error. } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionType ¶
type ActionType string
ActionType is the type that holds the CRUD action used for the WorkOS Audit Log.
const ( Create ActionType = "C" Read ActionType = "R" Update ActionType = "U" Delete ActionType = "D" )
Constants that enumerate the different action types.
type Client ¶
type Client struct { // The WorkOS api key. It can be found in // https://dashboard.workos.com/api-keys. APIKey string // The http.Client that is used to post audit log events to WorkOS. Defaults // to http.Client. HTTPClient *http.Client // The endpoint used to request Workos. Defaults to // https://api.workos.com/events. Endpoint string // The function used to encode in JSON. Defaults to json.Marshal. JSONEncode func(v interface{}) ([]byte, error) // contains filtered or unexported fields }
Client represents a client that performs auditlog request to WorkOS API.
type Event ¶
type Event struct { Action string `json:"action"` ActionType ActionType `json:"action_type"` ActorName string `json:"actor_name"` ActorID string `json:"actor_id"` Group string `json:"group"` // If no key is provided or the key is empty, the key will not be attached // to the request. IdempotencyKey string `json:"-"` // An ip address that locates where the audit log occurred. Location string `json:"location"` // The event metadata. It can't contain more than 50 keys. A key can't // exeed 40 characters. Metadata Metadata `json:"metadata,omitempty"` // The time when the audit log occurred. // // Defaults to time.Now(). OccurredAt time.Time `json:"occurred_at"` TargetName string `json:"target_name"` TargetID string `json:"target_id"` }
Event represents an Audit Log event.
Click to show internal directories.
Click to hide internal directories.