Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: AB Test functionality #1058

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
}
Loading