diff --git a/public/app/core/services/echo/init.ts b/public/app/core/services/echo/init.ts index d4ff585b700..5e49e72422a 100644 --- a/public/app/core/services/echo/init.ts +++ b/public/app/core/services/echo/init.ts @@ -146,7 +146,19 @@ async function initRudderstackBackend() { return; } - const modulePromise = config.featureToggles.rudderstackUpgrade + // this will need to be updated when rudderstackSdkV3Url is added + // Desired logic: if only one of the sdk urls is provided, use respective code + // otherwise defer to the feature toggle. + const fakeConfigRudderstackSdkV3Url: string | undefined = undefined; + + const hasOldSdkUrl = Boolean(config.rudderstackSdkUrl); + const hasNewSdkUrl = Boolean(fakeConfigRudderstackSdkV3Url); + const onlyOneConfigURLSet = hasOldSdkUrl !== hasNewSdkUrl; + const useNewRudderstack = onlyOneConfigURLSet ? hasNewSdkUrl : config.featureToggles.rudderstackUpgrade; + + const configUrl = useNewRudderstack ? fakeConfigRudderstackSdkV3Url : config.rudderstackSdkUrl; + + const modulePromise = useNewRudderstack ? import('./backends/analytics/RudderstackV3Backend') : import('./backends/analytics/RudderstackBackend'); @@ -157,7 +169,7 @@ async function initRudderstackBackend() { dataPlaneUrl: config.rudderstackDataPlaneUrl, user: contextSrv.user, sdkUrl: config.rudderstackSdkUrl, - configUrl: config.rudderstackConfigUrl, + configUrl: configUrl, integrationsUrl: config.rudderstackIntegrationsUrl, buildInfo: config.buildInfo, })