Skip to content

Commit

Permalink
feat: AB Test functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
noahmmcgivern committed Sep 27, 2023
1 parent a8b0fd1 commit cda67b2
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
3 changes: 3 additions & 0 deletions newrelic/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

log "github.com/sirupsen/logrus"

abtest "github.com/newrelic/newrelic-client-go/v2/pkg/abTest"
"github.com/newrelic/newrelic-client-go/v2/pkg/accountmanagement"
"github.com/newrelic/newrelic-client-go/v2/pkg/accounts"
"github.com/newrelic/newrelic-client-go/v2/pkg/agentapplications"
Expand Down Expand Up @@ -40,6 +41,7 @@ import (

// NewRelic is a collection of New Relic APIs.
type NewRelic struct {
AbTest abtest.AbTest
AccountManagement accountmanagement.Accountmanagement
AgentApplications agentapplications.AgentApplications
Accounts accounts.Accounts
Expand Down Expand Up @@ -94,6 +96,7 @@ func New(opts ...ConfigOption) (*NewRelic, error) {
nr := &NewRelic{
config: cfg,

AbTest: abtest.New(cfg),
AccountManagement: accountmanagement.New(cfg),
AgentApplications: agentapplications.New(cfg),
Accounts: accounts.New(cfg),
Expand Down
25 changes: 25 additions & 0 deletions pkg/abTest/abTest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Manually added
package abtest

import (
"github.com/newrelic/newrelic-client-go/v2/internal/http"
"github.com/newrelic/newrelic-client-go/v2/pkg/config"
"github.com/newrelic/newrelic-client-go/v2/pkg/logging"
)

type AbTest struct {
client http.Client
logger logging.Logger
}

// New is used to create a new Ab Test.
func New(config config.Config) AbTest {
client := http.NewClient(config)

pkg := AbTest{
client: client,
logger: config.GetLogger(),
}

return pkg
}
49 changes: 49 additions & 0 deletions pkg/abTest/abTest_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pkg/abTest/abTest_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Manually added types
package abtest

// AbTestGetVariationResponse - A response returning a VariationKey and a potential array of abTestError
type AbTestGetVariationResponse struct {
// An array of errors
Errors []abTestError `json:"errors,omitempty"`
// Variation key denoted the inclusion status of an accountId for a given experiment
VariationKey string `json:"variationKey,omitempty"`
}

// abTestError - An error Message combined with its Type of error
type abTestError struct {
// A description of the error
Message string `json:"message"`
// The kind of error which occurred
Type string `json:"type"`
}

0 comments on commit cda67b2

Please sign in to comment.