diff --git a/scripts/deploy/upload-source-maps.ts b/scripts/deploy/upload-source-maps.ts index 0208562d08..b8137c7e34 100644 --- a/scripts/deploy/upload-source-maps.ts +++ b/scripts/deploy/upload-source-maps.ts @@ -88,10 +88,13 @@ function uploadToDatadog( sites: string[] ): void { for (const site of sites) { - if (!site) { - printLog(`No source maps upload configured for ${site}, skipping...`) + const apiKey = getTelemetryOrgApiKey(site) + + if (!apiKey) { + printLog(`No API key configured for ${site}, skipping...`) continue } + printLog(`Uploading ${packageName} source maps with prefix ${prefix} for ${site}...`) command` @@ -103,7 +106,7 @@ function uploadToDatadog( --repository-url https://www.github.com/datadog/browser-sdk ` .withEnvironment({ - DATADOG_API_KEY: getTelemetryOrgApiKey(site), + DATADOG_API_KEY: apiKey, DATADOG_SITE: site, }) .run() diff --git a/scripts/lib/secrets.ts b/scripts/lib/secrets.ts index d601e019e2..b5f7ef27db 100644 --- a/scripts/lib/secrets.ts +++ b/scripts/lib/secrets.ts @@ -42,14 +42,22 @@ export function getOrg2AppKey(): string { return getSecretKey('ci.browser-sdk.datadog_ci_application_key') } -export function getTelemetryOrgApiKey(site: string): string { +export function getTelemetryOrgApiKey(site: string): string | undefined { const normalizedSite = site.replaceAll('.', '-') - return getSecretKey(`ci.browser-sdk.source-maps.${normalizedSite}.ci_api_key`) + try { + return getSecretKey(`ci.browser-sdk.source-maps.${normalizedSite}.ci_api_key`) + } catch { + return + } } -export function getTelemetryOrgApplicationKey(site: string): string { +export function getTelemetryOrgApplicationKey(site: string): string | undefined { const normalizedSite = site.replaceAll('.', '-') - return getSecretKey(`ci.browser-sdk.telemetry.${normalizedSite}.ci_app_key`) + try { + return getSecretKey(`ci.browser-sdk.telemetry.${normalizedSite}.ci_app_key`) + } catch { + return + } } export function getNpmToken(): string {