@segment/action-destinations 3.107.0-alpha.3 → 3.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/destinations/amplitude/index.js +1 -3
  2. package/dist/destinations/amplitude/index.js.map +1 -1
  3. package/dist/destinations/google-enhanced-conversions/generated-types.d.ts +1 -2
  4. package/dist/destinations/google-enhanced-conversions/index.js +7 -14
  5. package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
  6. package/dist/destinations/google-enhanced-conversions/postConversion/index.js +1 -7
  7. package/dist/destinations/google-enhanced-conversions/postConversion/index.js.map +1 -1
  8. package/dist/destinations/index.js +0 -1
  9. package/dist/destinations/index.js.map +1 -1
  10. package/dist/destinations/salesforce/customObject/index.js +0 -4
  11. package/dist/destinations/salesforce/customObject/index.js.map +1 -1
  12. package/dist/destinations/salesforce/sf-operations.d.ts +0 -1
  13. package/dist/destinations/salesforce/sf-operations.js +6 -20
  14. package/dist/destinations/salesforce/sf-operations.js.map +1 -1
  15. package/dist/destinations/salesforce/sf-properties.js +1 -2
  16. package/dist/destinations/salesforce/sf-properties.js.map +1 -1
  17. package/package.json +4 -4
  18. package/dist/destinations/amplitude/emptyObject.d.ts +0 -2
  19. package/dist/destinations/amplitude/emptyObject.js +0 -7
  20. package/dist/destinations/amplitude/emptyObject.js.map +0 -1
  21. package/dist/destinations/amplitude/logEventV2/generated-types.d.ts +0 -77
  22. package/dist/destinations/amplitude/logEventV2/generated-types.js +0 -3
  23. package/dist/destinations/amplitude/logEventV2/generated-types.js.map +0 -1
  24. package/dist/destinations/amplitude/logEventV2/index.d.ts +0 -13
  25. package/dist/destinations/amplitude/logEventV2/index.js +0 -237
  26. package/dist/destinations/amplitude/logEventV2/index.js.map +0 -1
  27. package/dist/destinations/google-enhanced-conversions/functions.d.ts +0 -6
  28. package/dist/destinations/google-enhanced-conversions/functions.js +0 -55
  29. package/dist/destinations/google-enhanced-conversions/functions.js.map +0 -1
  30. package/dist/destinations/google-enhanced-conversions/types.d.ts +0 -23
  31. package/dist/destinations/google-enhanced-conversions/types.js +0 -5
  32. package/dist/destinations/google-enhanced-conversions/types.js.map +0 -1
  33. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.d.ts +0 -11
  34. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.js +0 -3
  35. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.js.map +0 -1
  36. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.d.ts +0 -5
  37. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js +0 -92
  38. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js.map +0 -1
  39. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.d.ts +0 -25
  40. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js +0 -3
  41. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js.map +0 -1
  42. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.d.ts +0 -5
  43. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js +0 -229
  44. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js.map +0 -1
  45. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.d.ts +0 -20
  46. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.js +0 -3
  47. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.js.map +0 -1
  48. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.d.ts +0 -5
  49. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js +0 -286
  50. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js.map +0 -1
  51. package/dist/destinations/hubspot/contact/generated-types.d.ts +0 -17
  52. package/dist/destinations/hubspot/contact/generated-types.js +0 -3
  53. package/dist/destinations/hubspot/contact/generated-types.js.map +0 -1
  54. package/dist/destinations/hubspot/contact/index.d.ts +0 -5
  55. package/dist/destinations/hubspot/contact/index.js +0 -186
  56. package/dist/destinations/hubspot/contact/index.js.map +0 -1
  57. package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.d.ts +0 -6
  58. package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js +0 -3
  59. package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js.map +0 -1
  60. package/dist/destinations/hubspot/createCustomObjectRecord/index.d.ts +0 -5
  61. package/dist/destinations/hubspot/createCustomObjectRecord/index.js +0 -41
  62. package/dist/destinations/hubspot/createCustomObjectRecord/index.js.map +0 -1
  63. package/dist/destinations/hubspot/generated-types.d.ts +0 -2
  64. package/dist/destinations/hubspot/generated-types.js +0 -3
  65. package/dist/destinations/hubspot/generated-types.js.map +0 -1
  66. package/dist/destinations/hubspot/index.d.ts +0 -4
  67. package/dist/destinations/hubspot/index.js +0 -46
  68. package/dist/destinations/hubspot/index.js.map +0 -1
  69. package/dist/destinations/hubspot/properties.d.ts +0 -1
  70. package/dist/destinations/hubspot/properties.js +0 -5
  71. package/dist/destinations/hubspot/properties.js.map +0 -1
  72. package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.d.ts +0 -10
  73. package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js +0 -3
  74. package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js.map +0 -1
  75. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.d.ts +0 -5
  76. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +0 -69
  77. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +0 -1
  78. package/dist/destinations/hubspot/testHelper.d.ts +0 -7
  79. package/dist/destinations/hubspot/testHelper.js +0 -24
  80. package/dist/destinations/hubspot/testHelper.js.map +0 -1
@@ -1,237 +0,0 @@
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 actions_core_1 = require("@segment/actions-core");
7
- const dayjs_1 = __importDefault(require("dayjs"));
8
- const emptyObject_1 = __importDefault(require("../emptyObject"));
9
- const event_schema_1 = require("../event-schema");
10
- const regional_endpoints_1 = require("../regional-endpoints");
11
- const user_agent_1 = require("../user-agent");
12
- const revenueKeys = ['revenue', 'price', 'productId', 'quantity', 'revenueType'];
13
- const action = {
14
- title: 'Log Event V2',
15
- description: 'Send an event to Amplitude',
16
- fields: {
17
- ...event_schema_1.eventSchema,
18
- products: {
19
- label: 'Products',
20
- description: 'The list of products purchased.',
21
- type: 'object',
22
- multiple: true,
23
- additionalProperties: true,
24
- properties: {
25
- price: {
26
- label: 'Price',
27
- type: 'number',
28
- description: 'The price of the item purchased. Required for revenue data if the revenue field is not sent. You can use negative values to indicate refunds.'
29
- },
30
- quantity: {
31
- label: 'Quantity',
32
- type: 'integer',
33
- description: 'The quantity of the item purchased. Defaults to 1 if not specified.'
34
- },
35
- revenue: {
36
- label: 'Revenue',
37
- type: 'number',
38
- description: 'Revenue = price * quantity. If you send all 3 fields of price, quantity, and revenue, then (price * quantity) will be used as the revenue value. You can use negative values to indicate refunds.'
39
- },
40
- productId: {
41
- label: 'Product ID',
42
- type: 'string',
43
- description: 'An identifier for the item purchased. You must send a price and quantity or revenue with this field.'
44
- },
45
- revenueType: {
46
- label: 'Revenue Type',
47
- type: 'string',
48
- description: 'The type of revenue for the item purchased. You must send a price and quantity or revenue with this field.'
49
- }
50
- },
51
- default: {
52
- '@arrayPath': [
53
- '$.properties.products',
54
- {
55
- price: {
56
- '@path': 'price'
57
- },
58
- revenue: {
59
- '@path': 'revenue'
60
- },
61
- quantity: {
62
- '@path': 'quantity'
63
- },
64
- productId: {
65
- '@path': 'productId'
66
- },
67
- revenueType: {
68
- '@path': 'revenueType'
69
- }
70
- }
71
- ]
72
- }
73
- },
74
- setOnce: {
75
- label: 'Set Once',
76
- description: 'The following fields will be set only once per session when using AJS2 as the source',
77
- type: 'object',
78
- additionalProperties: true,
79
- properties: {
80
- initial_referrer: {
81
- label: 'Initial Referrer',
82
- type: 'string',
83
- description: 'The referrer of the web request'
84
- },
85
- initial_utm_source: {
86
- label: 'Initial UTM Source',
87
- type: 'string'
88
- },
89
- initial_utm_medium: {
90
- label: 'Initial UTM Medium',
91
- type: 'string'
92
- },
93
- initial_utm_campaign: {
94
- label: 'Initial UTM Campaign',
95
- type: 'string'
96
- },
97
- initial_utm_term: {
98
- label: 'Initial UTM Term',
99
- type: 'string'
100
- },
101
- initial_utm_content: {
102
- label: 'Initial UTM Content',
103
- type: 'string'
104
- }
105
- },
106
- default: {
107
- initial_referrer: { '@path': '$.context.page.referrer' },
108
- initial_utm_source: { '@path': '$.context.campaign.source' },
109
- initial_utm_medium: { '@path': '$.context.campaign.medium' },
110
- initial_utm_campaign: { '@path': '$.context.campaign.name' },
111
- initial_utm_term: { '@path': '$.context.campaign.term' },
112
- initial_utm_content: { '@path': '$.context.campaign.content' }
113
- }
114
- },
115
- setAlways: {
116
- label: 'Set Always',
117
- description: 'The following fields will be set every session when using AJS2 as the source',
118
- type: 'object',
119
- additionalProperties: true,
120
- properties: {
121
- referrer: {
122
- label: 'Referrer',
123
- type: 'string'
124
- },
125
- utm_source: {
126
- label: 'UTM Source',
127
- type: 'string'
128
- },
129
- utm_medium: {
130
- label: 'UTM Medium',
131
- type: 'string'
132
- },
133
- utm_campaign: {
134
- label: 'UTM Campaign',
135
- type: 'string'
136
- },
137
- utm_term: {
138
- label: 'UTM Term',
139
- type: 'string'
140
- },
141
- utm_content: {
142
- label: 'UTM Content',
143
- type: 'string'
144
- }
145
- },
146
- default: {
147
- referrer: { '@path': '$.context.page.referrer' },
148
- utm_source: { '@path': '$.context.campaign.source' },
149
- utm_medium: { '@path': '$.context.campaign.medium' },
150
- utm_campaign: { '@path': '$.context.campaign.name' },
151
- utm_term: { '@path': '$.context.campaign.term' },
152
- utm_content: { '@path': '$.context.campaign.content' }
153
- }
154
- },
155
- add: {
156
- label: 'Add',
157
- description: "Increment a user property by a number with add. If the user property doesn't have a value set yet, it's initialized to 0.",
158
- type: 'object',
159
- additionalProperties: true,
160
- defaultObjectUI: 'keyvalue'
161
- },
162
- use_batch_endpoint: {
163
- label: 'Use Batch Endpoint',
164
- description: "If true, events are sent to Amplitude's `batch` endpoint rather than their `httpapi` events endpoint. Enabling this setting may help reduce 429s – or throttling errors – from Amplitude. More information about Amplitude's throttling is available in [their docs](https://developers.amplitude.com/docs/batch-event-upload-api#429s-in-depth).",
165
- type: 'boolean',
166
- default: false
167
- },
168
- userAgent: {
169
- label: 'User Agent',
170
- type: 'string',
171
- description: 'The user agent of the device sending the event.',
172
- default: {
173
- '@path': '$.context.userAgent'
174
- }
175
- },
176
- userAgentParsing: {
177
- label: 'User Agent Parsing',
178
- type: 'boolean',
179
- description: 'Enabling this setting will set the Device manufacturer, Device Model and OS Name properties based on the user agent string provided in the userAgent field',
180
- default: true
181
- },
182
- min_id_length: {
183
- label: 'Minimum ID Length',
184
- description: 'Amplitude has a default minimum id length of 5 characters for user_id and device_id fields. This field allows the minimum to be overridden to allow shorter id lengths.',
185
- allowNull: true,
186
- type: 'integer'
187
- }
188
- },
189
- perform: (request, { payload, settings }) => {
190
- const { time, session_id, userAgent, userAgentParsing, min_id_length, library, setOnce, setAlways, add, ...rest } = actions_core_1.omit(payload, revenueKeys);
191
- const properties = rest;
192
- let options;
193
- if (properties.platform) {
194
- properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android');
195
- }
196
- if (library) {
197
- if (library === 'analytics.js')
198
- properties.platform = 'Web';
199
- }
200
- if (time && dayjs_1.default.utc(time).isValid()) {
201
- properties.time = dayjs_1.default.utc(time).valueOf();
202
- }
203
- if (session_id && dayjs_1.default.utc(session_id).isValid()) {
204
- properties.session_id = dayjs_1.default.utc(session_id).valueOf();
205
- }
206
- if (min_id_length && min_id_length > 0) {
207
- options = { min_id_length };
208
- }
209
- if (emptyObject_1.default(setOnce)) {
210
- properties.user_properties = { ...properties.user_properties, $setOnce: setOnce };
211
- }
212
- if (emptyObject_1.default(setAlways)) {
213
- properties.user_properties = { ...properties.user_properties, $set: setAlways };
214
- }
215
- if (emptyObject_1.default(add)) {
216
- properties.user_properties = { ...properties.user_properties, $add: add };
217
- }
218
- const events = [
219
- {
220
- ...(userAgentParsing && user_agent_1.parseUserAgentProperties(userAgent)),
221
- ...actions_core_1.removeUndefined(properties),
222
- library: 'segment'
223
- }
224
- ];
225
- const endpoint = regional_endpoints_1.getEndpointByRegion(payload.use_batch_endpoint ? 'batch' : 'httpapi', settings.endpoint);
226
- return request(endpoint, {
227
- method: 'post',
228
- json: {
229
- api_key: settings.apiKey,
230
- events,
231
- options
232
- }
233
- });
234
- }
235
- };
236
- exports.default = action;
237
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amplitude/logEventV2/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA+E;AAC/E,kDAAyB;AACzB,iEAA2D;AAC3D,kDAA6C;AAE7C,8DAA2D;AAC3D,8CAAwD;AAYxD,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;AAEhF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,4BAA4B;IACzC,MAAM,EAAE;QACN,GAAG,0BAAW;QACd,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,iCAAiC;YAC9C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,IAAI;YAC1B,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,KAAK,EAAE,OAAO;oBACd,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,+IAA+I;iBAClJ;gBACD,QAAQ,EAAE;oBACR,KAAK,EAAE,U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S,CAAC,CAAC;gBAE5D,GAAG,8BAAe,CAAC,UAAU,CAAC;gBAC9B,OAAO,EAAE,SAAS;aACnB;SACF,CAAA;QAED,MAAM,QAAQ,GAAG,wCAAmB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAEzG,OAAO,OAAO,CAAC,QAAQ,EAAE;YACvB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,OAAO,EAAE,QAAQ,CAAC,MAAM;gBACxB,MAAM;gBACN,OAAO;aACR;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,6 +0,0 @@
1
- import { ConversionCustomVariable, PartialErrorResponse, QueryResponse } from './types';
2
- import { ModifiedResponse, RequestClient } from '@segment/actions-core';
3
- export declare function formatCustomVariables(customVariables: object | undefined, customVariableIdsResults: Array<ConversionCustomVariable>): object | undefined;
4
- export declare const hash: (value: string | undefined) => string | undefined;
5
- export declare function getCustomVariables(customerId: string, auth: any, request: RequestClient): Promise<ModifiedResponse<QueryResponse[]>>;
6
- export declare function handleGoogleErrors(response: ModifiedResponse<PartialErrorResponse>): void;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleGoogleErrors = exports.getCustomVariables = exports.hash = exports.formatCustomVariables = void 0;
4
- const crypto_1 = require("crypto");
5
- const actions_core_1 = require("@segment/actions-core");
6
- const types_1 = require("./types");
7
- function formatCustomVariables(customVariables, customVariableIdsResults) {
8
- if (!customVariables) {
9
- return undefined;
10
- }
11
- const resourceNames = {};
12
- Object.entries(customVariableIdsResults).forEach(([_, customVariables]) => {
13
- resourceNames[customVariables.conversionCustomVariable.name] = customVariables.conversionCustomVariable.resourceName;
14
- });
15
- const variables = [];
16
- Object.entries(customVariables).forEach(([key, value]) => {
17
- if (resourceNames[key] != undefined) {
18
- const variable = {
19
- conversionCustomVariable: resourceNames[key],
20
- value: value
21
- };
22
- variables.push(variable);
23
- }
24
- });
25
- return variables;
26
- }
27
- exports.formatCustomVariables = formatCustomVariables;
28
- const hash = (value) => {
29
- if (value === undefined)
30
- return;
31
- const hash = crypto_1.createHash('sha256');
32
- hash.update(value);
33
- return hash.digest('hex');
34
- };
35
- exports.hash = hash;
36
- async function getCustomVariables(customerId, auth, request) {
37
- return await request(`${types_1.GoogleAdsAPI}/${customerId}/googleAds:searchStream`, {
38
- method: 'post',
39
- headers: {
40
- authorization: `Bearer ${auth?.accessToken}`,
41
- 'developer-token': `${process.env.ADWORDS_DEVELOPER_TOKEN}`
42
- },
43
- json: {
44
- query: `SELECT conversion_custom_variable.id, conversion_custom_variable.name FROM conversion_custom_variable`
45
- }
46
- });
47
- }
48
- exports.getCustomVariables = getCustomVariables;
49
- function handleGoogleErrors(response) {
50
- if (response.data.partialFailureError.code !== 0) {
51
- throw new actions_core_1.IntegrationError(response.data.partialFailureError.message, 'INVALID_ARGUMENT', 400);
52
- }
53
- }
54
- exports.handleGoogleErrors = handleGoogleErrors;
55
- //# sourceMappingURL=functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/google-enhanced-conversions/functions.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC,wDAAyF;AACzF,mCAAsC;AAEtC,SAAgB,qBAAqB,CACnC,eAAmC,EACnC,wBAAyD;IAEzD,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,SAAS,CAAA;KACjB;IAGD,MAAM,aAAa,GAA2B,EAAE,CAAA;IAChD,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,EAAE;QACxE,aAAa,CAAC,eAAe,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,wBAAwB,CAAC,YAAY,CAAA;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,IAAI,KAAK,CAAC,EAAE;QAChD,MAAM,IAAI,+BAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAA;KAC/F;AACH,CAAC;AAJD,gDAIC"}
@@ -1,23 +0,0 @@
1
- export interface CartItem {
2
- productId?: string;
3
- quantity?: number;
4
- unitPrice?: number;
5
- }
6
- export interface ConversionCustomVariable {
7
- conversionCustomVariable: {
8
- resourceName: string;
9
- id: string;
10
- name: string;
11
- };
12
- }
13
- export interface QueryResponse {
14
- results: Array<ConversionCustomVariable>;
15
- }
16
- export interface PartialErrorResponse {
17
- partialFailureError: {
18
- code: number;
19
- message: string;
20
- };
21
- results: {}[];
22
- }
23
- export declare const GoogleAdsAPI = "https://googleads.googleapis.com/v11/customers";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleAdsAPI = void 0;
4
- exports.GoogleAdsAPI = 'https://googleads.googleapis.com/v11/customers';
5
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/google-enhanced-conversions/types.ts"],"names":[],"mappings":";;;AA0Ba,QAAA,YAAY,GAAG,gDAAgD,CAAA"}
@@ -1,11 +0,0 @@
1
- export interface Payload {
2
- conversion_action: string;
3
- caller_id: string;
4
- call_timestamp?: string;
5
- conversion_timestamp: string;
6
- value?: number;
7
- currency?: string;
8
- custom_variables?: {
9
- [k: string]: unknown;
10
- };
11
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=generated-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { ActionDefinition } from '@segment/actions-core';
2
- import type { Settings } from '../generated-types';
3
- import type { Payload } from './generated-types';
4
- declare const action: ActionDefinition<Settings, Payload>;
5
- export default action;
@@ -1,92 +0,0 @@
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
@@ -1 +0,0 @@
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,w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AA;QAC5B,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,25 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=generated-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { ActionDefinition } from '@segment/actions-core';
2
- import type { Settings } from '../generated-types';
3
- import type { Payload } from './generated-types';
4
- declare const action: ActionDefinition<Settings, Payload>;
5
- export default action;