Skip to content

Commit 8fdd76e

Browse files
committed
detect firstlaunch, also remove old history migration code
1 parent 5b0daaf commit 8fdd76e

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

cmd/server/main-server.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func beforeSendActivityUpdate(ctx context.Context) {
199199
}
200200
}
201201

202-
func startupActivityUpdate() {
202+
func startupActivityUpdate(firstLaunch bool) {
203203
ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
204204
defer cancelFn()
205205
activity := wshrpc.ActivityUpdate{Startup: 1}
@@ -209,7 +209,7 @@ func startupActivityUpdate() {
209209
}
210210
autoUpdateChannel := telemetry.AutoUpdateChannel()
211211
autoUpdateEnabled := telemetry.IsAutoUpdateEnabled()
212-
tevent := telemetrydata.MakeTEvent("app:startup", telemetrydata.TEventProps{
212+
props := telemetrydata.TEventProps{
213213
UserSet: &telemetrydata.TEventUserProps{
214214
ClientVersion: "v" + WaveVersion,
215215
ClientBuildTime: BuildTime,
@@ -222,7 +222,11 @@ func startupActivityUpdate() {
222222
UserSetOnce: &telemetrydata.TEventUserProps{
223223
ClientInitialVersion: "v" + WaveVersion,
224224
},
225-
})
225+
}
226+
if firstLaunch {
227+
props.AppFirstLaunch = true
228+
}
229+
tevent := telemetrydata.MakeTEvent("app:startup", props)
226230
err = telemetry.RecordTEvent(ctx, tevent)
227231
if err != nil {
228232
log.Printf("error recording startup event: %v\n", err)
@@ -367,11 +371,14 @@ func main() {
367371
log.Printf("error initializing wsh and shell-integration files: %v\n", err)
368372
}
369373
}()
370-
err = wcore.EnsureInitialData()
374+
firstLaunch, err := wcore.EnsureInitialData()
371375
if err != nil {
372376
log.Printf("error ensuring initial data: %v\n", err)
373377
return
374378
}
379+
if firstLaunch {
380+
log.Printf("first launch detected")
381+
}
375382
err = clearTempFiles()
376383
if err != nil {
377384
log.Printf("error clearing temp files: %v\n", err)
@@ -385,7 +392,7 @@ func main() {
385392
go stdinReadWatch()
386393
go telemetryLoop()
387394
go updateTelemetryCountsLoop()
388-
startupActivityUpdate() // must be after startConfigWatcher()
395+
startupActivityUpdate(firstLaunch) // must be after startConfigWatcher()
389396
blocklogger.InitBlockLogger()
390397

391398
webListener, err := web.MakeTCPListener("web")

pkg/telemetry/telemetrydata/telemetrydata.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ type TEventProps struct {
7070
FgMinutes int `json:"activity:fgminutes,omitempty"`
7171
OpenMinutes int `json:"activity:openminutes,omitempty"`
7272

73-
AppFirstDay bool `json:"app:firstday,omitempty"`
73+
AppFirstDay bool `json:"app:firstday,omitempty"`
74+
AppFirstLaunch bool `json:"app:firstlaunch,omitempty"`
7475

7576
ActionInitiator string `json:"action:initiator,omitempty" tstype:"\"keyboard\" | \"mouse\""`
7677
PanicType string `json:"debug:panictype,omitempty"`

pkg/wcore/wcore.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
// orchestrating the wave object store, the wave pubsub system, and the wave rpc system
2121

2222
// Ensures that the initial data is present in the store, creates an initial window if needed
23-
func EnsureInitialData() error {
23+
func EnsureInitialData() (bool, error) {
2424
// does not need to run in a transaction since it is called on startup
2525
ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
2626
defer cancelFn()
@@ -29,11 +29,7 @@ func EnsureInitialData() error {
2929
if err == wstore.ErrNotFound {
3030
client, err = CreateClient(ctx)
3131
if err != nil {
32-
return fmt.Errorf("error creating client: %w", err)
33-
}
34-
migrateErr := wstore.TryMigrateOldHistory()
35-
if migrateErr != nil {
36-
log.Printf("error migrating old history: %v\n", migrateErr)
32+
return false, fmt.Errorf("error creating client: %w", err)
3733
}
3834
firstLaunch = true
3935
}
@@ -42,33 +38,33 @@ func EnsureInitialData() error {
4238
client.TempOID = uuid.NewString()
4339
err = wstore.DBUpdate(ctx, client)
4440
if err != nil {
45-
return fmt.Errorf("error updating client: %w", err)
41+
return firstLaunch, fmt.Errorf("error updating client: %w", err)
4642
}
4743
}
4844
log.Printf("clientid: %s\n", client.OID)
4945
if len(client.WindowIds) == 1 {
5046
log.Println("client has one window")
5147
CheckAndFixWindow(ctx, client.WindowIds[0])
52-
return nil
48+
return firstLaunch, nil
5349
}
5450
if len(client.WindowIds) > 0 {
5551
log.Println("client has windows")
56-
return nil
52+
return firstLaunch, nil
5753
}
5854
wsId := ""
5955
if firstLaunch {
6056
log.Println("client has no windows and first launch, creating starter workspace")
6157
starterWs, err := CreateWorkspace(ctx, "Starter workspace", "custom@wave-logo-solid", "#58C142", false, true)
6258
if err != nil {
63-
return fmt.Errorf("error creating starter workspace: %w", err)
59+
return firstLaunch, fmt.Errorf("error creating starter workspace: %w", err)
6460
}
6561
wsId = starterWs.OID
6662
}
6763
_, err = CreateWindow(ctx, nil, wsId)
6864
if err != nil {
69-
return fmt.Errorf("error creating window: %w", err)
65+
return firstLaunch, fmt.Errorf("error creating window: %w", err)
7066
}
71-
return nil
67+
return firstLaunch, nil
7268
}
7369

7470
func CreateClient(ctx context.Context) (*waveobj.Client, error) {

0 commit comments

Comments
 (0)