Files
Sebastian Serth 94404370c4 Upgrade Sentry to v8 and remove custom Dependabot grouping
As part of the upgrade process, we need to rework the tracing instrumentation. Now, we are just wrapping all async functions in a new sentry transaction, which will automatically end once the function returns.

Further, the structure of the Sentry packages got reworked, so that we only need a single package by now. This removes the need to group dependabot updates.

Co-authored-by: Jan Graichen <jgraichen@altimos.de>
2024-05-24 14:52:14 +02:00

79 lines
2.5 KiB
JavaScript

Array.prototype.includes = function(element) {
return this.indexOf(element) !== -1;
};
window.CodeOcean = {
refresh: function() {
Turbolinks.visit(window.location.pathname);
}
};
const ANIMATION_DURATION = 500;
$.isController = function(name) {
return $('div[data-controller="' + name + '"]').isPresent();
};
$.fn.isPresent = function() {
return this.length > 0;
};
$.fn.scrollTo = function(selector) {
$(this).animate({
scrollTop: $(document.querySelector(selector)).offset().top - $(this).offset().top + $(this).scrollTop()
}, ANIMATION_DURATION);
};
$(document).on('turbolinks:load', function() {
// Update all CSRF tokens on the page to reduce InvalidAuthenticityToken errors
// See https://github.com/rails/jquery-ujs/issues/456 for details
$.rails.refreshCSRFTokens();
$('.reloadCurrentPage').on('click', function() {
window.location.reload();
});
// Set current user and current contributor
window.current_user = JSON.parse($('meta[name="current-user"]')?.attr('content') || null);
window.current_contributor = JSON.parse($('meta[name="current-contributor"]')?.attr('content') || null);
// Set locale for all JavaScript functions
const htmlTag = $('html')
I18n.defaultLocale = htmlTag.data('default-locale');
I18n.locale = htmlTag.attr('lang');
jQuery.timeago.settings.lang = I18n.locale;
// Initialize Sentry
const sentrySettings = $('meta[name="sentry"]')
// Workaround for Turbolinks: We must not re-initialize the Relay object when visiting another page
if (sentrySettings && sentrySettings.data()['enabled'] && Sentry.getReplay() === undefined) {
Sentry.init({
dsn: sentrySettings.data('dsn'),
attachStacktrace: true,
release: sentrySettings.data('release'),
environment: sentrySettings.data('environment'),
autoSessionTracking: true,
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.0,
replaysOnErrorSampleRate: 1.0,
integrations: window.SentryIntegrations(),
profilesSampleRate: 1.0,
initialScope: scope =>{
if (current_user) {
scope.setUser(_.omit(current_user, 'displayname'));
}
return scope;
}
});
}
// Enable all tooltips
$('[data-bs-toggle="tooltip"]').tooltip();
// Enable sorttable again, as it is disabled otherwise by Turbolinks
if (sorttable) {
sorttable.init.done = false;
sorttable.init();
}
});