Skip to content

Commit 3e0658a

Browse files
committed
add provider and local to wave ai telemetry
1 parent 128a786 commit 3e0658a

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

pkg/aiusechat/uctypes/uctypes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ type AIMetrics struct {
332332
WidgetAccess bool `json:"widgetaccess"`
333333
ThinkingLevel string `json:"thinkinglevel,omitempty"`
334334
AIMode string `json:"aimode,omitempty"`
335+
AIProvider string `json:"aiprovider,omitempty"`
336+
IsLocal bool `json:"islocal,omitempty"`
335337
}
336338

337339
type AIFunctionCallInput struct {

pkg/aiusechat/usechat.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ func getSystemPrompt(apiType string, model string, isBuilder bool) []string {
6060
return []string{basePrompt}
6161
}
6262

63+
func isLocalEndpoint(endpoint string) bool {
64+
if endpoint == "" {
65+
return false
66+
}
67+
endpointLower := strings.ToLower(endpoint)
68+
return strings.Contains(endpointLower, "localhost") || strings.Contains(endpointLower, "127.0.0.1")
69+
}
70+
6371
func getWaveAISettings(premium bool, builderMode bool, rtInfo waveobj.ObjRTInfo) (*uctypes.AIOptsType, error) {
6472
maxTokens := DefaultMaxTokens
6573
if builderMode {
@@ -353,6 +361,11 @@ func RunAIChat(ctx context.Context, sseHandler *sse.SSEHandlerCh, backend UseCha
353361
defer activeChats.Delete(chatOpts.ChatId)
354362

355363
stepNum := chatstore.DefaultChatStore.CountUserMessages(chatOpts.ChatId)
364+
aiProvider := chatOpts.Config.Provider
365+
if aiProvider == "" {
366+
aiProvider = uctypes.AIProvider_Custom
367+
}
368+
isLocal := isLocalEndpoint(chatOpts.Config.Endpoint)
356369
metrics := &uctypes.AIMetrics{
357370
ChatId: chatOpts.ChatId,
358371
StepNum: stepNum,
@@ -364,6 +377,8 @@ func RunAIChat(ctx context.Context, sseHandler *sse.SSEHandlerCh, backend UseCha
364377
ToolDetail: make(map[string]int),
365378
ThinkingLevel: chatOpts.Config.ThinkingLevel,
366379
AIMode: chatOpts.Config.AIMode,
380+
AIProvider: aiProvider,
381+
IsLocal: isLocal,
367382
}
368383
firstStep := true
369384
var cont *uctypes.WaveContinueResponse
@@ -563,6 +578,8 @@ func sendAIMetricsTelemetry(ctx context.Context, metrics *uctypes.AIMetrics) {
563578
WaveAIWidgetAccess: metrics.WidgetAccess,
564579
WaveAIThinkingLevel: metrics.ThinkingLevel,
565580
WaveAIMode: metrics.AIMode,
581+
WaveAIProvider: metrics.AIProvider,
582+
WaveAIIsLocal: metrics.IsLocal,
566583
})
567584
_ = telemetry.RecordTEvent(ctx, event)
568585
}

pkg/telemetry/telemetrydata/telemetrydata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ type TEventProps struct {
148148
WaveAIWidgetAccess bool `json:"waveai:widgetaccess,omitempty"`
149149
WaveAIThinkingLevel string `json:"waveai:thinkinglevel,omitempty"`
150150
WaveAIMode string `json:"waveai:mode,omitempty"`
151+
WaveAIProvider string `json:"waveai:provider,omitempty"`
152+
WaveAIIsLocal bool `json:"waveai:islocal,omitempty"`
151153
WaveAIFeedback string `json:"waveai:feedback,omitempty" tstype:"\"good\" | \"bad\""`
152154
WaveAIAction string `json:"waveai:action,omitempty"`
153155

0 commit comments

Comments
 (0)