@segment/action-destinations 3.106.0 → 3.107.0-alpha.2
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/amplitude/emptyObject.d.ts +2 -0
- package/dist/destinations/amplitude/emptyObject.js +7 -0
- package/dist/destinations/amplitude/emptyObject.js.map +1 -0
- package/dist/destinations/amplitude/index.js +3 -1
- package/dist/destinations/amplitude/index.js.map +1 -1
- package/dist/destinations/amplitude/logEventV2/generated-types.d.ts +77 -0
- package/dist/destinations/amplitude/logEventV2/generated-types.js +3 -0
- package/dist/destinations/amplitude/logEventV2/generated-types.js.map +1 -0
- package/dist/destinations/amplitude/logEventV2/index.d.ts +13 -0
- package/dist/destinations/amplitude/logEventV2/index.js +237 -0
- package/dist/destinations/amplitude/logEventV2/index.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/functions.d.ts +6 -0
- package/dist/destinations/google-enhanced-conversions/functions.js +55 -0
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/generated-types.d.ts +2 -1
- package/dist/destinations/google-enhanced-conversions/index.js +14 -7
- package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/postConversion/index.js +7 -1
- package/dist/destinations/google-enhanced-conversions/postConversion/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/types.d.ts +23 -0
- package/dist/destinations/google-enhanced-conversions/types.js +5 -0
- package/dist/destinations/google-enhanced-conversions/types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.d.ts +11 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.js +3 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.d.ts +5 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js +92 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.d.ts +25 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js +3 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.d.ts +5 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js +229 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.d.ts +20 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.js +3 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.d.ts +5 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js +286 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js.map +1 -0
- package/dist/destinations/hubspot/contact/generated-types.d.ts +17 -0
- package/dist/destinations/hubspot/contact/generated-types.js +3 -0
- package/dist/destinations/hubspot/contact/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/contact/index.d.ts +5 -0
- package/dist/destinations/hubspot/contact/index.js +186 -0
- package/dist/destinations/hubspot/contact/index.js.map +1 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.d.ts +6 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js +3 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/index.d.ts +5 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/index.js +41 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/index.js.map +1 -0
- package/dist/destinations/hubspot/generated-types.d.ts +2 -0
- package/dist/destinations/hubspot/generated-types.js +3 -0
- package/dist/destinations/hubspot/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/index.d.ts +4 -0
- package/dist/destinations/hubspot/index.js +46 -0
- package/dist/destinations/hubspot/index.js.map +1 -0
- package/dist/destinations/hubspot/properties.d.ts +1 -0
- package/dist/destinations/hubspot/properties.js +5 -0
- package/dist/destinations/hubspot/properties.js.map +1 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.d.ts +10 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js +3 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.d.ts +5 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +69 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -0
- package/dist/destinations/hubspot/testHelper.d.ts +7 -0
- package/dist/destinations/hubspot/testHelper.js +24 -0
- package/dist/destinations/hubspot/testHelper.js.map +1 -0
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/loops/index.js +1 -1
- package/dist/destinations/loops/index.js.map +1 -1
- package/dist/destinations/salesforce/customObject/index.js +12 -1
- package/dist/destinations/salesforce/customObject/index.js.map +1 -1
- package/dist/destinations/salesforce/sf-operations.d.ts +3 -0
- package/dist/destinations/salesforce/sf-operations.js +42 -0
- package/dist/destinations/salesforce/sf-operations.js.map +1 -1
- package/dist/destinations/salesforce/sf-properties.js +2 -1
- package/dist/destinations/salesforce/sf-properties.js.map +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const functions_1 = require("../functions");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Upload Call Conversion',
|
|
8
|
+
description: 'Upload an offline call conversion to the Google Ads API.',
|
|
9
|
+
fields: {
|
|
10
|
+
conversion_action: {
|
|
11
|
+
label: 'Conversion Action ID',
|
|
12
|
+
description: 'The ID of the conversion action associated with this conversion. To find the Conversion Action ID, click on your conversion in Google Ads and get the value for `ctId` in the URL. For example, if the URL is `https://ads.google.com/aw/conversions/detail?ocid=00000000&ctId=570000000`, your Conversion Action ID is `570000000`.',
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
caller_id: {
|
|
17
|
+
label: 'Caller ID',
|
|
18
|
+
description: 'The caller ID from which this call was placed. Caller ID is expected to be in E.164 format with preceding + sign, e.g. "+16502531234".',
|
|
19
|
+
type: 'string',
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
call_timestamp: {
|
|
23
|
+
label: 'Call Timestamp',
|
|
24
|
+
description: 'The date time at which the call occurred. The timezone must be specified. The format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", e.g. "2019-01-01 12:32:45-08:00".',
|
|
25
|
+
type: 'string'
|
|
26
|
+
},
|
|
27
|
+
conversion_timestamp: {
|
|
28
|
+
label: 'Conversion Timestamp',
|
|
29
|
+
description: 'The date time at which the conversion occurred. Must be after the click time. The timezone must be specified. The format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", e.g. "2019-01-01 12:32:45-08:00".',
|
|
30
|
+
type: 'string',
|
|
31
|
+
required: true,
|
|
32
|
+
default: {
|
|
33
|
+
'@path': '$.timestamp'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
value: {
|
|
37
|
+
label: 'Value',
|
|
38
|
+
description: 'The value of the conversion for the advertiser.',
|
|
39
|
+
type: 'number',
|
|
40
|
+
default: {
|
|
41
|
+
'@path': '$.properties.total'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
currency: {
|
|
45
|
+
label: 'Currency',
|
|
46
|
+
description: 'Currency associated with the conversion value. This is the ISO 4217 3-character currency code.',
|
|
47
|
+
type: 'string',
|
|
48
|
+
default: {
|
|
49
|
+
'@path': '$.properties.currency'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
custom_variables: {
|
|
53
|
+
label: 'Custom Variables',
|
|
54
|
+
description: 'The custom variables associated with this conversion. On the left-hand side, input the name of the custom variable as it appears in your Google Ads account. On the right-hand side, map the Segment field that contains the corresponding value See [Google’s documentation on how to create custom conversion variables](https://developers.google.com/google-ads/api/docs/conversions/conversion-custom-variables).',
|
|
55
|
+
type: 'object',
|
|
56
|
+
additionalProperties: true,
|
|
57
|
+
defaultObjectUI: 'keyvalue:only'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
perform: async (request, { auth, settings, payload }) => {
|
|
61
|
+
if (!settings.customerId) {
|
|
62
|
+
throw new actions_core_1.IntegrationError('Customer ID is required for this action. Please set it in destination settings.', 'Missing required fields.', 400);
|
|
63
|
+
}
|
|
64
|
+
settings.customerId = settings.customerId.replace(/-/g, '');
|
|
65
|
+
const request_object = {
|
|
66
|
+
conversionAction: `customers/${settings.customerId}/conversionActions/${payload.conversion_action}`,
|
|
67
|
+
callerId: payload.caller_id,
|
|
68
|
+
callStartDateTime: payload.call_timestamp?.replace(/T/, ' ').replace(/\..+/, '+00:00'),
|
|
69
|
+
conversionDateTime: payload.conversion_timestamp.replace(/T/, ' ').replace(/\..+/, '+00:00'),
|
|
70
|
+
conversionValue: payload.value,
|
|
71
|
+
currencyCode: payload.currency
|
|
72
|
+
};
|
|
73
|
+
if (payload.custom_variables) {
|
|
74
|
+
const customVariableIds = await functions_1.getCustomVariables(settings.customerId, auth, request);
|
|
75
|
+
request_object.customVariables = functions_1.formatCustomVariables(payload.custom_variables, customVariableIds.data[0].results);
|
|
76
|
+
}
|
|
77
|
+
const response = await request(`${types_1.GoogleAdsAPI}/${settings.customerId}:uploadCallConversions`, {
|
|
78
|
+
method: 'post',
|
|
79
|
+
headers: {
|
|
80
|
+
'developer-token': `${process.env.ADWORDS_DEVELOPER_TOKEN}`
|
|
81
|
+
},
|
|
82
|
+
json: {
|
|
83
|
+
conversions: [request_object],
|
|
84
|
+
partialFailure: true
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
functions_1.handleGoogleErrors(response);
|
|
88
|
+
return response;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.default = action;
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadCallConversion/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAG1E,4CAA4F;AAC5F,oCAA6D;AAG7D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,0DAA0D;IACvE,MAAM,EAAE;QACN,iBAAiB,EAAE;YACjB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,sUAAsU;YACxU,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,wIAAwI;YAC1I,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,cAAc,EAAE;YACd,KAAK,EAAE,gBAAgB;YACvB,WAAW,EACT,0JAA0J;YAC5J,IAAI,EAAE,QAAQ;SACf;QACD,oBAAoB,EAAE;YACpB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,8LAA8L;YAChM,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,iDAAiD;YAC9D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,oBAAoB;aAC9B;SACF;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE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,iCAAqB,CACpD,OAAO,CAAC,gBAAgB,EACxB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAClC,CAAA;SACF;QAED,MAAM,QAAQ,GAA2C,MAAM,OAAO,CACpE,GAAG,oBAAY,IAAI,QAAQ,CAAC,UAAU,wBAAwB,EAC9D;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE;aAC5D;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,CAAC,cAAc,CAAC;gBAC7B,cAAc,EAAE,IAAI;aACrB;SACF,CACF,CAAA;QAED,8BAAkB,CAAC,QAAQ,CAAC,CAAA;QAC5B,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
conversion_action: string;
|
|
3
|
+
gclid?: string;
|
|
4
|
+
gbraid?: string;
|
|
5
|
+
wbraid?: string;
|
|
6
|
+
conversion_timestamp: string;
|
|
7
|
+
email_address?: string;
|
|
8
|
+
phone_number?: string;
|
|
9
|
+
order_id?: string;
|
|
10
|
+
value?: number;
|
|
11
|
+
currency?: string;
|
|
12
|
+
conversion_environment?: string;
|
|
13
|
+
merchant_id?: string;
|
|
14
|
+
merchant_country_code?: string;
|
|
15
|
+
merchant_language_code?: string;
|
|
16
|
+
local_cost?: number;
|
|
17
|
+
items?: {
|
|
18
|
+
product_id?: string;
|
|
19
|
+
quantity?: number;
|
|
20
|
+
price?: number;
|
|
21
|
+
}[];
|
|
22
|
+
custom_variables?: {
|
|
23
|
+
[k: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
}
|
package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const functions_1 = require("../functions");
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Upload Click Conversion',
|
|
8
|
+
description: 'Upload an offline click conversion to the Google Ads API.',
|
|
9
|
+
fields: {
|
|
10
|
+
conversion_action: {
|
|
11
|
+
label: 'Conversion Action ID',
|
|
12
|
+
description: 'The ID of the conversion action associated with this conversion. To find the Conversion Action ID, click on your conversion in Google Ads and get the value for `ctId` in the URL. For example, if the URL is `https://ads.google.com/aw/conversions/detail?ocid=00000000&ctId=570000000`, your Conversion Action ID is `570000000`.',
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
gclid: {
|
|
17
|
+
label: 'GCLID',
|
|
18
|
+
description: 'The Google click ID (gclid) associated with this conversion.',
|
|
19
|
+
type: 'string'
|
|
20
|
+
},
|
|
21
|
+
gbraid: {
|
|
22
|
+
label: 'GBRAID',
|
|
23
|
+
description: 'The click identifier for clicks associated with app conversions and originating from iOS devices starting with iOS14.',
|
|
24
|
+
type: 'string'
|
|
25
|
+
},
|
|
26
|
+
wbraid: {
|
|
27
|
+
label: 'WBRAID',
|
|
28
|
+
description: 'The click identifier for clicks associated with web conversions and originating from iOS devices starting with iOS14.',
|
|
29
|
+
type: 'string'
|
|
30
|
+
},
|
|
31
|
+
conversion_timestamp: {
|
|
32
|
+
label: 'Conversion Timestamp',
|
|
33
|
+
description: 'The date time at which the conversion occurred. Must be after the click time. The timezone must be specified. The format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", e.g. "2019-01-01 12:32:45-08:00".',
|
|
34
|
+
type: 'string',
|
|
35
|
+
required: true,
|
|
36
|
+
default: {
|
|
37
|
+
'@path': '$.timestamp'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
email_address: {
|
|
41
|
+
label: 'Email Address',
|
|
42
|
+
description: 'Email address of the individual who triggered the conversion event. Segment will hash this value before sending to Google.',
|
|
43
|
+
type: 'string',
|
|
44
|
+
format: 'email',
|
|
45
|
+
default: {
|
|
46
|
+
'@if': {
|
|
47
|
+
exists: { '@path': '$.properties.email' },
|
|
48
|
+
then: { '@path': '$.properties.email' },
|
|
49
|
+
else: { '@path': '$.context.traits.email' }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
phone_number: {
|
|
54
|
+
label: 'Phone Number',
|
|
55
|
+
description: 'Phone number of the individual who triggered the conversion event, in E.164 standard format, e.g. +14150000000. Segment will hash this value before sending to Google.',
|
|
56
|
+
type: 'string',
|
|
57
|
+
default: {
|
|
58
|
+
'@if': {
|
|
59
|
+
exists: { '@path': '$.properties.phone' },
|
|
60
|
+
then: { '@path': '$.properties.phone' },
|
|
61
|
+
else: { '@path': '$.context.traits.phone' }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
order_id: {
|
|
66
|
+
label: 'Order ID',
|
|
67
|
+
description: 'The order ID associated with the conversion. An order ID can only be used for one conversion per conversion action.',
|
|
68
|
+
type: 'string',
|
|
69
|
+
default: {
|
|
70
|
+
'@if': {
|
|
71
|
+
exists: { '@path': '$.properties.orderId' },
|
|
72
|
+
then: { '@path': '$.properties.orderId' },
|
|
73
|
+
else: { '@path': '$.properties.order_id' }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
value: {
|
|
78
|
+
label: 'Value',
|
|
79
|
+
description: 'The value of the conversion for the advertiser.',
|
|
80
|
+
type: 'number',
|
|
81
|
+
default: {
|
|
82
|
+
'@path': '$.properties.total'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
currency: {
|
|
86
|
+
label: 'Currency',
|
|
87
|
+
description: 'Currency associated with the conversion value. This is the ISO 4217 3-character currency code.',
|
|
88
|
+
type: 'string',
|
|
89
|
+
default: {
|
|
90
|
+
'@path': '$.properties.currency'
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
conversion_environment: {
|
|
94
|
+
label: 'Conversion Environment',
|
|
95
|
+
description: 'The environment this conversion was recorded on, e.g. APP or WEB.',
|
|
96
|
+
type: 'string',
|
|
97
|
+
choices: [
|
|
98
|
+
{ label: 'APP', value: 'APP' },
|
|
99
|
+
{ label: 'WEB', value: 'WEB' },
|
|
100
|
+
{ label: 'UNSPECIFIED', value: 'UNSPECIFIED' }
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
merchant_id: {
|
|
104
|
+
label: 'Merchant Center ID',
|
|
105
|
+
description: 'The ID of the Merchant Center account where the items are uploaded.',
|
|
106
|
+
type: 'string'
|
|
107
|
+
},
|
|
108
|
+
merchant_country_code: {
|
|
109
|
+
label: 'Merchant Center Feed Country Code',
|
|
110
|
+
description: 'The ISO 3166 two-character region code of the Merchant Center feed where the items are uploaded.',
|
|
111
|
+
type: 'string'
|
|
112
|
+
},
|
|
113
|
+
merchant_language_code: {
|
|
114
|
+
label: 'Merchant Center Feed Language Code',
|
|
115
|
+
description: 'The ISO 639-1 language code of the Merchant Center feed where the items are uploaded.',
|
|
116
|
+
type: 'string'
|
|
117
|
+
},
|
|
118
|
+
local_cost: {
|
|
119
|
+
label: 'Local Transaction Cost',
|
|
120
|
+
description: 'Sum of all transaction-level discounts, such as free shipping and coupon discounts for the whole cart.',
|
|
121
|
+
type: 'number'
|
|
122
|
+
},
|
|
123
|
+
items: {
|
|
124
|
+
label: 'Items',
|
|
125
|
+
description: 'Data of the items purchased.',
|
|
126
|
+
type: 'object',
|
|
127
|
+
multiple: true,
|
|
128
|
+
properties: {
|
|
129
|
+
product_id: {
|
|
130
|
+
label: 'Product ID',
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'The ID of the item sold.'
|
|
133
|
+
},
|
|
134
|
+
quantity: {
|
|
135
|
+
label: 'Quantity',
|
|
136
|
+
type: 'number',
|
|
137
|
+
description: 'Number of items sold.'
|
|
138
|
+
},
|
|
139
|
+
price: {
|
|
140
|
+
label: 'Price',
|
|
141
|
+
type: 'number',
|
|
142
|
+
description: 'Unit price excluding tax, shipping, and any transaction level discounts.'
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
default: {
|
|
146
|
+
'@arrayPath': [
|
|
147
|
+
'$.properties.products',
|
|
148
|
+
{
|
|
149
|
+
product_id: {
|
|
150
|
+
'@path': '$.product_id'
|
|
151
|
+
},
|
|
152
|
+
quantity: {
|
|
153
|
+
'@path': '$.quantity'
|
|
154
|
+
},
|
|
155
|
+
price: {
|
|
156
|
+
'@path': '$.price'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
custom_variables: {
|
|
163
|
+
label: 'Custom Variables',
|
|
164
|
+
description: 'The custom variables associated with this conversion. On the left-hand side, input the name of the custom variable as it appears in your Google Ads account. On the right-hand side, map the Segment field that contains the corresponding value See [Google’s documentation on how to create custom conversion variables.](https://developers.google.com/google-ads/api/docs/conversions/conversion-custom-variables) ',
|
|
165
|
+
type: 'object',
|
|
166
|
+
additionalProperties: true,
|
|
167
|
+
defaultObjectUI: 'keyvalue:only'
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
perform: async (request, { auth, settings, payload }) => {
|
|
171
|
+
if (!settings.customerId) {
|
|
172
|
+
throw new actions_core_1.IntegrationError('Customer ID is required for this action. Please set it in destination settings.', 'Missing required fields.', 400);
|
|
173
|
+
}
|
|
174
|
+
settings.customerId = settings.customerId.replace(/-/g, '');
|
|
175
|
+
let cartItems = [];
|
|
176
|
+
if (payload.items) {
|
|
177
|
+
cartItems = payload.items.map((product) => {
|
|
178
|
+
return {
|
|
179
|
+
productId: product.product_id,
|
|
180
|
+
quantity: product.quantity,
|
|
181
|
+
unitPrice: product.price
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const request_object = {
|
|
186
|
+
conversionAction: `customers/${settings.customerId}/conversionActions/${payload.conversion_action}`,
|
|
187
|
+
conversionDateTime: payload.conversion_timestamp.replace(/T/, ' ').replace(/\..+/, '+00:00'),
|
|
188
|
+
gclid: payload.gclid,
|
|
189
|
+
gbraid: payload.gbraid,
|
|
190
|
+
wbraid: payload.wbraid,
|
|
191
|
+
orderId: payload.order_id,
|
|
192
|
+
conversionValue: payload.value,
|
|
193
|
+
currencyCode: payload.currency,
|
|
194
|
+
conversionEnvironment: payload.conversion_environment,
|
|
195
|
+
cartData: {
|
|
196
|
+
merchantId: payload.merchant_id,
|
|
197
|
+
feedCountryCode: payload.merchant_country_code,
|
|
198
|
+
feedLanguageCode: payload.merchant_language_code,
|
|
199
|
+
localTransactionCost: payload.local_cost,
|
|
200
|
+
items: cartItems
|
|
201
|
+
},
|
|
202
|
+
userIdentifiers: []
|
|
203
|
+
};
|
|
204
|
+
if (payload.custom_variables) {
|
|
205
|
+
const customVariableIds = await functions_1.getCustomVariables(settings.customerId, auth, request);
|
|
206
|
+
request_object.customVariables = functions_1.formatCustomVariables(payload.custom_variables, customVariableIds.data[0].results);
|
|
207
|
+
}
|
|
208
|
+
if (payload.email_address) {
|
|
209
|
+
request_object.userIdentifiers.push({ hashedEmail: functions_1.hash(payload.email_address) });
|
|
210
|
+
}
|
|
211
|
+
if (payload.phone_number) {
|
|
212
|
+
request_object.userIdentifiers.push({ hashedPhoneNumber: functions_1.hash(payload.phone_number) });
|
|
213
|
+
}
|
|
214
|
+
const response = await request(`${types_1.GoogleAdsAPI}/${settings.customerId}:uploadClickConversions`, {
|
|
215
|
+
method: 'post',
|
|
216
|
+
headers: {
|
|
217
|
+
'developer-token': `${process.env.ADWORDS_DEVELOPER_TOKEN}`
|
|
218
|
+
},
|
|
219
|
+
json: {
|
|
220
|
+
conversions: [request_object],
|
|
221
|
+
partialFailure: true
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
functions_1.handleGoogleErrors(response);
|
|
225
|
+
return response;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
exports.default = action;
|
|
229
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadClickConversion/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAG1E,oCAAuE;AACvE,4CAAkG;AAGlG,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,2DAA2D;IACxE,MAAM,EAAE;QACN,iBAAiB,EAAE;YACjB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,sUAAsU;YACxU,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,8DAA8D;YAC3E,IAAI,EAAE,QAAQ;SACf;QACD,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ;YACf,WAAW,EACT,uHAAuH;YACzH,IAAI,EAAE,QAAQ;SACf;QACD,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ;YACf,WAAW,EACT,uHAAuH;YACzH,IAAI,EAAE,QAAQ;SACf;QACD,oBAAoB,EAAE;YACpB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,8LAA8L;YAChM,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,aAAa,EAAE;YACb,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,4HAA4H;YAC9H,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,KAAK,E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kB,CAAC,QAAQ,CAAC,CAAA;QAC5B,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
conversion_action: string;
|
|
3
|
+
adjustment_type: string;
|
|
4
|
+
adjustment_timestamp: string;
|
|
5
|
+
order_id?: string;
|
|
6
|
+
gclid?: string;
|
|
7
|
+
conversion_timestamp?: string;
|
|
8
|
+
restatement_value?: number;
|
|
9
|
+
restatement_currency_code?: string;
|
|
10
|
+
email_address?: string;
|
|
11
|
+
phone_number?: string;
|
|
12
|
+
first_name?: string;
|
|
13
|
+
last_name?: string;
|
|
14
|
+
city?: string;
|
|
15
|
+
state?: string;
|
|
16
|
+
country?: string;
|
|
17
|
+
postal_code?: string;
|
|
18
|
+
street_address?: string;
|
|
19
|
+
user_agent?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.ts"],"names":[],"mappings":""}
|