Skip to content

Commit

Permalink
chore: set knock user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
vlymar committed May 21, 2024
1 parent 04b10db commit a4904bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions knock/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"

"github.com/hashicorp/go-cleanhttp"
"github.com/knocklabs/knock-go/knock/internal"
)

const (
Expand Down Expand Up @@ -122,6 +124,8 @@ func NewClient(opts ...ClientOption) (*Client, error) {
// do makes an HTTP request and populates the given struct v from the response.
func (c *Client) do(ctx context.Context, req *http.Request, v interface{}) ([]byte, error) {
req = req.WithContext(ctx)
req.Header.Set("User-Agent", fmt.Sprintf("knocklabs/go@%s", internal.SDKVersion))

res, err := c.client.Do(req)
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions knock/internal/sdk_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package internal

// This is used for formatting the SDK's user agent. It should be updated before
// releasing new versions of the SDK. Eventually we can automate this process.
const SDKVersion = "0.1.16"

0 comments on commit a4904bb

Please sign in to comment.