Skip to content

Commit 3f3aac3

Browse files
committed
👷 handle undefined api key for source-maps upload to new DC
1 parent 315751d commit 3f3aac3

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

‎scripts/deploy/upload-source-maps.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ function uploadToDatadog(
8888
sites: string[]
8989
): void {
9090
for (const site of sites) {
91-
if (!site) {
92-
printLog(`No source maps upload configured for ${site}, skipping...`)
91+
const apiKey = getTelemetryOrgApiKey(site)
92+
93+
if (!apiKey) {
94+
printLog(`No API key configured for ${site}, skipping...`)
9395
continue
9496
}
97+
9598
printLog(`Uploading ${packageName} source maps with prefix ${prefix} for ${site}...`)
9699

97100
command`
@@ -103,7 +106,7 @@ function uploadToDatadog(
103106
--repository-url https://www.github.com/datadog/browser-sdk
104107
`
105108
.withEnvironment({
106-
DATADOG_API_KEY: getTelemetryOrgApiKey(site),
109+
DATADOG_API_KEY: apiKey,
107110
DATADOG_SITE: site,
108111
})
109112
.run()

‎scripts/lib/secrets.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,22 @@ export function getOrg2AppKey(): string {
4242
return getSecretKey('ci.browser-sdk.datadog_ci_application_key')
4343
}
4444

45-
export function getTelemetryOrgApiKey(site: string): string {
45+
export function getTelemetryOrgApiKey(site: string): string | undefined {
4646
const normalizedSite = site.replaceAll('.', '-')
47-
return getSecretKey(`ci.browser-sdk.source-maps.${normalizedSite}.ci_api_key`)
47+
try {
48+
return getSecretKey(`ci.browser-sdk.source-maps.${normalizedSite}.ci_api_key`)
49+
} catch {
50+
return
51+
}
4852
}
4953

50-
export function getTelemetryOrgApplicationKey(site: string): string {
54+
export function getTelemetryOrgApplicationKey(site: string): string | undefined {
5155
const normalizedSite = site.replaceAll('.', '-')
52-
return getSecretKey(`ci.browser-sdk.telemetry.${normalizedSite}.ci_app_key`)
56+
try {
57+
return getSecretKey(`ci.browser-sdk.telemetry.${normalizedSite}.ci_app_key`)
58+
} catch {
59+
return
60+
}
5361
}
5462

5563
export function getNpmToken(): string {

0 commit comments

Comments
 (0)