Skip to content

Commit 37dd5db

Browse files
authored
Merge pull request #244 from Shopify/bugsnag_proxy_for_observe
Enable Bugsnag Proxy for Observe Error Management Beta
2 parents 7732e15 + 01d1a0d commit 37dd5db

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

.golangci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ linters-settings:
3838
# put imports beginning with prefix after 3rd-party packages;
3939
# it's a comma-separated list of prefixes
4040
local-prefixes: github.com/Shopify/goose
41-
golint:
42-
min-confidence: 0
4341
lll:
4442
line-length: 140
45-
maligned:
46-
suggest-new: true
4743
gosec:
4844
excludes:
4945
- G115

bugsnag/bugsnagger.go

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,48 @@ func httpRequestMiddleware(event *bugsnaggo.Event, config *bugsnaggo.Configurati
210210
return nil
211211
}
212212

213-
func (snagger *bugsnagger) Setup(apiKey string, commit string, env string, packages []string) {
214-
// Add the bugsnag package and it's folder location on disk to bugsnag's ProjectPackages.
215-
// This will ensure that Notify calls from bugsnagger.go will always share the same file name
216-
// and will retain grouping across Shopify/goose dependency upgrades.
213+
type bugsnagOpts struct {
214+
endpoints bugsnaggo.Endpoints
215+
}
216+
217+
type BugsnaggerOption func(opts *bugsnagOpts)
218+
219+
// WithEndpoints sets the endpoints for the bugsnag client
220+
func WithEndpoints(notifier bugsnaggo.Endpoints) BugsnaggerOption {
221+
return func(opts *bugsnagOpts) {
222+
opts.endpoints = notifier
223+
}
224+
}
225+
226+
// Setup initializes the bugsnag client with the given API key, commit, environment, and packages.
227+
// By default, it will use the endpoints for Shopify internal error analytics service.
228+
func (snagger *bugsnagger) Setup(
229+
apiKey string,
230+
commit string,
231+
env string,
232+
packages []string,
233+
opts ...BugsnaggerOption,
234+
) {
235+
// Add the bugsnag package and its folder location on disk to Bugsnag's ProjectPackages.
236+
// This ensures Notify calls from bugsnagger.go always share the same file name
237+
// and retain grouping across Shopify/goose dependency upgrades.
217238
packages = append(packages, "main*", "github.com/Shopify/goose/bugsnag")
218239
if _, file, _, ok := runtime.Caller(0); ok {
219240
gooseMod := strings.TrimSuffix(file, "bugsnag/bugsnagger.go")
220241
packages = append(packages, gooseMod+"*")
221242
}
222243

244+
var bo = &bugsnagOpts{
245+
endpoints: bugsnaggo.Endpoints{
246+
Notify: "https://error-analytics-production.shopifysvc.com",
247+
Sessions: "https://error-analytics-sessions-production.shopifysvc.com",
248+
},
249+
}
250+
251+
for _, opt := range opts {
252+
opt(bo)
253+
}
254+
223255
bugsnaggo.OnBeforeNotify(httpRequestMiddleware)
224256
bugsnaggo.Configure(bugsnaggo.Configuration{
225257
APIKey: apiKey,
@@ -228,6 +260,7 @@ func (snagger *bugsnagger) Setup(apiKey string, commit string, env string, packa
228260
ReleaseStage: env,
229261
Synchronous: true,
230262
PanicHandler: panicHandler,
263+
Endpoints: bo.endpoints,
231264
})
232265
}
233266

0 commit comments

Comments
 (0)