@@ -11,6 +11,7 @@ import { getComputeEnvType, getOperatingSystem } from '../shared/telemetry/util'
1111import { AuthFormId } from '../login/webview/vue/types'
1212import { getLogger } from '../shared/logger/logger'
1313
14+ const logger = getLogger ( 'notifications' )
1415/**
1516 * Evaluates if a given version fits into the parameters specified by a notification, e.g:
1617 *
@@ -72,31 +73,51 @@ export class RuleEngine {
7273 constructor ( private readonly context : RuleContext ) { }
7374
7475 public shouldDisplayNotification ( payload : ToolkitNotification ) {
75- return this . evaluate ( payload . displayIf )
76+ return this . evaluate ( payload . id , payload . displayIf )
7677 }
7778
78- private evaluate ( condition : DisplayIf ) : boolean {
79+ private evaluate ( id : string , condition : DisplayIf ) : boolean {
7980 const currentExt = globals . context . extension . id
8081 if ( condition . extensionId !== currentExt ) {
82+ logger . verbose (
83+ 'notification id: (%s) did NOT pass extension id check, actual ext id: (%s), expected ext id: (%s)' ,
84+ id ,
85+ currentExt ,
86+ condition . extensionId
87+ )
8188 return false
8289 }
8390
8491 if ( condition . ideVersion ) {
8592 if ( ! isValidVersion ( this . context . ideVersion , condition . ideVersion ) ) {
93+ logger . verbose (
94+ 'notification id: (%s) did NOT pass IDE version check, actual version: (%s), expected version: (%s)' ,
95+ id ,
96+ this . context . ideVersion ,
97+ condition . ideVersion
98+ )
8699 return false
87100 }
88101 }
89102 if ( condition . extensionVersion ) {
90103 if ( ! isValidVersion ( this . context . extensionVersion , condition . extensionVersion ) ) {
104+ logger . verbose (
105+ 'notification id: (%s) did NOT pass extension version check, actual ext version: (%s), expected ext version: (%s)' ,
106+ id ,
107+ this . context . extensionVersion ,
108+ condition . extensionVersion
109+ )
91110 return false
92111 }
93112 }
94113
95114 if ( condition . additionalCriteria ) {
96115 for ( const criteria of condition . additionalCriteria ) {
97116 if ( ! this . evaluateRule ( criteria ) ) {
117+ logger . verbose ( 'notification id: (%s) did NOT pass criteria check: %O' , id , criteria )
98118 return false
99119 }
120+ logger . debug ( 'notification id: (%s) passed criteria check: %O' , id , criteria )
100121 }
101122 }
102123
@@ -176,7 +197,7 @@ export async function getRuleContext(context: vscode.ExtensionContext, authState
176197 }
177198
178199 const { activeExtensions, ...loggableRuleContext } = ruleContext
179- getLogger ( 'notifications' ) . debug ( 'getRuleContext() determined rule context: %O' , loggableRuleContext )
200+ logger . debug ( 'getRuleContext() determined rule context: %O' , loggableRuleContext )
180201
181202 return ruleContext
182203}
0 commit comments