forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanic.go
More file actions
33 lines (28 loc) · 917 Bytes
/
Copy pathpanic.go
File metadata and controls
33 lines (28 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package gateway
import (
"context"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/errors"
)
func (g *Gateway) SendPanic(ctx context.Context, req *entity.PanicRequest) (bool, error) {
gqlReq, err := g.NewRequestWithAuth(`
mutation($command: String!, $error: String!, $stacktrace: String!, $projectId: String, $environmentId: String) {
sendTelemetry(command: $command, error: $error, stacktrace: $stacktrace, projectId: $projectId, environmentId: $environmentId)
}
`)
if err != nil {
return false, err
}
gqlReq.Var("command", req.Command)
gqlReq.Var("error", req.PanicError)
gqlReq.Var("stacktrace", req.Stacktrace)
gqlReq.Var("projectId", req.ProjectID)
gqlReq.Var("environmentId", req.EnvironmentID)
var resp struct {
Status bool `json:"sendTelemetry"`
}
if err := gqlReq.Run(ctx, &resp); err != nil {
return false, errors.TelemetryFailed
}
return resp.Status, nil
}