feedback

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	USER_ROLE_KEY             = "user_role"
	NODE_IDENTITY_KEY         = "node_identity"
	NODE_COUNTRY_KEY          = "node_country"
	IP_TYPE_KEY               = "ip_type"
	IP_KEY                    = "ip"
	CONTACT_TYPE              = "contact"
	USER_TYPE                 = "user"
	DEFAULT_INTERCOM_BASE_URL = "https://api.intercom.io"
)

keys of intercom custom attributes

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateBugReportRequest added in v1.3.0

type CreateBugReportRequest struct {
	NodeIdentity string `form:"nodeIdentity" example:"0xF0345F6251Bef9447A08766b9DA2B07b28aD80B0" validate:"required"`
	Description  string `form:"description" minLength:"30" validate:"required"`
	Email        string `form:"email" validate:"required"`
	File         *multipart.FileHeader
}

CreateBugReportRequest create bug report request

func ParseBugReportRequest added in v1.3.0

func ParseBugReportRequest(c *gin.Context) (CreateBugReportRequest, []error)

ParseBugReportRequest parses CreateBugReportRequest from HTTP request

type CreateBugReportResponse added in v1.3.0

type CreateBugReportResponse struct {
	IssueId      string `json:"issueId"`
	Message      string `json:"message"`
	Email        string `json:"email"`
	NodeIdentity string `json:"node_identity"`
}

CreateBugReportResponse represents a successful bug report creation

type CreateGithubIssueRequest

type CreateGithubIssueRequest struct {
	UserId      string                `form:"userId"`
	Description string                `form:"description"`
	Email       string                `form:"email"`
	File        *multipart.FileHeader `form:"file"`
}

CreateGithubIssueRequest create github issue request

func ParseGithubIssueRequest

func ParseGithubIssueRequest(c *gin.Context) (CreateGithubIssueRequest, []error)

ParseGithubIssueRequest parses CreateGithubIssueRequest from HTTP request

type CreateGithubIssueResponse

type CreateGithubIssueResponse struct {
	IssueId string `json:"issueId"`
}

CreateGithubIssueResponse represents a successful github issue creation

type CreateIntercomIssueRequest added in v1.2.0

type CreateIntercomIssueRequest struct {
	UserId       string `form:"userId" validate:"optional"`
	NodeIdentity string `form:"nodeIdentity" validate:"required"`
	UserType     string `form:"userType" validate:"optional"`
	NodeCountry  string `form:"nodeCountry" validate:"optional"`
	IpType       string `form:"ipType" validate:"optional"`
	Ip           string `form:"ip" validate:"optional"`
	Description  string `form:"description" validate:"required" minLength:"30"`
	Email        string `form:"email" validate:"required"`
	File         *multipart.FileHeader
}

CreateIntercomIssueRequest create intercom issue request

func ParseIntercomIssueRequest added in v1.2.0

func ParseIntercomIssueRequest(c *gin.Context) (CreateIntercomIssueRequest, []error)

ParseIntercomIssueRequest parses CreateIntercomIssueRequest from HTTP request

type CreateIntercomIssueResponse added in v1.2.0

type CreateIntercomIssueResponse struct {
	ConversationId string `json:"conversationId"`
}

CreateIntercomIssueResponse represents a successful intercom issue creation

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint user feedback endpoint

func NewEndpoint

func NewEndpoint(githubReporter Reporter, intercomReporter ReporterWithMessage, storage Uploader, rateLimiter *infra.RateLimiter) *Endpoint

NewEndpoint creates new Endpoint

func (*Endpoint) CreateBugReport added in v1.3.0

func (e *Endpoint) CreateBugReport(c *gin.Context)

CreateBugReport creates a new bug report.

@Tags bug-report @Summary create a new bug report @Param request formData feedback.CreateBugReportRequest true "bug report request" @Param file formData file true "log file" @Accepts multipart/form-data @Produces json @Success 200 {object} feedback.CreateBugReportResponse @Failure 400 {object} apierror.APIErrorResponse @Failure 429 @Failure 503 {object} apierror.APIErrorResponse @Router /v1/bug-report [post]

func (*Endpoint) CreateGithubIssue deprecated

func (e *Endpoint) CreateGithubIssue(c *gin.Context)

CreateGithubIssue creates a new Github issue with user report

Deprecated: use CreateBugReport instead

func (*Endpoint) CreateIntercomIssue added in v1.2.0

func (e *Endpoint) CreateIntercomIssue(c *gin.Context)

CreateIntercomIssue creates a new Intercom chat with the issue with user report Deprecated: use CreateBugReport instead

@Tags bug-report @Summary create a new bug in intercom @Param request formData feedback.CreateIntercomIssueRequest true "bug report request" @Param file formData file true "log file" @Accepts multipart/form-data @Produces json @Success 200 {object} feedback.CreateIntercomIssueResponse @Failure 400 {object} apierror.APIErrorResponse @Failure 429 @Failure 503 {object} apierror.APIErrorResponse @Router /v1/intercom [post] @Deprecated

func (*Endpoint) RegisterRoutes

func (e *Endpoint) RegisterRoutes(r gin.IRoutes)

RegisterRoutes registers feedback API routes

type GithubReporter added in v1.2.0

type GithubReporter struct {
	// contains filtered or unexported fields
}

GithubReporter reports issues to Github

func NewGithubReporter added in v1.2.0

func NewGithubReporter(opts *NewGithubReporterOpts) (*GithubReporter, error)

NewGithubReporter creates a new GithubReporter

func (*GithubReporter) ReportIssue added in v1.2.0

func (rep *GithubReporter) ReportIssue(report *Report) (issueId string, err error)

ReportIssue reports issue

type IntercomReporter added in v1.2.0

type IntercomReporter struct {
	// contains filtered or unexported fields
}

IntercomReporter reports issues to Intercom

func NewIntercomReporter added in v1.2.0

func NewIntercomReporter(opts *NewIntercomReporterOpts) *IntercomReporter

NewIntercomReporter creates a new IntercomReporter

func (*IntercomReporter) GetBugReportMessage added in v1.3.0

func (rep *IntercomReporter) GetBugReportMessage(report *Report) (message string, err error)

func (*IntercomReporter) ReportIssue added in v1.2.0

func (rep *IntercomReporter) ReportIssue(report *Report) (conversationId string, err error)

ReportIssue creates a issue message for the user in intercom

type NewGithubReporterOpts added in v1.2.0

type NewGithubReporterOpts struct {
	GithubBaseUrlOverride *string
	Token                 string
	Owner                 string
	Repository            string
	LogProxyBaseUrl       string
}

NewGithubReporterOpts GithubReporter initialization options

type NewIntercomReporterOpts added in v1.2.0

type NewIntercomReporterOpts struct {
	Token           string
	IntercomBaseURL string
	LogProxyBaseUrl string
}

NewIntercomReporterOpts Reporter initialization options

type NewStorageOpts

type NewStorageOpts struct {
	EndpointURL string
	Bucket      string
}

NewStorageOpts options to initialize Storage

type Report

type Report struct {
	UserId       string
	NodeIdentity string
	UserType     string
	NodeCountry  string
	IpType       string
	Ip           string
	Description  string
	Email        string
	LogURL       url.URL
}

Report represents an issue report

type Reporter

type Reporter interface {
	ReportIssue(report *Report) (issueId string, err error)
}

Reporter reports issues and returns their id

type ReporterWithMessage added in v1.3.0

type ReporterWithMessage interface {
	Reporter
	GetBugReportMessage(report *Report) (message string, err error)
}

ReporterWithMessage reports issues and generates bug report messages

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage file storage

func New

func New(opts *NewStorageOpts) (storage *Storage, err error)

New creates a new Storage

func (*Storage) Upload

func (s *Storage) Upload(filepath string) (url *url.URL, err error)

Upload uploads file to storage and returns its URL

type Uploader added in v1.2.0

type Uploader interface {
	Upload(filepath string) (url *url.URL, err error)
}

Uploader uploads a file and returns the url

Jump to

Keyboard shortcuts

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