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