@@ -637,6 +637,43 @@ export async function performAsoPlgOnboarding({
637637 onboarding . setSiteId ( site . getId ( ) ) ;
638638 steps . siteResolved = true ;
639639
640+ // Step 5a: Alert when detected delivery type differs from the stored one.
641+ // Skip for newly created sites — delivery type was just set from findDeliveryType in Step 5.
642+ // We alert instead of auto-correcting because findDeliveryType is not 100% reliable.
643+ if ( ! presetDeliveryType && ! steps . siteCreated ) {
644+ const existingDeliveryType = site . getDeliveryType ( ) ;
645+ let detectedDeliveryType ;
646+ try {
647+ detectedDeliveryType = await findDeliveryType ( baseURL ) ;
648+ } catch ( e ) {
649+ log . warn ( `Failed to detect delivery type for ${ baseURL } : ${ e . message } ` ) ;
650+ }
651+ if (
652+ detectedDeliveryType
653+ && detectedDeliveryType !== SiteModel . DELIVERY_TYPES . OTHER
654+ && detectedDeliveryType !== existingDeliveryType
655+ ) {
656+ log . warn ( `Delivery type mismatch for site ${ site . getId ( ) } (${ baseURL } ): stored=${ existingDeliveryType } detected=${ detectedDeliveryType } ` ) ;
657+ const channelId = env . SLACK_PLG_ONBOARDING_CHANNEL_ID ;
658+ const token = env . SLACK_BOT_TOKEN ;
659+ /* c8 ignore next */
660+ if ( channelId && token ) {
661+ const message = ':warning: *PLG Onboarding — Delivery Type Mismatch*\n\n'
662+ + `• *Site ID:* \`${ site . getId ( ) } \`\n`
663+ + `• *Domain:* \`${ baseURL } \`\n`
664+ + `• *Org ID:* \`${ organizationId } \`\n`
665+ + `• *Org:* ${ organization . getName ( ) } (\`${ imsOrgId } \`)\n`
666+ + `• *Stored delivery type:* \`${ existingDeliveryType } \`\n`
667+ + `• *Detected delivery type:* \`${ detectedDeliveryType } \`` ;
668+ try {
669+ await context . postSlackMessage ( channelId , message , token ) ;
670+ } catch ( err ) {
671+ log . error ( `Failed to post delivery type mismatch alert: ${ err . message } ` ) ;
672+ }
673+ }
674+ }
675+ }
676+
640677 // Step 5b: Resolve canonical URL early so the RUM lookup uses the correct hostname
641678 const siteConfig = site . getConfig ( ) ;
642679 const currentFetchConfig = siteConfig . getFetchConfig ( ) || { } ;
0 commit comments