2016-05-27 23:27:54 +08:00
|
|
|
package rollbar
|
2016-05-24 22:32:42 +08:00
|
|
|
|
|
|
|
|
import "strconv"
|
|
|
|
|
|
|
|
|
|
type Event interface {
|
|
|
|
|
Tags() map[string]string
|
|
|
|
|
Fields() map[string]interface{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DummyEvent struct {
|
|
|
|
|
EventName string `json:"event_name"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-31 16:26:37 +08:00
|
|
|
type NewItemDataItemLastOccurrence struct {
|
2016-05-24 22:32:42 +08:00
|
|
|
Language string `json:"language"`
|
|
|
|
|
Level string `json:"level"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NewItemDataItem struct {
|
2024-05-31 16:26:37 +08:00
|
|
|
ID int `json:"id"`
|
|
|
|
|
Environment string `json:"environment"`
|
|
|
|
|
ProjectID int `json:"project_id"`
|
|
|
|
|
LastOccurrence NewItemDataItemLastOccurrence `json:"last_occurrence"`
|
2016-05-24 22:32:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NewItemData struct {
|
|
|
|
|
Item NewItemDataItem `json:"item"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NewItem struct {
|
|
|
|
|
EventName string `json:"event_name"`
|
|
|
|
|
Data NewItemData `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ni *NewItem) Tags() map[string]string {
|
|
|
|
|
return map[string]string{
|
|
|
|
|
"event": ni.EventName,
|
|
|
|
|
"environment": ni.Data.Item.Environment,
|
2021-03-02 05:04:35 +08:00
|
|
|
"project_id": strconv.Itoa(ni.Data.Item.ProjectID),
|
2024-05-31 16:26:37 +08:00
|
|
|
"language": ni.Data.Item.LastOccurrence.Language,
|
|
|
|
|
"level": ni.Data.Item.LastOccurrence.Level,
|
2016-05-24 22:32:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ni *NewItem) Fields() map[string]interface{} {
|
|
|
|
|
return map[string]interface{}{
|
2021-03-02 05:04:35 +08:00
|
|
|
"id": ni.Data.Item.ID,
|
2016-05-24 22:32:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-30 02:49:22 +08:00
|
|
|
type OccurrenceDataOccurrence struct {
|
|
|
|
|
Language string `json:"language"`
|
|
|
|
|
Level string `json:"level"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type OccurrenceDataItem struct {
|
2021-03-02 05:04:35 +08:00
|
|
|
ID int `json:"id"`
|
2017-09-30 02:49:22 +08:00
|
|
|
Environment string `json:"environment"`
|
2021-03-02 05:04:35 +08:00
|
|
|
ProjectID int `json:"project_id"`
|
2017-09-30 02:49:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type OccurrenceData struct {
|
|
|
|
|
Item OccurrenceDataItem `json:"item"`
|
|
|
|
|
Occurrence OccurrenceDataOccurrence `json:"occurrence"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Occurrence struct {
|
|
|
|
|
EventName string `json:"event_name"`
|
|
|
|
|
Data OccurrenceData `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *Occurrence) Tags() map[string]string {
|
|
|
|
|
return map[string]string{
|
|
|
|
|
"event": o.EventName,
|
|
|
|
|
"environment": o.Data.Item.Environment,
|
2021-03-02 05:04:35 +08:00
|
|
|
"project_id": strconv.Itoa(o.Data.Item.ProjectID),
|
2017-09-30 02:49:22 +08:00
|
|
|
"language": o.Data.Occurrence.Language,
|
|
|
|
|
"level": o.Data.Occurrence.Level,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *Occurrence) Fields() map[string]interface{} {
|
|
|
|
|
return map[string]interface{}{
|
2021-03-02 05:04:35 +08:00
|
|
|
"id": o.Data.Item.ID,
|
2017-09-30 02:49:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-24 22:32:42 +08:00
|
|
|
type DeployDataDeploy struct {
|
2021-03-02 05:04:35 +08:00
|
|
|
ID int `json:"id"`
|
2016-05-24 22:32:42 +08:00
|
|
|
Environment string `json:"environment"`
|
2021-03-02 05:04:35 +08:00
|
|
|
ProjectID int `json:"project_id"`
|
2016-05-24 22:32:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DeployData struct {
|
|
|
|
|
Deploy DeployDataDeploy `json:"deploy"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Deploy struct {
|
|
|
|
|
EventName string `json:"event_name"`
|
|
|
|
|
Data DeployData `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ni *Deploy) Tags() map[string]string {
|
|
|
|
|
return map[string]string{
|
|
|
|
|
"event": ni.EventName,
|
|
|
|
|
"environment": ni.Data.Deploy.Environment,
|
2021-03-02 05:04:35 +08:00
|
|
|
"project_id": strconv.Itoa(ni.Data.Deploy.ProjectID),
|
2016-05-24 22:32:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ni *Deploy) Fields() map[string]interface{} {
|
|
|
|
|
return map[string]interface{}{
|
2021-03-02 05:04:35 +08:00
|
|
|
"id": ni.Data.Deploy.ID,
|
2016-05-24 22:32:42 +08:00
|
|
|
}
|
|
|
|
|
}
|