| 159 | * @param {string | undefined} sentryEnvironment |
| 160 | */ |
| 161 | export function buildCsp(sentryRelease, sentryEnvironment) { |
| 162 | const builtCsp = structuredClone(csp); |
| 163 | if (sentryEnvironment !== undefined && sentryRelease !== undefined) { |
| 164 | builtCsp["report-uri"] = [ |
| 165 | `https://o561021.ingest.us.sentry.io/api/5699757/security/?sentry_key=13c8b3a8d1e547c9b9493de997b04337&sentry_environment=${sentryEnvironment}&sentry_release=${sentryRelease}`, |
| 166 | ]; |
| 167 | } |
| 168 | const directives = Object.entries(builtCsp).map( |
| 169 | ([key, values]) => `${key} ${values.join(" ")}`, |
| 170 | ); |
| 171 | |
| 172 | return directives.join("; "); |
| 173 | } |