Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Jun 7, 2024
1 parent c1f8bdb commit 5ed5733
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tubular/scripts/frontend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ 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):
""" Combines the common and environment configs NPM_PRIVATE packages """
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):
Expand Down Expand Up @@ -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,
Expand All @@ -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. """
Expand Down

0 comments on commit 5ed5733

Please sign in to comment.