Skip to content

Commit 262cdc5

Browse files
authored
Add feedback widget with gtag event (#79)
1 parent eb553ac commit 262cdc5

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

package-lock.json

+14-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"clsx": "^2.0.0",
2727
"prism-react-renderer": "^2.3.0",
2828
"react": "^18.0.0",
29-
"react-dom": "^18.0.0"
29+
"react-dom": "^18.0.0",
30+
"react-simple-star-rating": "^5.1.7"
3031
},
3132
"devDependencies": {
3233
"@docusaurus/module-type-aliases": "3.1.1",

src/components/Feedback/index.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { Rating } from 'react-simple-star-rating';
3+
4+
const Feedback = () => {
5+
const [rating, setRating] = useState(0);
6+
7+
const handleRating = (rate) => {
8+
setRating(rate);
9+
console.log(window.location.pathname.toString())
10+
11+
if (window.gtag) {
12+
window.gtag('event', 'rating', {
13+
event_category: 'Feedback',
14+
event_label: window.location.pathname,
15+
value: rate,
16+
});
17+
}
18+
};
19+
20+
return (
21+
<div style={{ textAlign: 'left', marginTop: '0vh' }}>
22+
<Rating
23+
onClick={handleRating}
24+
ratingValue={rating}
25+
size={40}
26+
fillColor="orange"
27+
emptyColor="lightgray"
28+
transition
29+
/>
30+
{/*<div style={{ marginTop: '20px', fontSize: '18px' }}>*/}
31+
{/* Your Rating: {rating / 20} stars*/}
32+
{/*</div>*/}
33+
</div>
34+
);
35+
};
36+
37+
export default Feedback;

yarn.lock

+7-2
Original file line numberDiff line numberDiff line change
@@ -6956,7 +6956,7 @@ react-dev-utils@^12.0.1:
69566956
strip-ansi "^6.0.1"
69576957
text-table "^0.2.0"
69586958

6959-
react-dom@*, "react-dom@^16.6.0 || ^17.0.0 || ^18.0.0", react-dom@^18.0.0, "react-dom@>= 16.8.0 < 19.0.0":
6959+
react-dom@*, "react-dom@^16.6.0 || ^17.0.0 || ^18.0.0", react-dom@^18.0.0, "react-dom@>= 16.8.0 < 19.0.0", react-dom@>=18.0.0:
69606960
version "18.3.1"
69616961
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz"
69626962
integrity sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==
@@ -7052,7 +7052,12 @@ react-router@^5.3.4, react-router@>=5, [email protected]:
70527052
tiny-invariant "^1.0.2"
70537053
tiny-warning "^1.0.0"
70547054

7055-
react@*, "react@^16.13.1 || ^17.0.0 || ^18.0.0", "react@^16.6.0 || ^17.0.0 || ^18.0.0", react@^18.0.0, react@^18.3.1, "react@>= 16.8.0 < 19.0.0", react@>=15, react@>=16, react@>=16.0.0:
7055+
react-simple-star-rating@^5.1.7:
7056+
version "5.1.7"
7057+
resolved "https://registry.npmjs.org/react-simple-star-rating/-/react-simple-star-rating-5.1.7.tgz"
7058+
integrity sha512-NTFkW8W3uwvI82Fv7JW5i7gmDjEZKxJmj+Z9vn+BjYIXT6ILdnU9qnSUP2cWrWN/WAUlue81f9SgM4CQcenltQ==
7059+
7060+
react@*, "react@^16.13.1 || ^17.0.0 || ^18.0.0", "react@^16.6.0 || ^17.0.0 || ^18.0.0", react@^18.0.0, react@^18.3.1, "react@>= 16.8.0 < 19.0.0", react@>=15, react@>=16, react@>=16.0.0, react@>=18.0.0:
70567061
version "18.3.1"
70577062
resolved "https://registry.npmjs.org/react/-/react-18.3.1.tgz"
70587063
integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==

0 commit comments

Comments
 (0)