import app from "../../amplitude.app.mjs";
export default {
key: "amplitude-send-event-data",
name: "Send Event Data",
description: "Sends user event data to Amplitude for analytics. [See the documentation](https://www.docs.developers.amplitude.com/analytics/apis/http-v2-api/#keys-for-the-event-argument)",
version: "0.0.1",
type: "action",
props: {
app,
userId: {
type: "string",
label: "User ID",
description: "A unique identifier for a user.",
},
deviceId: {
type: "string",
label: "Device ID",
description: "A unique identifier for a device.",
},
eventType: {
type: "string",
label: "Event Type",
description: "The type of event being sent.",
},
time: {
type: "integer",
label: "Time",
description: "The time the event occurred in milliseconds since epoch.",
optional: true,
},
eventProperties: {
type: "object",
label: "Event Properties",
description: "A dictionary of key-value pairs that represent additional data to be sent along with the event.",
optional: true,
},
userProperties: {
type: "object",
label: "User Properties",
description: "A dictionary of key-value pairs that represent additional data tied to the user.",
optional: true,
},
groups: {
type: "object",
label: "Groups",
description: "Dictionary of key-value pairs that represent groups to associate with the user.",
optional: true,
},
groupProperties: {
type: "object",
label: "Group Properties",
description: "Dictionary of key-value pairs that represent additional data tied to the groups.",
optional: true,
},
skipUserPropertiesSync: {
type: "boolean",
label: "Skip User Properties Sync",
description: "If true, user property operations in the same event are not applied to the user.",
optional: true,
},
appVersion: {
type: "string",
label: "App Version",
description: "The version of the application.",
optional: true,
},
platform: {
type: "string",
label: "Platform",
description: "The platform the user is on.",
optional: true,
},
osName: {
type: "string",
label: "OS Name",
description: "The name of the operating system the user is using.",
optional: true,
},
osVersion: {
type: "string",
label: "OS Version",
description: "The version of the operating system the user is using.",
optional: true,
},
deviceBrand: {
type: "string",
label: "Device Brand",
description: "The brand of the device the user is using.",
optional: true,
},
deviceManufacturer: {
type: "string",
label: "Device Manufacturer",
description: "The manufacturer of the device the user is using.",
optional: true,
},
deviceModel: {
type: "string",
label: "Device Model",
description: "The model of the device the user is using.",
optional: true,
},
carrier: {
type: "string",
label: "Carrier",
description: "The carrier the user is using.",
optional: true,
},
country: {
type: "string",
label: "Country",
description: "The country of the user.",
optional: true,
},
region: {
type: "string",
label: "Region",
description: "The region of the user.",
optional: true,
},
city: {
type: "string",
label: "City",
description: "The city of the user.",
optional: true,
},
dma: {
type: "string",
label: "DMA",
description: "The designated market area of the user.",
optional: true,
},
language: {
type: "string",
label: "Language",
description: "The language set by the user.",
optional: true,
},
price: {
type: "string",
label: "Price",
description: "The price of the product.",
optional: true,
},
quantity: {
type: "integer",
label: "Quantity",
description: "The quantity of the product.",
optional: true,
},
revenue: {
type: "string",
label: "Revenue",
description: "The revenue from the product.",
optional: true,
},
productId: {
type: "string",
label: "Product ID",
description: "The ID of the product.",
optional: true,
},
revenueType: {
type: "string",
label: "Revenue Type",
description: "The type of revenue.",
optional: true,
},
locationLat: {
type: "string",
label: "Location Latitude",
description: "The latitude of the user's location.",
optional: true,
},
locationLng: {
type: "string",
label: "Location Longitude",
description: "The longitude of the user's location.",
optional: true,
},
ip: {
type: "string",
label: "IP",
description: "The IP address of the user.",
optional: true,
},
idfa: {
type: "string",
label: "IDFA",
description: "Identifier for Advertisers.",
optional: true,
},
idfv: {
type: "string",
label: "IDFV",
description: "Identifier for Vendors.",
optional: true,
},
adid: {
type: "string",
label: "ADID",
description: "Google Play Advertising ID.",
optional: true,
},
androidId: {
type: "string",
label: "Android ID",
description: "Android ID.",
optional: true,
},
eventId: {
type: "integer",
label: "Event ID",
description: "A unique identifier for the event.",
optional: true,
},
sessionId: {
type: "integer",
label: "Session ID",
description: "A unique identifier for the session.",
optional: true,
},
insertId: {
type: "string",
label: "Insert ID",
description: "A unique identifier for the event that is used for deduplication.",
optional: true,
},
plan: {
type: "object",
label: "Plan",
description: "Dictionary of key-value pairs that represent the plan.",
optional: true,
default: {
branch: "",
source: "",
version: "",
},
},
},
async run({ $ }) {
const eventData = {
user_id: this.userId,
device_id: this.deviceId,
event_type: this.eventType,
time: this.time,
event_properties: this.eventProperties,
user_properties: this.userProperties,
groups: this.groups,
group_properties: this.groupProperties,
$skip_user_properties_sync: this.skipUserPropertiesSync,
app_version: this.appVersion,
platform: this.platform,
os_name: this.osName,
os_version: this.osVersion,
device_brand: this.deviceBrand,
device_manufacturer: this.deviceManufacturer,
device_model: this.deviceModel,
carrier: this.carrier,
country: this.country,
region: this.region,
city: this.city,
dma: this.dma,
language: this.language,
price: this.price,
quantity: this.quantity,
revenue: this.revenue,
productId: this.productId,
revenueType: this.revenueType,
location_lat: this.locationLat,
location_lng: this.locationLng,
ip: this.ip,
idfa: this.idfa,
idfv: this.idfv,
adid: this.adid,
android_id: this.androidId,
event_id: this.eventId,
session_id: this.sessionId,
insert_id: this.insertId,
plan: this.plan,
};
const response = await this.app.sendEventData({
$,
data: {
events: [
eventData,
],
},
});
$.export("$summary", "Successfully sent new event data");
return response;
},
};