warnly

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package warnly provides the core types and interfaces for the Warnly application. It is a so-called root package, other layers speak using this package, not each other.

Index

Constants

View Source
const DefaultMessage = "(No error message)"

DefaultMessage is used when we can't get the error message from stacktrace.

View Source
const DefaultTeamID = 1
View Source
const (
	HTTPMethodUndefined uint8 = 10
)
View Source
const PageSize = 5
View Source
const (
	QueueTopic = "warnly.queue"
)

Variables

View Source
var AllowedIssuesTypes = [...]IssuesType{IssuesTypeAll, IssuesTypeNew}
View Source
var AllowedPriorities = [...]IssuePriority{
	PriorityLow,
	PriorityMedium,
	PriorityHigh,
}
View Source
var ErrConsumerAlreadyRunning = errors.New("consumer.Run: consumer already running")

ErrConsumerAlreadyRunning is returned by consumer.Run if it has already been called.

View Source
var ErrDuplicate = errors.New("entity already exists in a database")

ErrDuplicate is returned when an entity already exists in a database.

View Source
var ErrInvalidAuthMethod = errors.New("invalid authentication method")

ErrInvalidAuthMethod is returned when the provided authentication method is invalid.

View Source
var ErrInvalidLoginCredentials = errors.New("invalid login credentials")

ErrInvalidLoginCredentials is returned when the provided login credentials are invalid.

View Source
var ErrNotFound = errors.New("entity was not found in database")

ErrNotFound is returned when an entity is not found in the database. It overrides sql.ErrNoRows to avoid leaking database implementation details.

View Source
var ErrProjectNotFound = errors.New("project not found")

ErrProjectNotFound is an error that is returned when the project is not found.

Functions

func Cut

func Cut(s string, n int) string

func GetBreaker

func GetBreaker(exceptions []Exception) string

func GetExceptionFramesAbsPath

func GetExceptionFramesAbsPath(exceptions []Exception) []string

GetExceptionFramesAbsPath is a exception_frames.abs_path.

func GetExceptionFramesColNo

func GetExceptionFramesColNo(exceptions []Exception) []uint32

func GetExceptionFramesFilename

func GetExceptionFramesFilename(exceptions []Exception) []string

func GetExceptionFramesFunction

func GetExceptionFramesFunction(exceptions []Exception) []string

func GetExceptionFramesLineNo

func GetExceptionFramesLineNo(exceptions []Exception) []uint32

func GetExceptionStackTypes

func GetExceptionStackTypes(exceptions []Exception) []string

GetExceptionStackTypes returns a list of exception stack types.

func GetExceptionStackValues

func GetExceptionStackValues(exceptions []Exception) []string

GetExceptionStackValues returns a list of exception stack values.

func GetExceptionType

func GetExceptionType(exceptions []Exception, defaultVal string) string

func GetExceptionValue

func GetExceptionValue(exceptions []Exception, defaultVal string) string

func GetHash

func GetHash(event *EventBody) (string, error)

func GetHashByMessage

func GetHashByMessage(event *EventBody) (string, error)

func GetHashByNormalizedMessage

func GetHashByNormalizedMessage(event *EventBody) (string, error)

func GetHashByNormalizedStackTrace

func GetHashByNormalizedStackTrace(event *EventBody) (string, error)

func GetHashByStackTrace

func GetHashByStackTrace(event *EventBody) (string, error)

func GetNormalizedHash

func GetNormalizedHash(event *EventBody) (string, error)

func GetSDKID

func GetSDKID(name string) uint8

func IsAllowedIssueType

func IsAllowedIssueType(issueType IssuesType) bool

IsAllowedIssueType checks whether provided issueType argument is included into predefined issue types allowed list.

func MustNanoID

func MustNanoID() string

MustNanoID is the same as New, but panics on error.

func NewNanoID

func NewNanoID() (string, error)

NewNanoID generates a new random ID. It returns an error if the ID generation fails.

func NormalizeMessage

func NormalizeMessage(message string) string

NormalizeMessage normalizes an error message for grouping.

func NumFormatted

func NumFormatted[T int | int64 | uint64 | float64](num T) string

func ParseDuration

func ParseDuration(input string) (time.Duration, error)

ParseDuration parses a string like "2h", "2d", "1w" into a time.Duration. The returned duration is always positive.

func ParseTimeRange

func ParseTimeRange(start, end string) (time.Time, time.Time, error)

ParseTimeRange parses a time range from two strings in the format "2006-01-02T15:04:05".

func TimeAgo

func TimeAgo(now func() time.Time, t time.Time, narrow bool) string

TimeAgo returns a human-readable string representing the time since the issue was last seen.

func UsernameFromEmail added in v0.2.0

func UsernameFromEmail(email string) (string, error)

UsernameFromEmail returns the username from the email.

func ValidateNanoID

func ValidateNanoID(fieldName, id string) error

ValidateNanoID validates a given ID.

Types

type Alert added in v0.5.0

type Alert struct {
	CreatedAt          time.Time
	UpdatedAt          time.Time
	LastTriggeredAt    *time.Time
	ResolvedAt         *time.Time
	NotificationSentAt *time.Time
	RuleName           string
	Description        string
	Status             AlertStatus
	ID                 int
	ProjectID          int
	TeamID             int
	Threshold          int
	Condition          AlertCondition // 1 = occurrences, 2 = users affected
	Timeframe          AlertTimeframe // 1=1min, 2=5min, 3=15min, 4=1h, 5=1d, 6=1w, 7=30d
	HighPriority       bool
}

Alert represents an alert rule.

func (*Alert) GetTimeframeDuration added in v0.5.0

func (a *Alert) GetTimeframeDuration() time.Duration

GetTimeframeDuration returns the duration for the timeframe.

type AlertCondition added in v0.5.0

type AlertCondition int
const (
	// AlertConditionOccurrences - when threshold number of occurrences is reached.
	AlertConditionOccurrences AlertCondition = 1
	// AlertConditionUsers - when threshold number of users is affected.
	AlertConditionUsers AlertCondition = 2
)

type AlertLock added in v0.5.0

type AlertLock struct {
	LockedAt   time.Time
	ExpiresAt  time.Time
	InstanceID string
	AlertID    int
}

AlertLock represents a distributed lock for alert processing.

type AlertNotification added in v0.5.0

type AlertNotification struct {
	CreatedAt        time.Time
	SentAt           *time.Time
	NotificationType AlertNotificationType
	Status           AlertNotificationStatus
	ErrorMessage     string
	ID               int64
	AlertID          int
	ChannelID        int
}

AlertNotification represents an alert notification record.

type AlertNotificationStatus added in v0.5.0

type AlertNotificationStatus string

AlertNotificationStatus represents the status of alert notification.

const (
	// AlertNotificationPending represents a pending notification.
	AlertNotificationPending AlertNotificationStatus = "pending"
	// AlertNotificationSent represents a sent notification.
	AlertNotificationSent AlertNotificationStatus = "sent"
	// AlertNotificationFailed represents a failed notification.
	AlertNotificationFailed AlertNotificationStatus = "failed"
)

type AlertNotificationType added in v0.5.0

type AlertNotificationType string

AlertNotificationType represents the type of alert notification.

const (
	// AlertNotificationTriggered represents a triggered alert notification.
	AlertNotificationTriggered AlertNotificationType = "triggered"
	// AlertNotificationResolved represents a resolved alert notification.
	AlertNotificationResolved AlertNotificationType = "resolved"
)

type AlertService added in v0.5.0

type AlertService interface {
	// ListAlerts returns a list of alerts for the given criteria.
	ListAlerts(ctx context.Context, req *ListAlertsRequest) (*ListAlertsResult, error)
	// CreateAlert creates a new alert.
	CreateAlert(ctx context.Context, req *CreateAlertRequest) (*Alert, error)
	// UpdateAlert updates an existing alert.
	UpdateAlert(ctx context.Context, req *UpdateAlertRequest) (*Alert, error)
	// DeleteAlert deletes an alert by ID.
	DeleteAlert(ctx context.Context, alertID int, user *User) error
	// GetAlert returns an alert by ID.
	GetAlert(ctx context.Context, alertID int, user *User) (*Alert, error)
}

AlertService encapsulates service domain logic.

type AlertStatus added in v0.5.0

type AlertStatus string
const (
	// AlertStatusActive represents an active alert.
	AlertStatusActive AlertStatus = "Active"
	// AlertStatusInactive represents an inactive alert.
	AlertStatusInactive AlertStatus = "Inactive"
	// AlertStatusTriggered represents a triggered alert.
	AlertStatusTriggered AlertStatus = "Triggered"
)

type AlertStore added in v0.5.0

type AlertStore interface {
	// ListAlerts returns a list of alerts for the given criteria.
	ListAlerts(ctx context.Context, teamIDs []int, projectName string, offset, limit int) ([]Alert, int, error)
	// CreateAlert creates a new alert.
	CreateAlert(ctx context.Context, alert *Alert) error
	// UpdateAlert updates an existing alert.
	UpdateAlert(ctx context.Context, alert *Alert) error
	// DeleteAlert deletes an alert by ID.
	DeleteAlert(ctx context.Context, alertID int) error
	// GetAlert returns an alert by ID.
	GetAlert(ctx context.Context, alertID int) (*Alert, error)
	// ListAlertsByProject returns alerts for a project.
	ListAlertsByProject(ctx context.Context, projectID int) ([]Alert, error)
}

AlertStore encapsulates the alert storage.

type AlertTimeframe added in v0.5.0

type AlertTimeframe int
const (
	// AlertTimeframe1Min - 1 minute.
	AlertTimeframe1Min AlertTimeframe = 1
	// AlertTimeframe5Min - 5 minutes.
	AlertTimeframe5Min AlertTimeframe = 2
	// AlertTimeframe15Min - 15 minutes.
	AlertTimeframe15Min AlertTimeframe = 3
	// AlertTimeframe1Hour - 1 hour.
	AlertTimeframe1Hour AlertTimeframe = 4
	// AlertTimeframe1Day - 1 day.
	AlertTimeframe1Day AlertTimeframe = 5
	// AlertTimeframe1Week - 1 week.
	AlertTimeframe1Week AlertTimeframe = 6
	// AlertTimeframe30Days - 30 days.
	AlertTimeframe30Days AlertTimeframe = 7
)

type AnalyticsStore

type AnalyticsStore interface {
	// CalculateEvents calculates the number of events per day split by hour.
	CalculateEvents(ctx context.Context, criteria *ListIssueMetricsCriteria) ([]EventsPerHour, error)
	// ListIssueMetrics lists issue metrics for the given project IDs and issue IDs within the specified time range.
	// It displays how many times each issue was seen, when it was first and last seen
	// and the number of unique users affected.
	ListIssueMetrics(ctx context.Context, criteria *ListIssueMetricsCriteria) ([]IssueMetrics, error)
	// CalculateEventsPerDay calculates the number of events per day for a given issue and project
	// within a specified time range.
	CalculateEventsPerDay(ctx context.Context, criteria *EventDefCriteria) ([]EventPerDay, error)
	// CountFields counts additional fields for a given issue and project within a specified time range.
	CountFields(ctx context.Context, criteria *EventDefCriteria) ([]FieldValueNum, error)
	// CalculateFields calculates the number of occurrences of each field for a given group and project
	// within a specified time range.
	CalculateFields(ctx context.Context, criteria FieldsCriteria) ([]TagCount, error)
	// GetIssueEvent retrieves a single event associated with a specific issue and project within a given time range.
	GetIssueEvent(ctx context.Context, criteria *EventDefCriteria) (*IssueEvent, error)
	// CountEvents counts the number of events based on the given criteria.
	CountEvents(ctx context.Context, criteria *EventCriteria) (uint64, error)
	// ListEvents lists error events based on the given criteria.
	ListEvents(ctx context.Context, criteria *EventCriteria) ([]EventEntry, error)
	// ListSlowQueries lists olap slow SQL queries from the system.
	ListSlowQueries(ctx context.Context) ([]SQLQuery, error)
	// ListSchemas lists olap database schemas from largest to smallest.
	ListSchemas(ctx context.Context) ([]Schema, error)
	// ListErrors lists recent errors from olap system.
	ListErrors(ctx context.Context, criteria ListErrorsCriteria) ([]AnalyticsStoreErr, error)
	// StoreEvent stores an event in the analytics database.
	StoreEvent(ctx context.Context, event *EventClickhouse) error
	// ListFieldFilters lists field filters for a given project.
	ListFieldFilters(ctx context.Context, criteria *FieldFilterCriteria) ([]Filter, error)
	// ListPopularTags lists popular tag keys across all events.
	ListPopularTags(ctx context.Context, criteria *ListPopularTagsCriteria) ([]TagCount, error)
	// ListTagValues lists popular values for a given tag.
	ListTagValues(ctx context.Context, criteria *ListTagValuesCriteria) ([]TagValueCount, error)
	// GetFilteredGroupIDs returns group IDs that match the query filters.
	GetFilteredGroupIDs(ctx context.Context, tokens []QueryToken, from, to time.Time, projectIDs []int) ([]int64, error)
	// GetEventPagination returns the pagination for an event.
	GetEventPagination(ctx context.Context, c *EventPaginationCriteria) (*EventPagination, error)
}

AnalyticsStore encapsulate the storage of analytics data. Generally speaking, it can be either clickhouse or druid or any other storage.

type AnalyticsStoreErr

type AnalyticsStoreErr struct {
	MaxLastErrorTime time.Time
	Name             string
	Count            uint64
}

AnalyticsStoreErr represents an error entry in the analytics store.

type AssignIssueRequest

type AssignIssueRequest struct {
	User      *User `json:"user"`
	IssueID   int   `json:"issue_id"`
	ProjectID int   `json:"project_id"`
	UserID    int   `json:"user_id"`
}

AssignIssueRequest represents the request to assign an issue to a user.

type AssignedUser

type AssignedUser struct {
	IssueID          int64
	AssignedToUserID sql.NullInt64
}

AssignedUser represents the result of assigned user to an issue.

type Assignment

type Assignment struct {
	AssignedAt       time.Time `json:"assigned_at"`
	IssueID          int64     `json:"issue_id"`
	AssignedToUserID int64     `json:"assigned_to_user_id"`
	AssignedToTeamID int64     `json:"assigned_to_team_id"`
	AssignedByUserID int64     `json:"assigned_by_user_id"`
}

Assignment represents the assignment of an issue to a user.

type Assignments

type Assignments struct {
	IssueToAssigned map[int64]*Teammate
}

func (*Assignments) AssignedUser

func (a *Assignments) AssignedUser(issueID int64) (*Teammate, bool)

AssignedUser returns the assigned user for the given issue.

type AssingmentStore

type AssingmentStore interface {
	// CreateAssingment creates a new issue assignment in the database.
	CreateAssingment(ctx context.Context, assignment *Assignment) error
	// DeleteAssignment unassigns an issue from a user.
	DeleteAssignment(ctx context.Context, issueID int64) error
	// ListAssingments lists all assignments for a given issue.
	ListAssingments(ctx context.Context, issueIDs []int64) ([]*AssignedUser, error)
	// ListAssignedFilters gets filters for assigned issues.
	ListAssignedFilters(ctx context.Context, criteria *GetAssignedFiltersCriteria) ([]Filter, error)
}

AssingmentStore is the interface for the assignment storage.

type AuthMethod added in v0.2.0

type AuthMethod string

AuthMethod represents the authentication method.

const (
	// AuthMethodInternal is the default authentication method.
	AuthMethodInternal AuthMethod = "internal"
	// AuthMethodOIDC is the authentication method for OIDC.
	AuthMethodOIDC AuthMethod = "oidc"
)

type Consumer added in v0.6.0

type Consumer interface {
	// Run executes the consumer in a blocking manner. Returns
	// ErrConsumerAlreadyRunning when it has already been called.
	Run(ctx context.Context) error
	// Healthy returns an error if the consumer isn't healthy.
	Healthy(ctx context.Context) error
	// Close closes the consumer.
	Close() error
}

Consumer wraps the implementation details of the consumer implementation. Consumer implementations must support the defined delivery types.

type Contexts

type Contexts struct {
	OS      OSContext      `json:"os"`
	Device  DeviceContext  `json:"device"`
	Runtime RuntimeContext `json:"runtime"`
}

Contexts represents the various context details.

type CreateAlertRequest added in v0.5.0

type CreateAlertRequest struct {
	User         *User
	RuleName     string
	ProjectID    int
	Threshold    int
	Condition    AlertCondition
	Timeframe    AlertTimeframe
	HighPriority bool
}

CreateAlertRequest is a request to create a new alert.

type CreateMessageRequest

type CreateMessageRequest struct {
	User           *User
	Content        string
	MentionedUsers []int
	ProjectID      int
	IssueID        int
}

type CreateProjectRequest

type CreateProjectRequest struct {
	Platform     string `schema:"platform,required"    validate:"required,gt=0,lt=32"`
	ProjectName  string `schema:"projectName,required" validate:"required,gt=0,lt=32"`
	Threshold    int    `schema:"threshold,required"   validate:"required,gt=0,lt=1000000"`
	Condition    int    `schema:"condition,required"   validate:"required,gt=0,lt=3"`
	Timeframe    int    `schema:"timeframe,required"   validate:"required,gt=0,lt=8"`
	TeamID       int    `schema:"team,required"        validate:"required,gt=0"`
	HighPriority bool   `schema:"highPriority"`
}

CreateProjectRequest is a request to create a new project. platform=go&highPriority=false&threshold=10&condition=1&timeframe=1&projectName=golang&team=1.

type Credentials

type Credentials struct {
	Identifier string // Can be email or username
	Password   string
	Token      string
	RememberMe bool
}

Credentials represents user login credentials.

type DeleteMessageRequest

type DeleteMessageRequest struct {
	User      *User
	MessageID int
	ProjectID int
	IssueID   int
}

type DeliveryType added in v0.6.0

type DeliveryType uint8

DeliveryType for the consumer. For more details See the supported DeliveryTypes.

const (
	// AtMostOnceDeliveryType acknowledges the message as soon as it's received
	// and decoded, without waiting for the message to be processed.
	AtMostOnceDeliveryType DeliveryType = iota
	// AtLeastOnceDeliveryType acknowledges the message after it has been
	// processed. It may or may not create duplicates, depending on how batches
	// are processed by the underlying Processor.
	AtLeastOnceDeliveryType
)

type DeviceContext

type DeviceContext struct {
	Arch   string `json:"arch"`
	NumCPU int    `json:"num_cpu"`
}

DeviceContext represents device-specific information.

type Discussion

type Discussion struct {
	Info      DiscussionInfo
	Teammates []Teammate
	Messages  []IssueMessage
}

type DiscussionInfo

type DiscussionInfo struct {
	IssueFirstSeen time.Time
	ProjectID      int
	IssueID        int
}

type Event

type Event struct {
	EventID string    `json:"event_id"`
	SentAt  time.Time `json:"sent_at"`
	DSN     string    `json:"dsn"`
	SDK     SDK       `json:"sdk"`
	Trace   Trace     `json:"trace"`
}

Event represents the main event structure.

type EventBody

type EventBody struct {
	Timestamp   SentryTimestamp   `json:"timestamp"`
	Modules     map[string]string `json:"modules"`
	Tags        map[string]string `json:"tags"`
	User        EventUser         `json:"user"`
	Message     string            `json:"message"`
	Platform    string            `json:"platform"`
	Release     string            `json:"release"`
	ServerName  string            `json:"server_name"`
	Level       string            `json:"level"`
	EventID     string            `json:"event_id"`
	Environment string            `json:"environment"`
	SDK         SDKBody           `json:"sdk"`
	Exception   ExceptionList     `json:"exception"`
	Threads     ThreadList        `json:"threads"`
	Extra       map[string]any    `json:"extra"`
	Contexts    Contexts          `json:"contexts"`
}

EventBody represents the main event structure. This is the structure that is sent to the Warnly server.

func (*EventBody) GetThreadFrames added in v0.6.1

func (e *EventBody) GetThreadFrames() []Frame

type EventClickhouse

type EventClickhouse struct {
	CreatedAt               time.Time  `ch:"created_at" json:"created_at"`
	SDKVersion              string     `ch:"sdk_version" json:"sdk_version"`
	User                    string     `ch:"user" json:"user"`
	UserEmail               string     `ch:"user_email" json:"user_email"`
	UserName                string     `ch:"user_name" json:"user_name"`
	UserUsername            string     `ch:"user_username" json:"user_username"`
	PrimaryHash             string     `ch:"primary_hash" json:"primary_hash"`
	Env                     string     `ch:"env" json:"env"`
	EventID                 string     `ch:"event_id" json:"event_id"`
	Message                 string     `ch:"message" json:"message"`
	IPv6                    string     `ch:"ipv6" json:"ipv6"`
	Release                 string     `ch:"release" json:"release"`
	Title                   string     `ch:"title" json:"title"`
	IPv4                    string     `ch:"ipv4" json:"ipv4"`
	ExceptionFramesInApp    Uint8Array `ch:"exception_frames.in_app" json:"exception_frames.in_app"`
	ContextsKey             []string   `ch:"contexts.key" json:"contexts.key"`
	ExceptionFramesColNo    []uint32   `ch:"exception_frames.colno" json:"exception_frames.colno"`
	ExceptionFramesAbsPath  []string   `ch:"exception_frames.abs_path" json:"exception_frames.abs_path"`
	ExceptionFramesLineNo   []uint32   `ch:"exception_frames.lineno" json:"exception_frames.lineno"`
	ExceptionStacksType     []string   `ch:"exception_stacks.type" json:"exception_stacks.type"`
	ExceptionStacksValue    []string   `ch:"exception_stacks.value" json:"exception_stacks.value"`
	TagsKey                 []string   `ch:"tags.key" json:"tags.key"`
	ExceptionFramesFunction []string   `ch:"exception_frames.function" json:"exception_frames.function"`
	TagsValue               []string   `ch:"tags.value" json:"tags.value"`
	ExceptionFramesFilename []string   `ch:"exception_frames.filename" json:"exception_frames.filename"`
	ContextsValue           []string   `ch:"contexts.value" json:"contexts.value"`
	GroupID                 uint64     `ch:"gid" json:"gid"`
	ProjectID               uint16     `ch:"pid" json:"pid"`
	Level                   uint8      `ch:"level" json:"level"`
	Type                    uint8      `ch:"type" json:"type"`
	SDKID                   uint8      `ch:"sdk_id" json:"sdk_id"`
	Platform                uint8      `ch:"platform" json:"platform"`
	RetentionDays           uint8      `ch:"retention_days" json:"retention_days"`
	Deleted                 uint8      `ch:"deleted" json:"deleted"`
}

EventClickhouse represents the event structure for ClickHouse storage. It is what ingested into ClickHouse as error events after normalization and processing.

type EventCriteria

type EventCriteria struct {
	From      time.Time
	To        time.Time
	Tags      map[string]QueryValue
	Message   string
	ProjectID int
	GroupID   int
	Limit     int
	Offset    int
}

EventCriteria represents the criteria for querying events.

type EventDefCriteria

type EventDefCriteria struct {
	From      time.Time
	To        time.Time
	EventID   string
	GroupID   int
	ProjectID int
}

EventDefCriteria represents the criteria for querying events.

type EventEntry

type EventEntry struct {
	CreatedAt    time.Time
	EventID      string
	Title        string
	Message      string
	Release      string
	Env          string
	UserEmail    string
	UserUsername string
	User         string
	UserName     string
	OS           string
}

EventEntry represents an event entry in the analytics store.

func (*EventEntry) DisplayUser

func (e *EventEntry) DisplayUser() string

DisplayUser returns a string representation of the user associated with the event. The order of preference is email, username, id, name, and finally "(unknown)" if none are available.

type EventPagination added in v0.5.0

type EventPagination struct {
	NextEventID  string
	PrevEventID  string
	FirstEventID string
	LastEventID  string
}

type EventPaginationCriteria added in v0.5.0

type EventPaginationCriteria struct {
	CreatedAt time.Time
	From      time.Time
	To        time.Time
	EventID   string
	ProjectID int
	GroupID   int
}

type EventPerDay

type EventPerDay struct {
	Time  time.Time
	GID   uint64
	Count uint64
}

EventPerDay represents the number of events per day.

type EventService

type EventService interface {
	// IngestEvent ingests and stores a new event in both OLTP and OLAP databases.
	IngestEvent(ctx context.Context, req IngestRequest) (IngestEventResult, error)
}

EventService defines the interface for event-related operations.

type EventType

type EventType = uint8
const (
	EventTypeException EventType = iota + 1
)

type EventUser

type EventUser struct {
	Data      map[string]string `json:"data"`
	ID        string            `json:"id"`
	Email     string            `json:"email"`
	IPAddress string            `json:"ip_address"`
	Username  string            `json:"username"`
	Name      string            `json:"name"`
}

EventUser represents user information associated with an event.

type EventsList

type EventsList []EventsPerHour

func (EventsList) DashboardData

func (e EventsList) DashboardData(now func() time.Time) string

DashboardData returns the data for frontend dashboard (24h period).

func (EventsList) DashboardDataForPeriod

func (e EventsList) DashboardDataForPeriod(now func() time.Time, period string) string

DashboardDataForPeriod returns the data for frontend dashboard adapted to the given period. Returns JSON array of [timestamps, counts] like: [[t1,t2,t3...], [c1,c2,c3...]].

func (EventsList) TotalErrors

func (e EventsList) TotalErrors() string

TotalErrors returns the total number of errors.

type EventsPerHour

type EventsPerHour struct {
	TS        time.Time
	ProjectID int
	Count     int
}

EventsPerHour represents the number of events per hour.

type Exception

type Exception struct {
	Type       string     `json:"type"`
	Value      string     `json:"value"`
	StackTrace StackTrace `json:"stacktrace"`
}

Exception represents an individual exception.

func NormalizeStackTrace

func NormalizeStackTrace(exceptions []Exception) []Exception

NormalizeStackTrace normalizes stack trace for consistent grouping.

type ExceptionList added in v0.6.1

type ExceptionList []Exception

ExceptionList handles both Sentry exception formats: - flat array: [{"type": "Error", ...}] - object with values: {"values": [{"type": "Error", ...}]}.

func (*ExceptionList) UnmarshalJSON added in v0.6.1

func (e *ExceptionList) UnmarshalJSON(data []byte) error

type Field

type Field struct{}

type FieldFilterCriteria

type FieldFilterCriteria struct {
	From       time.Time
	To         time.Time
	ProjectIDs []int
}

type FieldValueNum

type FieldValueNum struct {
	FirstSeen       time.Time
	LastSeen        time.Time
	Tag             string
	Value           string
	Count           uint64
	PercentsOfTotal float64
}

FieldValueNum represents a tag value and its associated metrics.

func ListTagValues

func ListTagValues(tag string, tv []FieldValueNum) []FieldValueNum

func (*FieldValueNum) PercentsFormatted

func (t *FieldValueNum) PercentsFormatted() string

type FieldsCriteria

type FieldsCriteria struct {
	From      time.Time
	To        time.Time
	IssueID   int
	ProjectID int
}

FieldsCriteria represents the criteria for querying fields.

type Filter

type Filter struct {
	Key      string
	Operator string
	Value    string
}

type Frame

type Frame struct {
	Function    string   `json:"function"`
	Module      string   `json:"module"`
	Package     string   `json:"package"`
	AbsPath     string   `json:"abs_path"`
	ContextLine string   `json:"context_line"`
	PreContext  []string `json:"pre_context"`
	PostContext []string `json:"post_context"`
	LineNo      uint32   `json:"lineno"`
	InApp       bool     `json:"in_app"`
}

Frame represents a single frame in the stack trace.

func (*Frame) GetModule added in v0.6.1

func (f *Frame) GetModule() string

GetModule returns Module if set, otherwise falls back to Package (used by Rust SDK).

type GetAssignedFiltersCriteria

type GetAssignedFiltersCriteria struct {
	CurrentUserTeamIDs []int
}

type GetDiscussionsRequest

type GetDiscussionsRequest struct {
	User      *User
	ProjectID int
	IssueID   int
}

type GetIssueCriteria

type GetIssueCriteria struct {
	// required.
	Hash string
	// required.
	ProjectID int
}

GetIssueCriteria is used to specify criteria for fetching an issue.

type GetIssueRequest

type GetIssueRequest struct {
	User      *User
	Period    string
	EventID   string
	Source    GetIssueRequestSource
	ProjectID int
	IssueID   int
}

type GetIssueRequestSource

type GetIssueRequestSource string
const (
	GetIssueRequestSourceIssue GetIssueRequestSource = "issue"
)

type GetOrCreateUserRequest added in v0.2.0

type GetOrCreateUserRequest struct {
	Email    string
	Username string
	Name     string
	Surname  string
}

GetOrCreateUserRequest represents a request to get or create a user.

type GroupMetrics

type GroupMetrics struct {
	FirstSeen time.Time
	LastSeen  time.Time
	GID       int
	TimesSeen int
	Users     int
}

GroupMetrics represents the metrics of the group.

type IngestEventResult

type IngestEventResult struct {
	// EventID is the ID of the ingested event.
	EventID string
}

type IngestRequest

type IngestRequest struct {
	Event      *EventBody
	IP         string
	ProjectKey string
	ProjectID  int
}

IngestRequest is a request to ingest a new event.

type Issue

type Issue struct {
	FirstSeen   time.Time     `json:"first_seen"`
	LastSeen    time.Time     `json:"last_seen"`
	Hash        string        `json:"hash"`
	Message     string        `json:"message"`
	View        string        `json:"view"`
	ErrorType   string        `json:"error_type"`
	UUID        UUID          `json:"uuid"`
	ID          int64         `json:"id"`
	NumComments int           `json:"num_comments"`
	ProjectID   int           `json:"project_id"`
	Priority    IssuePriority `json:"priority"`
}

Issue represents a collection of error events mapped by their hash.

type IssueDetails

type IssueDetails struct {
	LastSeen      time.Time
	FirstSeen     time.Time
	LastEvent     *IssueEvent
	Assignments   *Assignments
	Request       *GetIssueRequest
	NextEventID   *string
	PrevEventID   *string
	FirstEventID  *string
	LastEventID   *string
	View          string
	ErrorValue    string
	Message       string
	ErrorType     string
	ProjectName   string
	TagCount      []TagCount
	TagValueNum   []FieldValueNum
	Teammates     []Teammate
	StackDetails  []StackDetail
	ProjectID     int
	Total24Hours  uint64
	Priority      IssuePriority
	Total30Days   uint64
	IssueID       int64
	MessagesCount int
	TimesSeen     uint64
	UserCount     uint64
	IsNew         bool
	Platform      Platform
}

func (*IssueDetails) Contexts added in v0.2.0

func (id *IssueDetails) Contexts() map[string]string

func (*IssueDetails) EventID

func (id *IssueDetails) EventID() string

func (*IssueDetails) GetPlatform

func (id *IssueDetails) GetPlatform() string

func (*IssueDetails) HasStackDetails

func (id *IssueDetails) HasStackDetails() bool

func (*IssueDetails) ListTagValues

func (id *IssueDetails) ListTagValues(tag string) []FieldValueNum

func (*IssueDetails) ProgressLen

func (id *IssueDetails) ProgressLen(val string) string

func (*IssueDetails) StackHidden

func (id *IssueDetails) StackHidden() []StackDetail

func (*IssueDetails) StackVisible

func (id *IssueDetails) StackVisible() []StackDetail

func (*IssueDetails) Tag

func (id *IssueDetails) Tag(tag string) string

func (*IssueDetails) TagKeyValue

func (id *IssueDetails) TagKeyValue() []TagKeyValue

type IssueEntry

type IssueEntry struct {
	LastSeen      time.Time
	FirstSeen     time.Time
	Type          string
	View          string
	Message       string
	ID            int64
	TimesSeen     uint64
	UserCount     uint64
	ProjectID     int
	MessagesCount int
}

IssueEntry is how we represent an issue in the system.

type IssueEvent

type IssueEvent struct {
	UserID                  string
	UserEmail               string
	UserName                string
	UserUsername            string
	EventID                 string
	CreatedAt               time.Time
	Env                     string
	Release                 string
	TagsKey                 []string
	TagsValue               []string
	ContextsKey             []string
	ContextsValue           []string
	Message                 string
	ExceptionFramesAbsPath  []string
	ExceptionFramesColno    []int
	ExceptionFramesFunction []string
	ExceptionFramesLineno   []int
	ExceptionFramesInApp    []int
}

type IssueInfo

type IssueInfo struct {
	UUID string `json:"uuid"`
	Hash string `json:"hash"`
	ID   int64  `json:"id"`
}

type IssueMessage

type IssueMessage struct {
	CreatedAt time.Time `json:"created_at"`
	Username  string    `json:"username"`
	Content   string    `json:"content"`
	ID        int       `json:"id"`
	UserID    int       `json:"user_id"`
}

IssueMessage represents a message in issue discussion with additional user information.

type IssueMetrics

type IssueMetrics struct {
	FirstSeen time.Time `json:"first_seen"`
	LastSeen  time.Time `json:"last_seen"`
	GID       uint64    `json:"gid"`
	TimesSeen uint64    `json:"times_seen"`
	UserCount uint64    `json:"user_count"`
}

IssueMetrics represents the metrics of an issue.

func GetMetrics

func GetMetrics(metrics []IssueMetrics, id int64) (IssueMetrics, bool)

type IssuePriority

type IssuePriority int
const (
	PriorityLow IssuePriority = iota + 1
	PriorityMedium
	PriorityHigh
)

func (IssuePriority) String

func (p IssuePriority) String() string

type IssueStore

type IssueStore interface {
	// GetIssue returns an issue by hash.
	GetIssue(ctx context.Context, criteria GetIssueCriteria) (*Issue, error)
	// GetIssueByID returns an issue by ID.
	GetIssueByID(ctx context.Context, id int64) (*Issue, error)
	// StoreIssue stores a new issue.
	StoreIssue(ctx context.Context, issue *Issue) error
	// ListIssues returns a list of issues.
	ListIssues(ctx context.Context, criteria *ListIssuesCriteria) ([]Issue, error)
	// UpdateLastSeen updates the last seen time of an issue.
	UpdateLastSeen(ctx context.Context, upd *UpdateLastSeen) error
}

type IssuesType

type IssuesType string
const (
	IssuesTypeAll IssuesType = "all"
	IssuesTypeNew IssuesType = "new"
)

type Level

type Level = uint8

Level represents the event level.

const (
	LevelFatal Level = iota + 1
	LevelError
	LevelWarning
	LevelInfo
	LevelDebug
	LevelTrace
	LevelUnknown
)

func GetLevel

func GetLevel(level string) Level

GetLevel returns the level by name.

type ListAlertsRequest added in v0.5.0

type ListAlertsRequest struct {
	User        *User
	TeamName    string
	ProjectName string
	Offset      int
	Limit       int
}

ListAlertsRequest is used to specify criteria for listing alerts.

type ListAlertsResult added in v0.5.0

type ListAlertsResult struct {
	Request     *ListAlertsRequest
	Alerts      []Alert
	Projects    []Project
	Teams       []Team
	TotalAlerts int
}

ListAlertsResult contains the result of listing alerts.

type ListErrorsCriteria

type ListErrorsCriteria struct {
	LastErrorTime time.Time
}

ListErrorsCriteria represents the criteria for listing errors from the analytics store.

type ListEventsRequest

type ListEventsRequest struct {
	User      *User
	Period    string
	Start     string
	End       string
	Query     string
	ProjectID int
	IssueID   int
	Offset    int
}

ListEventsRequest is a request structure for listing all events per issue.

type ListEventsResult

type ListEventsResult struct {
	Request     *ListEventsRequest
	Events      []EventEntry
	PopularTags []TagCount
	ProjectID   int
	IssueID     int
	TotalEvents uint64
	Offset      int
}

type ListFieldsRequest

type ListFieldsRequest struct {
	User      *User
	ProjectID int
	IssueID   int
}

type ListFieldsResult

type ListFieldsResult struct {
	ProjectName   string
	TagCount      []TagCount
	FieldValueNum []FieldValueNum
}

type ListIssueMetricsCriteria

type ListIssueMetricsCriteria struct {
	From       time.Time
	To         time.Time
	ProjectIDs []int
	GroupIDs   []int64
}

ListIssueMetricsCriteria represents the criteria for listing issue metrics.

type ListIssuesCriteria

type ListIssuesCriteria struct {
	From       time.Time
	To         time.Time
	ProjectIDs []int
	GroupIDs   []int64
}

ListIssuesCriteria is used to specify criteria for listing issues.

type ListIssuesRequest

type ListIssuesRequest struct {
	User        *User
	Period      string
	Start       string
	End         string
	Query       string
	ProjectName string
	ProjectIDs  []int
	Offset      int
	Limit       int
}

type ListIssuesResult

type ListIssuesResult struct {
	RequestedProject string
	Request          *ListIssuesRequest
	LastProject      *Project
	Issues           []IssueEntry
	Projects         []Project
	PopularTags      []TagCount
	TotalIssues      int
}

func (*ListIssuesResult) NoIssues

func (l *ListIssuesResult) NoIssues() bool

type ListPopularTagsCriteria

type ListPopularTagsCriteria struct {
	From       time.Time
	To         time.Time
	ProjectIDs []int
	Limit      int
}

type ListPopularTagsRequest

type ListPopularTagsRequest struct {
	User        *User
	ProjectName string
	Period      string
	Limit       int
}

type ListProjectsCriteria

type ListProjectsCriteria struct {
	Name   string `schema:"name"`
	TeamID int    `schema:"team"`
}

ListProjectsCriteria is a criteria to list projects.

func (*ListProjectsCriteria) IsEmpty

func (c *ListProjectsCriteria) IsEmpty() bool

IsEmpty returns true if the criteria is empty.

type ListProjectsResult

type ListProjectsResult struct {
	Criteria *ListProjectsCriteria
	Projects []Project
	Teams    []Team
}

type ListTagValuesCriteria

type ListTagValuesCriteria struct {
	From       time.Time
	To         time.Time
	Tag        string
	ProjectIDs []int
	Limit      int
}

type ListTagValuesRequest

type ListTagValuesRequest struct {
	User        *User
	Tag         string
	ProjectName string
	Period      string
	Start       string
	End         string
	Limit       int
}

type ListTeammatesRequest

type ListTeammatesRequest struct {
	User      *User
	ProjectID int
}

ListTeammatesRequest is a request to list teammates for a project.

type Mention

type Mention struct {
	CreatedAt       time.Time `json:"created_at"`
	ID              int       `json:"id"`
	MessageID       int       `json:"message_id"`
	MentionedUserID int       `json:"mentioned_user_id"`
}

Mention represents a mention of a user in a message in issue discussion.

type MentionStore

type MentionStore interface {
	// CreateMentions creates new mentions in issue discussion (when user was tagged with "@").
	CreateMentions(ctx context.Context, mentions []Mention) error
	// DeleteMentions deletes mentions in issue discussion.
	DeleteMentions(ctx context.Context, messageID int) error
}

MentionStore encapsulates the methods to interact with database for Mention entity.

type Message

type Message struct {
	CreatedAt time.Time `json:"created_at"`
	Content   string    `json:"content"`
	ID        int       `json:"id"`
	IssueID   int64     `json:"issue_id"`
	UserID    int       `json:"user_id"`
}

Message represents a text message in issue discussion (user comment).

type MessageCount

type MessageCount struct {
	IssueID      int64 `json:"issue_id"`
	MessageCount int   `json:"message_count"`
}

MessageCount represents a count of messages in the issue discussion.

type MessageStore

type MessageStore interface {
	// CreateMessage creates a new message in the issue discussion.
	// Set identifier to pointer to the message created.
	CreateMessage(ctx context.Context, message *Message) error
	// ListIssueMessages lists all messages in the issue discussion.
	ListIssueMessages(ctx context.Context, issueID int64) ([]IssueMessage, error)
	// CountMessages counts all messages in the issue discussion.
	CountMessages(ctx context.Context, issueID int64) (int, error)
	// DeleteMessage deletes a message in the issue discussion.
	DeleteMessage(ctx context.Context, messageID, userID int) error
	// CountMessagesByIDs counts all messages in the issue discussion by IDs.
	CountMessagesByIDs(ctx context.Context, issueIDs []int64) ([]MessageCount, error)
}

MessageStore encapsulates the methods to interact with database for message entity (issue comment).

type MessageView

type MessageView struct {
	ViewedAt  time.Time `json:"viewed_at"`
	ID        int       `json:"id"`
	MessageID int       `json:"message_id"`
	UserID    int       `json:"user_id"`
}

MessageView represents a view of a message by a user. It is used to track which users have viewed a message in issue discussion.

type NotificationChannel added in v0.5.0

type NotificationChannel struct {
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Name        string
	ChannelType NotificationChannelType
	TeamID      int
	ID          int
	Enabled     bool
}

NotificationChannel represents a notification channel configuration.

type NotificationChannelType added in v0.5.0

type NotificationChannelType string

NotificationChannelType represents the type of notification channel.

const (
	// NotificationChannelWebhook represents Webhook notification channel.
	NotificationChannelWebhook NotificationChannelType = "webhook"
)

type NotificationService added in v0.5.0

type NotificationService interface {
	// SaveWebhookConfig saves or updates webhook configuration for a team.
	SaveWebhookConfig(ctx context.Context, req *SaveWebhookConfigRequest) error
	// GetWebhookConfigWithSecretByTeamID returns the webhook configuration with decrypted secret for a team.
	GetWebhookConfigWithSecretByTeamID(ctx context.Context, teamID int) (*WebhookConfigWithSecret, error)
}

NotificationService encapsulates service domain logic.

type NotificationStore added in v0.5.0

type NotificationStore interface {
	// CreateNotificationChannel creates a new notification channel.
	CreateNotificationChannel(ctx context.Context, channel *NotificationChannel) error
	// GetNotificationChannel returns a notification channel by ID.
	GetNotificationChannel(ctx context.Context, channelID int) (*NotificationChannel, error)
	// ListNotificationChannels returns all notification channels for a team.
	ListNotificationChannels(ctx context.Context, teamID int) ([]NotificationChannel, error)
	// UpdateNotificationChannel updates a notification channel.
	UpdateNotificationChannel(ctx context.Context, channel *NotificationChannel) error
	// DeleteNotificationChannel deletes a notification channel.
	DeleteNotificationChannel(ctx context.Context, channelID int) error

	// CreateWebhookConfig creates a new webhook configuration.
	CreateWebhookConfig(ctx context.Context, config *WebhookConfig) error
	// GetWebhookConfig returns a webhook configuration by channel ID.
	GetWebhookConfig(ctx context.Context, channelID int) (*WebhookConfig, error)
	// UpdateWebhookConfig updates a webhook configuration.
	UpdateWebhookConfig(ctx context.Context, config *WebhookConfig) error

	// CreateAlertNotification creates a new alert notification record.
	CreateAlertNotification(ctx context.Context, notification *AlertNotification) error
	// UpdateAlertNotification updates an alert notification record.
	UpdateAlertNotification(ctx context.Context, notification *AlertNotification) error
	// ListPendingNotifications returns all pending notifications.
	ListPendingNotifications(ctx context.Context, limit int) ([]AlertNotification, error)

	// AcquireAlertLock attempts to acquire a lock for processing an alert.
	AcquireAlertLock(ctx context.Context, lock *AlertLock) (bool, error)
	// ReleaseAlertLock releases a lock for an alert.
	ReleaseAlertLock(ctx context.Context, alertID int, instanceID string) error
	// CleanupExpiredLocks removes expired locks.
	CleanupExpiredLocks(ctx context.Context, now time.Time) error
}

NotificationStore encapsulates the notification storage.

type OIDCState added in v0.2.0

type OIDCState struct {
	State        string   `cbor:"state"`
	Nonce        string   `cbor:"nonce"`
	CodeVerifier string   `cbor:"code_verifier"`
	Scopes       []string `cbor:"scopes"`
}

type OSContext

type OSContext struct {
	Name string `json:"name"`
}

OSContext represents operating system information.

type Platform

type Platform int8

Platform represents the platform of the project.

const (
	// PlatformGolang represents the Go platform.
	PlatformGolang Platform = iota + 1
	// PlatformRust represents the Rust platform.
	PlatformRust
)

func PlatformByName

func PlatformByName(name string) Platform

PlatformByName returns the platform by name.

func (Platform) String

func (p Platform) String() string

String returns the string representation of the platform.

type Processor added in v0.6.0

type Processor interface {
	// Process processes one or more records within the passed context.
	// Process takes ownership of the passed records, callers must not mutate
	// a record after Process has been called.
	Process(ctx context.Context, record Record) error
}

Processor defines record processing signature.

type ProcessorFunc added in v0.6.0

type ProcessorFunc func(context.Context, Record) error

ProcessorFunc is a function type that implements the Processor interface.

func (ProcessorFunc) Process added in v0.6.0

func (f ProcessorFunc) Process(ctx context.Context, rs Record) error

Process returns f(ctx, records...).

type Producer added in v0.6.0

type Producer interface {
	// Produce produces N records. If the Producer is synchronous, waits until
	// all records are produced, otherwise, returns as soon as the records are
	// stored in the producer buffer, or when the records are produced to the
	// queue if sync producing is configured.
	// If the context has been enriched with metadata, each entry will be added
	// as a record's header.
	// Produce takes ownership of Record and any modifications after Produce is
	// called may cause an unhandled exception.
	Produce(ctx context.Context, rs ...Record) error
	// Healthy returns an error if the producer isn't healthy.
	Healthy(ctx context.Context) error
	// Close closes the producer.
	Close() error
}

Producer wraps the producer implementation details. Producer implementations must support sync and async production.

type Project

type Project struct {
	CreatedAt       time.Time
	Name            string
	Key             string
	Events          EventsList
	GroupMetrics    []GroupMetrics
	IssueList       []IssueEntry
	NewIssueList    []IssueEntry
	ResultIssueList []IssueEntry
	ID              int
	UserID          int
	TeamID          int
	AllLength       int
	NewLength       int
	Platform        Platform
}

Project is a representation of a project in the system.

type ProjectDetails

type ProjectDetails struct {
	Project     *Project
	Assignments *Assignments
	Period      string
	Issues      IssuesType
	Teammates   []Teammate
	Page        int
}

func (*ProjectDetails) AllLength

func (pd *ProjectDetails) AllLength() string

func (*ProjectDetails) NewLength

func (pd *ProjectDetails) NewLength() string

type ProjectDetailsRequest

type ProjectDetailsRequest struct {
	Issues    IssuesType
	Period    string
	Start     string
	End       string
	ProjectID int
	Page      int
}

type ProjectInfo

type ProjectInfo struct {
	Name     string
	DSN      string
	Platform string
	ID       int
}

ProjectInfo is a representation of a project.

type ProjectOptions

type ProjectOptions struct {
	Name          string
	ID            int
	Platform      Platform
	RetentionDays uint8
}

type ProjectService

type ProjectService interface {
	// CreateProject creates a new project.
	CreateProject(ctx context.Context, req *CreateProjectRequest, user *User) (*ProjectInfo, error)
	// ListProjects returns a list of projects for the given teams.
	ListProjects(ctx context.Context, criteria *ListProjectsCriteria, user *User) (*ListProjectsResult, error)
	// ListTeams returns a list of teams associated with the user.
	ListTeams(ctx context.Context, user *User) ([]Team, error)
	// GetProject returns a project by identifier.
	GetProject(ctx context.Context, projectID int, user *User) (*Project, error)
	// DeleteProject deletes a project by ID.
	DeleteProject(ctx context.Context, projectID int, user *User) error
	// GetProjectDetails returns the project details.
	GetProjectDetails(ctx context.Context, req *ProjectDetailsRequest, user *User) (*ProjectDetails, error)
	// GetIssue returns the issue by ID.
	GetIssue(ctx context.Context, req *GetIssueRequest) (*IssueDetails, error)

	GetDiscussion(ctx context.Context, req *GetDiscussionsRequest) (*Discussion, error)

	// ListFields returns a list of fields related to an issue.
	// e.g. how many times a field like browser or os was seen in events.
	ListFields(ctx context.Context, req *ListFieldsRequest) (*ListFieldsResult, error)

	// ListEvents handles "All Errors" page per issue listing all error events.
	ListEvents(ctx context.Context, req *ListEventsRequest) (*ListEventsResult, error)

	// ListIssues returns a list of issues for specified projects.
	ListIssues(ctx context.Context, req *ListIssuesRequest) (*ListIssuesResult, error)

	// ListTeammates returns a list of teammates for the specified project.
	ListTeammates(ctx context.Context, req *ListTeammatesRequest) ([]Teammate, error)

	// CreateMessage creates a new message in the discussion.
	CreateMessage(ctx context.Context, req *CreateMessageRequest) (*Discussion, error)

	// DeleteMessage deletes a message in the discussion.
	DeleteMessage(ctx context.Context, req *DeleteMessageRequest) (*Discussion, error)

	// AssignIssue assigns an issue to a user.
	AssignIssue(ctx context.Context, req *AssignIssueRequest) error

	// DeleteAssignment unassigns an issue from a user.
	DeleteAssignment(ctx context.Context, req *UnassignIssueRequest) error

	// SearchProject searches for projects by name. Returns ErrProjectNotFound if no project is found.
	SearchProject(ctx context.Context, name string, user *User) (*Project, error)
	// ListPopularTags lists popular tag keys for search suggestions.
	ListPopularTags(ctx context.Context, req *ListPopularTagsRequest) ([]TagCount, error)
	// ListTagValues lists popular values for a given tag.
	ListTagValues(ctx context.Context, req *ListTagValuesRequest) ([]TagValueCount, error)
}

ProjectService encapsulates service domain logic.

type ProjectStore

type ProjectStore interface {
	// CreateProject creates a new project.
	CreateProject(ctx context.Context, project *Project) error
	// ListProjects returns a list of projects for the given teams.
	ListProjects(ctx context.Context, teamIDs []int, name string) ([]Project, error)
	// DeleteProject deletes a project by ID.
	DeleteProject(ctx context.Context, projectID int) error
	// GetProject returns a project by identifier.
	GetProject(ctx context.Context, projectID int) (*Project, error)
	// GetOptions returns the project options.
	GetOptions(ctx context.Context, projectID int, projectKey string) (*ProjectOptions, error)
}

ProjectStore encapsulates the project storage.

type QueryToken

type QueryToken struct {
	Key       string `json:"key"`
	Operator  string `json:"operator"`
	Value     string `json:"value"`
	IsRawText bool   `json:"isRawText"`
}

func ParseQuery

func ParseQuery(query string) []QueryToken

ParseQuery parses a query string into QueryTokens. Supports quoted values, operators like : and !:, and raw text.

type QueryValue

type QueryValue struct {
	Value string
	IsNot bool
}

QueryValue represents a value in a query with an optional negation flag.

type Record added in v0.6.0

type Record struct {
	// Topics holds the topic where the record will be produced.
	Topic Topic
	// OrderingKey is an optional field that is hashed to map to a partition.
	// Records with same ordering key are routed to the same partition.
	OrderingKey []byte
	// Value holds the record's content. It must not be mutated after Produce.
	Value []byte
	// Partition identifies the partition ID where the record was polled from.
	// It is optional and only used for consumers.
	// When not specified, the zero value for int32 (0) identifies the only partition.
	Partition int32
}

Record wraps a record's value with the topic where it's produced / consumed.

type RuntimeContext

type RuntimeContext struct {
	Name          string `json:"name"`
	Version       string `json:"version"`
	GoMaxProcs    int    `json:"go_maxprocs"`
	GoNumCgoCalls int    `json:"go_numcgocalls"`
	GoNumRoutines int    `json:"go_numroutines"`
}

RuntimeContext represents runtime-specific information.

type SDK

type SDK struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Event represents the main event structure.

type SDKBody

type SDKBody struct {
	Name         string       `json:"name"`
	Version      string       `json:"version"`
	Integrations []string     `json:"integrations"`
	Packages     []SDKPackage `json:"packages"`
}

SDKBody represents SDK details.

type SDKPackage

type SDKPackage struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

SDKPackage represents individual SDK packages.

type SQLQuery

type SQLQuery struct {
	NormalizedQuery       string  `json:"normalized_query"`
	TotalReadBytes        string  `json:"total_read_bytes"`
	NormalizedQueryHash   string  `json:"normalized_query_hash"`
	TotalReadBytesNumeric float64 `json:"total_read_bytes_numeric"`
	AvgDuration           float64 `json:"avg_duration"`
	AvgResultRows         float64 `json:"avg_result_rows"`
	CallsPerMinute        float64 `json:"calls_per_minute"`
	TotalCalls            uint64  `json:"total_calls"`
	PercentageIOPS        float64 `json:"percentage_iops"`
	PercentageRuntime     float64 `json:"percentage_runtime"`
	Percent               float64 `json:"percent"`
	ReadBytes             uint64  `json:"read_bytes"`
}

SQLQuery represents a slow SQL query.

type SaveWebhookConfigRequest added in v0.5.0

type SaveWebhookConfigRequest struct {
	User   *User
	URL    string
	Secret string
	TeamID int
}

SaveWebhookConfigRequest is a request to save or update webhook configuration.

type Schema

type Schema struct {
	Name          string `json:"name"`
	ReadableBytes string `json:"readable_bytes"`
	Engine        string `json:"engine"`
	PartitionKey  string `json:"partition_key"`
	TotalBytes    uint64 `json:"total_bytes"`
	TotalRows     uint64 `json:"total_rows"`
}

Schema represents a database schema.

type SentryTimestamp added in v0.6.1

type SentryTimestamp struct {
	time.Time
}

SentryTimestamp handles both RFC3339 strings and unix float timestamps.

func (SentryTimestamp) MarshalJSON added in v0.6.1

func (t SentryTimestamp) MarshalJSON() ([]byte, error)

func (*SentryTimestamp) UnmarshalJSON added in v0.6.1

func (t *SentryTimestamp) UnmarshalJSON(data []byte) error

type Session

type Session struct {
	User *User
}

Session represents a user session, including the authenticated user.

type SessionService

type SessionService interface {
	// SignIn authenticates a user by email or username and password.
	SignIn(ctx context.Context, credentials *Credentials) (*Session, error)
	// GetOrCreateUser creates a new user if it does not exist in the database
	// or returns the existing user.
	GetOrCreateUser(ctx context.Context, req *GetOrCreateUserRequest) (*Session, error)
}

SessionService defines methods for session management.

type SessionStore

type SessionStore interface {
	// GetHashedPassword retrieves the hashed password for a given email.
	GetHashedPassword(ctx context.Context, email string) ([]byte, error)
	// GetHashedPasswordByIdentifier retrieves the hashed password for a given identifier.
	GetHashedPasswordByIdentifier(ctx context.Context, identifier UserIdentifier) ([]byte, error)
}

SessionStore defines methods for session data management.

type StackDetail

type StackDetail struct {
	Filepath     string
	FunctionName string
	LineNo       int
	InApp        bool
}

func GetStackDetails

func GetStackDetails(event *IssueEvent) []StackDetail

func (*StackDetail) InAppStr

func (sd *StackDetail) InAppStr() string

type StackTrace

type StackTrace struct {
	Frames []Frame `json:"frames"`
}

StackTrace represents the stack trace details.

type SystemService

type SystemService interface {
	// ListSlowQueries lists olap slow queries from the system.
	ListSlowQueries(ctx context.Context) ([]SQLQuery, error)
	// ListSchemas lists olap database schemas from largest to smallest.
	ListSchemas(ctx context.Context) ([]Schema, error)
	// ListErrors lists recent errors from olap system for the last 24 hours.
	ListErrors(ctx context.Context) ([]AnalyticsStoreErr, error)
}

SystemService reports olap resource usage.

type TagCount

type TagCount struct {
	Tag   string
	Count uint64
}

TagCount represents a tag and its count.

type TagKeyValue

type TagKeyValue struct {
	Key   string
	Value string
}

type TagValueCount

type TagValueCount struct {
	Value string `json:"value"`
	Count uint64 `json:"count"`
}

type Team

type Team struct {
	CreatedAt time.Time
	Name      string
	ID        int
	OwnerID   int
}

Team is a representation of a team in the system.

type TeamStore

type TeamStore interface {
	// CreateTeam creates a new team.
	CreateTeam(ctx context.Context, team Team) error
	// ListTeams returns a list of teams for the given user.
	ListTeams(ctx context.Context, userID int) ([]Team, error)
	// ListTeammates returns a list of teammates for the given team.
	ListTeammates(ctx context.Context, teamIDs []int) ([]Teammate, error)
	// AddUserToTeam adds a user to a team.
	AddUserToTeam(ctx context.Context, createdAt time.Time, userID int64, teamID int) error
}

TeamStore encapsulates the team storage.

type Teammate

type Teammate struct {
	Name     string
	Surname  string
	Email    string
	Username string
	ID       int64
}

Teammate is a user while listing teammates.

func (*Teammate) AvatarInitials

func (t *Teammate) AvatarInitials() string

AvatarInitials returns the initials of the teammate in uppercase.

func (*Teammate) FullName

func (t *Teammate) FullName() string

FullName returns the full name of the teammate.

type TeammateAssign

type TeammateAssign struct {
	Teammate

	Assigned bool
}

type TestWebhookRequest added in v0.5.0

type TestWebhookRequest struct {
	User   *User
	TeamID int
}

TestWebhookRequest is a request to send a test notification to the configured webhook.

type Thread added in v0.6.1

type Thread struct {
	ID         string     `json:"id"`
	Name       string     `json:"name"`
	StackTrace StackTrace `json:"stacktrace"`
	Current    bool       `json:"current"`
}

Thread represents a thread with an optional stack trace.

type ThreadList added in v0.6.1

type ThreadList []Thread

ThreadList handles both Sentry thread formats: - flat array: [{"id": "1", ...}] - object with values: {"values": [{"id": "1", ...}]}.

func (*ThreadList) UnmarshalJSON added in v0.6.1

func (t *ThreadList) UnmarshalJSON(data []byte) error

type Topic added in v0.6.0

type Topic string

Topic represents a destination topic where to produce a message/record.

type TopicConsumer added in v0.6.0

type TopicConsumer struct {
	// Optional topic to monitor.
	Topic Topic
	// Optional regex expression to match topics for monitoring.
	Regex string
	// Required consumer name.
	Consumer string
}

TopicConsumer is used to monitor a set of consumer topics.

type Trace

type Trace struct {
	Environment string `json:"environment"`
	PublicKey   string `json:"public_key"`
	Release     string `json:"release"`
	TraceID     string `json:"trace_id"`
}

Event represents the main event structure.

type UUID

type UUID []byte

UUID represents a 16-byte universally unique identifier this type is a wrapper around google/uuid with the following differences

  • type is a byte slice instead of [16]byte
  • db serialization converts uuid to bytes as opposed to string

func NewUUID

func NewUUID() UUID

NewUUID generates a new UUID.

func ParseUUID

func ParseUUID(s string) (UUID, error)

ParseUUID returns a UUID parsed from the given string representation.

func (*UUID) Scan

func (u *UUID) Scan(src any) error

Scan implements sql.Scanner interface to allow this type to be parsed transparently by database drivers.

func (UUID) String

func (u UUID) String() string

String returns the 36 byet hexstring representation of this uuid return empty string if this uuid is nil.

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value implements sql.Valuer so that UUIDs can be written to databases transparently. This method returns a byte slice representation of uuid.

type Uint8Array added in v0.6.0

type Uint8Array []uint8

Uint8Array is a custom type that serializes []uint8 as a JSON array of numbers instead of the default base64 encoding for []byte.

func GetExceptionFramesInApp

func GetExceptionFramesInApp(exceptions []Exception) Uint8Array

func (Uint8Array) MarshalJSON added in v0.6.0

func (a Uint8Array) MarshalJSON() ([]byte, error)

func (*Uint8Array) UnmarshalJSON added in v0.6.0

func (a *Uint8Array) UnmarshalJSON(data []byte) error

type UnassignIssueRequest

type UnassignIssueRequest struct {
	User      *User `json:"user"`
	IssueID   int   `json:"issue_id"`
	ProjectID int   `json:"project_id"`
}

UnassignIssueRequest represents the request to unassign an issue from a user.

type UpdateAlertRequest added in v0.5.0

type UpdateAlertRequest struct {
	User         *User
	RuleName     string
	Status       AlertStatus
	AlertID      int
	Threshold    int
	Condition    AlertCondition
	Timeframe    AlertTimeframe
	HighPriority bool
}

UpdateAlertRequest is a request to update an alert.

type UpdateLastSeen

type UpdateLastSeen struct {
	LastSeen  time.Time
	Message   string
	ErrorType string
	View      string
	IssueID   int64
}

type User

type User struct {
	Email      string     `cbor:"email"`
	Name       string     `cbor:"name"`
	Surname    string     `cbor:"surname"`
	Username   string     `cbor:"username"`
	AuthMethod AuthMethod `cbor:"auth_method"`
	ID         int64      `cbor:"id"`
}

User represents a user in the system.

func (*User) AvatarInitials

func (u *User) AvatarInitials() string

AvatarInitials returns the initials of the user for avatar display.

func (*User) FullName

func (u *User) FullName() string

FullName returns the full name of the user.

type UserIdentifier added in v0.2.0

type UserIdentifier struct {
	Value   string
	IsEmail bool
}

UserIdentifier represents a user identifier that can be either email or username.

type UserStore

type UserStore interface {
	// GetUser retrieves a user by email.
	GetUser(ctx context.Context, email string) (*User, error)
	// GetUserByIdentifier retrieves a user by identifier (email or username).
	GetUserByIdentifier(ctx context.Context, identifier UserIdentifier) (*User, error)
	// CreateUser creates a new user with the provided email and hashed password.
	CreateUser(ctx context.Context, email, username string, hashedPassword []byte) error
	// CreateUserOIDC creates a new user with the provided email and oidc claims.
	CreateUserOIDC(ctx context.Context, userData *GetOrCreateUserRequest) (int64, error)
}

UserStore defines methods for user data management.

type WebhookConfig added in v0.5.0

type WebhookConfig struct {
	CreatedAt       time.Time
	UpdatedAt       time.Time
	VerifiedAt      *time.Time
	URL             string
	SecretEncrypted string
	ID              int
	ChannelID       int
}

WebhookConfig represents webhook configuration.

type WebhookConfigWithSecret added in v0.5.0

type WebhookConfigWithSecret struct {
	URL    string
	Secret string
}

WebhookConfigWithSecret holds webhook config with decrypted secret.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL