Skip to content

Commit

Permalink
add the hash to the slack message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Oct 11, 2022
1 parent 8bd78cd commit 3141e6d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions docs/src/modules/components/AppLayoutDocsFooter.js
Expand Up @@ -111,7 +111,7 @@ async function postFeedback(data) {
}

async function postFeedbackOnSlack(data) {
const { rating, comment } = data;
const { rating, comment, commentedSection } = data;

if (!comment || comment.length < 10) {
return;
Expand Down Expand Up @@ -162,7 +162,9 @@ async function postFeedbackOnSlack(data) {
const simpleSlackMessage = [
`New comment ${rating > 0 ? '👍' : '👎'}`,
`>${comment.split('\n').join('\n>')}`,
`sent from ${window.location.href}`,
`sent from ${window.location.href}${commentedSection.hash ? `#${commentedSection.hash}` : ''}${
commentedSection.text ? ` (section ${commentedSection.text})` : ''
}`,
].join('\n\n');

try {
Expand Down Expand Up @@ -193,7 +195,7 @@ async function getUserFeedback(id) {
}
}

async function submitFeedback(page, rating, comment, language) {
async function submitFeedback(page, rating, comment, language, commentedSection) {
const data = {
id: getCookie('feedbackId'),
page,
Expand All @@ -203,7 +205,7 @@ async function submitFeedback(page, rating, comment, language) {
language,
};

await postFeedbackOnSlack(data);
await postFeedbackOnSlack({ ...data, commentedSection });
const result = await postFeedback(data);
if (result) {
document.cookie = `feedbackId=${result.id};path=/;max-age=31536000`;
Expand Down Expand Up @@ -289,7 +291,13 @@ export default function AppLayoutDocsFooter(props) {
setSnackbarMessage(t('feedbackFailed'));
}

const result = await submitFeedback(activePage.pathname, rating, comment, userLanguage);
const result = await submitFeedback(
activePage.pathname,
rating,
comment,
userLanguage,
commentedSection,
);
if (result) {
setSnackbarMessage(t('feedbackSubmitted'));
} else {
Expand Down

0 comments on commit 3141e6d

Please sign in to comment.