| 1 |
import { |
| 2 |
resolveNotificationLink, |
| 3 |
siteHost, |
| 4 |
} from '@notifications/notification-link'; |
| 5 |
import { notificationFor } from '@notifications/selection'; |
| 6 |
|
| 7 |
export const AGENT_CHAT_SLOT = 'agent-chat'; |
| 8 |
|
| 9 |
export const notificationSuggestion = () => { |
| 10 |
const notification = notificationFor(AGENT_CHAT_SLOT); |
| 11 |
if (!notification) return null; |
| 12 |
|
| 13 |
const message = notification['content-agent-chat']; |
| 14 |
const { href } = resolveNotificationLink(notification, siteHost()); |
| 15 |
if (!message || !href) return null; |
| 16 |
|
| 17 |
const slug = notification.slug; |
| 18 |
const source = notification.source; |
| 19 |
|
| 20 |
return { |
| 21 |
id: `notification-${slug}`, |
| 22 |
type: 'external-link', |
| 23 |
message, |
| 24 |
url: href, |
| 25 |
viewTelemetry: { |
| 26 |
key: 'notification_view', |
| 27 |
payload: { slug, slot: AGENT_CHAT_SLOT, source }, |
| 28 |
}, |
| 29 |
telemetry: { |
| 30 |
key: 'notification_click', |
| 31 |
payload: { slug, slot: AGENT_CHAT_SLOT, source }, |
| 32 |
}, |
| 33 |
}; |
| 34 |
}; |
| 35 |
|