@@ -3,6 +3,7 @@ import communicationStore from "../store/communication"
3
3
import commonStore from '../store/common' ;
4
4
import { formatExportedChartDatas } from "../utils/save"
5
5
import { checkUploadPrivacy } from '../utils/userConfig' ;
6
+ import { tracker } from "@/utils/tracker" ;
6
7
7
8
import { chartToWorkflow } from "@kanaries/graphic-walker"
8
9
import { DocumentTextIcon } from '@heroicons/react/24/outline' ;
@@ -60,9 +61,10 @@ export function getSaveTool(
60
61
} , 500 ) ;
61
62
}
62
63
63
- const onClick = async ( ) => {
64
+ const onClick = async ( where : string ) => {
64
65
if ( saving ) return ;
65
66
setSaving ( true ) ;
67
+ tracker . track ( "click" , { "entity" : `save_${ where } ` , "spec_type" : props . specType } )
66
68
67
69
// if exportChart is undefined, it means that the chart is not reload, so we think dont need to save.
68
70
if ( gwRef . current ?. exportChart === undefined ) {
@@ -109,14 +111,19 @@ export function getSaveTool(
109
111
}
110
112
}
111
113
114
+ const onClickUpload = ( ) => {
115
+ commonStore . setUploadChartModalOpen ( true ) ;
116
+ tracker . track ( "click" , { "entity" : "save_icon_form_upload" , "spec_type" : props . specType } ) ;
117
+ }
118
+
112
119
useEffect ( ( ) => {
113
120
let locker = false ;
114
121
document . addEventListener ( "keydown" , ( event ) => {
115
122
if ( ( event . metaKey || event . ctrlKey ) && event . key === 's' ) {
116
123
event . preventDefault ( ) ;
117
124
if ( locker ) return ;
118
125
locker = true ;
119
- onClick ( ) . then ( ( ) => {
126
+ onClick ( "from_keyboard" ) . then ( ( ) => {
120
127
locker = false ;
121
128
} ) ;
122
129
}
@@ -132,16 +139,16 @@ export function getSaveTool(
132
139
} ,
133
140
form : (
134
141
< div className = 'flex flex-col' >
135
- < Button variant = "ghost" aria-label = "save spec" onClick = { onClick } >
142
+ < Button variant = "ghost" aria-label = "save spec" onClick = { ( ) => onClick ( "icon_form_save" ) } >
136
143
save spec
137
144
</ Button >
138
145
{ showUploadButton && (
139
- < Button variant = "ghost" aria-label = "upload chart" onClick = { ( ) => { commonStore . setUploadChartModalOpen ( true ) } } >
146
+ < Button variant = "ghost" aria-label = "upload chart" onClick = { onClickUpload } >
140
147
upload chart
141
148
</ Button >
142
149
) }
143
150
</ div >
144
151
) ,
145
- onClick : onClick ,
152
+ onClick : ( ) => onClick ( "icon" ) ,
146
153
}
147
154
}
0 commit comments