@caruuto/caruuto-js 0.7.0 → 0.8.0

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.
@@ -319,6 +319,49 @@ module.exports = function (CaruutoClient, clientInstance) {
319
319
  const url = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/turn`
320
320
  const response = await doFetch(this, url, body)
321
321
  return response.json()
322
+ }.bind(clientInstance),
323
+
324
+ /**
325
+ * Record a click on a link surfaced in an assistant response — powers the
326
+ * CTA-click and conversion panels on the analytics dashboard. Caruuto
327
+ * classifies the link as 'internal' or 'external' relative to the
328
+ * project's site_domain and persists it to ai_link_click_events.
329
+ *
330
+ * @param {Object} opts
331
+ * @param {string} opts.conversationId - The conversation the link appeared in
332
+ * @param {string} opts.projectId
333
+ * @param {string} opts.url - The full clicked URL, exactly as rendered
334
+ * @param {string} [opts.linkLabel] - The link's visible text
335
+ * @param {number} [opts.messageIndex] - Position of the assistant message clicked from
336
+ * @returns {Promise<{ ok: boolean }>}
337
+ */
338
+ trackLinkClick: async function ({
339
+ conversationId,
340
+ projectId,
341
+ url,
342
+ linkLabel,
343
+ messageIndex
344
+ } = {}) {
345
+ if (!conversationId) {
346
+ throw new Error('conversationId is required')
347
+ }
348
+
349
+ if (!projectId) {
350
+ throw new Error('projectId is required')
351
+ }
352
+
353
+ if (!url) {
354
+ throw new Error('url is required')
355
+ }
356
+
357
+ const body = { project_id: projectId, url }
358
+
359
+ if (linkLabel) body.link_label = linkLabel
360
+ if (messageIndex !== undefined) body.message_index = messageIndex
361
+
362
+ const trackUrl = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/link-click`
363
+ const response = await doFetch(this, trackUrl, body)
364
+ return response.json()
322
365
  }.bind(clientInstance)
323
366
  }
324
367
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caruuto/caruuto-js",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A high-level library for interacting with Caruuto",
5
5
  "exports": "./index.js",
6
6
  "scripts": {