@@ -210,16 +210,48 @@ func httpRequestMiddleware(event *bugsnaggo.Event, config *bugsnaggo.Configurati
210
210
return nil
211
211
}
212
212
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.
217
238
packages = append (packages , "main*" , "github.com/Shopify/goose/bugsnag" )
218
239
if _ , file , _ , ok := runtime .Caller (0 ); ok {
219
240
gooseMod := strings .TrimSuffix (file , "bugsnag/bugsnagger.go" )
220
241
packages = append (packages , gooseMod + "*" )
221
242
}
222
243
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
+
223
255
bugsnaggo .OnBeforeNotify (httpRequestMiddleware )
224
256
bugsnaggo .Configure (bugsnaggo.Configuration {
225
257
APIKey : apiKey ,
@@ -228,6 +260,7 @@ func (snagger *bugsnagger) Setup(apiKey string, commit string, env string, packa
228
260
ReleaseStage : env ,
229
261
Synchronous : true ,
230
262
PanicHandler : panicHandler ,
263
+ Endpoints : bo .endpoints ,
231
264
})
232
265
}
233
266
0 commit comments