@segment/action-destinations 3.218.0 → 3.219.0-staging.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/airship/utilities.js +2 -2
- package/dist/destinations/airship/utilities.js.map +1 -1
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.d.ts +1 -0
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js +8 -1
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
- package/dist/destinations/engage/twilio/utils/PhoneMessageSender.d.ts +0 -1
- package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js +2 -2
- package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js.map +1 -1
- package/dist/destinations/fullstory/identifyUserV2/generated-types.d.ts +1 -1
- package/dist/destinations/fullstory/identifyUserV2/index.js +1 -1
- package/dist/destinations/fullstory/identifyUserV2/index.js.map +1 -1
- package/dist/destinations/fullstory/index.js +1 -1
- package/dist/destinations/fullstory/index.js.map +1 -1
- package/dist/destinations/fullstory/request-params.d.ts +2 -2
- package/dist/destinations/fullstory/request-params.js +6 -6
- package/dist/destinations/fullstory/request-params.js.map +1 -1
- package/dist/destinations/fullstory/trackEventV2/generated-types.d.ts +1 -1
- package/dist/destinations/fullstory/trackEventV2/index.js +1 -1
- package/dist/destinations/fullstory/trackEventV2/index.js.map +1 -1
- package/dist/destinations/hyperengage/commonFields.d.ts +3 -0
- package/dist/destinations/hyperengage/commonFields.js +165 -0
- package/dist/destinations/hyperengage/commonFields.js.map +1 -0
- package/dist/destinations/hyperengage/generated-types.d.ts +4 -0
- package/dist/destinations/{liveramp-audiences/audienceEnteredSFTP.types.js → hyperengage/generated-types.js} +1 -1
- package/dist/destinations/hyperengage/generated-types.js.map +1 -0
- package/dist/destinations/hyperengage/group/generated-types.d.ts +35 -0
- package/dist/destinations/hyperengage/group/generated-types.js +3 -0
- package/dist/destinations/hyperengage/group/generated-types.js.map +1 -0
- package/dist/destinations/hyperengage/group/index.d.ts +5 -0
- package/dist/destinations/hyperengage/group/index.js +81 -0
- package/dist/destinations/hyperengage/group/index.js.map +1 -0
- package/dist/destinations/hyperengage/identify/generated-types.d.ts +36 -0
- package/dist/destinations/hyperengage/identify/generated-types.js +3 -0
- package/dist/destinations/hyperengage/identify/generated-types.js.map +1 -0
- package/dist/destinations/hyperengage/identify/index.d.ts +5 -0
- package/dist/destinations/hyperengage/identify/index.js +110 -0
- package/dist/destinations/hyperengage/identify/index.js.map +1 -0
- package/dist/destinations/hyperengage/index.d.ts +4 -0
- package/dist/destinations/hyperengage/index.js +72 -0
- package/dist/destinations/hyperengage/index.js.map +1 -0
- package/dist/destinations/hyperengage/track/generated-types.d.ts +32 -0
- package/dist/destinations/hyperengage/track/generated-types.js +3 -0
- package/dist/destinations/hyperengage/track/generated-types.js.map +1 -0
- package/dist/destinations/hyperengage/track/index.d.ts +5 -0
- package/dist/destinations/hyperengage/track/index.js +54 -0
- package/dist/destinations/hyperengage/track/index.js.map +1 -0
- package/dist/destinations/hyperengage/validateInput.d.ts +2 -0
- package/dist/destinations/hyperengage/validateInput.js +90 -0
- package/dist/destinations/hyperengage/validateInput.js.map +1 -0
- package/dist/destinations/index.js +3 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/klaviyo/config.d.ts +1 -0
- package/dist/destinations/klaviyo/config.js +5 -0
- package/dist/destinations/klaviyo/config.js.map +1 -0
- package/dist/destinations/klaviyo/index.js +9 -5
- package/dist/destinations/klaviyo/index.js.map +1 -1
- package/dist/destinations/klaviyo/orderCompleted/generated-types.d.ts +22 -0
- package/dist/destinations/klaviyo/orderCompleted/generated-types.js +3 -0
- package/dist/destinations/klaviyo/orderCompleted/generated-types.js.map +1 -0
- package/dist/destinations/klaviyo/orderCompleted/index.d.ts +5 -0
- package/dist/destinations/klaviyo/orderCompleted/index.js +152 -0
- package/dist/destinations/klaviyo/orderCompleted/index.js.map +1 -0
- package/dist/destinations/klaviyo/trackEvent/generated-types.d.ts +16 -0
- package/dist/destinations/klaviyo/trackEvent/generated-types.js +3 -0
- package/dist/destinations/klaviyo/trackEvent/generated-types.js.map +1 -0
- package/dist/destinations/klaviyo/trackEvent/index.d.ts +5 -0
- package/dist/destinations/klaviyo/trackEvent/index.js +118 -0
- package/dist/destinations/klaviyo/trackEvent/index.js.map +1 -0
- package/dist/destinations/klaviyo/types.d.ts +61 -0
- package/dist/destinations/klaviyo/types.js +8 -0
- package/dist/destinations/klaviyo/types.js.map +1 -0
- package/dist/destinations/klaviyo/upsertProfile/generated-types.d.ts +21 -1
- package/dist/destinations/klaviyo/upsertProfile/index.js +150 -5
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js.map +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js.map +1 -1
- package/dist/destinations/pinterest-conversions/pinterest-capi-custom-data.js +1 -1
- package/dist/destinations/pinterest-conversions/pinterest-capi-custom-data.js.map +1 -1
- package/dist/destinations/pinterest-conversions/reportConversionEvent/generated-types.d.ts +1 -1
- package/dist/destinations/snap-conversions-api/_tests_/index.test.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/awsClient.d.ts +0 -1
- package/dist/destinations/the-trade-desk-crm/awsClient.js +0 -1
- package/dist/destinations/the-trade-desk-crm/awsClient.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/functions.js +5 -54
- package/dist/destinations/the-trade-desk-crm/functions.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/generated-types.d.ts +1 -1
- package/dist/destinations/the-trade-desk-crm/index.js +3 -2
- package/dist/destinations/the-trade-desk-crm/index.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/properties.d.ts +0 -2
- package/dist/destinations/the-trade-desk-crm/properties.js +1 -18
- package/dist/destinations/the-trade-desk-crm/properties.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/syncAudience/generated-types.d.ts +0 -2
- package/dist/destinations/the-trade-desk-crm/syncAudience/index.js +0 -2
- package/dist/destinations/the-trade-desk-crm/syncAudience/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/addToAudience/index.js +2 -9
- package/dist/destinations/tiktok-audiences/addToAudience/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/addUser/index.js +2 -9
- package/dist/destinations/tiktok-audiences/addUser/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/constants.d.ts +1 -1
- package/dist/destinations/tiktok-audiences/constants.js +1 -1
- package/dist/destinations/tiktok-audiences/constants.js.map +1 -1
- package/dist/destinations/tiktok-audiences/removeFromAudience/index.js +2 -9
- package/dist/destinations/tiktok-audiences/removeFromAudience/index.js.map +1 -1
- package/dist/destinations/tiktok-audiences/removeUser/index.js +2 -9
- package/dist/destinations/tiktok-audiences/removeUser/index.js.map +1 -1
- package/dist/destinations/yahoo-audiences/constants.d.ts +2 -0
- package/dist/destinations/yahoo-audiences/constants.js +6 -0
- package/dist/destinations/yahoo-audiences/constants.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js +3 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.d.ts +5 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.js +33 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.d.ts +6 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.js +3 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.d.ts +5 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.js +45 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/generated-types.d.ts +12 -0
- package/dist/destinations/yahoo-audiences/generated-types.js +3 -0
- package/dist/destinations/yahoo-audiences/generated-types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/index.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/index.js +145 -0
- package/dist/destinations/yahoo-audiences/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/types.d.ts +25 -0
- package/dist/destinations/yahoo-audiences/types.js +3 -0
- package/dist/destinations/yahoo-audiences/types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/updateSegment/generated-types.d.ts +17 -0
- package/dist/destinations/yahoo-audiences/updateSegment/generated-types.js +3 -0
- package/dist/destinations/yahoo-audiences/updateSegment/generated-types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/updateSegment/index.d.ts +5 -0
- package/dist/destinations/yahoo-audiences/updateSegment/index.js +168 -0
- package/dist/destinations/yahoo-audiences/updateSegment/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/utils-rt.d.ts +10 -0
- package/dist/destinations/yahoo-audiences/utils-rt.js +95 -0
- package/dist/destinations/yahoo-audiences/utils-rt.js.map +1 -0
- package/dist/destinations/yahoo-audiences/utils-tax.d.ts +10 -0
- package/dist/destinations/yahoo-audiences/utils-tax.js +67 -0
- package/dist/destinations/yahoo-audiences/utils-tax.js.map +1 -0
- package/dist/destinations/yahoo-audiences/utils.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/utils.js +30 -0
- package/dist/destinations/yahoo-audiences/utils.js.map +1 -0
- package/package.json +2 -2
- package/dist/destinations/liveramp-audiences/audienceEnteredSFTP.types.d.ts +0 -16
- package/dist/destinations/liveramp-audiences/audienceEnteredSFTP.types.js.map +0 -1
|
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const upsertProfile_1 = __importDefault(require("./upsertProfile"));
|
|
7
|
-
const
|
|
7
|
+
const config_1 = require("./config");
|
|
8
|
+
const trackEvent_1 = __importDefault(require("./trackEvent"));
|
|
9
|
+
const orderCompleted_1 = __importDefault(require("./orderCompleted"));
|
|
8
10
|
const destination = {
|
|
9
11
|
name: 'Klaviyo (Actions)',
|
|
10
12
|
slug: 'actions-klaviyo',
|
|
@@ -20,13 +22,13 @@ const destination = {
|
|
|
20
22
|
}
|
|
21
23
|
},
|
|
22
24
|
testAuthentication: (request) => {
|
|
23
|
-
return request(`${API_URL}/accounts/`, {
|
|
25
|
+
return request(`${config_1.API_URL}/accounts/`, {
|
|
24
26
|
method: 'get'
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
},
|
|
28
30
|
onDelete: async (request, { payload }) => {
|
|
29
|
-
return request(`${API_URL}/data-privacy-deletion-jobs/`, {
|
|
31
|
+
return request(`${config_1.API_URL}/data-privacy-deletion-jobs/`, {
|
|
30
32
|
method: 'post',
|
|
31
33
|
json: {
|
|
32
34
|
data: {
|
|
@@ -48,12 +50,14 @@ const destination = {
|
|
|
48
50
|
headers: {
|
|
49
51
|
Authorization: `Klaviyo-API-Key ${settings.api_key}`,
|
|
50
52
|
Accept: 'application/json',
|
|
51
|
-
revision:
|
|
53
|
+
revision: '2023-09-15'
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
},
|
|
55
57
|
actions: {
|
|
56
|
-
upsertProfile: upsertProfile_1.default
|
|
58
|
+
upsertProfile: upsertProfile_1.default,
|
|
59
|
+
trackEvent: trackEvent_1.default,
|
|
60
|
+
orderCompleted: orderCompleted_1.default
|
|
57
61
|
}
|
|
58
62
|
};
|
|
59
63
|
exports.default = destination;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;AAC3C,qCAAkC;AAElC,8DAAqC;AAErC,sEAA6C;AAE7C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,wGAAwG;gBACrH,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,GAAG,gBAAO,YAAY,EAAE;gBACrC,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,GAAG,gBAAO,8BAA8B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,2BAA2B;oBACjC,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;gCACf,EAAE,EAAE,OAAO,CAAC,MAAM;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,YAAY;aACvB;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;QACb,UAAU,EAAV,oBAAU;QACV,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
profile: {
|
|
3
|
+
email?: string;
|
|
4
|
+
phone_number?: string;
|
|
5
|
+
other_properties?: {
|
|
6
|
+
[k: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
metric_name: string;
|
|
10
|
+
properties: {
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
time?: string | number;
|
|
14
|
+
value?: number;
|
|
15
|
+
unique_id?: string;
|
|
16
|
+
products?: {
|
|
17
|
+
value?: number;
|
|
18
|
+
properties?: {
|
|
19
|
+
[k: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/orderCompleted/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const createEventData = (payload) => ({
|
|
6
|
+
data: {
|
|
7
|
+
type: 'event',
|
|
8
|
+
attributes: {
|
|
9
|
+
properties: { ...payload.properties },
|
|
10
|
+
time: payload.time,
|
|
11
|
+
value: payload.value,
|
|
12
|
+
metric: {
|
|
13
|
+
data: {
|
|
14
|
+
type: 'metric',
|
|
15
|
+
attributes: {
|
|
16
|
+
name: 'Order Completed'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
profile: {
|
|
21
|
+
data: {
|
|
22
|
+
type: 'profile',
|
|
23
|
+
attributes: {
|
|
24
|
+
...payload.profile
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const sendProductRequests = async (payload, eventData, request) => {
|
|
32
|
+
if (payload.products && Array.isArray(payload.products)) {
|
|
33
|
+
const productPromises = payload?.products?.map((product) => {
|
|
34
|
+
eventData.data.attributes.properties = product.properties;
|
|
35
|
+
eventData.data.attributes.value = product.value;
|
|
36
|
+
eventData.data.attributes.metric.data.attributes.name = 'Ordered Product';
|
|
37
|
+
return request(`${config_1.API_URL}/events/`, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
json: eventData
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
await Promise.all(productPromises);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const action = {
|
|
46
|
+
title: 'Order Completed',
|
|
47
|
+
description: 'Order Completed Event action tracks users Order Completed events and associate it with their profile.',
|
|
48
|
+
defaultSubscription: 'type = "track"',
|
|
49
|
+
fields: {
|
|
50
|
+
profile: {
|
|
51
|
+
label: 'Profile',
|
|
52
|
+
description: `Properties of the profile that triggered this event.`,
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
email: {
|
|
56
|
+
label: 'Email',
|
|
57
|
+
type: 'string'
|
|
58
|
+
},
|
|
59
|
+
phone_number: {
|
|
60
|
+
label: 'Phone Number',
|
|
61
|
+
type: 'string'
|
|
62
|
+
},
|
|
63
|
+
other_properties: {
|
|
64
|
+
label: 'Other Properties',
|
|
65
|
+
type: 'object'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
metric_name: {
|
|
71
|
+
label: 'Metric Name',
|
|
72
|
+
description: 'Name of the event. Must be less than 128 characters.',
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: {
|
|
75
|
+
'@path': '$.event'
|
|
76
|
+
},
|
|
77
|
+
required: true
|
|
78
|
+
},
|
|
79
|
+
properties: {
|
|
80
|
+
description: `Properties of this event.`,
|
|
81
|
+
label: 'Properties',
|
|
82
|
+
type: 'object',
|
|
83
|
+
default: {
|
|
84
|
+
'@path': '$.properties'
|
|
85
|
+
},
|
|
86
|
+
required: true
|
|
87
|
+
},
|
|
88
|
+
time: {
|
|
89
|
+
label: 'Time',
|
|
90
|
+
description: `When this event occurred. By default, the time the request was received will be used.
|
|
91
|
+
The time is truncated to the second. The time must be after the year 2000 and can only
|
|
92
|
+
be up to 1 year in the future.
|
|
93
|
+
`,
|
|
94
|
+
type: 'datetime',
|
|
95
|
+
default: {
|
|
96
|
+
'@path': '$.timestamp'
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
value: {
|
|
100
|
+
label: 'Value',
|
|
101
|
+
description: 'A numeric value to associate with this event. For example, the dollar amount of a purchase.',
|
|
102
|
+
type: 'number'
|
|
103
|
+
},
|
|
104
|
+
unique_id: {
|
|
105
|
+
label: 'Unique ID',
|
|
106
|
+
description: `A unique identifier for an event. If the unique_id is repeated for the same
|
|
107
|
+
profile and metric, only the first processed event will be recorded. If this is not
|
|
108
|
+
present, this will use the time to the second. Using the default, this limits only one
|
|
109
|
+
event per profile per second.
|
|
110
|
+
`,
|
|
111
|
+
type: 'string',
|
|
112
|
+
default: {
|
|
113
|
+
'@path': '$.event'
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
products: {
|
|
117
|
+
label: 'Products',
|
|
118
|
+
description: 'List of products purchased in the order.',
|
|
119
|
+
multiple: true,
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
value: {
|
|
123
|
+
label: 'Value',
|
|
124
|
+
description: 'A numeric value to associate with this event. For example, the dollar amount of a purchase.',
|
|
125
|
+
type: 'number'
|
|
126
|
+
},
|
|
127
|
+
properties: {
|
|
128
|
+
description: `Properties of this event.`,
|
|
129
|
+
label: 'Properties',
|
|
130
|
+
type: 'object'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
perform: async (request, { payload }) => {
|
|
136
|
+
const { email, phone_number } = payload.profile;
|
|
137
|
+
if (!email && !phone_number) {
|
|
138
|
+
throw new actions_core_1.IntegrationError('One of Phone Number or Email is required.', 'Missing required fields', 400);
|
|
139
|
+
}
|
|
140
|
+
const eventData = createEventData(payload);
|
|
141
|
+
const event = await request(`${config_1.API_URL}/events/`, {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
json: eventData
|
|
144
|
+
});
|
|
145
|
+
if (event.status == 202 && Array.isArray(payload.products)) {
|
|
146
|
+
await sendProductRequests(payload, eventData, request);
|
|
147
|
+
}
|
|
148
|
+
return event;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
exports.default = action;
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/orderCompleted/index.ts"],"names":[],"mappings":";;AAGA,wDAAuE;AACvE,sCAAmC;AAGnC,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC;IAC7C,IAAI,EAAE;QACJ,IAAI,EAAE,OAAO;QACb,UAAU,EAAE;YACV,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;YACrC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,iBAAiB;qBACxB;iBACF;aACF;YACD,OAAO,EAAE;gBACP,IAAI,EAAE;oBACJ,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE;wBACV,GAAG,OAAO,CAAC,OAAO;qBACnB;iBACF;aACF;SACF;KACF;CACF,CAAC,CAAA;AAEF,MAAM,mBAAmB,GAAG,KAAK,EAAE,OAAgB,EAAE,SAAoB,EAAE,OAAsB,EAAE,EAAE;IACnG,IAAI,OAAO,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AAG,CAAC,CAAA;SACxG;QAED,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QAE1C,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,gBAAO,UAAU,EAAE;YAChD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,SAAS;SAChB,CAAC,CAAA;QAEF,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC1D,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;SACvD;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
profile: {
|
|
3
|
+
email?: string | null;
|
|
4
|
+
phone_number?: string | null;
|
|
5
|
+
other_properties?: {
|
|
6
|
+
[k: string]: unknown;
|
|
7
|
+
} | null;
|
|
8
|
+
};
|
|
9
|
+
metric_name: string;
|
|
10
|
+
properties: {
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
time?: string | number;
|
|
14
|
+
value?: number;
|
|
15
|
+
unique_id?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/trackEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Track Event',
|
|
7
|
+
description: 'Track user events and associate it with their profile.',
|
|
8
|
+
defaultSubscription: 'type = "track"',
|
|
9
|
+
fields: {
|
|
10
|
+
profile: {
|
|
11
|
+
label: 'Profile',
|
|
12
|
+
description: `Properties of the profile that triggered this event.`,
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
email: {
|
|
16
|
+
label: 'Email',
|
|
17
|
+
type: 'string',
|
|
18
|
+
allowNull: true
|
|
19
|
+
},
|
|
20
|
+
phone_number: {
|
|
21
|
+
label: 'Phone Number',
|
|
22
|
+
type: 'string',
|
|
23
|
+
allowNull: true
|
|
24
|
+
},
|
|
25
|
+
other_properties: {
|
|
26
|
+
label: 'Other Properties',
|
|
27
|
+
type: 'object',
|
|
28
|
+
allowNull: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
metric_name: {
|
|
34
|
+
label: 'Metric Name',
|
|
35
|
+
description: 'Name of the event. Must be less than 128 characters.',
|
|
36
|
+
type: 'string',
|
|
37
|
+
default: {
|
|
38
|
+
'@path': '$.event'
|
|
39
|
+
},
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
properties: {
|
|
43
|
+
description: `Properties of this event.`,
|
|
44
|
+
label: 'Properties',
|
|
45
|
+
type: 'object',
|
|
46
|
+
default: {
|
|
47
|
+
'@path': '$.properties'
|
|
48
|
+
},
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
time: {
|
|
52
|
+
label: 'Time',
|
|
53
|
+
description: `When this event occurred. By default, the time the request was received will be used.
|
|
54
|
+
The time is truncated to the second. The time must be after the year 2000 and can only
|
|
55
|
+
be up to 1 year in the future.
|
|
56
|
+
`,
|
|
57
|
+
type: 'datetime',
|
|
58
|
+
default: {
|
|
59
|
+
'@path': '$.timestamp'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
value: {
|
|
63
|
+
label: 'Value',
|
|
64
|
+
description: 'A numeric value to associate with this event. For example, the dollar amount of a purchase.',
|
|
65
|
+
type: 'number'
|
|
66
|
+
},
|
|
67
|
+
unique_id: {
|
|
68
|
+
label: 'Unique ID',
|
|
69
|
+
description: `A unique identifier for an event. If the unique_id is repeated for the same
|
|
70
|
+
profile and metric, only the first processed event will be recorded. If this is not
|
|
71
|
+
present, this will use the time to the second. Using the default, this limits only one
|
|
72
|
+
event per profile per second.
|
|
73
|
+
`,
|
|
74
|
+
type: 'string',
|
|
75
|
+
default: {
|
|
76
|
+
'@path': '$.event'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
perform: (request, { payload }) => {
|
|
81
|
+
const { email, phone_number } = payload.profile;
|
|
82
|
+
if (!email && !phone_number) {
|
|
83
|
+
throw new actions_core_1.IntegrationError('One of Phone Number or Email is required.', 'Missing required fields', 400);
|
|
84
|
+
}
|
|
85
|
+
const eventData = {
|
|
86
|
+
data: {
|
|
87
|
+
type: 'event',
|
|
88
|
+
attributes: {
|
|
89
|
+
properties: { ...payload.properties },
|
|
90
|
+
time: payload.time,
|
|
91
|
+
value: payload.value,
|
|
92
|
+
metric: {
|
|
93
|
+
data: {
|
|
94
|
+
type: 'metric',
|
|
95
|
+
attributes: {
|
|
96
|
+
name: payload.metric_name
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
profile: {
|
|
101
|
+
data: {
|
|
102
|
+
type: 'profile',
|
|
103
|
+
attributes: {
|
|
104
|
+
...payload.profile
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return request(`${config_1.API_URL}/events/`, {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
json: eventData
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
exports.default = action;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/trackEvent/index.ts"],"names":[],"mappings":";;AAIA,wDAAwD;AACxD,sCAAm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,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;QAE/C,IAAI,CAAC,KAAK,IAAI,CAAC,YAAY,EAAE;YAC3B,MAAM,IAAI,+BAAgB,CAAC,2CAA2C,EAAE,yBAAyB,EAAE,GAAG,CAAC,CAAA;SACxG;QAED,MAAM,SAAS,GAAG;YAChB,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE;oBACV,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;oBACrC,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,MAAM,EAAE;wBACN,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,IAAI,EAAE,OAAO,CAAC,WAAW;6BAC1B;yBACF;qBACF;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE;4BACJ,IAAI,EAAE,SAAS;4BACf,UAAU,EAAE;gCACV,GAAG,OAAO,CAAC,OAAO;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAA;QAED,OAAO,OAAO,CAAC,GAAG,gBAAO,UAAU,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,SAAS;SAChB,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { HTTPError } from '@segment/actions-core';
|
|
2
|
+
export declare class KlaviyoAPIError extends HTTPError {
|
|
3
|
+
response: Response & {
|
|
4
|
+
data: {
|
|
5
|
+
errors: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
status: number;
|
|
8
|
+
code: string;
|
|
9
|
+
title: string;
|
|
10
|
+
detail: string;
|
|
11
|
+
source: {
|
|
12
|
+
pointer: string;
|
|
13
|
+
};
|
|
14
|
+
meta: {
|
|
15
|
+
duplicate_profile_id: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface ProfileData {
|
|
23
|
+
data: {
|
|
24
|
+
type: string;
|
|
25
|
+
id?: string;
|
|
26
|
+
attributes: {
|
|
27
|
+
email?: string;
|
|
28
|
+
external_id?: string;
|
|
29
|
+
phone_number?: string;
|
|
30
|
+
[key: string]: string | Record<string, unknown> | undefined;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface EventData {
|
|
35
|
+
data: {
|
|
36
|
+
type: string;
|
|
37
|
+
attributes: {
|
|
38
|
+
properties?: object;
|
|
39
|
+
time?: string | number;
|
|
40
|
+
value?: number;
|
|
41
|
+
metric: {
|
|
42
|
+
data: {
|
|
43
|
+
type: string;
|
|
44
|
+
attributes: {
|
|
45
|
+
name?: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
profile: {
|
|
50
|
+
data: {
|
|
51
|
+
type: string;
|
|
52
|
+
attributes: {
|
|
53
|
+
email?: string;
|
|
54
|
+
phone_number?: string;
|
|
55
|
+
other_properties?: object;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KlaviyoAPIError = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
class KlaviyoAPIError extends actions_core_1.HTTPError {
|
|
6
|
+
}
|
|
7
|
+
exports.KlaviyoAPIError = KlaviyoAPIError;
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/types.ts"],"names":[],"mappings":";;;AAAA,wDAAiD;AAEjD,MAAa,eAAgB,SAAQ,wBAAS;CAmB7C;AAnBD,0CAmBC"}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
|
-
|
|
2
|
+
email?: string;
|
|
3
|
+
phone_number?: string;
|
|
4
|
+
external_id?: string;
|
|
5
|
+
first_name?: string;
|
|
6
|
+
last_name?: string;
|
|
7
|
+
organization?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
image?: string;
|
|
10
|
+
location?: {
|
|
11
|
+
address1?: string | null;
|
|
12
|
+
address2?: string | null;
|
|
13
|
+
city?: string | null;
|
|
14
|
+
region?: string | null;
|
|
15
|
+
zip?: string | null;
|
|
16
|
+
latitude?: string | null;
|
|
17
|
+
longitude?: string | null;
|
|
18
|
+
country?: string | null;
|
|
19
|
+
};
|
|
20
|
+
properties?: {
|
|
21
|
+
[k: string]: unknown;
|
|
22
|
+
};
|
|
3
23
|
}
|