I am using NodeJS SDK to insert events and event_properties using HTTP API v2, and user_properites using identify
My sample code block looks as below
import { Identify } from '@amplitude/identify'
import * as Amplitude from '@amplitude/node'
const client = Amplitude.init(amplitude_api);
const identify = new Identify();
const payload ={event_type: eventType,
device_id: row.deviceid,
user_id: row.userid,
event_properties: row,
event_date: moment(row.timestamp).format('YYYY-MM-DD'),
timestamp: new Date(row.timestamp),
update_timestamp:new Date().toISOString(),
context: {ip: row.ipaddress},
// "user_properties": {
// user_id: row.userid,
// device_id: row.deviceid,
// partner_id: row.partnerid,
// slotid: row.slotid
// },
}
identify.set('user_id', row.userid).set('device_id',row.deviceid)
const userProperties = {'partner_id':row.partner_id as string,'osname':row.osname,'devicetype': row.devicetype}
identify.append('partner_id',row.partner_id as string)
const identifyEvent = identify.identifyUser('user_id','device_id')
client.logEvent(identifyEvent);
client.logEvent(payload)
Questions:
- It looks like I don’t have to use identify API for user_properties as we can pass these with events itself (client.logEvent(payload)) . Is this assumption correct. I have commented the user_properties in my code for now but I could get the user_id, device_id, partner_id and slotid inserted into user_properties of Amplitude just fine. Is this a good way to implement this or should I have to look at other ways like insert into identify end point before event endpoint
- If I need to user identify I could only pass user_id, device_id into the “const identifyEvent = identify.identifyUser('user_id','device_id')”. Any third value is not allowed here. I also tried to append to identify using “identify.append('partner_id',row.partner_id as string) “, doesn’t seem to work as well
- So if I need to use identify how can I ingest more user_properties other than just user_id and device_id
- How can run my segment reports based on event_date instead of insert date in the default date option available. Screenshot attached
- How can I filter using between clause in for dates or any other attribute in where condition. Screenshot attached
-