@netlify/spark-ui 1.8.5 → 1.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,34 @@
1
- import { u as a } from "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
- import { C as t, K as r } from "../../../chunks/ChatInterface.BD7rlv4H.js";
3
- import '../../../assets/AskNetlify.css';function n(e) {
4
- return /* @__PURE__ */ a(
5
- r,
1
+ import { u as t } from "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
+ import { A as a } from "../../../chunks/hooks.module.DGkdD5n9.js";
3
+ import { C as s, K as i } from "../../../chunks/ChatInterface.BD7rlv4H.js";
4
+ import '../../../assets/AskNetlify.css';function m(o) {
5
+ const e = a();
6
+ return /* @__PURE__ */ t(
7
+ i,
6
8
  {
7
9
  integrationId: "3c0789a6-c6a8-4fbc-b0cc-235f9e4a6351",
8
10
  callbacks: {
9
11
  askAI: {
10
- onQuerySubmit: (o) => console.log("Question asked:", o.question)
12
+ onQuerySubmit: (r) => {
13
+ var n;
14
+ (n = e == null ? void 0 : e.current) == null || n.track("ask:new_query", {
15
+ question: r.question,
16
+ thread_id: r.threadId
17
+ });
18
+ },
19
+ onAnswerGenerationCompleted: (r) => {
20
+ var n;
21
+ (n = e == null ? void 0 : e.current) == null || n.track("ask:answer_generated", {
22
+ question_id: r.questionAnswerId,
23
+ answer_length: r.answer.length
24
+ });
25
+ }
11
26
  }
12
27
  },
13
- children: /* @__PURE__ */ a(t, { ...e })
28
+ children: /* @__PURE__ */ t(s, { ...o })
14
29
  }
15
30
  );
16
31
  }
17
32
  export {
18
- n as default
33
+ m as default
19
34
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "1.8.5",
4
+ "version": "1.8.6",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -1,4 +1,6 @@
1
+ import { useRef } from 'preact/hooks';
1
2
  import { KapaProvider } from '@kapaai/react-sdk';
3
+ import Analytics from '@analtyics/analytics';
2
4
  import ChatInterface from './components/ChatInterface';
3
5
  import './AskNetlify.css';
4
6
 
@@ -7,12 +9,24 @@ interface AskNetlifyProps {
7
9
  }
8
10
 
9
11
  export default function AskNetlify(props: AskNetlifyProps) {
12
+ const analyticsRef = useRef<Analytics>();
10
13
  return (
11
14
  <KapaProvider
12
15
  integrationId="3c0789a6-c6a8-4fbc-b0cc-235f9e4a6351"
13
16
  callbacks={{
14
17
  askAI: {
15
- onQuerySubmit: data => console.log('Question asked:', data.question),
18
+ onQuerySubmit: data => {
19
+ analyticsRef?.current?.track('ask:new_query', {
20
+ question: data.question,
21
+ thread_id: data.threadId,
22
+ });
23
+ },
24
+ onAnswerGenerationCompleted: data => {
25
+ analyticsRef?.current?.track('ask:answer_generated', {
26
+ question_id: data.questionAnswerId,
27
+ answer_length: data.answer.length,
28
+ });
29
+ },
16
30
  },
17
31
  }}
18
32
  >