@@ -5,13 +5,16 @@ import { Config } from './Config'
55import { Log } from '~/utils'
66import { isDev , isProd , isTest } from '~/env'
77import { Global } from '~/extension'
8+ import { LocaleTreeItem , ProgressSubmenuItem } from '~/views'
9+ import { CommandOptions } from '~/commands/manipulations/common'
810
911const HEAP_ID_DEV = '1082064308'
1012const HEAP_ID_PROD = '4118173713'
1113
1214const HEAP_ID = isProd ? HEAP_ID_PROD : HEAP_ID_DEV
1315
1416export enum TelemetryKey {
17+ Activated = 'activated' ,
1518 DeleteKey = 'delete_key' ,
1619 Disabled = 'disabled' ,
1720 EditKey = 'edit_key' ,
@@ -21,20 +24,26 @@ export enum TelemetryKey {
2124 ExtractStringBulk = 'extract_string_bulk' ,
2225 GoToKey = 'goto_key' ,
2326 InsertKey = 'insert_key' ,
27+ Installed = 'installed' ,
2428 NewKey = 'new_key' ,
2529 RenameKey = 'rename_key' ,
2630 ReviewAddComment = 'review_add_comment' ,
2731 ReviewApplySuggestion = 'review_apply_suggestion' ,
2832 ReviewApplyTranslation = 'review_apply_translation' ,
2933 TranslateKey = 'translate_key' ,
34+ Updated = 'updated' ,
35+ ReviewEditComment = 'review_edit_comment' ,
36+ ReviewResolveComment = 'review_resolve_comment'
3037}
3138
3239export enum ActionSource {
3340 None = 'none' ,
3441 CommandPattele = 'command_pattele' ,
3542 TreeView = 'tree_view' ,
3643 Hover = 'hover' ,
37- ContextMenu = 'context_menu'
44+ ContextMenu = 'context_menu' ,
45+ UiEditor = 'ui_editor' ,
46+ Review = 'review'
3847}
3948
4049export interface TelemetryEvent {
@@ -63,6 +72,17 @@ export class Telemetry {
6372 return this . _id
6473 }
6574
75+ static checkVersionChange ( ) {
76+ const previousVersion = Config . ctx . globalState . get ( 'i18n-ally.previous-version' )
77+
78+ if ( ! previousVersion )
79+ Telemetry . track ( TelemetryKey . Installed , { new_version : version } )
80+ else if ( previousVersion !== version )
81+ Telemetry . track ( TelemetryKey . Updated , { new_version : version , previous_version : previousVersion } )
82+
83+ Config . ctx . globalState . update ( 'i18n-ally.previous-version' , version )
84+ }
85+
6686 static get isEnabled ( ) {
6787 return Config . telemetry && ! isTest
6888 }
@@ -119,6 +139,12 @@ export class Telemetry {
119139 }
120140 }
121141
142+ static getActionSource ( item ?: LocaleTreeItem | ProgressSubmenuItem | CommandOptions ) {
143+ return ( item instanceof LocaleTreeItem || item instanceof ProgressSubmenuItem )
144+ ? ActionSource . TreeView
145+ : item ?. actionSource || ActionSource . CommandPattele
146+ }
147+
122148 static async updateUserProperties ( ) {
123149 if ( ! this . isEnabled )
124150 return
0 commit comments