@@ -13,26 +13,26 @@ const mockLdClient: LDClientMin = {
1313
1414const testContext : LDContext = { kind : 'user' , key : 'test-user' } ;
1515const configKey = 'test-config' ;
16- const versionKey = 'v1' ;
16+ const variationKey = 'v1' ;
1717
1818beforeEach ( ( ) => {
1919 jest . clearAllMocks ( ) ;
2020} ) ;
2121
2222it ( 'tracks duration' , ( ) => {
23- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
23+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
2424 tracker . trackDuration ( 1000 ) ;
2525
2626 expect ( mockTrack ) . toHaveBeenCalledWith (
2727 '$ld:ai:duration:total' ,
2828 testContext ,
29- { configKey, versionKey } ,
29+ { configKey, variationKey } ,
3030 1000 ,
3131 ) ;
3232} ) ;
3333
3434it ( 'tracks duration of async function' , async ( ) => {
35- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
35+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
3636 jest . spyOn ( global . Date , 'now' ) . mockReturnValueOnce ( 1000 ) . mockReturnValueOnce ( 2000 ) ;
3737
3838 const result = await tracker . trackDurationOf ( async ( ) => 'test-result' ) ;
@@ -41,49 +41,49 @@ it('tracks duration of async function', async () => {
4141 expect ( mockTrack ) . toHaveBeenCalledWith (
4242 '$ld:ai:duration:total' ,
4343 testContext ,
44- { configKey, versionKey } ,
44+ { configKey, variationKey } ,
4545 1000 ,
4646 ) ;
4747} ) ;
4848
4949it ( 'tracks positive feedback' , ( ) => {
50- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
50+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
5151 tracker . trackFeedback ( { kind : LDFeedbackKind . Positive } ) ;
5252
5353 expect ( mockTrack ) . toHaveBeenCalledWith (
5454 '$ld:ai:feedback:user:positive' ,
5555 testContext ,
56- { configKey, versionKey } ,
56+ { configKey, variationKey } ,
5757 1 ,
5858 ) ;
5959} ) ;
6060
6161it ( 'tracks negative feedback' , ( ) => {
62- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
62+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
6363 tracker . trackFeedback ( { kind : LDFeedbackKind . Negative } ) ;
6464
6565 expect ( mockTrack ) . toHaveBeenCalledWith (
6666 '$ld:ai:feedback:user:negative' ,
6767 testContext ,
68- { configKey, versionKey } ,
68+ { configKey, variationKey } ,
6969 1 ,
7070 ) ;
7171} ) ;
7272
7373it ( 'tracks success' , ( ) => {
74- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
74+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
7575 tracker . trackSuccess ( ) ;
7676
7777 expect ( mockTrack ) . toHaveBeenCalledWith (
7878 '$ld:ai:generation' ,
7979 testContext ,
80- { configKey, versionKey } ,
80+ { configKey, variationKey } ,
8181 1 ,
8282 ) ;
8383} ) ;
8484
8585it ( 'tracks OpenAI usage' , async ( ) => {
86- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
86+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
8787 jest . spyOn ( global . Date , 'now' ) . mockReturnValueOnce ( 1000 ) . mockReturnValueOnce ( 2000 ) ;
8888
8989 const TOTAL_TOKENS = 100 ;
@@ -101,41 +101,41 @@ it('tracks OpenAI usage', async () => {
101101 expect ( mockTrack ) . toHaveBeenCalledWith (
102102 '$ld:ai:duration:total' ,
103103 testContext ,
104- { configKey, versionKey } ,
104+ { configKey, variationKey } ,
105105 1000 ,
106106 ) ;
107107
108108 expect ( mockTrack ) . toHaveBeenCalledWith (
109109 '$ld:ai:generation' ,
110110 testContext ,
111- { configKey, versionKey } ,
111+ { configKey, variationKey } ,
112112 1 ,
113113 ) ;
114114
115115 expect ( mockTrack ) . toHaveBeenCalledWith (
116116 '$ld:ai:tokens:total' ,
117117 testContext ,
118- { configKey, versionKey } ,
118+ { configKey, variationKey } ,
119119 TOTAL_TOKENS ,
120120 ) ;
121121
122122 expect ( mockTrack ) . toHaveBeenCalledWith (
123123 '$ld:ai:tokens:input' ,
124124 testContext ,
125- { configKey, versionKey } ,
125+ { configKey, variationKey } ,
126126 PROMPT_TOKENS ,
127127 ) ;
128128
129129 expect ( mockTrack ) . toHaveBeenCalledWith (
130130 '$ld:ai:tokens:output' ,
131131 testContext ,
132- { configKey, versionKey } ,
132+ { configKey, variationKey } ,
133133 COMPLETION_TOKENS ,
134134 ) ;
135135} ) ;
136136
137137it ( 'tracks Bedrock conversation with successful response' , ( ) => {
138- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
138+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
139139
140140 const TOTAL_TOKENS = 100 ;
141141 const PROMPT_TOKENS = 49 ;
@@ -156,41 +156,41 @@ it('tracks Bedrock conversation with successful response', () => {
156156 expect ( mockTrack ) . toHaveBeenCalledWith (
157157 '$ld:ai:generation' ,
158158 testContext ,
159- { configKey, versionKey } ,
159+ { configKey, variationKey } ,
160160 1 ,
161161 ) ;
162162
163163 expect ( mockTrack ) . toHaveBeenCalledWith (
164164 '$ld:ai:duration:total' ,
165165 testContext ,
166- { configKey, versionKey } ,
166+ { configKey, variationKey } ,
167167 500 ,
168168 ) ;
169169
170170 expect ( mockTrack ) . toHaveBeenCalledWith (
171171 '$ld:ai:tokens:total' ,
172172 testContext ,
173- { configKey, versionKey } ,
173+ { configKey, variationKey } ,
174174 TOTAL_TOKENS ,
175175 ) ;
176176
177177 expect ( mockTrack ) . toHaveBeenCalledWith (
178178 '$ld:ai:tokens:input' ,
179179 testContext ,
180- { configKey, versionKey } ,
180+ { configKey, variationKey } ,
181181 PROMPT_TOKENS ,
182182 ) ;
183183
184184 expect ( mockTrack ) . toHaveBeenCalledWith (
185185 '$ld:ai:tokens:output' ,
186186 testContext ,
187- { configKey, versionKey } ,
187+ { configKey, variationKey } ,
188188 COMPLETION_TOKENS ,
189189 ) ;
190190} ) ;
191191
192192it ( 'tracks Bedrock conversation with error response' , ( ) => {
193- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
193+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
194194
195195 const response = {
196196 $metadata : { httpStatusCode : 400 } ,
@@ -204,7 +204,7 @@ it('tracks Bedrock conversation with error response', () => {
204204} ) ;
205205
206206it ( 'tracks tokens' , ( ) => {
207- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
207+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
208208
209209 const TOTAL_TOKENS = 100 ;
210210 const PROMPT_TOKENS = 49 ;
@@ -219,27 +219,27 @@ it('tracks tokens', () => {
219219 expect ( mockTrack ) . toHaveBeenCalledWith (
220220 '$ld:ai:tokens:total' ,
221221 testContext ,
222- { configKey, versionKey } ,
222+ { configKey, variationKey } ,
223223 TOTAL_TOKENS ,
224224 ) ;
225225
226226 expect ( mockTrack ) . toHaveBeenCalledWith (
227227 '$ld:ai:tokens:input' ,
228228 testContext ,
229- { configKey, versionKey } ,
229+ { configKey, variationKey } ,
230230 PROMPT_TOKENS ,
231231 ) ;
232232
233233 expect ( mockTrack ) . toHaveBeenCalledWith (
234234 '$ld:ai:tokens:output' ,
235235 testContext ,
236- { configKey, versionKey } ,
236+ { configKey, variationKey } ,
237237 COMPLETION_TOKENS ,
238238 ) ;
239239} ) ;
240240
241241it ( 'only tracks non-zero token counts' , ( ) => {
242- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
242+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
243243
244244 tracker . trackTokens ( {
245245 total : 0 ,
@@ -257,7 +257,7 @@ it('only tracks non-zero token counts', () => {
257257 expect ( mockTrack ) . toHaveBeenCalledWith (
258258 '$ld:ai:tokens:input' ,
259259 testContext ,
260- { configKey, versionKey } ,
260+ { configKey, variationKey } ,
261261 50 ,
262262 ) ;
263263
@@ -270,15 +270,15 @@ it('only tracks non-zero token counts', () => {
270270} ) ;
271271
272272it ( 'returns empty summary when no metrics tracked' , ( ) => {
273- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
273+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
274274
275275 const summary = tracker . getSummary ( ) ;
276276
277277 expect ( summary ) . toEqual ( { } ) ;
278278} ) ;
279279
280280it ( 'summarizes tracked metrics' , ( ) => {
281- const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , versionKey , testContext ) ;
281+ const tracker = new LDAIConfigTrackerImpl ( mockLdClient , configKey , variationKey , testContext ) ;
282282
283283 tracker . trackDuration ( 1000 ) ;
284284 tracker . trackTokens ( {
0 commit comments