Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): ios session timeline #1624

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
440 changes: 266 additions & 174 deletions backend/api/measure/app.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion backend/api/replay/cpu.go → backend/api/timeline/cpu.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package replay
package timeline

import (
"backend/api/event"
"time"
)

// CPUUsage represents cpu usage
// events suitable for session timeline.
type CPUUsage struct {
Time time.Time `json:"timestamp"`
Value float64 `json:"value"`
}

// ComputeCPUUsage computes cpu usage
// events for session timeline.
func ComputeCPUUsage(events []event.EventField) (result []CPUUsage) {
for _, event := range events {
usage := CPUUsage{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package replay
package timeline

import (
"backend/api/event"
Expand All @@ -11,7 +11,7 @@ import (
)

// Exception represents exception events suitable
// for session replay.
// for session timeline.
type Exception struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand Down Expand Up @@ -43,7 +43,7 @@ func (e Exception) GetTimestamp() time.Time {
}

// ANR represents anr events suitable
// for session replay.
// for session timeline.
type ANR struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand Down Expand Up @@ -73,7 +73,7 @@ func (a ANR) GetTimestamp() time.Time {
}

// ComputeExceptions computes exceptions
// for session replay.
// for session timeline.
func ComputeExceptions(ctx context.Context, appId *uuid.UUID, events []event.EventField) (result []ThreadGrouper, err error) {
for _, event := range events {

Expand Down Expand Up @@ -121,7 +121,7 @@ func ComputeExceptions(ctx context.Context, appId *uuid.UUID, events []event.Eve
}

// ComputeANR computes anrs
// for session replay.
// for session timeline.
func ComputeANRs(ctx context.Context, appId *uuid.UUID, events []event.EventField) (result []ThreadGrouper, err error) {
for _, event := range events {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package replay
package timeline

import (
"backend/api/event"
Expand Down Expand Up @@ -28,7 +28,7 @@ func (c Custom) GetTimestamp() time.Time {
}

// ComputeCustom computes custom events
// for session replay.
// for session timeline.
func ComputeCustom(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
navs := Custom{
Expand Down
18 changes: 9 additions & 9 deletions backend/api/replay/doc.go → backend/api/timeline/doc.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Package replay provides capabilities & functionalities
// for session replay.
package replay
// Package timeline provides capabilities & functionalities
// for session timeline.
package timeline

/*
This package holds types and computational logic suited
for session replay functionality. Here's a high-level
for session timeline functionality. Here's a high-level
breakdown of each.

- **cpu**: operations related to app's cpu usage
Expand All @@ -19,14 +19,14 @@ breakdown of each.
- **exit** - operations related to app's stop timings and events

Additionally, this package also contains glue code to massage the
shape of session replay objects.
shape of session timeline objects.

Example:

```go
import {
"backend/api/event"
"backend/api/replay"
"backend/api/timeline"
"fmt"
}

Expand All @@ -44,11 +44,11 @@ func main() {
}

// perform compute
gestureClicks := replay.ComputeGestureClicks(clickEvents)
gestureClicks := timeline.ComputeGestureClicks(clickEvents)

// organize events by thread
gcThreads := replay.GroupByThreads(gestureClicks)
threads := make(replay.Threads)
gcThreads := timeline.GroupByThreads(gestureClicks)
threads := make(timeline.Threads)
threads.Organize(event.TypeGestureClick, gcThreads)

fmt.Println("threads", threads)
Expand Down
6 changes: 3 additions & 3 deletions backend/api/replay/exit.go → backend/api/timeline/exit.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package replay
package timeline

import (
"backend/api/event"
"time"
)

// AppExit represents app exit events
// suitable for session replay.
// suitable for session timeline.
type AppExit struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand All @@ -28,7 +28,7 @@ func (ae AppExit) GetTimestamp() time.Time {
}

// ComputeAppExits computes app exit
// events for session replay.
// events for session timeline.
func ComputeAppExits(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
appExits := AppExit{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package replay
package timeline

import (
"backend/api/event"
"time"
)

// GestureClick represents click events suitable
// for session replay.
// for session timeline.
type GestureClick struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand Down Expand Up @@ -34,7 +34,7 @@ func (gc GestureClick) GetTimestamp() time.Time {
}

// GestureLongClick represents long press events
// suitable for session replay.
// suitable for session timeline.
type GestureLongClick struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand All @@ -61,7 +61,7 @@ func (glc GestureLongClick) GetTimestamp() time.Time {
}

// GestureScroll represents scroll gesture events
// suitable for session replay.
// suitable for session timeline.
type GestureScroll struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand Down Expand Up @@ -89,7 +89,7 @@ func (gs GestureScroll) GetTimestamp() time.Time {
}

// ComputeGestureClicks computes click gestures
// for session replay.
// for session timeline.
func ComputeGestureClicks(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
gestureClicks := GestureClick{
Expand All @@ -112,7 +112,7 @@ func ComputeGestureClicks(events []event.EventField) (result []ThreadGrouper) {
}

// ComputeGestureLongClicks computes long click gestures
// for session replay.
// for session timeline.
func ComputeGestureLongClicks(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
gestureLongClicks := GestureLongClick{
Expand All @@ -134,7 +134,7 @@ func ComputeGestureLongClicks(events []event.EventField) (result []ThreadGrouper
}

// ComputeGestureScrolls computes scroll gestures
// for session replay.
// for session timeline.
func ComputeGestureScrolls(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
gestureScrolls := GestureScroll{
Expand Down
14 changes: 7 additions & 7 deletions backend/api/replay/launch.go → backend/api/timeline/launch.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package replay
package timeline

import (
"backend/api/event"
Expand All @@ -10,7 +10,7 @@ import (
var NominalColdLaunchThreshold = 30 * time.Second

// ColdLaunch represents cold launch events
// suitable for session replay.
// suitable for session timeline.
type ColdLaunch struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand All @@ -32,7 +32,7 @@ func (cl ColdLaunch) GetTimestamp() time.Time {
}

// WarmLaunch represents warm launch events
// suitable for session replay.
// suitable for session timeline.
type WarmLaunch struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand All @@ -57,7 +57,7 @@ func (wl WarmLaunch) GetTimestamp() time.Time {
}

// HotLaunch represents hot launch events
// suitable for session replay.
// suitable for session timeline.
type HotLaunch struct {
EventType string `json:"event_type"`
UDAttribute *event.UDAttribute `json:"user_defined_attribute"`
Expand All @@ -82,7 +82,7 @@ func (hl HotLaunch) GetTimestamp() time.Time {
}

// ComputeColdLaunches computes cold launch events
// for session replay.
// for session timeline.
func ComputeColdLaunches(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
coldLaunches := ColdLaunch{
Expand All @@ -99,7 +99,7 @@ func ComputeColdLaunches(events []event.EventField) (result []ThreadGrouper) {
}

// ComputeWarmLaunches computes warm launch events
// for session replay.
// for session timeline.
func ComputeWarmLaunches(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
warmLaunches := WarmLaunch{
Expand All @@ -119,7 +119,7 @@ func ComputeWarmLaunches(events []event.EventField) (result []ThreadGrouper) {
}

// ComputeHotLaunches computes hot launch events
// for session replay.
// for session timeline.
func ComputeHotLaunches(events []event.EventField) (result []ThreadGrouper) {
for _, event := range events {
hotLaunches := HotLaunch{
Expand Down
Loading
Loading