nextui/apps/docs/components/featurebase/fb-changelog-button.tsx
աӄա 4957f56e86
feat: featurebase integration (#2425)
* feat(utils): add featurebase utils

* feat(config): add changelog, feedback and roadmap routes

* feat(app): add featurebase script

* feat(docs): add NEXT_PUBLIC_FB_FEEDBACK_URL

* feat(featurebase): add featurebase components

* feat(components): add featurebase components to navbar

* feat(components): add featurebase components to sidebar

* chore(config): remove changelog and feedback at this moment

* fix(components): fb-roadmap-link styles

* chore(components): hide feedback and changelog at this moment

* feat(docs): add NEXT_PUBLIC_FB_FEEDBACK_ORG

* feat(featurebase): add trackEvent & revise props
2024-03-03 16:20:40 -03:00

47 lines
1.1 KiB
TypeScript

"use client";
import {useEffect} from "react";
import {trackEvent} from "@/utils/va";
type Props = {
className?: string;
};
// ref: https://developers.featurebase.app/install/changelog-widget/install
export const FbChangelogButton = ({className}: Props) => {
useEffect(() => {
const win = window as any;
if (typeof win.Featurebase !== "function") {
win.Featurebase = function () {
// eslint-disable-next-line prefer-rest-params
(win.Featurebase.q = win.Featurebase.q || []).push(arguments);
};
}
win.Featurebase("initialize_changelog_widget", {
organization: process.env.NEXT_PUBLIC_FB_FEEDBACK_ORG,
theme: "dark",
usersName: "",
fullscreenPopup: true,
alwaysShow: true,
});
}, []);
const fbButtonOnClick = () => {
(window as any).Featurebase("manually_open_changelog_popup");
trackEvent("Featurebase - Changelog", {
name: "featurebase-changelog",
action: "press",
category: "featurebase",
});
};
return (
<button className={className} onClick={fbButtonOnClick}>
Changelog <span id="fb-update-badge" />
</button>
);
};