Skip to content

Commit

Permalink
[chore] rename audit log to audit trail (#39)
Browse files Browse the repository at this point in the history
* rename audit-log to audit trail

* rename files
  • Loading branch information
maxchehab authored Mar 15, 2020
1 parent 1301cea commit 8ad2e26
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 29 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

A Golang SDK to interact with [WorkOS](https://workos.com) APIs.

- [Auditlog](https://github.com/workos-inc/workos-go/tree/master/pkg/auditlog)
- [AuditTrail](https://github.com/workos-inc/workos-go/tree/master/pkg/audittrail)
- [SSO](https://github.com/workos-inc/workos-go/tree/master/pkg/sso)

## Install
Expand All @@ -28,4 +28,3 @@ go get -u github.com/workos-inc/workos-go/...
- Enter a title
- Enter a description
- Click on the `Publish release` button

18 changes: 9 additions & 9 deletions pkg/auditlog/README.md → pkg/audittrail/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# auditlog
# audittrail

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos-inc/workos-go/pkg/auditlog)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos-inc/workos-go/pkg/audittrail)

A Go package to send audit logs events to WorkOS.
A Go package to send audit trails events to WorkOS.

## Install

```sh
go get -u github.com/workos-inc/workos-go/pkg/auditlog
go get -u github.com/workos-inc/workos-go/pkg/audittrail
```

## How it works

```go
package main

import "github.com/workos-inc/workos-go/pkg/auditlog"
import "github.com/workos-inc/workos-go/pkg/audittrail"

func main() {
auditlog.SetAPIKey("my_api_key")
audittrail.SetAPIKey("my_api_key")

// Wherever you need to publish an audit log event:
err := auditlog.Publish(ctx.Background(), auditlog.Event{
// Wherever you need to publish an audit trail event:
err := audittrail.Publish(ctx.Background(), audittrail.Event{
Action: "document.viewed",
ActionType: auditlog.Create,
ActionType: audittrail.Create,
ActorName: "Jairo Kunde",
ActorID: "user_01DGZ0FAXN978HCET66Q98QMTQ",
Group: "abstract.com",
Expand Down
22 changes: 11 additions & 11 deletions pkg/auditlog/auditlog.go → pkg/audittrail/audittrail.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Package auditlog is a package to send audit logs events to WorkOS.
// Package audittrail is a package to send audit trail events to WorkOS.
//
// Example:
// func main() {
// auditlog.SetAPIKey("my_api_key")
// audittrail.SetAPIKey("my_api_key")
//
// // Wherever you need to publish an audit log event:
// err := auditlog.Publish(context.Background(), auditlog.Event{
// // Wherever you need to publish an audit trail event:
// err := audittrail.Publish(context.Background(), audittrail.Event{
// Action: "document.viewed",
// ActionType: auditlog.Create,
// ActionType: audittrail.Create,
// ActorName: "Jairo Kunde",
// ActorID: "user_01DGZ0FAXN978HCET66Q98QMTQ",
// Group: "abstract.com",
Expand All @@ -20,7 +20,7 @@
// // Handle error.
// }
// }
package auditlog
package audittrail

import (
"context"
Expand All @@ -35,7 +35,7 @@ var (
Endpoint: "https://api.workos.com/events",
}

// GlobalMetadata are metadata that are injected in every audit log events.
// GlobalMetadata are metadata that are injected in every audit trail events.
GlobalMetadata Metadata

errTooMuchMetadataKeys = errors.New("too much metadata key")
Expand All @@ -51,7 +51,7 @@ func Publish(ctx context.Context, e Event) error {
return DefaultClient.Publish(ctx, e)
}

// Event represents an Audit Log event.
// Event represents an Audit Trail event.
type Event struct {
Action string `json:"action"`
ActionType ActionType `json:"action_type"`
Expand All @@ -67,14 +67,14 @@ type Event struct {
// to the request.
IdempotencyKey string `json:"-"`

// An ip address that locates where the audit log occurred.
// An ip address that locates where the audit trail 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.
// The time when the audit trail occurred.
//
// Defaults to time.Now().
OccurredAt time.Time `json:"occurred_at"`
Expand All @@ -95,7 +95,7 @@ const (
Delete ActionType = "D"
)

// Metadata represents metadata to be attached to an audit log event.
// Metadata represents metadata to be attached to an audit trail event.
type Metadata map[string]interface{}

// Merges the given metadata. Values from m are not overridden by the ones from
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auditlog
package audittrail

import (
"context"
Expand All @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestAuditLog(t *testing.T) {
func TestAuditTrail(t *testing.T) {
handler := &defaultTestHandler{}
handlerFunc := func(w http.ResponseWriter, r *http.Request) {
handler.ServeHTTP(w, r)
Expand Down
6 changes: 3 additions & 3 deletions pkg/auditlog/client.go → pkg/audittrail/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auditlog
package audittrail

import (
"bytes"
Expand All @@ -11,13 +11,13 @@ import (
"github.com/workos-inc/workos-go/internal/workos"
)

// Client represents a client that performs auditlog request to WorkOS API.
// Client represents a client that performs audittrail request to WorkOS API.
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
// The http.Client that is used to post audit trail events to WorkOS. Defaults
// to http.Client.
HTTPClient *http.Client

Expand Down
4 changes: 2 additions & 2 deletions pkg/auditlog/client_test.go → pkg/audittrail/client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auditlog
package audittrail

import (
"context"
Expand Down Expand Up @@ -127,7 +127,7 @@ func (h *defaultTestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Unit test to hit the prod api directly. Uncomment and provide an APIKey to
// test.
//
// func TestClientPubliPublishLive(t *testing.T) {
// func TestClientPublishLive(t *testing.T) {
// client := &Client{
// APIKey: "xxxxxx",
// }
Expand Down

0 comments on commit 8ad2e26

Please sign in to comment.