@@ -27,6 +27,7 @@ type globalKey =
27
27
| stepFunctionsKey
28
28
| ToolIdStateKey
29
29
| JsonSchemasKey
30
+ | 'amazonq.telemetry.migrated'
30
31
| 'aws.amazonq.codewhisperer.newCustomizations'
31
32
| 'aws.amazonq.hasShownWalkthrough'
32
33
| 'aws.amazonq.showTryChatCodeLens'
@@ -61,6 +62,8 @@ type globalKey =
61
62
| 'region'
62
63
// TODO: implement this via `PromptSettings` instead of globalState.
63
64
| 'sam.sync.updateMessage'
65
+ | 'telemetryClientId'
66
+ | 'telemetryId'
64
67
65
68
/**
66
69
* Extension-local (not visible to other vscode extensions) shared state which persists after IDE
@@ -75,7 +78,7 @@ type globalKey =
75
78
* - garbage collection
76
79
*/
77
80
export class GlobalState implements vscode . Memento {
78
- constructor ( private readonly memento : vscode . Memento ) { }
81
+ constructor ( protected readonly memento : vscode . Memento ) { }
79
82
80
83
keys ( ) : readonly string [ ] {
81
84
return this . memento . keys ( )
@@ -93,9 +96,9 @@ export class GlobalState implements vscode.Memento {
93
96
* {@link String}, {@link Boolean}, etc.
94
97
* @param defaultVal Value returned if `key` has no value.
95
98
*/
96
- getStrict < T > ( key : globalKey , type : TypeConstructor < T > , defaulVal ?: T ) {
99
+ getStrict < T > ( key : globalKey , type : TypeConstructor < T > , defaultVal ?: T ) {
97
100
try {
98
- const val = this . memento . get < T > ( key ) ?? defaulVal
101
+ const val = this . memento . get < T > ( key ) ?? defaultVal
99
102
return ! type || val === undefined ? val : cast ( val , type )
100
103
} catch ( e ) {
101
104
const msg = `GlobalState: invalid state (or read failed) for key: "${ key } "`
@@ -117,27 +120,27 @@ export class GlobalState implements vscode.Memento {
117
120
* @param key Key name
118
121
* @param defaultVal Value returned if `key` has no value.
119
122
*/
120
- get < T > ( key : globalKey , defaulVal ?: T ) : T | undefined {
123
+ get < T > ( key : globalKey , defaultVal ?: T ) : T | undefined {
121
124
const skip = ( o : any ) => o as T // Don't type check.
122
- return this . getStrict ( key , skip , defaulVal )
125
+ return this . getStrict ( key , skip , defaultVal )
123
126
}
124
127
125
128
/**
126
- * Gets the value for `key` if it satisfies the `type` specification, else logs an error and returns `defaulVal `.
129
+ * Gets the value for `key` if it satisfies the `type` specification, else logs an error and returns `defaultVal `.
127
130
*
128
131
* @param key Key name
129
132
* @param type Type validator function, or primitive type constructor such as {@link Object},
130
133
* {@link String}, {@link Boolean}, etc.
131
134
* @param defaultVal Value returned if `key` has no value.
132
135
*/
133
136
tryGet < T > ( key : globalKey , type : TypeConstructor < T > ) : T | undefined
134
- tryGet < T > ( key : globalKey , type : TypeConstructor < T > , defaulVal : T ) : T
135
- tryGet < T > ( key : globalKey , type : TypeConstructor < T > , defaulVal ?: T ) : T | undefined {
137
+ tryGet < T > ( key : globalKey , type : TypeConstructor < T > , defaultVal : T ) : T
138
+ tryGet < T > ( key : globalKey , type : TypeConstructor < T > , defaultVal ?: T ) : T | undefined {
136
139
try {
137
- return this . getStrict ( key , type , defaulVal )
140
+ return this . getStrict ( key , type , defaultVal )
138
141
} catch ( e ) {
139
142
getLogger ( ) . error ( '%s' , ( e as Error ) . message )
140
- return defaulVal
143
+ return defaultVal
141
144
}
142
145
}
143
146
0 commit comments