@segment/action-destinations 3.251.0-staging-4f80e07be → 3.251.0-staging-8aa33a6cf
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/engage/twilio/sendWhatsApp/WhatsAppMessageSender.d.ts +1 -0
- package/dist/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.js +19 -11
- package/dist/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.js.map +1 -1
- package/dist/destinations/klaviyo/properties.js +1 -1
- package/package.json +2 -2
- package/dist/destinations/engage/sendgrid/Profile.d.ts +0 -6
- package/dist/destinations/engage/sendgrid/Profile.js +0 -3
- package/dist/destinations/engage/sendgrid/Profile.js.map +0 -1
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +0 -21
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +0 -174
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +0 -1
- package/dist/destinations/moloco-rmp/addToCart/generated-types.d.ts +0 -28
- package/dist/destinations/moloco-rmp/addToCart/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/addToCart/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/addToCart/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/addToCart/index.js +0 -44
- package/dist/destinations/moloco-rmp/addToCart/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/addToWishlist/generated-types.d.ts +0 -32
- package/dist/destinations/moloco-rmp/addToWishlist/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/addToWishlist/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/addToWishlist/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/addToWishlist/index.js +0 -45
- package/dist/destinations/moloco-rmp/addToWishlist/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/convert.d.ts +0 -9
- package/dist/destinations/moloco-rmp/common/convert.js +0 -83
- package/dist/destinations/moloco-rmp/common/convert.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/event.d.ts +0 -10
- package/dist/destinations/moloco-rmp/common/event.js +0 -15
- package/dist/destinations/moloco-rmp/common/event.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/fields.d.ts +0 -14
- package/dist/destinations/moloco-rmp/common/fields.js +0 -348
- package/dist/destinations/moloco-rmp/common/fields.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/payload/moloco.d.ts +0 -35
- package/dist/destinations/moloco-rmp/common/payload/moloco.js +0 -3
- package/dist/destinations/moloco-rmp/common/payload/moloco.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/payload/segment.d.ts +0 -40
- package/dist/destinations/moloco-rmp/common/payload/segment.js +0 -3
- package/dist/destinations/moloco-rmp/common/payload/segment.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/request-client.d.ts +0 -11
- package/dist/destinations/moloco-rmp/common/request-client.js +0 -28
- package/dist/destinations/moloco-rmp/common/request-client.js.map +0 -1
- package/dist/destinations/moloco-rmp/common/settings.d.ts +0 -4
- package/dist/destinations/moloco-rmp/common/settings.js +0 -3
- package/dist/destinations/moloco-rmp/common/settings.js.map +0 -1
- package/dist/destinations/moloco-rmp/generated-types.d.ts +0 -5
- package/dist/destinations/moloco-rmp/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/home/generated-types.d.ts +0 -28
- package/dist/destinations/moloco-rmp/home/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/home/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/home/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/home/index.js +0 -29
- package/dist/destinations/moloco-rmp/home/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/index.d.ts +0 -4
- package/dist/destinations/moloco-rmp/index.js +0 -117
- package/dist/destinations/moloco-rmp/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/itemPageView/generated-types.d.ts +0 -28
- package/dist/destinations/moloco-rmp/itemPageView/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/itemPageView/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/itemPageView/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/itemPageView/index.js +0 -44
- package/dist/destinations/moloco-rmp/itemPageView/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/land/generated-types.d.ts +0 -29
- package/dist/destinations/moloco-rmp/land/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/land/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/land/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/land/index.js +0 -33
- package/dist/destinations/moloco-rmp/land/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/pageView/generated-types.d.ts +0 -29
- package/dist/destinations/moloco-rmp/pageView/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/pageView/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/pageView/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/pageView/index.js +0 -36
- package/dist/destinations/moloco-rmp/pageView/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/purchase/generated-types.d.ts +0 -36
- package/dist/destinations/moloco-rmp/purchase/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/purchase/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/purchase/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/purchase/index.js +0 -37
- package/dist/destinations/moloco-rmp/purchase/index.js.map +0 -1
- package/dist/destinations/moloco-rmp/search/generated-types.d.ts +0 -30
- package/dist/destinations/moloco-rmp/search/generated-types.js +0 -3
- package/dist/destinations/moloco-rmp/search/generated-types.js.map +0 -1
- package/dist/destinations/moloco-rmp/search/index.d.ts +0 -5
- package/dist/destinations/moloco-rmp/search/index.js +0 -34
- package/dist/destinations/moloco-rmp/search/index.js.map +0 -1
|
@@ -22,29 +22,34 @@ class WhatsAppMessageSender extends utils_1.PhoneMessageSender {
|
|
|
22
22
|
return 'whatsapp';
|
|
23
23
|
}
|
|
24
24
|
async getBody(phone) {
|
|
25
|
-
let parsedPhone;
|
|
26
|
-
try {
|
|
27
|
-
parsedPhone = phoneUtil.parse(phone, 'US');
|
|
28
|
-
parsedPhone = phoneUtil.format(parsedPhone, google_libphonenumber_1.PhoneNumberFormat.E164);
|
|
29
|
-
parsedPhone = `whatsapp:${parsedPhone}`;
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
const underlyingError = e;
|
|
33
|
-
throw new actions_core_1.IntegrationError('Phone number must be able to be formatted to e164 for whatsapp. ' + underlyingError.message, `INVALID_PHONE`, 400);
|
|
34
|
-
}
|
|
35
25
|
if (!this.payload.contentSid) {
|
|
36
26
|
throw new actions_core_1.IntegrationError('A valid whatsApp Content SID was not provided.', `INVALID_CONTENT_SID`, 400);
|
|
37
27
|
}
|
|
38
28
|
const params = {
|
|
39
29
|
ContentSid: this.payload.contentSid,
|
|
40
30
|
From: this.payload.from,
|
|
41
|
-
To:
|
|
31
|
+
To: this.parsePhoneNumber(phone)
|
|
42
32
|
};
|
|
43
33
|
const contentVariables = await this.getVariables();
|
|
44
34
|
if (contentVariables)
|
|
45
35
|
params['ContentVariables'] = contentVariables;
|
|
46
36
|
return new URLSearchParams(params);
|
|
47
37
|
}
|
|
38
|
+
parsePhoneNumber(phone) {
|
|
39
|
+
let parsedPhone;
|
|
40
|
+
try {
|
|
41
|
+
parsedPhone = phoneUtil.parse(phone, 'US');
|
|
42
|
+
if (!phoneUtil.isPossibleNumber(parsedPhone) || !phoneUtil.isValidNumber(parsedPhone)) {
|
|
43
|
+
parsedPhone = phoneUtil.parse('+' + phone, 'US');
|
|
44
|
+
}
|
|
45
|
+
parsedPhone = phoneUtil.format(parsedPhone, google_libphonenumber_1.PhoneNumberFormat.E164);
|
|
46
|
+
return `whatsapp:${parsedPhone}`;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
const underlyingError = e;
|
|
50
|
+
throw new actions_core_1.IntegrationError('Phone number must be able to be formatted to e164 for whatsapp. ' + underlyingError.message, `INVALID_PHONE`, 400);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
48
53
|
async getVariables() {
|
|
49
54
|
if (!this.payload.traitEnrichment && this.payload.contentVariables)
|
|
50
55
|
return JSON.stringify(this.payload.contentVariables) ?? null;
|
|
@@ -68,6 +73,9 @@ class WhatsAppMessageSender extends utils_1.PhoneMessageSender {
|
|
|
68
73
|
__decorate([
|
|
69
74
|
utils_2.track()
|
|
70
75
|
], WhatsAppMessageSender.prototype, "getBody", null);
|
|
76
|
+
__decorate([
|
|
77
|
+
utils_2.track()
|
|
78
|
+
], WhatsAppMessageSender.prototype, "parsePhoneNumber", null);
|
|
71
79
|
__decorate([
|
|
72
80
|
utils_2.track({
|
|
73
81
|
wrapIntegrationError: () => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WhatsAppMessageSender.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.ts"],"names":[],"mappings":";;;;;;;;;AACA,uCAA6C;AAE7C,wDAAwD;AACxD,iEAA0E;AAC1E,oCAA6C;AAC7C,uCAAmC;AAEnC,MAAM,SAAS,GAAG,uCAAe,CAAC,WAAW,EAAE,CAAA;AAC/C,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAE7B,MAAa,qBAAsB,SAAQ,0BAA2B;IACpE,IAAI,sBAAsB;QACxB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAC1C,CAAC;IACD,cAAc;QACZ,OAAO,UAAU,CAAA;IACnB,CAAC;IAGD,KAAK,CAAC,OAAO,CAAC,KAAa;QACzB,IAAI,
|
|
1
|
+
{"version":3,"file":"WhatsAppMessageSender.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.ts"],"names":[],"mappings":";;;;;;;;;AACA,uCAA6C;AAE7C,w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,oBAAoB,EAAE,GAAG,EAAE,CAAC;YAC1B,iDAAiD;YACjD,4CAA4C;YAC5C,GAAG;SACJ;KACF,CAAC;yDAwBD;AAnFH,sDAoFC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.batch_size = exports.enable_batching = exports.external_id = exports.email = exports.list_id = void 0;
|
|
4
4
|
exports.list_id = {
|
|
5
5
|
label: 'List Id',
|
|
6
|
-
description:
|
|
6
|
+
description: "'Insert the ID of the default list that you'd like to subscribe users to when you call .identify().'",
|
|
7
7
|
type: 'string',
|
|
8
8
|
default: {
|
|
9
9
|
'@path': '$.context.personas.external_audience_id'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/action-destinations",
|
|
3
3
|
"description": "Destination Actions engine and definitions.",
|
|
4
|
-
"version": "3.251.0-staging-
|
|
4
|
+
"version": "3.251.0-staging-8aa33a6cf",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@bufbuild/protobuf": "^1.4.2",
|
|
44
44
|
"@bufbuild/protoc-gen-es": "^1.4.2",
|
|
45
45
|
"@segment/a1-notation": "^2.1.4",
|
|
46
|
-
"@segment/actions-core": "3.100.
|
|
46
|
+
"@segment/actions-core": "3.100.1-staging-8aa33a6cf",
|
|
47
47
|
"@segment/actions-shared": "^1.81.0",
|
|
48
48
|
"@types/node": "^18.11.15",
|
|
49
49
|
"ajv-formats": "^2.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Profile.js","sourceRoot":"","sources":["../../../../src/destinations/engage/sendgrid/Profile.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { InputField } from '@segment/actions-core';
|
|
2
|
-
import { RequestClient } from '@segment/actions-core';
|
|
3
|
-
import { Logger, StatsClient, DataFeedCache } from '@segment/actions-core/destination-kit';
|
|
4
|
-
import type { Settings } from '../generated-types';
|
|
5
|
-
import { Profile } from '../Profile';
|
|
6
|
-
export declare type ApiLookupConfig = {
|
|
7
|
-
id?: string | undefined;
|
|
8
|
-
name: string;
|
|
9
|
-
url: string;
|
|
10
|
-
method: string;
|
|
11
|
-
cacheTtl: number;
|
|
12
|
-
body?: string | undefined;
|
|
13
|
-
headers?: object | undefined;
|
|
14
|
-
responseType: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const getRequestId: ({ method, url, body, headers }: ApiLookupConfig) => string;
|
|
17
|
-
export declare const getCachedResponse: ({ responseType }: ApiLookupConfig, requestId: string, dataFeedCache: DataFeedCache, datafeedTags: string[]) => Promise<any>;
|
|
18
|
-
export declare const performApiLookup: (request: RequestClient, apiLookupConfig: ApiLookupConfig, profile: Profile, statsClient: StatsClient | undefined, tags: string[], settings: Settings, logger?: Logger | undefined, dataFeedCache?: DataFeedCache | undefined) => Promise<any>;
|
|
19
|
-
export declare const apiLookupActionFields: Record<string, InputField>;
|
|
20
|
-
export declare const apiLookupLiquidKey = "lookups";
|
|
21
|
-
export declare const FLAGON_NAME_DATA_FEEDS = "is-datafeeds-enabled";
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FLAGON_NAME_DATA_FEEDS = exports.apiLookupLiquidKey = exports.apiLookupActionFields = exports.performApiLookup = exports.getCachedResponse = exports.getRequestId = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
6
|
-
const liquidjs_1 = require("liquidjs");
|
|
7
|
-
const Liquid = new liquidjs_1.Liquid();
|
|
8
|
-
const maxResponseSizeBytes = 1000000;
|
|
9
|
-
const renderLiquidFields = async ({ id, url, body }, profile, datafeedTags, settings, logger) => {
|
|
10
|
-
let renderedUrl;
|
|
11
|
-
let renderedBody;
|
|
12
|
-
try {
|
|
13
|
-
renderedUrl = await Liquid.parseAndRender(url, { profile });
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
logger?.error(`TE Messaging: Email datafeed url parse failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
|
|
17
|
-
datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:rendering_failure', 'rendering:url');
|
|
18
|
-
throw new actions_core_1.IntegrationError('Unable to parse email api lookup url', 'api lookup url parse failure', 400);
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
renderedBody = body ? await Liquid.parseAndRender(body, { profile }) : undefined;
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
logger?.error(`TE Messaging: Email datafeed body parse failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
|
|
25
|
-
datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:rendering_failure', 'rendering:body');
|
|
26
|
-
throw new actions_core_1.IntegrationError('Unable to parse email api lookup body', 'api lookup body parse failure', 400);
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
renderedUrl,
|
|
30
|
-
renderedBody
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const getRequestId = ({ method, url, body, headers }) => {
|
|
34
|
-
const requestHash = crypto_1.createHash('sha256');
|
|
35
|
-
requestHash.update(`${method}${url}${body}${JSON.stringify(headers)}`);
|
|
36
|
-
const requestId = requestHash.digest('hex');
|
|
37
|
-
return requestId;
|
|
38
|
-
};
|
|
39
|
-
exports.getRequestId = getRequestId;
|
|
40
|
-
const getCachedResponse = async ({ responseType }, requestId, dataFeedCache, datafeedTags) => {
|
|
41
|
-
const cachedResponse = await dataFeedCache?.getRequestResponse(requestId);
|
|
42
|
-
if (!cachedResponse) {
|
|
43
|
-
datafeedTags.push('cache_hit:false');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
datafeedTags.push('cache_hit:true');
|
|
47
|
-
if (responseType === 'json') {
|
|
48
|
-
return JSON.parse(cachedResponse);
|
|
49
|
-
}
|
|
50
|
-
return cachedResponse;
|
|
51
|
-
};
|
|
52
|
-
exports.getCachedResponse = getCachedResponse;
|
|
53
|
-
const performApiLookup = async (request, apiLookupConfig, profile, statsClient, tags, settings, logger, dataFeedCache) => {
|
|
54
|
-
const { id, method, headers, cacheTtl, name } = apiLookupConfig;
|
|
55
|
-
const datafeedTags = [
|
|
56
|
-
...tags,
|
|
57
|
-
`datafeed_id:${id}`,
|
|
58
|
-
`datafeed_name:${name}`,
|
|
59
|
-
`space_id:${settings.spaceId}`,
|
|
60
|
-
`cache_ttl_greater_than_0:${cacheTtl > 0}`
|
|
61
|
-
];
|
|
62
|
-
try {
|
|
63
|
-
const { renderedUrl, renderedBody } = await renderLiquidFields(apiLookupConfig, profile, datafeedTags, settings, logger);
|
|
64
|
-
const requestId = exports.getRequestId({ ...apiLookupConfig, url: renderedUrl, body: renderedBody });
|
|
65
|
-
if (cacheTtl > 0 && dataFeedCache) {
|
|
66
|
-
const cachedResponse = await exports.getCachedResponse(apiLookupConfig, requestId, dataFeedCache, datafeedTags);
|
|
67
|
-
if (cachedResponse) {
|
|
68
|
-
datafeedTags.push('error:false');
|
|
69
|
-
return cachedResponse;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
let data;
|
|
73
|
-
try {
|
|
74
|
-
const res = await request(renderedUrl, {
|
|
75
|
-
headers: headers ?? undefined,
|
|
76
|
-
timeout: 3000,
|
|
77
|
-
method: method,
|
|
78
|
-
body: renderedBody,
|
|
79
|
-
skipResponseCloning: true
|
|
80
|
-
});
|
|
81
|
-
data = await res.data;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
const respError = error.response;
|
|
85
|
-
logger?.error(`TE Messaging: Email api lookup failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
|
|
86
|
-
datafeedTags.push(`error:true`, `error_message:${error.message}`, `error_status:${respError?.status}`, 'reason:api_call_failure');
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
const dataString = JSON.stringify(data);
|
|
90
|
-
const size = Buffer.byteLength(dataString, 'utf-8');
|
|
91
|
-
datafeedTags.push(`response_size_greater_than_mb:${size > maxResponseSizeBytes}`);
|
|
92
|
-
if (cacheTtl > 0) {
|
|
93
|
-
if (size <= maxResponseSizeBytes) {
|
|
94
|
-
try {
|
|
95
|
-
await dataFeedCache?.setRequestResponse(requestId, dataString, cacheTtl / 1000);
|
|
96
|
-
datafeedTags.push('cache_set:true');
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
logger?.error(`TE Messaging: Email api lookup cache set failure - api lookup id: ${id} - ${settings.spaceId} - [${err}]`);
|
|
100
|
-
datafeedTags.push('cache_set:false');
|
|
101
|
-
datafeedTags.push('error:true', 'reason:cache_set_failure', `error_message:${err?.message}`);
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
datafeedTags.push('cache_set:false');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return data;
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
const isErrorCapturedInTags = datafeedTags.find((str) => str.includes('error:true'));
|
|
113
|
-
if (!isErrorCapturedInTags) {
|
|
114
|
-
datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:unknown');
|
|
115
|
-
}
|
|
116
|
-
tags.push('reason:datafeed_failure');
|
|
117
|
-
logger?.error(`TE Messaging: Email api lookup failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
finally {
|
|
121
|
-
statsClient?.incr('datafeed-execution', 1, datafeedTags);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
exports.performApiLookup = performApiLookup;
|
|
125
|
-
exports.apiLookupActionFields = {
|
|
126
|
-
id: {
|
|
127
|
-
label: 'ID',
|
|
128
|
-
description: 'The id of the API lookup for use in logging & observability',
|
|
129
|
-
type: 'string'
|
|
130
|
-
},
|
|
131
|
-
name: {
|
|
132
|
-
label: 'Name',
|
|
133
|
-
description: 'The name of the API lookup referenced in liquid syntax',
|
|
134
|
-
type: 'string',
|
|
135
|
-
required: true
|
|
136
|
-
},
|
|
137
|
-
url: {
|
|
138
|
-
label: 'URL',
|
|
139
|
-
description: 'The URL endpoint to call',
|
|
140
|
-
type: 'string',
|
|
141
|
-
required: true
|
|
142
|
-
},
|
|
143
|
-
method: {
|
|
144
|
-
label: 'Request Method',
|
|
145
|
-
description: 'The request method, e.g. GET/POST/etc.',
|
|
146
|
-
type: 'string',
|
|
147
|
-
required: true
|
|
148
|
-
},
|
|
149
|
-
cacheTtl: {
|
|
150
|
-
label: 'Cache TTL',
|
|
151
|
-
description: 'The cache TTL in ms',
|
|
152
|
-
type: 'integer',
|
|
153
|
-
required: true
|
|
154
|
-
},
|
|
155
|
-
body: {
|
|
156
|
-
label: 'Request Body',
|
|
157
|
-
description: 'The request body for use with POST/PUT/PATCH requests',
|
|
158
|
-
type: 'string'
|
|
159
|
-
},
|
|
160
|
-
headers: {
|
|
161
|
-
label: 'Request Headers',
|
|
162
|
-
description: 'Headers in JSON to be sent with the request',
|
|
163
|
-
type: 'object'
|
|
164
|
-
},
|
|
165
|
-
responseType: {
|
|
166
|
-
label: 'Response Type',
|
|
167
|
-
description: 'The response type of the request. Currently only supporting JSON.',
|
|
168
|
-
type: 'string',
|
|
169
|
-
required: true
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
exports.apiLookupLiquidKey = 'lookups';
|
|
173
|
-
exports.FLAGON_NAME_DATA_FEEDS = 'is-datafeeds-enabled';
|
|
174
|
-
//# sourceMappingURL=api-lookups.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-lookups.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/sendgrid/previewApiLookup/api-lookups.ts"],"names":[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QACtB,WAAW,EAAE,mEAAmE;QAChF,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAA;AAEY,QAAA,kBAAkB,GAAG,SAAS,CAAA;AAE9B,QAAA,sBAAsB,GAAG,sBAAsB,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export interface Payload {
|
|
2
|
-
event_id?: string;
|
|
3
|
-
timestamp: string | number;
|
|
4
|
-
user_id?: string;
|
|
5
|
-
device?: {
|
|
6
|
-
os?: string;
|
|
7
|
-
os_version?: string;
|
|
8
|
-
advertising_id?: string;
|
|
9
|
-
unique_device_id?: string;
|
|
10
|
-
model?: string;
|
|
11
|
-
ua?: string;
|
|
12
|
-
language?: string;
|
|
13
|
-
ip?: string;
|
|
14
|
-
};
|
|
15
|
-
session_id?: string;
|
|
16
|
-
default_currency?: string;
|
|
17
|
-
items: {
|
|
18
|
-
id: string;
|
|
19
|
-
price?: number;
|
|
20
|
-
currency?: string;
|
|
21
|
-
quantity?: number;
|
|
22
|
-
seller_id?: string;
|
|
23
|
-
}[];
|
|
24
|
-
page_id?: string;
|
|
25
|
-
page_identifier_tokens?: {
|
|
26
|
-
[k: string]: unknown;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/moloco-rmp/addToCart/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const event_1 = require("../common/event");
|
|
4
|
-
const fields_1 = require("../common/fields");
|
|
5
|
-
const request_client_1 = require("../common/request-client");
|
|
6
|
-
const convert_1 = require("../common/convert");
|
|
7
|
-
const action = {
|
|
8
|
-
title: 'Add to Cart',
|
|
9
|
-
description: 'Represents a user adding an item to their cart',
|
|
10
|
-
defaultSubscription: 'type = "track" and event = "Product Added"',
|
|
11
|
-
fields: {
|
|
12
|
-
event_id: fields_1.event_id,
|
|
13
|
-
timestamp: fields_1.timestamp,
|
|
14
|
-
user_id: fields_1.user_id,
|
|
15
|
-
device: fields_1.device,
|
|
16
|
-
session_id: fields_1.session_id,
|
|
17
|
-
default_currency: fields_1.default_currency,
|
|
18
|
-
items: {
|
|
19
|
-
...fields_1.items,
|
|
20
|
-
required: true,
|
|
21
|
-
default: {
|
|
22
|
-
'@arrayPath': [
|
|
23
|
-
'$.properties',
|
|
24
|
-
{
|
|
25
|
-
id: { '@path': '$.product_id' },
|
|
26
|
-
price: { '@path': '$.price' },
|
|
27
|
-
currency: { '@path': '$.currency' },
|
|
28
|
-
quantity: { '@path': '$.quantity' },
|
|
29
|
-
seller_id: { '@path': '$.seller_id' }
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
page_id: fields_1.page_id,
|
|
35
|
-
page_identifier_tokens: fields_1.page_identifier_tokens
|
|
36
|
-
},
|
|
37
|
-
perform: (request, { payload, settings }) => {
|
|
38
|
-
const client = new request_client_1.MolocoAPIClient(request, settings);
|
|
39
|
-
const body = convert_1.convertEvent({ eventType: event_1.EventType.AddToCart, payload, settings });
|
|
40
|
-
return client.sendEvent(body);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
exports.default = action;
|
|
44
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/moloco-rmp/addToCart/index.ts"],"names":[],"mappings":";;AACA,2CAA2C;AAC3C,6CAUyB;AACzB,6DAA0D;AAC1D,+CAAgD;AAIhD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,gDAAgD;IAC7D,mBAAmB,EAAE,4CAA4C;IACjE,MAAM,EAAE;QACN,QAAQ,EAAR,iBAAQ;QACR,SAAS,EAAT,kBAAS;QACT,OAAO,EAAP,gBAAO;QACP,MAAM,EAAN,eAAM;QACN,UAAU,EAAV,mBAAU;QACV,gBAAgB,EAAhB,yBAAgB;QAChB,KAAK,EAAE;YACL,GAAG,cAAK;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,YAAY,EAAE;oBACZ,cAAc;oBACd;wBACE,EAAE,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;wBAC/B,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;wBAC7B,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE;wBACnC,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE;wBACnC,SAAS,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;qBACtC;iBACF;aACF;SACF;QACD,OAAO,EAAP,gBAAO;QACP,sBAAsB,EAAtB,+BAAsB;KACvB;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,IAAI,gCAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QACrD,MAAM,IAAI,GAAG,sBAAY,CAAC,EAAE,SAAS,EAAE,iBAAS,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;QAChF,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface Payload {
|
|
2
|
-
event_id?: string;
|
|
3
|
-
timestamp: string | number;
|
|
4
|
-
user_id?: string;
|
|
5
|
-
device?: {
|
|
6
|
-
os?: string;
|
|
7
|
-
os_version?: string;
|
|
8
|
-
advertising_id?: string;
|
|
9
|
-
unique_device_id?: string;
|
|
10
|
-
model?: string;
|
|
11
|
-
ua?: string;
|
|
12
|
-
language?: string;
|
|
13
|
-
ip?: string;
|
|
14
|
-
};
|
|
15
|
-
session_id?: string;
|
|
16
|
-
default_currency?: string;
|
|
17
|
-
items: {
|
|
18
|
-
id: string;
|
|
19
|
-
price?: number;
|
|
20
|
-
currency?: string;
|
|
21
|
-
quantity?: number;
|
|
22
|
-
seller_id?: string;
|
|
23
|
-
}[];
|
|
24
|
-
revenue?: {
|
|
25
|
-
price: number;
|
|
26
|
-
currency: string;
|
|
27
|
-
};
|
|
28
|
-
page_id?: string;
|
|
29
|
-
page_identifier_tokens?: {
|
|
30
|
-
[k: string]: unknown;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/moloco-rmp/addToWishlist/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const event_1 = require("../common/event");
|
|
4
|
-
const fields_1 = require("../common/fields");
|
|
5
|
-
const request_client_1 = require("../common/request-client");
|
|
6
|
-
const convert_1 = require("../common/convert");
|
|
7
|
-
const action = {
|
|
8
|
-
title: 'Add to Wishlist',
|
|
9
|
-
description: 'Represents a user adding an item to their wishlist',
|
|
10
|
-
defaultSubscription: 'type = "track" and event = "Product Added to Wishlist"',
|
|
11
|
-
fields: {
|
|
12
|
-
event_id: fields_1.event_id,
|
|
13
|
-
timestamp: fields_1.timestamp,
|
|
14
|
-
user_id: fields_1.user_id,
|
|
15
|
-
device: fields_1.device,
|
|
16
|
-
session_id: fields_1.session_id,
|
|
17
|
-
default_currency: fields_1.default_currency,
|
|
18
|
-
items: {
|
|
19
|
-
...fields_1.items,
|
|
20
|
-
required: true,
|
|
21
|
-
default: {
|
|
22
|
-
'@arrayPath': [
|
|
23
|
-
'$.properties',
|
|
24
|
-
{
|
|
25
|
-
id: { '@path': '$.product_id' },
|
|
26
|
-
price: { '@path': '$.price' },
|
|
27
|
-
currency: { '@path': '$.currency' },
|
|
28
|
-
quantity: { '@path': '$.quantity' },
|
|
29
|
-
seller_id: { '@path': '$.seller_id' }
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
revenue: fields_1.revenue,
|
|
35
|
-
page_id: fields_1.page_id,
|
|
36
|
-
page_identifier_tokens: fields_1.page_identifier_tokens
|
|
37
|
-
},
|
|
38
|
-
perform: (request, { payload, settings }) => {
|
|
39
|
-
const client = new request_client_1.MolocoAPIClient(request, settings);
|
|
40
|
-
const body = convert_1.convertEvent({ eventType: event_1.EventType.AddtoWishlist, payload, settings });
|
|
41
|
-
return client.sendEvent(body);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
exports.default = action;
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/moloco-rmp/addToWishlist/index.ts"],"names":[],"mappings":";;AACA,2CAA2C;AAC3C,6CAWyB;AACzB,6DAA0D;AAC1D,+CAAgD;AAIhD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,oDAAoD;IACjE,mBAAmB,EAAE,wDAAwD;IAC7E,MAAM,EAAE;QACN,QAAQ,EAAR,iBAAQ;QACR,SAAS,EAAT,kBAAS;QACT,OAAO,EAAP,gBAAO;QACP,MAAM,EAAN,eAAM;QACN,UAAU,EAAV,mBAAU;QACV,gBAAgB,EAAhB,yBAAgB;QAChB,KAAK,EAAE;YACL,GAAG,cAAK;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,YAAY,EAAE;oBACZ,cAAc;oBACd;wBACE,EAAE,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;wBAC/B,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;wBAC7B,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE;wBACnC,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE;wBACnC,SAAS,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;qBACtC;iBACF;aACF;SACF;QACD,OAAO,EAAP,gBAAO;QACP,OAAO,EAAP,gBAAO;QACP,sBAAsB,EAAtB,+BAAsB;KACvB;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,IAAI,gCAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QACrD,MAAM,IAAI,GAAG,sBAAY,CAAC,EAAE,SAAS,EAAE,iBAAS,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;QACpF,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EventType } from './event';
|
|
2
|
-
import { Settings } from '../generated-types';
|
|
3
|
-
import { EventPayload as SegmentEventPayload } from './payload/segment';
|
|
4
|
-
import { EventPayload as MolocoEventPayload } from './payload/moloco';
|
|
5
|
-
export declare function convertEvent(args: {
|
|
6
|
-
eventType: EventType;
|
|
7
|
-
payload: SegmentEventPayload;
|
|
8
|
-
settings: Settings;
|
|
9
|
-
}): MolocoEventPayload;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertEvent = void 0;
|
|
4
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
-
function convertEvent(args) {
|
|
6
|
-
const { eventType, payload, settings } = args;
|
|
7
|
-
return {
|
|
8
|
-
event_type: eventType,
|
|
9
|
-
channel_type: settings.channel_type,
|
|
10
|
-
timestamp: payload.timestamp,
|
|
11
|
-
id: payload.event_id ?? undefined,
|
|
12
|
-
user_id: payload.user_id ?? undefined,
|
|
13
|
-
device: payload.device ? convertDevicePayload(payload.device) : undefined,
|
|
14
|
-
session_id: payload.session_id ?? undefined,
|
|
15
|
-
revenue: payload.revenue
|
|
16
|
-
? {
|
|
17
|
-
amount: payload.revenue.price,
|
|
18
|
-
currency: payload.revenue.currency
|
|
19
|
-
}
|
|
20
|
-
: undefined,
|
|
21
|
-
search_query: payload.search_query ?? undefined,
|
|
22
|
-
referrer_page_id: payload.referrer_page_id ?? undefined,
|
|
23
|
-
shipping_charge: payload.shipping_charge
|
|
24
|
-
? {
|
|
25
|
-
amount: payload.shipping_charge.price,
|
|
26
|
-
currency: payload.shipping_charge.currency
|
|
27
|
-
}
|
|
28
|
-
: undefined,
|
|
29
|
-
items: payload.items
|
|
30
|
-
? payload.items.map((item) => convertItemPayload({ payload: item, defaultCurrency: payload.default_currency }))
|
|
31
|
-
: undefined,
|
|
32
|
-
page_id: payload.page_id ||
|
|
33
|
-
(payload.page_identifier_tokens ? convertPageIdentifierTokensToPageId(payload.page_identifier_tokens) : undefined)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.convertEvent = convertEvent;
|
|
37
|
-
function convertItemPayload(args) {
|
|
38
|
-
const { payload, defaultCurrency } = args;
|
|
39
|
-
const actualCurrency = payload.currency ?? defaultCurrency;
|
|
40
|
-
if ((payload.price !== undefined && actualCurrency === undefined) ||
|
|
41
|
-
(payload.price === undefined && actualCurrency !== undefined)) {
|
|
42
|
-
throw new actions_core_1.PayloadValidationError('Price and Currency/Default Currency should be both present or both absent');
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
id: payload.id,
|
|
46
|
-
quantity: payload.quantity,
|
|
47
|
-
seller_id: payload.seller_id,
|
|
48
|
-
price: payload.price && actualCurrency
|
|
49
|
-
? {
|
|
50
|
-
amount: payload.price,
|
|
51
|
-
currency: actualCurrency
|
|
52
|
-
}
|
|
53
|
-
: undefined
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function convertOs(os) {
|
|
57
|
-
os = os.toUpperCase();
|
|
58
|
-
if (os === 'IPADOS') {
|
|
59
|
-
os = 'IOS';
|
|
60
|
-
}
|
|
61
|
-
return os;
|
|
62
|
-
}
|
|
63
|
-
function convertDevicePayload(payload) {
|
|
64
|
-
return {
|
|
65
|
-
os: payload.os ? convertOs(payload.os) : undefined,
|
|
66
|
-
os_version: payload.os_version ?? undefined,
|
|
67
|
-
advertising_id: payload.advertising_id ?? undefined,
|
|
68
|
-
unique_device_id: payload.unique_device_id ?? undefined,
|
|
69
|
-
model: payload.model ?? undefined,
|
|
70
|
-
ua: payload.ua ?? undefined,
|
|
71
|
-
language: payload.language ?? undefined,
|
|
72
|
-
ip: payload.ip ?? undefined
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function convertPageIdentifierTokensToPageId(tokens) {
|
|
76
|
-
if (tokens === undefined) {
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
|
-
return Object.entries(tokens)
|
|
80
|
-
.map(([key, value]) => `${key}:${value}`)
|
|
81
|
-
.join(';');
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../src/destinations/moloco-rmp/common/convert.ts"],"names":[],"mappings":";;;AAAA,wDAA8D;AAiB9D,SAAgB,YAAY,CAAC,IAI5B;IACC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;IAE7C,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,EAAE,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;QACjC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;QACrC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAo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