Skip to content

Commit

Permalink
fix(sentry): Fix Sentry integration not working
Browse files Browse the repository at this point in the history
Closes toggl#2328
  • Loading branch information
pkvach committed Sep 15, 2024
1 parent 362be1f commit cdd9b35
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/content/sentry.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
'use strict';

togglbutton.render('.group-detail:not(.toggl)', { observe: true }, function () {
const errType = $('h3 > span > span').textContent.trim();
const detail = $('.message').textContent.trim();
const project = $('.project-select').textContent.trim();
const description = errType + ': ' + detail;
togglbutton.render('.group-detail:not(.toggl)', { observe: true }, function (elem) {
const pageTitle = $('title').textContent.trim();

// Extract the project name from the page title, assuming it's the last part after ' — '
const pageTitleParts = pageTitle.split(' — ');
const projectName = pageTitleParts.length > 1 ? pageTitleParts[pageTitleParts.length - 1] : '';

const link = togglbutton.createTimerLink({
className: 'sentry',
description: description,
projectName: project
description: pageTitle,
projectName: projectName
});

$('.group-detail .nav-tabs').appendChild(link);
const tabListElement = elem.querySelector('ul[role="tablist"]');
if (tabListElement) {
tabListElement.appendChild(link);
}
});

0 comments on commit cdd9b35

Please sign in to comment.