import assert from "assert"; import { RawEvent, NormalizedEvent } from "../../types"; export default (event: RawEvent): NormalizedEvent<"canny"> => { assert(event, `Canny:StatusChanges null event: ${event}`); assert( event.id, `Canny:StatusChanges event is missing the required field id ${event}` ); assert( event.created, `Canny:StatusChanges event is missing the required field created ${event}` ); return { id: `canny|${event.id}`, ts: Date.parse(event.created), user_info: { source_user_id: (event.changer && event.changer.id) || null, user_id: (event.changer && event.changer.userID) || null, name: (event.changer && event.changer.name) || null, email: (event.changer && event.changer.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.changer ? event.changer.isAdmin : null, title: null, birthday: null, company: { name: null, id: null, industry: null, employee_count: null, plan: null }, created_at: event.changer ? Date.parse(event.changer.created) : null, age: null, gender: null, website: null, custom_attributes: null }, text: event.status || null, href: (event.post && event.post.url) || null, is_bad: false, direction: event.changer ? event.changer.isAdmin ? "outbound" : "inbound" : null, source: "canny", stream: "status_changes" }; };