Skip to content

Commit bf4123f

Browse files
authored
feat(platform): Kapa.ai integration (#11935)
1 parent 6db67a6 commit bf4123f

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

app/layout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ export default function RootLayout({children}: {children: React.ReactNode}) {
4949
data-api="https://plausible.io/api/event"
5050
src="https://plausible.io/js/script.tagged-events.js"
5151
/>
52+
<Script
53+
async
54+
src="https://widget.kapa.ai/kapa-widget.bundle.js"
55+
data-website-id="cac7cc70-969e-4bc1-a968-55534a839be4"
56+
data-button-hide // do not render kapa ai button
57+
data-modal-override-open-class="kapa-ai-class" // all elements with this class will open the kapa ai modal
58+
data-project-name="Sentry"
59+
data-project-color="#6A5FC1"
60+
data-project-logo="https://docs.sentry.io/_next/static/media/sentry-logo-dark.fc8e1eeb.svg"
61+
data-font-family="var(--font-rubik)"
62+
/>
5263
</html>
5364
);
5465
}

src/components/search/index.tsx

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import {Fragment, useCallback, useEffect, useRef, useState} from 'react';
4+
import {Button} from '@radix-ui/themes';
45
import {captureException} from '@sentry/nextjs';
56
import {
67
Hit,
@@ -20,7 +21,6 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
2021
import styles from './search.module.scss';
2122

2223
import {Logo} from '../logo';
23-
import {NavLink} from '../navlink';
2424

2525
// Initialize Algolia Insights
2626
algoliaInsights('init', {
@@ -271,28 +271,32 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
271271
{showChatBot && (
272272
<Fragment>
273273
<span className="text-[var(--desatPurple10)] hidden md:inline">or</span>
274-
<NavLink
275-
href="https://docsbot.ai/chat/skFEy0qDC01GrRrZ7Crs/EPqsd8nu2XmKzWnd45tL"
276-
target="_blank"
277-
style={{textWrap: 'nowrap'}}
278-
className="hidden md:flex items-center"
274+
<Button
275+
asChild
276+
variant="ghost"
277+
color="gray"
278+
size="3"
279+
radius="medium"
280+
className="font-medium text-[var(--foreground)] py-2 px-3 uppercase cursor-pointer kapa-ai-class"
279281
>
280-
<svg
281-
xmlns="http://www.w3.org/2000/svg"
282-
fill="none"
283-
viewBox="0 0 24 24"
284-
strokeWidth={1.5}
285-
stroke="currentColor"
286-
className="size-5"
287-
>
288-
<path
289-
strokeLinecap="round"
290-
strokeLinejoin="round"
291-
d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"
292-
/>
293-
</svg>
294-
<span>Ask AI</span>
295-
</NavLink>
282+
<div>
283+
<svg
284+
xmlns="http://www.w3.org/2000/svg"
285+
fill="none"
286+
viewBox="0 0 24 24"
287+
strokeWidth={1.5}
288+
stroke="currentColor"
289+
className="size-5"
290+
>
291+
<path
292+
strokeLinecap="round"
293+
strokeLinejoin="round"
294+
d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"
295+
/>
296+
</svg>
297+
<span>Ask AI</span>
298+
</div>
299+
</Button>
296300
</Fragment>
297301
)}
298302
</div>
@@ -376,7 +380,9 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
376380

377381
{!loading && totalHits === 0 && (
378382
<div className={styles['sgs-hit-empty-state']}>
379-
No results for <em>{query}</em>
383+
<button className="kapa-ai-class font-bold">
384+
Can't find what you're looking for? Ask our AI!
385+
</button>
380386
</div>
381387
)}
382388

vercel.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"key": "Content-Security-Policy",
20-
"value": "upgrade-insecure-requests; default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.sentry-cdn.com www.googletagmanager.com plausible.io vercel.live; connect-src 'self' *.sentry.io sentry.io *.algolia.net *.algolianet.com *.algolia.io plausible.io reload.getsentry.net storage.googleapis.com; img-src * 'self' data: www.google.com www.googletagmanager.com; style-src 'self' 'unsafe-inline'; font-src 'self' fonts.gstatic.com; frame-src demo.arcade.software player.vimeo.com; worker-src blob:; report-uri https://o1.ingest.sentry.io/api/1267915/security/?sentry_key=ad63ba38287245f2803dc220be959636; report-to csp"
20+
"value": "upgrade-insecure-requests; default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.sentry-cdn.com www.googletagmanager.com plausible.io widget.kapa.ai www.gstatic.com www.google.com vercel.live; connect-src 'self' *.sentry.io sentry.io *.algolia.net *.algolianet.com *.algolia.io kapa-widget-proxy-la7dkmplpq-uc.a.run.app plausible.io reload.getsentry.net storage.googleapis.com; img-src * 'self' data: www.google.com www.googletagmanager.com; style-src 'self' 'unsafe-inline'; font-src 'self' fonts.gstatic.com; frame-src www.google.com recaptcha.google.com demo.arcade.software player.vimeo.com; worker-src blob:; report-uri https://o1.ingest.sentry.io/api/1267915/security/?sentry_key=ad63ba38287245f2803dc220be959636; report-to csp"
2121
},
2222
{
2323
"key": "NEL",
@@ -31,4 +31,4 @@
3131
}
3232
],
3333
"trailingSlash": true
34-
}
34+
}

0 commit comments

Comments
 (0)