Singular-S2S
npm package to send events from server based on user interaction et. al.
Installation
npm install singular-s2s
Usage example
import Singular from "singular-s2s";
const eventData: any = {
n: "event_name",
e: JSON.stringify(payload), //event data
p: platform, // Android or iOS
i: packageIdentifier, // your app package name like com.company.com
ip: IP, // user iP
utime: epochInSeconds(),
umilisec: getEpoch(),
custom_user_id: userEvent.user_uid,
};
if (platform === Platform.ANDROID) {
eventData.andi = headers["device-id"].toLowerCase();
}
if (platform === Platform.IOS) {
eventData.idfv = headers["device-id"].toUpperCase();
}
const singular = new Singular(SINGULAR_CONFIG.API_KEY);
// code is executed with try catch block so check if error
const {error, response} = await singular.sendEvent(eventData);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Author
praveenkumarKajla |