|
1 | | -import {useEffect} from 'react'; |
2 | | -import {MessageSquare} from 'lucide-react'; |
3 | | -import Script from 'next/script'; |
4 | | -import {SidebarMenuButton, SidebarMenuItem} from "@/components/ui/sidebar"; |
5 | | -import {useUserClient} from "@/hooks/useUserClient"; |
6 | | -import FEATURES from "@/config/features"; |
7 | | - |
8 | | -declare global { |
9 | | - interface Window { |
10 | | - Canny: { |
11 | | - (command: string, options: any): void; |
12 | | - q?: any[]; |
13 | | - }; |
14 | | - } |
15 | | -} |
| 1 | +import { MessageSquare } from 'lucide-react'; |
| 2 | +import { SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar"; |
16 | 3 |
|
17 | 4 | export function GiveFeedbackLink() { |
18 | | - const {user} = useUserClient() |
19 | | - |
20 | | - |
21 | | - useEffect(() => { |
22 | | - if(!FEATURES.ANALYTICS.ENABLE_CANNY){ |
23 | | - return |
24 | | - } |
25 | | - |
26 | | - if (user) { |
27 | | - window.Canny?.('identify', { |
28 | | - appID: '67bb830551e0a8fecd8c7b5e', |
29 | | - user: { |
30 | | - email: user.email ?? '', |
31 | | - name: user.user_metadata?.full_name || user.email || '', |
32 | | - id: user.id, |
33 | | - avatarURL: user.user_metadata?.avatar_url, |
34 | | - created: user.created_at ? new Date(user.created_at).toISOString() : undefined, |
35 | | - }, |
36 | | - }); |
37 | | - } |
38 | | - }, [user]); |
39 | | - |
40 | 5 | return ( |
41 | 6 | <SidebarMenuItem> |
42 | | - {/* Load Canny script once */} |
43 | | - {FEATURES.ANALYTICS.ENABLE_CANNY && <Script |
44 | | - id="canny-sdk" |
45 | | - strategy="lazyOnload" |
46 | | - dangerouslySetInnerHTML={{ |
47 | | - __html: ` |
48 | | - !function(w,d,i,s){function l(){if(!d.getElementById(i)){var f=d.getElementsByTagName(s)[0],e=d.createElement(s);e.type="text/javascript",e.async=!0,e.src="https://canny.io/sdk.js",f.parentNode.insertBefore(e,f)}}if("function"!=typeof w.Canny){var c=function(){c.q.push(arguments)};c.q=[],w.Canny=c,"complete"===d.readyState?l():w.attachEvent?w.attachEvent("onload",l):w.addEventListener("load",l,!1)}}(window,document,"canny-jssdk","script"); |
49 | | - `, |
50 | | - }} |
51 | | - />} |
52 | | - |
53 | 7 | <SidebarMenuButton asChild |
54 | | - className="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-white"> |
| 8 | + className="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-white"> |
55 | 9 | <a |
56 | 10 | className="w-full" |
57 | | - data-canny-link |
58 | | - href="https://api200.canny.io/feature-requests" |
| 11 | + target="_blank" |
| 12 | + href="https://github.com/API-200/api200/discussions/categories/q-a" |
59 | 13 | > |
60 | | - <MessageSquare className="mr-2 h-4 w-4"/> |
61 | | - Give Feedback |
| 14 | + <MessageSquare className="mr-2 h-4 w-4" /> |
| 15 | + Get Support |
62 | 16 | </a> |
63 | 17 | </SidebarMenuButton> |
64 | 18 | </SidebarMenuItem> |
|
0 commit comments