@@ -4,6 +4,7 @@ import { CompletionTimer } from './completionTimer';
44
55import axios , { AxiosResponse } from 'axios'
66import { slice } from 'lodash' ;
7+ import { activateService } from '@remixproject/plugin-utils' ;
78const _paq = ( window . _paq = window . _paq || [ ] )
89
910const controller = new AbortController ( ) ;
@@ -14,6 +15,9 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
1415 props : EditorUIProps
1516 monaco : any
1617 completionEnabled : boolean
18+ task : string
19+ currentCompletion
20+
1721 constructor ( props : any , monaco : any ) {
1822 this . props = props
1923 this . monaco = monaco
@@ -28,6 +32,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
2832 const lineRange = model . getFullModelRange ( ) . setStartPosition ( lineNumber , 1 ) . setEndPosition ( lineNumber + 1 , 1 ) ;
2933 return model . getValueInRange ( lineRange ) ;
3034 }
35+
3136 // get text before the position of the completion
3237 const word = model . getValueInRange ( {
3338 startLineNumber : 1 ,
@@ -65,6 +70,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
6570 // use the code generation model, only take max 1000 word as context
6671 this . props . plugin . call ( 'terminal' , 'log' , { type : 'aitypewriterwarning' , value : 'Solcoder - generating code for following comment: ' + ask . replace ( '///' , '' ) } )
6772
73+ this . task = 'code_generation'
6874 const data = await this . props . plugin . call ( 'solcoder' , 'code_generation' , word )
6975
7076 const parsedData = data [ 0 ] . trimStart ( ) //JSON.parse(data).trimStart()
@@ -103,15 +109,16 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
103109 if ( word . replace ( / + $ / , '' ) . endsWith ( '\n' ) ) {
104110 // Code insertion
105111 try {
112+ this . task = 'code_insertion'
106113 const output = await this . props . plugin . call ( 'solcoder' , 'code_insertion' , word , word_after )
107114 const generatedText = output [ 0 ] // no need to clean it. should already be
108-
115+ console . log ( 'generatedText' , generatedText )
109116 const item : monacoTypes . languages . InlineCompletion = {
110117 insertText : generatedText
111118 } ;
112119
113120 this . completionEnabled = false
114- const handleCompletionTimer = new CompletionTimer ( 5000 , ( ) => { this . completionEnabled = true } ) ;
121+ const handleCompletionTimer = new CompletionTimer ( 1000 , ( ) => { this . completionEnabled = true } ) ;
115122 handleCompletionTimer . start ( )
116123
117124 return {
@@ -127,6 +134,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
127134 let result
128135 try {
129136 // Code completion
137+ this . task = 'code_completion'
130138 const output = await this . props . plugin . call ( 'solcoder' , 'code_completion' , word )
131139 const generatedText = output [ 0 ]
132140 let clean = generatedText
@@ -168,14 +176,15 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
168176 }
169177
170178 handleItemDidShow ?( completions : monacoTypes . languages . InlineCompletions < monacoTypes . languages . InlineCompletion > , item : monacoTypes . languages . InlineCompletion , updatedInsertText : string ) : void {
171-
179+ this . currentCompletion = { 'item' :item , 'task' :this . task }
180+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , this . task + '_did_show' ] )
172181 }
173182 handlePartialAccept ?( completions : monacoTypes . languages . InlineCompletions < monacoTypes . languages . InlineCompletion > , item : monacoTypes . languages . InlineCompletion , acceptedCharacters : number ) : void {
174-
183+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , this . task + '_partial_accept' ] )
175184 }
176185 freeInlineCompletions ( completions : monacoTypes . languages . InlineCompletions < monacoTypes . languages . InlineCompletion > ) : void {
177-
178186 }
187+
179188 groupId ?: string ;
180189 yieldsToGroupIds ?: string [ ] ;
181190 toString ?( ) : string {
0 commit comments