Rudderstack: Update init logic to automatically use new url when new config is set (#115275)

update rudderstack init logic
to rely on existence of old or new sdk config option being set and only defer to feature toggle if both or neither is set
This commit is contained in:
Luminessa Starlight
2025-12-16 15:01:53 -05:00
committed by GitHub
parent bd8f0083ce
commit 30fb1c032a
+14 -2
View File
@@ -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,
})