-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsegment-track.after.js
More file actions
68 lines (67 loc) · 1.97 KB
/
Copy pathsegment-track.after.js
File metadata and controls
68 lines (67 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// legacy_hash_id: a_2wim5R
import { axios } from "@pipedream/platform";
export default {
key: "segment-track",
name: "Track actions your users perform",
description: "Track lets you record the actions your users perform (note requires userId or anonymousId)",
version: "0.3.1",
type: "action",
props: {
segment: {
type: "app",
app: "segment",
},
anonymousId: {
type: "string",
description: "A pseudo-unique substitute for a User ID, for cases when you don't have an absolutely unique identifier. A userId or an anonymousId is required.",
optional: true,
},
context: {
type: "object",
description: "Dictionary of extra information that provides useful context about a message, but is not directly related to the API call like ip address or locale",
optional: true,
},
event: {
type: "string",
description: "Name of the action that a user has performed.",
},
integrations: {
type: "object",
description: "Dictionary of destinations to either enable or disable",
optional: true,
},
properties: {
type: "object",
description: "Free-form dictionary of properties of the event, like revenue",
optional: true,
},
timestamp: {
type: "string",
description: "ISO-8601 date string",
optional: true,
},
userId: {
type: "string",
description: "Unique identifier for the user in your database. A userId or an anonymousId is required.",
optional: true,
},
},
async run({ $ }) {
return await axios($, {
method: "post",
url: "https://api.segment.io/v1/track",
auth: {
username: this.segment.$auth.write_key,
},
data: {
anonymousId: this.anonymousId,
context: this.context,
event: this.event,
integrations: this.integrations,
properties: this.properties,
timestamp: this.timestamp,
userId: this.userId,
},
});
},
};