@@ -27,6 +27,7 @@ type globalKey =
2727 | stepFunctionsKey
2828 | ToolIdStateKey
2929 | JsonSchemasKey
30+ | 'amazonq.telemetry.migrated'
3031 | 'aws.amazonq.codewhisperer.newCustomizations'
3132 | 'aws.amazonq.hasShownWalkthrough'
3233 | 'aws.amazonq.showTryChatCodeLens'
@@ -61,6 +62,8 @@ type globalKey =
6162 | 'region'
6263 // TODO: implement this via `PromptSettings` instead of globalState.
6364 | 'sam.sync.updateMessage'
65+ | 'telemetryClientId'
66+ | 'telemetryId'
6467
6568/**
6669 * Extension-local (not visible to other vscode extensions) shared state which persists after IDE
@@ -75,7 +78,7 @@ type globalKey =
7578 * - garbage collection
7679 */
7780export class GlobalState implements vscode . Memento {
78- constructor ( private readonly memento : vscode . Memento ) { }
81+ constructor ( protected readonly memento : vscode . Memento ) { }
7982
8083 keys ( ) : readonly string [ ] {
8184 return this . memento . keys ( )
@@ -93,9 +96,9 @@ export class GlobalState implements vscode.Memento {
9396 * {@link String}, {@link Boolean}, etc.
9497 * @param defaultVal Value returned if `key` has no value.
9598 */
96- getStrict < T > ( key : globalKey , type : TypeConstructor < T > , defaulVal ?: T ) {
99+ getStrict < T > ( key : globalKey , type : TypeConstructor < T > , defaultVal ?: T ) {
97100 try {
98- const val = this . memento . get < T > ( key ) ?? defaulVal
101+ const val = this . memento . get < T > ( key ) ?? defaultVal
99102 return ! type || val === undefined ? val : cast ( val , type )
100103 } catch ( e ) {
101104 const msg = `GlobalState: invalid state (or read failed) for key: "${ key } "`
@@ -117,27 +120,27 @@ export class GlobalState implements vscode.Memento {
117120 * @param key Key name
118121 * @param defaultVal Value returned if `key` has no value.
119122 */
120- get < T > ( key : globalKey , defaulVal ?: T ) : T | undefined {
123+ get < T > ( key : globalKey , defaultVal ?: T ) : T | undefined {
121124 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 )
123126 }
124127
125128 /**
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 `.
127130 *
128131 * @param key Key name
129132 * @param type Type validator function, or primitive type constructor such as {@link Object},
130133 * {@link String}, {@link Boolean}, etc.
131134 * @param defaultVal Value returned if `key` has no value.
132135 */
133136 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 {
136139 try {
137- return this . getStrict ( key , type , defaulVal )
140+ return this . getStrict ( key , type , defaultVal )
138141 } catch ( e ) {
139142 getLogger ( ) . error ( '%s' , ( e as Error ) . message )
140- return defaulVal
143+ return defaultVal
141144 }
142145 }
143146
0 commit comments