appmetrics

package
v0.139.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

EventSchemaMap Every event should have a schema attached

View Source
var NavigateToCofxSchema = map[string]interface{}{
	"type": "object",
	"properties": map[string]interface{}{
		"view_id": map[string]interface{}{
			"type":      "string",
			"maxLength": 32,
		},
		"params": map[string]interface{}{
			"type": "object",
			"properties": map[string]interface{}{
				"screen": map[string]interface{}{
					"type":      "string",
					"maxLength": 32,
				},
			},
			"additionalProperties": false,
			"required":             []string{"screen"},
		},
	},
	"additionalProperties": false,
	"required":             []string{"view_id", "params"},
}

Functions

func GetAppMetricsIDs added in v0.86.2

func GetAppMetricsIDs(appMetrics []AppMetric) []int

Types

type AppMetric

type AppMetric struct {
	ID         int                `json:"-"`
	MessageID  string             `json:"message_id"`
	Event      AppMetricEventType `json:"event"`
	Value      json.RawMessage    `json:"value"`
	AppVersion string             `json:"app_version"`
	OS         string             `json:"os"`
	SessionID  string             `json:"session_id"`
	CreatedAt  time.Time          `json:"created_at"`
	Processed  bool               `json:"processed"`
	ReceivedAt time.Time          `json:"received_at"`
}

Value is `json.RawMessage` so we can send any json shape, including strings Validation is handled using JSON schemas defined in validators.go, instead of Golang structs

func GenerateMetrics added in v0.86.2

func GenerateMetrics(num int) []AppMetric

type AppMetricEventType

type AppMetricEventType string
const (
	// status-mobile navigation events
	NavigateTo         AppMetricEventType = "navigate-to"
	ScreensOnWillFocus AppMetricEventType = "screens/on-will-focus"
)

type AppMetricValidationError

type AppMetricValidationError struct {
	Metric AppMetric
	Errors []gojsonschema.ResultError
}

type Database

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

Database sql wrapper for operations with browser objects.

func NewDB

func NewDB(db *sql.DB) *Database

func (Database) Close

func (db Database) Close() error

Close closes database.

func (*Database) DeleteOlderThan added in v0.86.2

func (db *Database) DeleteOlderThan(date *time.Time) (err error)

func (*Database) GetAppMetrics

func (db *Database) GetAppMetrics(limit int, offset int) (page Page, err error)

func (*Database) GetMessagesOlderThan added in v0.86.2

func (db *Database) GetMessagesOlderThan(date *time.Time) ([]AppMetric, error)

func (*Database) GetUnprocessed added in v0.86.2

func (db *Database) GetUnprocessed() ([]AppMetric, error)

func (*Database) GetUnprocessedGroupedBySession added in v0.86.2

func (db *Database) GetUnprocessedGroupedBySession() (map[string][]AppMetric, error)

func (*Database) SaveAppMetrics

func (db *Database) SaveAppMetrics(appMetrics []AppMetric, sessionID string) (err error)

func (*Database) SetToProcessed added in v0.86.2

func (db *Database) SetToProcessed(appMetrics []AppMetric) (err error)

func (*Database) SetToProcessedByIDs added in v0.86.2

func (db *Database) SetToProcessedByIDs(ids []int) (err error)

func (*Database) ValidateAppMetrics

func (db *Database) ValidateAppMetrics(appMetrics []AppMetric) (err error)

type Page added in v0.79.1

type Page struct {
	AppMetrics []AppMetric
	TotalCount int
}

Jump to

Keyboard shortcuts

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