@@ -125,7 +125,9 @@ function GetLlmoOpportunityUsageCommand(context) {
125125 } ) ;
126126
127127 const { dataAccess, log } = context ;
128- const { Site, Organization, Opportunity } = dataAccess ;
128+ const {
129+ Site, Organization, Opportunity, Entitlement,
130+ } = dataAccess ;
129131
130132 const countLlmoOpportunities = async ( siteId ) => {
131133 const opportunities = await Opportunity . allBySiteId ( siteId ) ;
@@ -191,6 +193,18 @@ function GetLlmoOpportunityUsageCommand(context) {
191193 log . info ( `Skipping excluded IMS org: ${ imsOrgId } for site: ${ site . getBaseURL ( ) } ` ) ;
192194 return null ;
193195 }
196+
197+ // Get tier from entitlements
198+ let tier = 'N/A' ;
199+ if ( organization ) {
200+ const entitlements = await Entitlement . allByOrganizationId ( organization . getId ( ) ) ;
201+ if ( entitlements && entitlements . length > 0 ) {
202+ const llmoEntitlement = entitlements . find ( ( e ) => e . getProductCode ( ) === 'LLMO' ) ;
203+ if ( llmoEntitlement ) {
204+ tier = llmoEntitlement . getTier ( ) ;
205+ }
206+ }
207+ }
194208 const containsGeo403 = queryIndex ?. data ?. some ( ( item ) => item . path . includes ( 'agentic-traffic/agentictraffic-errors-403' ) ) || false ;
195209 const containsGeo404 = queryIndex ?. data ?. some ( ( item ) => item . path . includes ( 'agentic-traffic/agentictraffic-errors-404' ) ) || false ;
196210 const containsGeo5xx = queryIndex ?. data ?. some ( ( item ) => item . path . includes ( 'agentic-traffic/agentictraffic-errors-5xx' ) ) || false ;
@@ -220,6 +234,7 @@ function GetLlmoOpportunityUsageCommand(context) {
220234 organizationId : site . getOrganizationId ( ) ,
221235 imsOrgName,
222236 imsOrgId,
237+ tier,
223238 totalOpportunities,
224239 containsGeo403,
225240 containsGeo404,
@@ -253,6 +268,7 @@ function GetLlmoOpportunityUsageCommand(context) {
253268 { id : 'organizationId' , title : 'Organization ID' } ,
254269 { id : 'imsOrgName' , title : 'IMS Org Name' } ,
255270 { id : 'imsOrgId' , title : 'IMS Org ID' } ,
271+ { id : 'tier' , title : 'Tier' } ,
256272 { id : 'containsGeo403' , title : 'Has Tech GEO 403' } ,
257273 { id : 'containsGeo404' , title : 'Has Tech GEO 404' } ,
258274 { id : 'containsGeo5xx' , title : 'Has Tech GEO 5xx' } ,
0 commit comments