@@ -8,7 +8,7 @@ import { AtlasServiceError } from '@mongodb-js/atlas-service/renderer';
8
8
import type { ConnectionInfo } from '@mongodb-js/compass-connections/provider' ;
9
9
import type { Document } from 'mongodb' ;
10
10
import type { Logger } from '@mongodb-js/compass-logging' ;
11
- import { EJSON , UUID } from 'bson' ;
11
+ import { EJSON } from 'bson' ;
12
12
import { signIntoAtlasWithModalPrompt } from './store/atlas-signin-reducer' ;
13
13
import { getStore } from './store/atlas-ai-store' ;
14
14
import { optIntoGenAIWithModalPrompt } from './store/atlas-optin-reducer' ;
@@ -198,17 +198,15 @@ const aiURLConfig = {
198
198
// Down the line we'd like to only use the admin api, however,
199
199
// we cannot currently call that from the Atlas UI. Pending CLOUDP-251201
200
200
'admin-api' : {
201
- 'user-access' : ( userId : string ) => `unauth/ai/api/v1/hello/${ userId } ` ,
202
201
aggregation : 'ai/api/v1/mql-aggregation' ,
203
202
query : 'ai/api/v1/mql-query' ,
204
203
} ,
205
204
cloud : {
206
- 'user-access' : ( userId : string ) => `ai/v1/hello/${ userId } ` ,
207
205
aggregation : ( groupId : string ) => `ai/v1/groups/${ groupId } /mql-aggregation` ,
208
206
query : ( groupId : string ) => `ai/v1/groups/${ groupId } /mql-query` ,
209
207
} ,
210
208
} as const ;
211
- type AIEndpoint = 'user-access' | ' query' | 'aggregation' ;
209
+ type AIEndpoint = 'query' | 'aggregation' ;
212
210
213
211
export class AtlasAiService {
214
212
private initPromise : Promise < void > | null = null ;
@@ -242,15 +240,6 @@ export class AtlasAiService {
242
240
connectionInfo ?: ConnectionInfo
243
241
) {
244
242
if ( this . apiURLPreset === 'cloud' ) {
245
- if ( urlId === 'user-access' ) {
246
- return this . atlasService . cloudEndpoint (
247
- aiURLConfig [ this . apiURLPreset ] [ urlId ] (
248
- this . preferences . getPreferences ( ) . telemetryAtlasUserId ??
249
- new UUID ( ) . toString ( )
250
- )
251
- ) ;
252
- }
253
-
254
243
const atlasMetadata = connectionInfo ?. atlasMetadata ;
255
244
if ( ! atlasMetadata ) {
256
245
throw new Error (
@@ -262,15 +251,7 @@ export class AtlasAiService {
262
251
aiURLConfig [ this . apiURLPreset ] [ urlId ] ( atlasMetadata . projectId )
263
252
) ;
264
253
}
265
- const urlConfig = aiURLConfig [ this . apiURLPreset ] [ urlId ] ;
266
- const urlPath =
267
- typeof urlConfig === 'function'
268
- ? urlConfig (
269
- this . preferences . getPreferences ( ) . telemetryAtlasUserId ??
270
- new UUID ( ) . toString ( )
271
- )
272
- : urlConfig ;
273
-
254
+ const urlPath = aiURLConfig [ this . apiURLPreset ] [ urlId ] ;
274
255
return this . atlasService . adminApiEndpoint ( urlPath ) ;
275
256
}
276
257
@@ -285,50 +266,14 @@ export class AtlasAiService {
285
266
}
286
267
}
287
268
288
- private async getAIFeatureEnablement ( ) : Promise < AIFeatureEnablement > {
289
- const url = this . getUrlForEndpoint ( 'user-access' ) ;
290
-
291
- const res = await this . atlasService . fetch ( url , {
292
- headers : {
293
- Accept : 'application/json' ,
269
+ async setupAIAccess ( ) : Promise < void > {
270
+ // We default GEN_AI_ACCESS on for everyone. Down the line if/when
271
+ // we add more features with partial rollout, we'll fetch access here.
272
+ await this . preferences . savePreferences ( {
273
+ cloudFeatureRolloutAccess : {
274
+ GEN_AI_COMPASS : true ,
294
275
} ,
295
276
} ) ;
296
- const body = await res . json ( ) ;
297
- this . validateAIFeatureEnablementResponse ( body ) ;
298
- return body ;
299
- }
300
-
301
- async setupAIAccess ( ) : Promise < void > {
302
- try {
303
- const featureResponse = await this . getAIFeatureEnablement ( ) ;
304
-
305
- const isAIFeatureEnabled =
306
- ! ! featureResponse ?. features ?. GEN_AI_COMPASS ?. enabled ;
307
-
308
- this . logger . log . info (
309
- this . logger . mongoLogId ( 1_001_000_300 ) ,
310
- 'AtlasAIService' ,
311
- 'Fetched if the AI feature is enabled' ,
312
- {
313
- enabled : isAIFeatureEnabled ,
314
- featureResponse,
315
- }
316
- ) ;
317
-
318
- await this . preferences . savePreferences ( {
319
- cloudFeatureRolloutAccess : {
320
- GEN_AI_COMPASS : isAIFeatureEnabled ,
321
- } ,
322
- } ) ;
323
- } catch ( err ) {
324
- // Default to what's already in Compass when we can't fetch the preference.
325
- this . logger . log . error (
326
- this . logger . mongoLogId ( 1_001_000_302 ) ,
327
- 'AtlasAIService' ,
328
- 'Failed to load if the AI feature is enabled' ,
329
- { error : ( err as Error ) . stack }
330
- ) ;
331
- }
332
277
}
333
278
334
279
async ensureAiFeatureAccess ( { signal } : { signal ?: AbortSignal } = { } ) {
0 commit comments