Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-9982: Overwrite sentry DSN for js tracking #181

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
}