From 5ed57334319c3774770666b1540cff0e0794bfdd Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 7 Jun 2024 08:54:54 -0400 Subject: [PATCH] chore: updates --- tubular/scripts/frontend_utils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tubular/scripts/frontend_utils.py b/tubular/scripts/frontend_utils.py index 4c2f7167..a74ea69e 100755 --- a/tubular/scripts/frontend_utils.py +++ b/tubular/scripts/frontend_utils.py @@ -145,7 +145,7 @@ def get_npm_aliases_config(self): npm_aliases_config = self.common_cfg.get('NPM_ALIASES', {}) npm_aliases_config.update(self.env_cfg.get('NPM_ALIASES', {})) if not npm_aliases_config: - self.LOG('No npm package aliases defined in config.') + self.LOG('No NPM package aliases defined in config.') return npm_aliases_config def get_npm_private_config(self): @@ -153,7 +153,7 @@ def get_npm_private_config(self): npm_private_config = self.common_cfg.get('NPM_PRIVATE', []) npm_private_config.extend(self.env_cfg.get('NPM_PRIVATE', [])) if not npm_private_config: - self.LOG('No npm private packages defined in config.') + self.LOG('No NPM private packages defined in config.') return list(set(npm_private_config)) def build_app(self, env_vars, fail_msg): @@ -220,32 +220,32 @@ def _deploy_to_s3(self, bucket_name, app_path): def _upload_js_sourcemaps(self, app_path): """ Upload JavaScript sourcemaps to Datadog. """ app_config = self.get_app_config() - api_key = app_config.get('DATADOG_API_KEY') - if not api_key: + datadog_api_key = os.environ.get('DATADOG_API_KEY') + if not datadog_api_key: # Can't upload source maps without ``DATADOG_API_KEY``, which must be set as an environment variable # before executing the Datadog CLI. The Datadog documentation suggests using a dedicated Datadog API key: # https://docs.datadoghq.com/real_user_monitoring/guide/upload-javascript-source-maps/ - self.LOG(1, 'Could not find Datadog API key while uploading source maps.') + self.LOG('Could not find DATADOG_API_KEY environment variable while uploading source maps.') return + service = app_config.get('DATADOG_SERVICE') + if not service: + self.LOG('Could not find DATADOG_SERVICE for app {} while uploading source maps.'.format(self.app_name)) + # Prioritize app-specific version override, if any, before default APP_VERSION commit SHA version version = app_config.get('DATADOG_VERSION') or app_config.get('APP_VERSION') if not version: - self.LOG(1, 'Could not find version for app {} while uploading source maps.'.format(self.app_name)) + self.LOG('Could not find version for app {} while uploading source maps.'.format(self.app_name)) return - env_vars = ' '.join([ - f'DATADOG_API_KEY={api_key}', - ]) command_args = ' '.join([ - f'--service="{app_config.get("DATADOG_SERVICE")}"', + f'--service="{service}"', f'--release-version="{version}"' '--minified-path-prefix="/"', # Sourcemaps are relative to the root when deployed ]) self.LOG('Uploading source maps to Datadog for app {}.'.format(self.app_name)) proc = subprocess.Popen( ' '.join([ - env_vars, './node_modules/.bin/datadog-ci sourcemaps upload', app_path, command_args, @@ -256,7 +256,7 @@ def _upload_js_sourcemaps(self, app_path): return_code = proc.wait() if return_code != 0: # If failure occurs, log the error and but don't fail the deployment. - self.LOG(1, 'Could not upload source maps to Datadog for app {}.'.format(self.app_name)) + self.LOG('Could not upload source maps to Datadog for app {}.'.format(self.app_name)) def deploy_site(self, bucket_name, app_path): """ Deploy files to bucket. """