@segment/action-destinations 3.337.0-staging.1 → 3.337.1
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/braze/updateUserProfile/__snapshots__/snapshot.test.d.ts +1 -0
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js +184 -0
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js.map +1 -0
- package/dist/destinations/courier/generated-types.d.ts +4 -0
- package/dist/destinations/courier/generated-types.js +3 -0
- package/dist/destinations/courier/generated-types.js.map +1 -0
- package/dist/destinations/courier/index.d.ts +4 -0
- package/dist/destinations/courier/index.js +44 -0
- package/dist/destinations/courier/index.js.map +1 -0
- package/dist/destinations/courier/postToCourier/generated-types.d.ts +5 -0
- package/dist/destinations/courier/postToCourier/generated-types.js +3 -0
- package/dist/destinations/courier/postToCourier/generated-types.js.map +1 -0
- package/dist/destinations/courier/postToCourier/index.d.ts +5 -0
- package/dist/destinations/courier/postToCourier/index.js +35 -0
- package/dist/destinations/courier/postToCourier/index.js.map +1 -0
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +2 -5
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +18 -98
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +1 -1
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js +2 -0
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +17 -17
- package/dist/destinations/facebook-conversions-api/constants.d.ts +1 -1
- package/dist/destinations/facebook-conversions-api/constants.js +1 -1
- package/dist/destinations/index.js +5 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/kameleoon/index.js +1 -1
- package/dist/destinations/kameleoon/index.js.map +1 -1
- package/dist/destinations/klaviyo/properties.js +1 -1
- package/dist/destinations/klaviyo/properties.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.d.ts +4 -0
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.js +3 -0
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.js.map +1 -0
- package/dist/destinations/klaviyo/removeProfileToList/index.d.ts +5 -0
- package/dist/destinations/klaviyo/removeProfileToList/index.js +43 -0
- package/dist/destinations/klaviyo/removeProfileToList/index.js.map +1 -0
- package/dist/destinations/mixpanel/utils.d.ts +13 -0
- package/dist/destinations/mixpanel/utils.js +117 -0
- package/dist/destinations/mixpanel/utils.js.map +1 -0
- package/dist/destinations/movable-ink/categoryView/generated-types.d.ts +22 -0
- package/dist/destinations/movable-ink/categoryView/generated-types.js +3 -0
- package/dist/destinations/movable-ink/categoryView/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/categoryView/index.d.ts +5 -0
- package/dist/destinations/movable-ink/categoryView/index.js +43 -0
- package/dist/destinations/movable-ink/categoryView/index.js.map +1 -0
- package/dist/destinations/movable-ink/conversion/generated-types.d.ts +20 -0
- package/dist/destinations/movable-ink/conversion/generated-types.js +3 -0
- package/dist/destinations/movable-ink/conversion/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/conversion/index.d.ts +5 -0
- package/dist/destinations/movable-ink/conversion/index.js +45 -0
- package/dist/destinations/movable-ink/conversion/index.js.map +1 -0
- package/dist/destinations/movable-ink/fields.d.ts +21 -0
- package/dist/destinations/movable-ink/fields.js +236 -0
- package/dist/destinations/movable-ink/fields.js.map +1 -0
- package/dist/destinations/movable-ink/identify/generated-types.d.ts +7 -0
- package/dist/destinations/movable-ink/identify/generated-types.js +3 -0
- package/dist/destinations/movable-ink/identify/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/identify/index.d.ts +5 -0
- package/dist/destinations/movable-ink/identify/index.js +32 -0
- package/dist/destinations/movable-ink/identify/index.js.map +1 -0
- package/dist/destinations/movable-ink/productAdded/generated-types.d.ts +22 -0
- package/dist/destinations/movable-ink/productAdded/generated-types.js +3 -0
- package/dist/destinations/movable-ink/productAdded/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/productAdded/index.d.ts +5 -0
- package/dist/destinations/movable-ink/productAdded/index.js +43 -0
- package/dist/destinations/movable-ink/productAdded/index.js.map +1 -0
- package/dist/destinations/movable-ink/productViewed/generated-types.d.ts +21 -0
- package/dist/destinations/movable-ink/productViewed/generated-types.js +3 -0
- package/dist/destinations/movable-ink/productViewed/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/productViewed/index.d.ts +5 -0
- package/dist/destinations/movable-ink/productViewed/index.js +43 -0
- package/dist/destinations/movable-ink/productViewed/index.js.map +1 -0
- package/dist/destinations/movable-ink/search/generated-types.d.ts +12 -0
- package/dist/destinations/movable-ink/search/generated-types.js +3 -0
- package/dist/destinations/movable-ink/search/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/search/index.d.ts +5 -0
- package/dist/destinations/movable-ink/search/index.js +43 -0
- package/dist/destinations/movable-ink/search/index.js.map +1 -0
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.d.ts +25 -0
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js +3 -0
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js.map +1 -0
- package/dist/destinations/movable-ink/sendCustomEvent/index.d.ts +5 -0
- package/dist/destinations/movable-ink/sendCustomEvent/index.js +48 -0
- package/dist/destinations/movable-ink/sendCustomEvent/index.js.map +1 -0
- package/dist/destinations/schematic/generated-types.d.ts +3 -0
- package/dist/destinations/schematic/generated-types.js +3 -0
- package/dist/destinations/schematic/generated-types.js.map +1 -0
- package/dist/destinations/schematic/identifyUser/generated-types.d.ts +18 -0
- package/dist/destinations/schematic/identifyUser/generated-types.js +3 -0
- package/dist/destinations/schematic/identifyUser/generated-types.js.map +1 -0
- package/dist/destinations/schematic/identifyUser/index.d.ts +5 -0
- package/dist/destinations/schematic/identifyUser/index.js +114 -0
- package/dist/destinations/schematic/identifyUser/index.js.map +1 -0
- package/dist/destinations/schematic/index.d.ts +4 -0
- package/dist/destinations/schematic/index.js +58 -0
- package/dist/destinations/schematic/index.js.map +1 -0
- package/dist/destinations/schematic/trackEvent/generated-types.d.ts +13 -0
- package/dist/destinations/schematic/trackEvent/generated-types.js +3 -0
- package/dist/destinations/schematic/trackEvent/generated-types.js.map +1 -0
- package/dist/destinations/schematic/trackEvent/index.d.ts +5 -0
- package/dist/destinations/schematic/trackEvent/index.js +89 -0
- package/dist/destinations/schematic/trackEvent/index.js.map +1 -0
- package/dist/destinations/segment/sendGroup/index.js +36 -0
- package/dist/destinations/segment/sendGroup/index.js.map +1 -1
- package/dist/destinations/segment/sendIdentify/index.js +37 -1
- package/dist/destinations/segment/sendIdentify/index.js.map +1 -1
- package/dist/destinations/segment/sendPage/index.js +44 -0
- package/dist/destinations/segment/sendPage/index.js.map +1 -1
- package/dist/destinations/segment/sendScreen/index.js +37 -0
- package/dist/destinations/segment/sendScreen/index.js.map +1 -1
- package/dist/destinations/segment/sendTrack/index.js +41 -0
- package/dist/destinations/segment/sendTrack/index.js.map +1 -1
- package/dist/destinations/surveysparrow/createContact/generated-types.d.ts +10 -0
- package/dist/destinations/surveysparrow/createContact/generated-types.js +3 -0
- package/dist/destinations/surveysparrow/createContact/generated-types.js.map +1 -0
- package/dist/destinations/surveysparrow/createContact/index.d.ts +5 -0
- package/dist/destinations/surveysparrow/createContact/index.js +105 -0
- package/dist/destinations/surveysparrow/createContact/index.js.map +1 -0
- package/dist/destinations/surveysparrow/generated-types.d.ts +3 -0
- package/dist/destinations/surveysparrow/generated-types.js +3 -0
- package/dist/destinations/surveysparrow/generated-types.js.map +1 -0
- package/dist/destinations/surveysparrow/index.d.ts +4 -0
- package/dist/destinations/surveysparrow/index.js +40 -0
- package/dist/destinations/surveysparrow/index.js.map +1 -0
- package/dist/destinations/surveysparrow/triggerSurvey/generated-types.d.ts +10 -0
- package/dist/destinations/surveysparrow/triggerSurvey/generated-types.js +3 -0
- package/dist/destinations/surveysparrow/triggerSurvey/generated-types.js.map +1 -0
- package/dist/destinations/surveysparrow/triggerSurvey/index.d.ts +8 -0
- package/dist/destinations/surveysparrow/triggerSurvey/index.js +165 -0
- package/dist/destinations/surveysparrow/triggerSurvey/index.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/common_fields.d.ts +2 -0
- package/dist/destinations/tiktok-conversions-sandbox/common_fields.js +244 -0
- package/dist/destinations/tiktok-conversions-sandbox/common_fields.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/formatter.d.ts +3 -0
- package/dist/destinations/tiktok-conversions-sandbox/formatter.js +43 -0
- package/dist/destinations/tiktok-conversions-sandbox/formatter.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/generated-types.d.ts +4 -0
- package/dist/destinations/tiktok-conversions-sandbox/generated-types.js +3 -0
- package/dist/destinations/tiktok-conversions-sandbox/generated-types.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/index.d.ts +4 -0
- package/dist/destinations/tiktok-conversions-sandbox/index.js +247 -0
- package/dist/destinations/tiktok-conversions-sandbox/index.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/reportWebEvent/generated-types.d.ts +33 -0
- package/dist/destinations/tiktok-conversions-sandbox/reportWebEvent/generated-types.js +3 -0
- package/dist/destinations/tiktok-conversions-sandbox/reportWebEvent/generated-types.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/reportWebEvent/index.d.ts +5 -0
- package/dist/destinations/tiktok-conversions-sandbox/reportWebEvent/index.js +16 -0
- package/dist/destinations/tiktok-conversions-sandbox/reportWebEvent/index.js.map +1 -0
- package/dist/destinations/tiktok-conversions-sandbox/utils.d.ts +4 -0
- package/dist/destinations/tiktok-conversions-sandbox/utils.js +65 -0
- package/dist/destinations/tiktok-conversions-sandbox/utils.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/common_fields.d.ts +2 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/common_fields.js +244 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/common_fields.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/formatter.d.ts +3 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/formatter.js +43 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/formatter.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/generated-types.d.ts +4 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/generated-types.js +3 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/generated-types.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/index.d.ts +4 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/index.js +251 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/index.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/reportOfflineEvent/generated-types.d.ts +33 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/reportOfflineEvent/generated-types.js +3 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/reportOfflineEvent/generated-types.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/reportOfflineEvent/index.d.ts +5 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/reportOfflineEvent/index.js +16 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/reportOfflineEvent/index.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackNonPaymentOfflineConversion/generated-types.d.ts +33 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackNonPaymentOfflineConversion/generated-types.js +3 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackNonPaymentOfflineConversion/generated-types.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackNonPaymentOfflineConversion/index.d.ts +5 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackNonPaymentOfflineConversion/index.js +16 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackNonPaymentOfflineConversion/index.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackPaymentOfflineConversion/generated-types.d.ts +33 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackPaymentOfflineConversion/generated-types.js +3 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackPaymentOfflineConversion/generated-types.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackPaymentOfflineConversion/index.d.ts +5 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackPaymentOfflineConversion/index.js +16 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/trackPaymentOfflineConversion/index.js.map +1 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/utils.d.ts +8 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/utils.js +68 -0
- package/dist/destinations/tiktok-offline-conversions-sandbox/utils.js.map +1 -0
- package/dist/destinations/trackey/group.types.d.ts +11 -0
- package/dist/destinations/trackey/group.types.js +3 -0
- package/dist/destinations/trackey/group.types.js.map +1 -0
- package/dist/destinations/trackey/identify.types.d.ts +11 -0
- package/dist/destinations/trackey/identify.types.js +3 -0
- package/dist/destinations/trackey/identify.types.js.map +1 -0
- package/dist/destinations/trackey/track.types.d.ts +12 -0
- package/dist/destinations/trackey/track.types.js +3 -0
- package/dist/destinations/trackey/track.types.js.map +1 -0
- package/package.json +3 -3
|
@@ -61,7 +61,48 @@ const action = {
|
|
|
61
61
|
};
|
|
62
62
|
statsContext?.statsClient?.incr('tapi_internal', 1, [...statsContext.tags, 'action:sendTrack']);
|
|
63
63
|
return { batch: [trackPayload] };
|
|
64
|
+
},
|
|
65
|
+
performBatch: (_request, { payload, statsContext }) => {
|
|
66
|
+
const trackPayload = payload.map((data) => {
|
|
67
|
+
if (!data.anonymous_id && !data.user_id) {
|
|
68
|
+
throw errors_1.MissingUserOrAnonymousIdThrowableError;
|
|
69
|
+
}
|
|
70
|
+
convertPayload(data);
|
|
71
|
+
});
|
|
72
|
+
statsContext?.statsClient?.incr('tapi_internal', 1, [...statsContext.tags, 'action:sendTrack']);
|
|
73
|
+
console.log('sducy: ', trackPayload);
|
|
74
|
+
return { batch: trackPayload };
|
|
64
75
|
}
|
|
65
76
|
};
|
|
77
|
+
function convertPayload(data) {
|
|
78
|
+
return {
|
|
79
|
+
userId: data?.user_id,
|
|
80
|
+
anonymousId: data?.anonymous_id,
|
|
81
|
+
timestamp: data?.timestamp,
|
|
82
|
+
event: data?.event_name,
|
|
83
|
+
context: {
|
|
84
|
+
traits: {
|
|
85
|
+
...data?.traits
|
|
86
|
+
},
|
|
87
|
+
app: data?.application,
|
|
88
|
+
campaign: data?.campaign_parameters,
|
|
89
|
+
device: data?.device,
|
|
90
|
+
ip: data?.ip_address,
|
|
91
|
+
locale: data?.locale,
|
|
92
|
+
location: data?.location,
|
|
93
|
+
network: data?.network,
|
|
94
|
+
os: data?.operating_system,
|
|
95
|
+
page: data?.page,
|
|
96
|
+
screen: data?.screen,
|
|
97
|
+
userAgent: data?.user_agent,
|
|
98
|
+
timezone: data?.timezone,
|
|
99
|
+
groupId: data?.group_id
|
|
100
|
+
},
|
|
101
|
+
properties: {
|
|
102
|
+
...data?.properties
|
|
103
|
+
},
|
|
104
|
+
type: 'track'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
66
107
|
exports.default = action;
|
|
67
108
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/segment/sendTrack/index.ts"],"names":[],"mappings":";;AAGA,8DAoB8B;AAC9B,sCAAkE;AAElE,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,iGAAiG;IAC9G,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,OAAO,EAAP,4BAAO;QACP,YAAY,EAAZ,iCAAY;QACZ,SAAS,EAAT,8BAAS;QACT,UAAU,EAAV,+BAAU;QACV,WAAW,EAAX,gCAAW;QACX,mBAAmB,EAAnB,wCAAmB;QACnB,MAAM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I,EAAE,OAAO;KACd,CAAA;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/surveysparrow/createContact/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Create or Update Contact in SurveySparrow',
|
|
6
|
+
defaultSubscription: 'type=identify',
|
|
7
|
+
description: 'This Action will create a new Contact or update an existing Contact in SurveySparrow. One of Email or Mobile are mandatory when creating a Contact.',
|
|
8
|
+
fields: {
|
|
9
|
+
full_name: {
|
|
10
|
+
label: 'Name',
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'Full name of the Contact',
|
|
13
|
+
default: {
|
|
14
|
+
'@if': {
|
|
15
|
+
exists: { '@path': '$.properties.name' },
|
|
16
|
+
then: { '@path': '$.properties.name' },
|
|
17
|
+
else: { '@path': '$.context.traits.name' }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
phone: {
|
|
22
|
+
label: 'Phone',
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'Non Mobile Phone number for the Contact. This should include + followed by Country Code. For Example, +18004810410',
|
|
25
|
+
default: {
|
|
26
|
+
'@if': {
|
|
27
|
+
exists: { '@path': '$.properties.phone' },
|
|
28
|
+
then: { '@path': '$.properties.phone' },
|
|
29
|
+
else: { '@path': '$.context.traits.phone' }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
mobile: {
|
|
34
|
+
label: 'Mobile',
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Mobile number for the Contact. This should include + followed by Country Code. For Example, +18004810410',
|
|
37
|
+
default: {
|
|
38
|
+
'@if': {
|
|
39
|
+
exists: { '@path': '$.properties.mobile' },
|
|
40
|
+
then: { '@path': '$.properties.mobile' },
|
|
41
|
+
else: { '@path': '$.context.traits.mobile' }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
email: {
|
|
46
|
+
label: 'Email',
|
|
47
|
+
type: 'string',
|
|
48
|
+
format: 'email',
|
|
49
|
+
description: 'Email Address for the Contact',
|
|
50
|
+
default: {
|
|
51
|
+
'@if': {
|
|
52
|
+
exists: { '@path': '$.properties.email' },
|
|
53
|
+
then: { '@path': '$.properties.email' },
|
|
54
|
+
else: { '@path': '$.context.traits.email' }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
job_title: {
|
|
59
|
+
label: 'Job Title',
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Job Title for the Contact',
|
|
62
|
+
default: {
|
|
63
|
+
'@if': {
|
|
64
|
+
exists: { '@path': '$.properties.job_title' },
|
|
65
|
+
then: { '@path': '$.properties.job_title' },
|
|
66
|
+
else: { '@path': '$.context.traits.job_title' }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
custom_fields: {
|
|
71
|
+
label: 'Custom Contact Properties',
|
|
72
|
+
type: 'object',
|
|
73
|
+
defaultObjectUI: 'keyvalue',
|
|
74
|
+
description: 'Key:Value Custom Properties to be added to the Contact in SurveySparrow. [Contact Property](https://support.surveysparrow.com/hc/en-us/articles/7078996288925-How-to-add-custom-properties-to-your-contact) should be created in SurveySparrow in advance.',
|
|
75
|
+
default: {
|
|
76
|
+
'@if': {
|
|
77
|
+
exists: { '@path': '$.properties.custom_fields' },
|
|
78
|
+
then: { '@path': '$.properties.custom_fields' },
|
|
79
|
+
else: { '@path': '$.context.traits.custom_fields' }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
perform: (request, { payload }) => {
|
|
85
|
+
if (payload.email || payload.mobile) {
|
|
86
|
+
const transformedPayload = {
|
|
87
|
+
full_name: payload.full_name,
|
|
88
|
+
phone: payload.phone,
|
|
89
|
+
mobile: payload.mobile,
|
|
90
|
+
email: payload.email,
|
|
91
|
+
job_title: payload.job_title,
|
|
92
|
+
...payload.custom_fields
|
|
93
|
+
};
|
|
94
|
+
return request('https://api.surveysparrow.com/v3/contacts', {
|
|
95
|
+
method: 'post',
|
|
96
|
+
json: transformedPayload
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new actions_core_1.PayloadValidationError('Either Email or Mobile are required');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.default = action;
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/surveysparrow/createContact/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAIhF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,2CAA2C;IAClD,mBAAmB,EAAE,eAAe;IACpC,WAAW,EACT,qJAAqJ;IACvJ,MAAM,EAAE;QACN,SAAS,EAAE;YACT,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;oBACxC,IAAI,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;oBACtC,IAAI,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE;iBAC3C;aACF;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,oHAAoH;YACtH,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;oBACzC,IAAI,EAAE,EAAE,OAAO,EAAE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AE,OAAO,EAAE,4BAA4B,EAAE;oBAC/C,IAAI,EAAE,EAAE,OAAO,EAAE,gCAAgC,EAAE;iBACpD;aACF;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE;YACnC,MAAM,kBAAkB,GAAG;gBACzB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,GAAG,OAAO,CAAC,aAAa;aACzB,CAAA;YACD,OAAO,OAAO,CAAC,2CAA2C,EAAE;gBAC1D,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,kBAAkB;aACzB,CAAC,CAAA;SACH;aAAM;YACL,MAAM,IAAI,qCAAsB,CAAC,qCAAqC,CAAC,CAAA;SACxE;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/surveysparrow/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const createContact_1 = __importDefault(require("./createContact"));
|
|
7
|
+
const triggerSurvey_1 = __importDefault(require("./triggerSurvey"));
|
|
8
|
+
const destination = {
|
|
9
|
+
name: 'Surveysparrow',
|
|
10
|
+
slug: 'actions-surveysparrow',
|
|
11
|
+
mode: 'cloud',
|
|
12
|
+
description: 'Trigger Surveys and Create Contacts in SurveySparrow',
|
|
13
|
+
authentication: {
|
|
14
|
+
scheme: 'custom',
|
|
15
|
+
fields: {
|
|
16
|
+
apiToken: {
|
|
17
|
+
label: 'Access Token',
|
|
18
|
+
description: 'SurveySparrow Access Token can be found in Settings > Apps and Integrations > Create a Custom app',
|
|
19
|
+
type: 'password',
|
|
20
|
+
required: true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
testAuthentication: (request) => {
|
|
24
|
+
return request(`https://api.surveysparrow.com/v3/users`, {
|
|
25
|
+
method: 'get'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
extendRequest({ settings }) {
|
|
30
|
+
return {
|
|
31
|
+
headers: { Authorization: `Bearer ${settings.apiToken}` }
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
createContact: createContact_1.default,
|
|
36
|
+
triggerSurvey: triggerSurvey_1.default
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.default = destination;
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/surveysparrow/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;AAE3C,oEAA2C;AAE3C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,sDAAsD;IAEnE,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,QAAQ,EAAE;gBACR,KAAK,EAAE,cAAc;gBACrB,WAAW,EACT,mGAAmG;gBACrG,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,wCAAwC,EAAE;gBACvD,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IACD,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,QAAQ,CAAC,QAAQ,EAAE,EAAE;SAC1D,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;QACb,aAAa,EAAb,uBAAa;KACd;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/surveysparrow/triggerSurvey/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../generated-types';
|
|
3
|
+
import type { Payload } from './generated-types';
|
|
4
|
+
import { DynamicFieldResponse } from '@segment/actions-core';
|
|
5
|
+
import { RequestClient } from '@segment/actions-core';
|
|
6
|
+
export declare function getSurveys(request: RequestClient): Promise<DynamicFieldResponse>;
|
|
7
|
+
declare const action: ActionDefinition<Settings, Payload>;
|
|
8
|
+
export default action;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSurveys = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
async function getSurveys(request) {
|
|
6
|
+
const choices = [];
|
|
7
|
+
try {
|
|
8
|
+
let has_next_page = false;
|
|
9
|
+
let page = 1;
|
|
10
|
+
do {
|
|
11
|
+
const response = await request(`https://api.surveysparrow.com/v3/surveys?page=${page}`, {
|
|
12
|
+
method: 'get'
|
|
13
|
+
});
|
|
14
|
+
const data = JSON.parse(response.content);
|
|
15
|
+
const surveys = data.data;
|
|
16
|
+
for (const survey of surveys) {
|
|
17
|
+
choices.push({
|
|
18
|
+
label: `${survey.name}`,
|
|
19
|
+
value: survey.id
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
page++;
|
|
23
|
+
has_next_page = data.has_next_page;
|
|
24
|
+
} while (has_next_page);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return getError(err);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
choices
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.getSurveys = getSurveys;
|
|
34
|
+
async function getError(err) {
|
|
35
|
+
const errResponse = err?.response;
|
|
36
|
+
const errorBody = await errResponse.json();
|
|
37
|
+
return {
|
|
38
|
+
choices: [],
|
|
39
|
+
error: {
|
|
40
|
+
message: errorBody?.meta?.error?.errorMessage ?? 'Unknown Error',
|
|
41
|
+
code: errResponse?.status.toString() ?? '500'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const action = {
|
|
46
|
+
title: 'Trigger Survey in SurveySparrow',
|
|
47
|
+
defaultSubscription: 'type=track and event="Trigger Survey"',
|
|
48
|
+
description: 'This Action will trigger a SurveySparrow survey to a user via Email, SMS or WhatsApp. The [Survey](https://support.surveysparrow.com/hc/en-us/articles/7079412445213-How-to-create-surveys-using-SurveySparrow) and required Share [Channel](https://support.surveysparrow.com/hc/en-us/articles/7078359450269-How-to-share-surveys-across-different-channels) should be created in SurveySparrow.',
|
|
49
|
+
fields: {
|
|
50
|
+
id: {
|
|
51
|
+
label: 'Channel ID',
|
|
52
|
+
type: 'number',
|
|
53
|
+
required: true,
|
|
54
|
+
description: 'Channel ID is the unique identifier for the Share Channel in SurveySparrow. This can be copied from the URL.',
|
|
55
|
+
default: {
|
|
56
|
+
'@path': '$.properties.channel_id'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
share_type: {
|
|
60
|
+
label: 'Share Type',
|
|
61
|
+
type: 'string',
|
|
62
|
+
required: true,
|
|
63
|
+
description: 'Type of Survey Share to be triggered',
|
|
64
|
+
choices: [
|
|
65
|
+
{
|
|
66
|
+
label: 'Email',
|
|
67
|
+
value: 'Email'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: 'SMS',
|
|
71
|
+
value: 'SMS'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: 'WhatsApp',
|
|
75
|
+
value: 'WhatsApp'
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
default: {
|
|
79
|
+
'@path': '$.properties.share_type'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
survey_id: {
|
|
83
|
+
label: 'Survey',
|
|
84
|
+
type: 'number',
|
|
85
|
+
required: true,
|
|
86
|
+
description: 'Select the SurveySparrow Survey you want to trigger',
|
|
87
|
+
dynamic: true,
|
|
88
|
+
default: {
|
|
89
|
+
'@path': '$.properties.survey_id'
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
mobile: {
|
|
93
|
+
label: 'Mobile',
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: 'Mobile number to send Survey to for either SMS or WhatsApp. This should include + followed by Country Code. For Example, +18004810410. Mobile is required for SMS or WhatsApp Shares',
|
|
96
|
+
default: {
|
|
97
|
+
'@if': {
|
|
98
|
+
exists: { '@path': '$.properties.mobile' },
|
|
99
|
+
then: { '@path': '$.properties.mobile' },
|
|
100
|
+
else: { '@path': '$.context.traits.mobile' }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
email: {
|
|
105
|
+
label: 'Email',
|
|
106
|
+
type: 'string',
|
|
107
|
+
format: 'email',
|
|
108
|
+
description: 'Email address to send Survey to. This is required for an Email Share.',
|
|
109
|
+
default: {
|
|
110
|
+
'@if': {
|
|
111
|
+
exists: { '@path': '$.properties.email' },
|
|
112
|
+
then: { '@path': '$.properties.email' },
|
|
113
|
+
else: { '@path': '$.context.traits.email' }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
variables: {
|
|
118
|
+
label: 'Variables',
|
|
119
|
+
type: 'object',
|
|
120
|
+
defaultObjectUI: 'keyvalue',
|
|
121
|
+
description: 'Variables you want to pass to SurveySparrow.',
|
|
122
|
+
default: {
|
|
123
|
+
'@path': '$.properties.variables'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
dynamicFields: {
|
|
128
|
+
survey_id: getSurveys
|
|
129
|
+
},
|
|
130
|
+
perform: (request, data) => {
|
|
131
|
+
switch (data.payload.share_type) {
|
|
132
|
+
case 'Email': {
|
|
133
|
+
if (!data.payload.email) {
|
|
134
|
+
throw new actions_core_1.PayloadValidationError('Email is a Required Field Email Shares');
|
|
135
|
+
}
|
|
136
|
+
else
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
case 'SMS':
|
|
140
|
+
case 'WhatsApp': {
|
|
141
|
+
if (!data.payload.mobile) {
|
|
142
|
+
throw new actions_core_1.PayloadValidationError(`Mobile is a Required Field for ${data.payload.share_type} Shares`);
|
|
143
|
+
}
|
|
144
|
+
else
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const payload = {
|
|
149
|
+
survey_id: data.payload.survey_id,
|
|
150
|
+
contacts: [
|
|
151
|
+
{
|
|
152
|
+
email: data.payload.email,
|
|
153
|
+
mobile: data.payload.mobile
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
variables: data.payload.variables
|
|
157
|
+
};
|
|
158
|
+
return request(`https://api.surveysparrow.com/v3/channels/${data.payload.id}`, {
|
|
159
|
+
method: 'put',
|
|
160
|
+
json: payload
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
exports.default = action;
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/surveysparrow/triggerSurvey/index.ts"],"names":[],"mappings":";;;AAIA,wDAA6E;AAGtE,KAAK,UAAU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