diff --git a/.env.example b/.env.example index ed5ce0fe76..b123d99fac 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,7 @@ INSIGHTS_ENABLED=false INSIGHTS_DEBUG=true POSTHOG_API_KEY='' POSTHOG_API_HOST='' +POSTHOG_FEEDBACK_SURVEY_NAME='' MIXPANEL_API_KEY='' MIXPANEL_AUTO_CAPTURE='' diff --git a/gatsby-browser.tsx b/gatsby-browser.tsx index e9cfcab83b..2a8da9b155 100644 --- a/gatsby-browser.tsx +++ b/gatsby-browser.tsx @@ -9,6 +9,8 @@ import { reducerBlogPosts, reducerSessionData, } from '@ably/ui/core/scripts'; +import { PostHogProvider } from 'posthog-js/react'; +import posthog from 'posthog-js'; import { reducerApiKeyData } from './src/redux/api-key/api-key-reducer'; import UserContextWrapper from './src/contexts/user-context/wrap-with-provider'; @@ -66,7 +68,7 @@ const InsightsWrapper = ({ children }) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - return children; + return {children}; }; export const wrapRootElement = ({ element }) => { diff --git a/gatsby-config.ts b/gatsby-config.ts index f1e20ddd77..f168fbdacc 100644 --- a/gatsby-config.ts +++ b/gatsby-config.ts @@ -38,6 +38,7 @@ export const siteMetadata = { mixpanelAutoCapture: !!process.env.MIXPANEL_AUTO_CAPTURE, posthogApiKey: process.env.POSTHOG_API_KEY, posthogHost: process.env.POSTHOG_API_HOST || 'https://insights.ably.com', + posthogFeedbackSurveyName: process.env.POSTHOG_FEEDBACK_SURVEY_NAME || 'Docs Feedback', conversationsUrl: process.env.CONVERSATIONS_API_URL, }, }; diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index 431377cc51..79c8761358 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -1,7 +1,24 @@ -import React from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; +import { useLocation } from '@reach/router'; import Icon from '@ably/ui/core/Icon'; import { IconName } from '@ably/ui/core/Icon/types'; import Status, { StatusUrl } from '@ably/ui/core/Status'; +import cn from '@ably/ui/core/utils/cn'; +import type { PageContextType } from './Layout'; +import { useLayoutContext } from 'src/contexts/layout-context'; +import Button from '@ably/ui/core/Button'; + +const ENABLE_FEEDBACK = false; + +type FeedbackMode = 'yes' | 'no' | 'feedback'; + +type FeedbackButton = { + label: string; + monoIcon: IconName; + colorIcon: IconName; + placeholder: string; + description?: string; +}; const leftFooterLinks = [ { label: 'Changelog', link: 'https://changelog.ably.com/' }, @@ -16,87 +33,305 @@ const rightFooterLinks = [ { label: 'Cookies', link: '/privacy' }, ]; -const socialLinks: { key: string; colorIcon: IconName; monoIcon: IconName; link: string }[] = [ - { key: 'x', colorIcon: 'icon-social-x', monoIcon: 'icon-social-x-mono', link: 'https://x.com/ablyrealtime' }, +const socialLinks: { key: string; icon: IconName; link: string }[] = [ + { key: 'x', icon: 'icon-social-x-mono', link: 'https://x.com/ablyrealtime' }, { key: 'linkedin', - colorIcon: 'icon-social-linkedin', - monoIcon: 'icon-social-linkedin-mono', + icon: 'icon-social-linkedin-mono', link: 'https://www.linkedin.com/company/ably-realtime', }, { key: 'github', - colorIcon: 'icon-social-github', - monoIcon: 'icon-social-github-mono', + icon: 'icon-social-github-mono', link: 'https://github.com/ably/', }, { key: 'discord', - colorIcon: 'icon-social-discord', - monoIcon: 'icon-social-discord-mono', + icon: 'icon-social-discord-mono', link: 'https://discord.gg/g8yqePUVDn', }, { key: 'stackoverflow', - colorIcon: 'icon-social-stackoverflow', - monoIcon: 'icon-social-stackoverflow-mono', + icon: 'icon-social-stackoverflow-mono', link: 'https://stackoverflow.com/questions/tagged/ably-realtime', }, { key: 'youtube', - colorIcon: 'icon-social-youtube', - monoIcon: 'icon-social-youtube-mono', + icon: 'icon-social-youtube-mono', link: 'https://www.youtube.com/c/AblyRealtime', }, ]; -const Footer: React.FC = () => ( -