Skip to content

Commit

Permalink
Merge pull request #181 from City-of-Helsinki/UHF-9982-js-sentry
Browse files Browse the repository at this point in the history
UHF-9982: Overwrite sentry DSN for js tracking
  • Loading branch information
hyrsky authored Oct 18, 2024
2 parents 189161e + f81752f commit 2327b07
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions helfi_api_base.install
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function helfi_api_base_install(bool $is_syncing = FALSE) : void {
->set('drush_error_handler', TRUE)
->set('request_tracing', TRUE)
->set('traces_sample_rate', 0.2)
->set('browser_traces_sample_rate', 0.2)
->set('database_tracing', TRUE)
->set('twig_tracing', TRUE)
->save();
Expand Down Expand Up @@ -188,3 +189,14 @@ function helfi_api_base_update_9019(): void {
\Drupal::configFactory()->getEditable('rest.resource.helfi_debug_data')
->delete();
}

/**
* UHF-9982: Configure sentry browser tracking.
*/
function helfi_api_base_update_9020(): void {
if (Drupal::moduleHandler()->moduleExists('raven')) {
Drupal::configFactory()->getEditable('raven.settings')
->set('browser_traces_sample_rate', 0.2)
->save();
}
}
12 changes: 12 additions & 0 deletions helfi_api_base.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

declare(strict_types=1);

use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\helfi_api_base\Features\FeatureManager;
Expand Down Expand Up @@ -123,3 +124,14 @@ function helfi_api_base_template_preprocess_default_variables_alter(array &$vari
$variables['lang_attributes']['fallback_dir'] = $attributes['dir'];
}
}

/**
* Implements hook_js_settings_alter().
*/
function helfi_api_base_js_settings_alter(array &$settings, AttachedAssetsInterface $assets): void {
// Raven sets DSN from SENTRY_DSN environment variable, which we use for
// PHP tracking.
if (isset($settings['raven']['options']['dsn'])) {
$settings['raven']['options']['dsn'] = getenv('SENTRY_DSN_PUBLIC');
}
}

0 comments on commit 2327b07

Please sign in to comment.