Skip to content

Commit 1c15139

Browse files
authored
Merge pull request #6496 from remix-project-org/matamo_ai_update
rm RemixAIEvent in matamo types
2 parents 4998811 + 8a813ba commit 1c15139

File tree

7 files changed

+39
-54
lines changed

7 files changed

+39
-54
lines changed

apps/remix-ide/src/app/plugins/remix-ai-assistant.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class RemixAIAssistant extends ViewPlugin {
104104
async handleActivity(type: string, payload: any) {
105105
// Never log user prompts - only track the activity type
106106
const eventName = type === 'promptSend' ? 'remixai-assistant-promptSend' : `remixai-assistant-${type}-${payload}`;
107-
trackMatomoEvent(this, { category: 'ai', action: 'remixAI', name: eventName as any, isClick: true })
107+
trackMatomoEvent(this, { category: 'ai', action: 'chatting', name: `${type}-${payload}`, isClick: true })
108108
}
109109

110110
updateComponent(state: {

apps/remix-ide/src/app/plugins/remixAIPlugin.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class RemixAIPlugin extends Plugin {
195195
params.threadId = newThreadID
196196
params.provider = 'anthropic' // enforce all generation to be only on anthropic
197197
useRag = false
198-
trackMatomoEvent(this, { category: 'ai', action: 'remixAI', name: 'GenerateNewAIWorkspace', isClick: false })
198+
trackMatomoEvent(this, { category: 'ai', action: 'GenerateNewAIWorkspace', name: 'GenerateNewAIWorkspace', isClick: false })
199199
let userPrompt = ''
200200

201201
if (useRag) {
@@ -239,7 +239,7 @@ export class RemixAIPlugin extends Plugin {
239239
params.threadId = newThreadID
240240
params.provider = this.assistantProvider
241241
useRag = false
242-
trackMatomoEvent(this, { category: 'ai', action: 'remixAI', name: 'WorkspaceAgentEdit', isClick: false })
242+
trackMatomoEvent(this, { category: 'ai', action: 'GenerateNewAIWorkspace', name: 'WorkspaceAgentEdit', isClick: false })
243243

244244
await statusCallback?.('Performing workspace request...')
245245
if (useRag) {
@@ -310,7 +310,7 @@ export class RemixAIPlugin extends Plugin {
310310
else {
311311
console.log("chatRequestBuffer is not empty. First process the last request.", this.chatRequestBuffer)
312312
}
313-
trackMatomoEvent(this, { category: 'ai', action: 'remixAI', name: 'remixAI_chat', isClick: false })
313+
trackMatomoEvent(this, { category: 'ai', action: 'chatting', name: 'remixAI_chat', isClick: false })
314314
}
315315

316316
async ProcessChatRequestBuffer(params:IParams=GenerationParams){

libs/remix-api/src/lib/plugins/matomo/events/ai-events.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* AI Events - AI and Copilot related tracking events
3-
*
3+
*
44
* This file contains all AI-related Matomo events including RemixAI interactions,
55
* Ollama local AI, and code completion features.
66
*
@@ -14,9 +14,12 @@ import { MatomoEventBase } from '../core/base-types';
1414

1515
export interface AIEvent extends MatomoEventBase {
1616
category: 'ai';
17-
action: 'remixAI';
18-
name:
19-
// Code completion & generation
17+
action:
18+
| 'remixAI'
19+
| 'error_explaining_SolidityError'
20+
| 'vulnerability_check_pasted_code'
21+
| 'generateDocumentation'
22+
| 'explainFunction'
2023
| 'Copilot_Completion_Accepted'
2124
| 'code_generation'
2225
| 'code_insertion'
@@ -33,17 +36,9 @@ export interface AIEvent extends MatomoEventBase {
3336
| 'error_explaining_SolidityError'
3437
// AI Context
3538
| 'AddingAIContext'
36-
// RemixAI workspace & chat
3739
| 'GenerateNewAIWorkspace'
38-
| 'WorkspaceAgentEdit'
39-
| 'remixAI_chat'
40-
| 'GenerateNewAIWorkspaceFromEditMode'
41-
| 'GenerateNewAIWorkspaceFromModal'
42-
// AI Provider selection
43-
| 'SetAIProvider'
44-
| 'SetOllamaModel'
45-
| 'ModeSwitch'
46-
// Ollama host discovery
40+
| 'chatting'
41+
| 'completion'
4742
| 'ollama_host_cache_hit'
4843
| 'ollama_port_check'
4944
| 'ollama_host_discovered_success'
@@ -91,18 +86,9 @@ export interface AIEvent extends MatomoEventBase {
9186
| 'ollama_fallback_to_provider'
9287
| 'ollama_unavailable'
9388
| 'ollama_connection_error'
94-
// Assistant feedback (kebab-case to match original)
95-
| 'like-response'
96-
| 'dislike-response';
97-
}
98-
99-
/**
100-
* @deprecated Use AIEvent with category: 'ai', action: 'remixAI' instead
101-
* This interface is kept for backward compatibility during migration
102-
*/
103-
export interface RemixAIEvent extends MatomoEventBase {
104-
category: 'remixAI';
105-
action:
89+
| 'ollama_model_selected'
90+
| 'ollama_model_set_backend_success'
91+
| 'ollama_model_set_backend_failed'
10692
| 'ModeSwitch'
10793
| 'GenerateNewAIWorkspaceFromEditMode'
10894
| 'SetAIProvider'

libs/remix-api/src/lib/plugins/matomo/index.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* Matomo Events - Modular Event System
3-
*
3+
*
44
* This is the main index for the split Matomo event system.
55
* It re-exports all events to maintain backward compatibility while
66
* organizing the code into manageable modules.
7-
*
7+
*
88
* Usage:
99
* import { trackMatomoEvent } from '@remix-api'
10-
*
10+
*
1111
* trackMatomoEvent(plugin, { category: 'ai', action: 'remixAI', name: 'code_generation', isClick: true })
1212
* trackMatomoEvent(plugin, { category: 'git', action: 'COMMIT', name: 'success', isClick: true })
1313
*/
@@ -18,7 +18,7 @@ export * from './core/categories';
1818

1919
// Event modules - organized by domain
2020
export * from './events/ai-events';
21-
export * from './events/compiler-events';
21+
export * from './events/compiler-events';
2222
export * from './events/git-events';
2323
export * from './events/ui-events';
2424
export * from './events/file-events';
@@ -27,7 +27,7 @@ export * from './events/plugin-events';
2727
export * from './events/tools-events';
2828

2929
// Import types for union
30-
import type { AIEvent, RemixAIEvent, RemixAIAssistantEvent } from './events/ai-events';
30+
import type { AIEvent, RemixAIAssistantEvent } from './events/ai-events';
3131
import type { CompilerEvent, SolidityCompilerEvent, CompilerContainerEvent } from './events/compiler-events';
3232
import type { GitEvent } from './events/git-events';
3333
import type { HomeTabEvent, TopbarEvent, LayoutEvent, SettingsEvent, ThemeEvent, LocaleEvent, LandingPageEvent, StatusBarEvent } from './events/ui-events';
@@ -40,17 +40,16 @@ import type { DebuggerEvent, EditorEvent, SolidityUnitTestingEvent, SolidityStat
4040
export type MatomoEvent = (
4141
// AI & Assistant events
4242
| AIEvent
43-
| RemixAIEvent
4443
| RemixAIAssistantEvent
45-
44+
4645
// Compilation events
4746
| CompilerEvent
4847
| SolidityCompilerEvent
4948
| CompilerContainerEvent
50-
49+
5150
// Version Control events
5251
| GitEvent
53-
52+
5453
// User Interface events
5554
| HomeTabEvent
5655
| TopbarEvent
@@ -66,12 +65,12 @@ export type MatomoEvent = (
6665
| WorkspaceEvent
6766
| StorageEvent
6867
| BackupEvent
69-
68+
7069
// Blockchain & Contract events
7170
| BlockchainEvent
7271
| UdappEvent
7372
| RunEvent
74-
73+
7574
// Plugin Management events
7675
| PluginEvent
7776
| ManagerEvent
@@ -80,7 +79,7 @@ export type MatomoEvent = (
8079
| MatomoManagerEvent
8180
| PluginPanelEvent
8281
| MigrateEvent
83-
82+
8483
// Development Tools events
8584
| DebuggerEvent
8685
| EditorEvent
@@ -99,7 +98,7 @@ export type MatomoEvent = (
9998
| NoirCompilerEvent
10099
| ContractVerificationEvent
101100
| LearnethEvent
102-
101+
103102
) & {
104103
// Ensure all events have these base properties for backward compatibility
105104
name?: string;

libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
307307
this.currentCompletion.task = this.task
308308

309309
this.rateLimiter.trackCompletionShown()
310-
this.trackMatomoEvent?.({ category: 'ai', action: 'remixAI', name: `${this.task}_did_show` as any, isClick: true })
310+
this.trackMatomoEvent?.({ category: 'ai', action: 'completion', name: this.task + '_did_show', isClick: true })
311311
}
312312

313313
handlePartialAccept?(
@@ -319,7 +319,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
319319
this.currentCompletion.task = this.task
320320

321321
this.rateLimiter.trackCompletionAccepted()
322-
this.trackMatomoEvent?.({ category: 'ai', action: 'remixAI', name: `${this.task}_partial_accept` as any, isClick: true })
322+
this.trackMatomoEvent?.({ category: 'ai', action: 'completion', name: this.task + '_partial_accept', isClick: true })
323323
}
324324

325325
freeInlineCompletions(

libs/remix-ui/remix-ai-assistant/src/components/prompt.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import GroupListMenu from "./contextOptMenu"
44
import { AiContextType, groupListType } from '../types/componentTypes'
55
import { AiAssistantType } from '../types/componentTypes'
66
import { CustomTooltip } from "@remix-ui/helper"
7-
import { RemixAIEvent, MatomoEvent } from '@remix-api';
7+
import { AIEvent, MatomoEvent } from '@remix-api';
88
import { TrackingContext } from '@remix-ide/tracking'
99

1010
// PromptArea component
@@ -84,7 +84,7 @@ export const PromptArea: React.FC<PromptAreaProps> = ({
8484
setIsMaximized
8585
}) => {
8686
const { trackMatomoEvent: baseTrackEvent } = useContext(TrackingContext)
87-
const trackMatomoEvent = <T extends MatomoEvent = RemixAIEvent>(event: T) => {
87+
const trackMatomoEvent = <T extends MatomoEvent = AIEvent>(event: T) => {
8888
baseTrackEvent?.<T>(event)
8989
}
9090

@@ -129,7 +129,7 @@ export const PromptArea: React.FC<PromptAreaProps> = ({
129129
className={`btn btn-sm ${aiMode === 'ask' ? 'btn-primary' : 'btn-outline-secondary'} px-2`}
130130
onClick={() => {
131131
setAiMode('ask')
132-
trackMatomoEvent({ category: 'ai', action: 'remixAI', name: 'ModeSwitch', value: 'ask', isClick: true })
132+
trackMatomoEvent({ category: 'ai', action: 'ModeSwitch', name: 'ask', isClick: true })
133133
}}
134134
title="Ask mode - Chat with AI"
135135
>
@@ -140,7 +140,7 @@ export const PromptArea: React.FC<PromptAreaProps> = ({
140140
className={`btn btn-sm ${aiMode === 'edit' ? 'btn-primary' : 'btn-outline-secondary'} px-2`}
141141
onClick={() => {
142142
setAiMode('edit')
143-
trackMatomoEvent({ category: 'ai', action: 'remixAI', name: 'ModeSwitch', value: 'edit', isClick: true })
143+
trackMatomoEvent({ category: 'ai', action: 'ModeSwitch', name: 'edit', isClick: true })
144144
}}
145145
title="Edit mode - Edit workspace code"
146146
>

libs/remix-ui/remix-ai-assistant/src/components/remix-ui-remix-ai-assistant.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { HandleOpenAIResponse, HandleMistralAIResponse, HandleAnthropicResponse,
66
import '../css/color.css'
77
import { Plugin } from '@remixproject/engine'
88
import { ModalTypes } from '@remix-ui/app'
9-
import { MatomoEvent, AIEvent, RemixAIEvent, RemixAIAssistantEvent } from '@remix-api'
9+
import { MatomoEvent, AIEvent, RemixAIAssistantEvent } from '@remix-api'
1010
import { TrackingContext } from '@remix-ide/tracking'
1111
import { PromptArea } from './prompt'
1212
import { ChatHistoryComponent } from './chat'
@@ -449,7 +449,7 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
449449
dispatchActivity('button', 'generateWorkspace')
450450
if (prompt && prompt.trim()) {
451451
await sendPrompt(`/workspace ${prompt.trim()}`)
452-
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'remixAI', name: 'GenerateNewAIWorkspaceFromEditMode', value: prompt, isClick: true })
452+
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'GenerateNewAIWorkspaceFromEditMode', name: prompt, isClick: true })
453453
}
454454
}, [sendPrompt])
455455

@@ -486,7 +486,7 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
486486
dispatchActivity('button', 'setAssistant')
487487
setMessages([])
488488
sendPrompt(`/setAssistant ${assistantChoice}`)
489-
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'remixAI', name: 'SetAIProvider', value: assistantChoice, isClick: true })
489+
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'SetAIProvider', name: assistantChoice, isClick: true })
490490
// Log specific Ollama selection
491491
if (assistantChoice === 'ollama') {
492492
trackMatomoEvent({ category: 'ai', action: 'remixAI', name: 'ollama_provider_selected', value: `from:${choiceSetting || 'unknown'}`, isClick: false })
@@ -605,7 +605,7 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
605605
console.warn('Failed to set model:', error)
606606
trackMatomoEvent({ category: 'ai', action: 'remixAI', name: 'ollama_model_set_backend_failed', value: `${modelName}|${error.message || 'unknown'}`, isClick: false })
607607
}
608-
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'remixAI', name: 'SetOllamaModel', value: modelName, isClick: true })
608+
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'SetOllamaModel', name: modelName, isClick: true })
609609
}, [props.plugin, selectedModel])
610610

611611
// refresh context whenever selection changes (even if selector is closed)
@@ -654,7 +654,7 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
654654

655655
if (description && description.trim()) {
656656
sendPrompt(`/generate ${description.trim()}`)
657-
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'remixAI', name: 'GenerateNewAIWorkspaceFromModal', value: description, isClick: true })
657+
trackMatomoEvent<AIEvent>({ category: 'ai', action: 'GenerateNewAIWorkspaceFromModal', name: description, isClick: true })
658658
}
659659
} catch {
660660
/* user cancelled */

0 commit comments

Comments
 (0)