import assert from "assert"; import { NormalizedEvent, RawEvent } from "../../types"; export default (event: RawEvent): NormalizedEvent<"canny"> => { assert(event, `Canny:Comments null event: ${event}`); assert( event.id, `Canny:Comments event is missing the required field id ${event}` ); assert( event.created, `Canny:Comments event is missing the required field created ${event}` ); return { id: `canny|${event.id}`, ts: Date.parse(event.created), user_info: { source_user_id: (event.author && event.author.id) || null, user_id: (event.author && event.author.userID) || null, name: (event.author && event.author.name) || null, email: (event.author && event.author.email) || null, ip: null, avatar: null, nickname: null, phone: null, city: null, continent_code: null, country: null, postal_code: null, region: null, timezone: null, country_code: null, address_line1: null, address_line2: null, user_agent: null, is_employee: event.author ? event.author.isAdmin : null, title: null, birthday: null, company: { name: null, id: null, industry: null, employee_count: null, plan: null }, created_at: event.author ? Date.parse(event.author.created) : null, age: null, gender: null, website: null, custom_attributes: null }, text: event.value || null, href: (event.post && event.post.url) || null, is_bad: false, direction: event.author ? event.author.isAdmin ? "outbound" : "inbound" : null, source: "canny", stream: "comments" }; };