@segment/action-destinations 3.110.0 → 3.110.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/amplitude/compact.d.ts +2 -0
- package/dist/destinations/amplitude/compact.js +7 -0
- package/dist/destinations/amplitude/compact.js.map +1 -0
- package/dist/destinations/amplitude/index.js +9 -7
- 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 +238 -0
- package/dist/destinations/amplitude/logEventV2/index.js.map +1 -0
- package/dist/destinations/hubspot/index.js +7 -2
- package/dist/destinations/hubspot/index.js.map +1 -1
- 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/upsertContact/generated-types.d.ts +17 -0
- package/dist/destinations/hubspot/upsertContact/generated-types.js +3 -0
- package/dist/destinations/hubspot/upsertContact/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/upsertContact/index.d.ts +5 -0
- package/dist/destinations/hubspot/upsertContact/index.js +183 -0
- package/dist/destinations/hubspot/upsertContact/index.js.map +1 -0
- package/dist/destinations/linkedin-audiences/index.js +32 -7
- package/dist/destinations/linkedin-audiences/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function compact(object) {
|
|
4
|
+
return Object.keys(Object.fromEntries(Object.entries(object ?? {}).filter(([_, v]) => v !== ''))).length > 0;
|
|
5
|
+
}
|
|
6
|
+
exports.default = compact;
|
|
7
|
+
//# sourceMappingURL=compact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact.js","sourceRoot":"","sources":["../../../src/destinations/amplitude/compact.ts"],"names":[],"mappings":";;AASA,SAAwB,OAAO,CAC7B,MAAiF;IAEjF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;AAC9G,CAAC;AAJD,0BAIC"}
|
|
@@ -10,12 +10,13 @@ const mapUser_1 = __importDefault(require("./mapUser"));
|
|
|
10
10
|
const groupIdentifyUser_1 = __importDefault(require("./groupIdentifyUser"));
|
|
11
11
|
const logPurchase_1 = __importDefault(require("./logPurchase"));
|
|
12
12
|
const regional_endpoints_1 = require("./regional-endpoints");
|
|
13
|
+
const logEventV2_1 = __importDefault(require("./logEventV2"));
|
|
13
14
|
const presets = [
|
|
14
15
|
{
|
|
15
16
|
name: 'Track Calls',
|
|
16
17
|
subscribe: 'type = "track" and event != "Order Completed"',
|
|
17
|
-
partnerAction: '
|
|
18
|
-
mapping: actions_core_1.defaultValues(
|
|
18
|
+
partnerAction: 'logEventV2',
|
|
19
|
+
mapping: actions_core_1.defaultValues(logEventV2_1.default.fields)
|
|
19
20
|
},
|
|
20
21
|
{
|
|
21
22
|
name: 'Order Completed Calls',
|
|
@@ -26,9 +27,9 @@ const presets = [
|
|
|
26
27
|
{
|
|
27
28
|
name: 'Page Calls',
|
|
28
29
|
subscribe: 'type = "page"',
|
|
29
|
-
partnerAction: '
|
|
30
|
+
partnerAction: 'logEventV2',
|
|
30
31
|
mapping: {
|
|
31
|
-
...actions_core_1.defaultValues(
|
|
32
|
+
...actions_core_1.defaultValues(logEventV2_1.default.fields),
|
|
32
33
|
event_type: {
|
|
33
34
|
'@template': 'Viewed {{name}}'
|
|
34
35
|
}
|
|
@@ -37,9 +38,9 @@ const presets = [
|
|
|
37
38
|
{
|
|
38
39
|
name: 'Screen Calls',
|
|
39
40
|
subscribe: 'type = "screen"',
|
|
40
|
-
partnerAction: '
|
|
41
|
+
partnerAction: 'logEventV2',
|
|
41
42
|
mapping: {
|
|
42
|
-
...actions_core_1.defaultValues(
|
|
43
|
+
...actions_core_1.defaultValues(logEventV2_1.default.fields),
|
|
43
44
|
event_type: {
|
|
44
45
|
'@template': 'Viewed {{name}}'
|
|
45
46
|
}
|
|
@@ -120,7 +121,8 @@ const destination = {
|
|
|
120
121
|
identifyUser: identifyUser_1.default,
|
|
121
122
|
mapUser: mapUser_1.default,
|
|
122
123
|
groupIdentifyUser: groupIdentifyUser_1.default,
|
|
123
|
-
logPurchase: logPurchase_1.default
|
|
124
|
+
logPurchase: logPurchase_1.default,
|
|
125
|
+
logEventV2: logEventV2_1.default
|
|
124
126
|
}
|
|
125
127
|
};
|
|
126
128
|
exports.default = destination;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/amplitude/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAqD;AACrD,kEAAyC;AACzC,0DAAiC;AACjC,wDAA+B;AAC/B,4EAAmD;AACnD,gEAAuC;AAEvC,6DAA0D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/amplitude/index.ts"],"names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E;gBACJ,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;gBAC1B,SAAS,EAAE,SAAS;aACrB;SACF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO;IACP,OAAO,EAAE;QACP,QAAQ,EAAR,kBAAQ;QACR,YAAY,EAAZ,sBAAY;QACZ,OAAO,EAAP,iBAAO;QACP,iBAAiB,EAAjB,2BAAiB;QACjB,WAAW,EAAX,qBAAW;QACX,UAAU,EAAV,oBAAU;KACX;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
user_id?: string | null;
|
|
3
|
+
device_id?: string;
|
|
4
|
+
event_type: string;
|
|
5
|
+
session_id?: string | number;
|
|
6
|
+
time?: string | number;
|
|
7
|
+
event_properties?: {
|
|
8
|
+
[k: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
user_properties?: {
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
groups?: {
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
app_version?: string;
|
|
17
|
+
platform?: string;
|
|
18
|
+
os_name?: string;
|
|
19
|
+
os_version?: string;
|
|
20
|
+
device_brand?: string;
|
|
21
|
+
device_manufacturer?: string;
|
|
22
|
+
device_model?: string;
|
|
23
|
+
carrier?: string;
|
|
24
|
+
country?: string;
|
|
25
|
+
region?: string;
|
|
26
|
+
city?: string;
|
|
27
|
+
dma?: string;
|
|
28
|
+
language?: string;
|
|
29
|
+
price?: number;
|
|
30
|
+
quantity?: number;
|
|
31
|
+
revenue?: number;
|
|
32
|
+
productId?: string;
|
|
33
|
+
revenueType?: string;
|
|
34
|
+
location_lat?: number;
|
|
35
|
+
location_lng?: number;
|
|
36
|
+
ip?: string;
|
|
37
|
+
idfa?: string;
|
|
38
|
+
idfv?: string;
|
|
39
|
+
adid?: string;
|
|
40
|
+
android_id?: string;
|
|
41
|
+
event_id?: number;
|
|
42
|
+
insert_id?: string;
|
|
43
|
+
library?: string;
|
|
44
|
+
products?: {
|
|
45
|
+
price?: number;
|
|
46
|
+
quantity?: number;
|
|
47
|
+
revenue?: number;
|
|
48
|
+
productId?: string;
|
|
49
|
+
revenueType?: string;
|
|
50
|
+
[k: string]: unknown;
|
|
51
|
+
}[];
|
|
52
|
+
setOnce?: {
|
|
53
|
+
initial_referrer?: string;
|
|
54
|
+
initial_utm_source?: string;
|
|
55
|
+
initial_utm_medium?: string;
|
|
56
|
+
initial_utm_campaign?: string;
|
|
57
|
+
initial_utm_term?: string;
|
|
58
|
+
initial_utm_content?: string;
|
|
59
|
+
[k: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
setAlways?: {
|
|
62
|
+
referrer?: string;
|
|
63
|
+
utm_source?: string;
|
|
64
|
+
utm_medium?: string;
|
|
65
|
+
utm_campaign?: string;
|
|
66
|
+
utm_term?: string;
|
|
67
|
+
utm_content?: string;
|
|
68
|
+
[k: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
add?: {
|
|
71
|
+
[k: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
use_batch_endpoint?: boolean;
|
|
74
|
+
userAgent?: string;
|
|
75
|
+
userAgentParsing?: boolean;
|
|
76
|
+
min_id_length?: number | null;
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/amplitude/logEventV2/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActionDefinition } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../generated-types';
|
|
3
|
+
import type { Payload } from './generated-types';
|
|
4
|
+
export interface AmplitudeEvent extends Omit<Payload, 'products' | 'time' | 'session_id'> {
|
|
5
|
+
library?: string;
|
|
6
|
+
time?: number;
|
|
7
|
+
session_id?: number;
|
|
8
|
+
options?: {
|
|
9
|
+
min_id_length: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare const action: ActionDefinition<Settings, Payload>;
|
|
13
|
+
export default action;
|
|
@@ -0,0 +1,238 @@
|
|
|
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 compact_1 = __importDefault(require("../compact"));
|
|
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
|
+
defaultSubscription: 'type = "track"',
|
|
17
|
+
fields: {
|
|
18
|
+
...event_schema_1.eventSchema,
|
|
19
|
+
products: {
|
|
20
|
+
label: 'Products',
|
|
21
|
+
description: 'The list of products purchased.',
|
|
22
|
+
type: 'object',
|
|
23
|
+
multiple: true,
|
|
24
|
+
additionalProperties: true,
|
|
25
|
+
properties: {
|
|
26
|
+
price: {
|
|
27
|
+
label: 'Price',
|
|
28
|
+
type: 'number',
|
|
29
|
+
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.'
|
|
30
|
+
},
|
|
31
|
+
quantity: {
|
|
32
|
+
label: 'Quantity',
|
|
33
|
+
type: 'integer',
|
|
34
|
+
description: 'The quantity of the item purchased. Defaults to 1 if not specified.'
|
|
35
|
+
},
|
|
36
|
+
revenue: {
|
|
37
|
+
label: 'Revenue',
|
|
38
|
+
type: 'number',
|
|
39
|
+
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.'
|
|
40
|
+
},
|
|
41
|
+
productId: {
|
|
42
|
+
label: 'Product ID',
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'An identifier for the item purchased. You must send a price and quantity or revenue with this field.'
|
|
45
|
+
},
|
|
46
|
+
revenueType: {
|
|
47
|
+
label: 'Revenue Type',
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'The type of revenue for the item purchased. You must send a price and quantity or revenue with this field.'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
default: {
|
|
53
|
+
'@arrayPath': [
|
|
54
|
+
'$.properties.products',
|
|
55
|
+
{
|
|
56
|
+
price: {
|
|
57
|
+
'@path': 'price'
|
|
58
|
+
},
|
|
59
|
+
revenue: {
|
|
60
|
+
'@path': 'revenue'
|
|
61
|
+
},
|
|
62
|
+
quantity: {
|
|
63
|
+
'@path': 'quantity'
|
|
64
|
+
},
|
|
65
|
+
productId: {
|
|
66
|
+
'@path': 'productId'
|
|
67
|
+
},
|
|
68
|
+
revenueType: {
|
|
69
|
+
'@path': 'revenueType'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
setOnce: {
|
|
76
|
+
label: 'Set Once',
|
|
77
|
+
description: 'The following fields will be set only once per session when using AJS2 as the source.',
|
|
78
|
+
type: 'object',
|
|
79
|
+
additionalProperties: true,
|
|
80
|
+
properties: {
|
|
81
|
+
initial_referrer: {
|
|
82
|
+
label: 'Initial Referrer',
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'The referrer of the web request.'
|
|
85
|
+
},
|
|
86
|
+
initial_utm_source: {
|
|
87
|
+
label: 'Initial UTM Source',
|
|
88
|
+
type: 'string'
|
|
89
|
+
},
|
|
90
|
+
initial_utm_medium: {
|
|
91
|
+
label: 'Initial UTM Medium',
|
|
92
|
+
type: 'string'
|
|
93
|
+
},
|
|
94
|
+
initial_utm_campaign: {
|
|
95
|
+
label: 'Initial UTM Campaign',
|
|
96
|
+
type: 'string'
|
|
97
|
+
},
|
|
98
|
+
initial_utm_term: {
|
|
99
|
+
label: 'Initial UTM Term',
|
|
100
|
+
type: 'string'
|
|
101
|
+
},
|
|
102
|
+
initial_utm_content: {
|
|
103
|
+
label: 'Initial UTM Content',
|
|
104
|
+
type: 'string'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
default: {
|
|
108
|
+
initial_referrer: { '@path': '$.context.page.referrer' },
|
|
109
|
+
initial_utm_source: { '@path': '$.context.campaign.source' },
|
|
110
|
+
initial_utm_medium: { '@path': '$.context.campaign.medium' },
|
|
111
|
+
initial_utm_campaign: { '@path': '$.context.campaign.name' },
|
|
112
|
+
initial_utm_term: { '@path': '$.context.campaign.term' },
|
|
113
|
+
initial_utm_content: { '@path': '$.context.campaign.content' }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
setAlways: {
|
|
117
|
+
label: 'Set Always',
|
|
118
|
+
description: 'The following fields will be set every session when using AJS2 as the source.',
|
|
119
|
+
type: 'object',
|
|
120
|
+
additionalProperties: true,
|
|
121
|
+
properties: {
|
|
122
|
+
referrer: {
|
|
123
|
+
label: 'Referrer',
|
|
124
|
+
type: 'string'
|
|
125
|
+
},
|
|
126
|
+
utm_source: {
|
|
127
|
+
label: 'UTM Source',
|
|
128
|
+
type: 'string'
|
|
129
|
+
},
|
|
130
|
+
utm_medium: {
|
|
131
|
+
label: 'UTM Medium',
|
|
132
|
+
type: 'string'
|
|
133
|
+
},
|
|
134
|
+
utm_campaign: {
|
|
135
|
+
label: 'UTM Campaign',
|
|
136
|
+
type: 'string'
|
|
137
|
+
},
|
|
138
|
+
utm_term: {
|
|
139
|
+
label: 'UTM Term',
|
|
140
|
+
type: 'string'
|
|
141
|
+
},
|
|
142
|
+
utm_content: {
|
|
143
|
+
label: 'UTM Content',
|
|
144
|
+
type: 'string'
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
default: {
|
|
148
|
+
referrer: { '@path': '$.context.page.referrer' },
|
|
149
|
+
utm_source: { '@path': '$.context.campaign.source' },
|
|
150
|
+
utm_medium: { '@path': '$.context.campaign.medium' },
|
|
151
|
+
utm_campaign: { '@path': '$.context.campaign.name' },
|
|
152
|
+
utm_term: { '@path': '$.context.campaign.term' },
|
|
153
|
+
utm_content: { '@path': '$.context.campaign.content' }
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
add: {
|
|
157
|
+
label: 'Add',
|
|
158
|
+
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.",
|
|
159
|
+
type: 'object',
|
|
160
|
+
additionalProperties: true,
|
|
161
|
+
defaultObjectUI: 'keyvalue'
|
|
162
|
+
},
|
|
163
|
+
use_batch_endpoint: {
|
|
164
|
+
label: 'Use Batch Endpoint',
|
|
165
|
+
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).",
|
|
166
|
+
type: 'boolean',
|
|
167
|
+
default: false
|
|
168
|
+
},
|
|
169
|
+
userAgent: {
|
|
170
|
+
label: 'User Agent',
|
|
171
|
+
type: 'string',
|
|
172
|
+
description: 'The user agent of the device sending the event.',
|
|
173
|
+
default: {
|
|
174
|
+
'@path': '$.context.userAgent'
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
userAgentParsing: {
|
|
178
|
+
label: 'User Agent Parsing',
|
|
179
|
+
type: 'boolean',
|
|
180
|
+
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.',
|
|
181
|
+
default: true
|
|
182
|
+
},
|
|
183
|
+
min_id_length: {
|
|
184
|
+
label: 'Minimum ID Length',
|
|
185
|
+
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.',
|
|
186
|
+
allowNull: true,
|
|
187
|
+
type: 'integer'
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
perform: (request, { payload, settings }) => {
|
|
191
|
+
const { time, session_id, userAgent, userAgentParsing, min_id_length, library, setOnce, setAlways, add, ...rest } = actions_core_1.omit(payload, revenueKeys);
|
|
192
|
+
const properties = rest;
|
|
193
|
+
let options;
|
|
194
|
+
if (properties.platform) {
|
|
195
|
+
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android');
|
|
196
|
+
}
|
|
197
|
+
if (library) {
|
|
198
|
+
if (library === 'analytics.js') {
|
|
199
|
+
properties.platform = 'Web';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (time && dayjs_1.default.utc(time).isValid()) {
|
|
203
|
+
properties.time = dayjs_1.default.utc(time).valueOf();
|
|
204
|
+
}
|
|
205
|
+
if (session_id && dayjs_1.default.utc(session_id).isValid()) {
|
|
206
|
+
properties.session_id = dayjs_1.default.utc(session_id).valueOf();
|
|
207
|
+
}
|
|
208
|
+
if (min_id_length && min_id_length > 0) {
|
|
209
|
+
options = { min_id_length };
|
|
210
|
+
}
|
|
211
|
+
const setUserProperties = (name, obj) => {
|
|
212
|
+
if (compact_1.default(obj)) {
|
|
213
|
+
properties.user_properties = { ...properties.user_properties, [name]: obj };
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
setUserProperties('$setOnce', setOnce);
|
|
217
|
+
setUserProperties('$set', setAlways);
|
|
218
|
+
setUserProperties('$add', add);
|
|
219
|
+
const events = [
|
|
220
|
+
{
|
|
221
|
+
...(userAgentParsing && user_agent_1.parseUserAgentProperties(userAgent)),
|
|
222
|
+
...actions_core_1.removeUndefined(properties),
|
|
223
|
+
library: 'segment'
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
const endpoint = regional_endpoints_1.getEndpointByRegion(payload.use_batch_endpoint ? 'batch' : 'httpapi', settings.endpoint);
|
|
227
|
+
return request(endpoint, {
|
|
228
|
+
method: 'post',
|
|
229
|
+
json: {
|
|
230
|
+
api_key: settings.apiKey,
|
|
231
|
+
events,
|
|
232
|
+
options
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
exports.default = action;
|
|
238
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amplitude/logEventV2/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA+E;AAC/E,kDAAyB;AACzB,yDAAgC;AAChC,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,mBAAmB,EAAE,gBAAgB;IACrC,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,UAAU;oBACjB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,qEAAqE;iBACnF;gBACD,OAAO,EAAE;oBACP,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,mMAAmM;iBACtM;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE,YAAY;oBACnB,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,s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AAM,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"}
|
|
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const sendCustomBehavioralEvent_1 = __importDefault(require("./sendCustomBehavioralEvent"));
|
|
7
|
+
const upsertContact_1 = __importDefault(require("./upsertContact"));
|
|
6
8
|
const createCustomObjectRecord_1 = __importDefault(require("./createCustomObjectRecord"));
|
|
9
|
+
const properties_1 = require("./properties");
|
|
7
10
|
const destination = {
|
|
8
11
|
name: 'Hubspot Cloud Mode (Actions)',
|
|
9
12
|
slug: 'actions-hubspot-cloud',
|
|
@@ -12,10 +15,10 @@ const destination = {
|
|
|
12
15
|
scheme: 'oauth2',
|
|
13
16
|
fields: {},
|
|
14
17
|
testAuthentication: (request) => {
|
|
15
|
-
return request(
|
|
18
|
+
return request(`${properties_1.hubSpotBaseURL}/crm/v3/objects/contacts?limit=1`);
|
|
16
19
|
},
|
|
17
20
|
refreshAccessToken: async (request, { auth }) => {
|
|
18
|
-
const res = await request(
|
|
21
|
+
const res = await request(`${properties_1.hubSpotBaseURL}/oauth/v1/token`, {
|
|
19
22
|
method: 'POST',
|
|
20
23
|
body: new URLSearchParams({
|
|
21
24
|
refresh_token: auth.refreshToken,
|
|
@@ -35,6 +38,8 @@ const destination = {
|
|
|
35
38
|
};
|
|
36
39
|
},
|
|
37
40
|
actions: {
|
|
41
|
+
sendCustomBehavioralEvent: sendCustomBehavioralEvent_1.default,
|
|
42
|
+
upsertContact: upsertContact_1.default,
|
|
38
43
|
createCustomObjectRecord: createCustomObjectRecord_1.default
|
|
39
44
|
}
|
|
40
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/index.ts"],"names":[],"mappings":";;;;;AAGA,0FAAiE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/index.ts"],"names":[],"mappings":";;;;;AAGA,4FAAmE;AACnE,oEAA2C;AAC3C,0FAAiE;AACjE,6CAA6C;AAK7C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,EAAE;QACV,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAE9B,OAAO,OAAO,CAAC,GAAG,2BAAc,kCAAkC,CAAC,CAAA;QACrE,CAAC;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAE9C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,GAAG,2BAAc,iBAAiB,EAAE;gBAClF,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,eAAe,CAAC;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,UAAU,EAAE,eAAe;iBAC5B,CAAC;aACH,CAAC,CAAA;YAEF,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,CAAA;QAChD,CAAC;KACF;IACD,aAAa,CAAC,EAAE,IAAI,EAAE;QACpB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;aAC7C;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,yBAAyB,EAAzB,mCAAyB;QACzB,aAAa,EAAb,uBAAa;QACb,wBAAwB,EAAxB,kCAAwB;KACzB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hubSpotBaseURL = "https://api.hubapi.com";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/properties.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/sendCustomBehavioralEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const properties_1 = require("../properties");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Send Custom Behavioral Event',
|
|
6
|
+
description: 'Send a custom behavioral event to HubSpot.',
|
|
7
|
+
defaultSubscription: 'type = "track"',
|
|
8
|
+
fields: {
|
|
9
|
+
eventName: {
|
|
10
|
+
label: 'Event Name',
|
|
11
|
+
description: 'The internal event name assigned by HubSpot. This can be found in your HubSpot account. Events must be predefined in HubSpot. Learn how to find the internal name in [HubSpot’s documentation](https://knowledge.hubspot.com/analytics-tools/create-custom-behavioral-events).',
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
occurredAt: {
|
|
16
|
+
label: 'Event Timestamp',
|
|
17
|
+
description: "The time when this event occurred. If this isn't set, the current time will be used.",
|
|
18
|
+
type: 'datetime',
|
|
19
|
+
default: {
|
|
20
|
+
'@path': '$.timestamp'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
email: {
|
|
24
|
+
label: 'Email Address',
|
|
25
|
+
description: 'The email of the contact associated with this event. This is required if no user token or object ID is provided.',
|
|
26
|
+
type: 'string',
|
|
27
|
+
format: 'email',
|
|
28
|
+
default: {
|
|
29
|
+
'@if': {
|
|
30
|
+
exists: { '@path': '$.properties.email' },
|
|
31
|
+
then: { '@path': '$.properties.email' },
|
|
32
|
+
else: { '@path': '$.context.traits.email' }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
utk: {
|
|
37
|
+
label: 'User Token',
|
|
38
|
+
description: 'The user token (utk) of the contact associated with this event. This is required if no email or object ID is provided.',
|
|
39
|
+
type: 'string'
|
|
40
|
+
},
|
|
41
|
+
objectId: {
|
|
42
|
+
label: 'Object ID',
|
|
43
|
+
description: 'The ID of the object associated with this event. This can be the HubSpot contact ID, company ID, or ID of any other object. This is required if no email or user token is provided.',
|
|
44
|
+
type: 'string'
|
|
45
|
+
},
|
|
46
|
+
properties: {
|
|
47
|
+
label: 'Event Properties',
|
|
48
|
+
description: 'Default or custom properties that describe the event. See more information in [HubSpot’s documentation](https://knowledge.hubspot.com/analytics-tools/create-custom-behavioral-events#add-and-manage-event-properties).',
|
|
49
|
+
type: 'object',
|
|
50
|
+
defaultObjectUI: 'keyvalue:only'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
perform: (request, { payload }) => {
|
|
54
|
+
const event = {
|
|
55
|
+
eventName: payload.eventName,
|
|
56
|
+
occurredAt: payload.occurredAt,
|
|
57
|
+
utk: payload.utk,
|
|
58
|
+
email: payload.email,
|
|
59
|
+
objectId: payload.objectId,
|
|
60
|
+
properties: payload.properties
|
|
61
|
+
};
|
|
62
|
+
return request(`${properties_1.hubSpotBaseURL}/events/v3/send`, {
|
|
63
|
+
method: 'post',
|
|
64
|
+
json: event
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.default = action;
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/sendCustomBehavioralEvent/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AC9B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAA;QACD,OAAO,OAAO,CAAC,GAAG,2BAAc,iBAAiB,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,KAAK;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
email: string;
|
|
3
|
+
company?: string;
|
|
4
|
+
firstname?: string;
|
|
5
|
+
lastname?: string;
|
|
6
|
+
phone?: string;
|
|
7
|
+
address?: string;
|
|
8
|
+
city?: string;
|
|
9
|
+
state?: string;
|
|
10
|
+
country?: string;
|
|
11
|
+
zip?: string;
|
|
12
|
+
website?: string;
|
|
13
|
+
lifecyclestage?: string;
|
|
14
|
+
properties?: {
|
|
15
|
+
[k: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertContact/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const properties_1 = require("../properties");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Upsert Contact',
|
|
7
|
+
description: 'Create or update a contact in HubSpot.',
|
|
8
|
+
defaultSubscription: 'type = "identify"',
|
|
9
|
+
fields: {
|
|
10
|
+
email: {
|
|
11
|
+
label: 'Email',
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The contact’s email. Email is used to uniquely identify contact records in HubSpot. If an existing contact is found with this email, we will update the contact. If a contact is not found, we will create a new contact.',
|
|
14
|
+
required: true,
|
|
15
|
+
format: 'email',
|
|
16
|
+
default: {
|
|
17
|
+
'@path': '$.traits.email'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
company: {
|
|
21
|
+
label: 'Company Name',
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'The contact’s company.',
|
|
24
|
+
default: {
|
|
25
|
+
'@path': '$.traits.company'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
firstname: {
|
|
29
|
+
label: 'First Name',
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'The contact’s first name.',
|
|
32
|
+
default: {
|
|
33
|
+
'@if': {
|
|
34
|
+
exists: { '@path': '$.traits.first_name' },
|
|
35
|
+
then: { '@path': '$.traits.first_name' },
|
|
36
|
+
else: { '@path': '$.traits.firstName' }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
lastname: {
|
|
41
|
+
label: 'Last Name',
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'The contact’s last name.',
|
|
44
|
+
default: {
|
|
45
|
+
'@if': {
|
|
46
|
+
exists: { '@path': '$.traits.last_name' },
|
|
47
|
+
then: { '@path': '$.traits.last_name' },
|
|
48
|
+
else: { '@path': '$.traits.lastName' }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
phone: {
|
|
53
|
+
label: 'Phone',
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'The contact’s phone number.',
|
|
56
|
+
default: {
|
|
57
|
+
'@path': '$.traits.phone'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
address: {
|
|
61
|
+
label: 'Street Address',
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: "The contact's street address, including apartment or unit number.",
|
|
64
|
+
default: {
|
|
65
|
+
'@path': '$.traits.address.street'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
city: {
|
|
69
|
+
label: 'City',
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: "The contact's city of residence.",
|
|
72
|
+
default: {
|
|
73
|
+
'@path': '$.traits.address.city'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
state: {
|
|
77
|
+
label: 'State',
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: "The contact's state of residence.",
|
|
80
|
+
default: {
|
|
81
|
+
'@path': '$.traits.address.state'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
country: {
|
|
85
|
+
label: 'Country',
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: "The contact's country of residence.",
|
|
88
|
+
default: {
|
|
89
|
+
'@path': '$.traits.address.country'
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
zip: {
|
|
93
|
+
label: 'Postal Code',
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: "The contact's zip code.",
|
|
96
|
+
default: {
|
|
97
|
+
'@if': {
|
|
98
|
+
exists: { '@path': '$.traits.address.postalCode' },
|
|
99
|
+
then: { '@path': '$.traits.address.postalCode' },
|
|
100
|
+
else: { '@path': '$.traits.address.postal_code' }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
website: {
|
|
105
|
+
label: 'Website',
|
|
106
|
+
type: 'string',
|
|
107
|
+
description: 'The contact’s company/other website.',
|
|
108
|
+
default: {
|
|
109
|
+
'@path': '$.traits.website'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
lifecyclestage: {
|
|
113
|
+
label: 'Lifecycle Stage',
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'The contact’s stage within the marketing/sales process. See more information on default and custom stages in [HubSpot’s documentation](https://knowledge.hubspot.com/contacts/use-lifecycle-stages). Segment supports moving status forwards or backwards.'
|
|
116
|
+
},
|
|
117
|
+
properties: {
|
|
118
|
+
label: 'Other properties',
|
|
119
|
+
type: 'object',
|
|
120
|
+
description: 'Any other default or custom contact properties. Custom properties must be predefined in HubSpot. See more information in [HubSpot’s documentation](https://knowledge.hubspot.com/crm-setup/manage-your-properties#create-custom-properties).',
|
|
121
|
+
defaultObjectUI: 'keyvalue:only'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
perform: async (request, { payload, transactionContext }) => {
|
|
125
|
+
const contactProperties = {
|
|
126
|
+
company: payload.company,
|
|
127
|
+
firstname: payload.firstname,
|
|
128
|
+
lastname: payload.lastname,
|
|
129
|
+
phone: payload.phone,
|
|
130
|
+
address: payload.address,
|
|
131
|
+
city: payload.city,
|
|
132
|
+
state: payload.state,
|
|
133
|
+
country: payload.country,
|
|
134
|
+
zip: payload.zip,
|
|
135
|
+
email: payload.email,
|
|
136
|
+
lifecyclestage: payload.lifecyclestage?.toLowerCase(),
|
|
137
|
+
...payload.properties
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
const response = await updateContact(request, payload.email, contactProperties);
|
|
141
|
+
transactionContext?.setTransaction('contact_id', response.data.id);
|
|
142
|
+
if (payload.lifecyclestage) {
|
|
143
|
+
const currentLCS = response.data.properties['lifecyclestage'];
|
|
144
|
+
const hasLCSChanged = currentLCS === payload.lifecyclestage.toLowerCase();
|
|
145
|
+
if (hasLCSChanged)
|
|
146
|
+
return response;
|
|
147
|
+
await updateContact(request, payload.email, { lifecyclestage: '' });
|
|
148
|
+
return updateContact(request, payload.email, contactProperties);
|
|
149
|
+
}
|
|
150
|
+
return response;
|
|
151
|
+
}
|
|
152
|
+
catch (ex) {
|
|
153
|
+
if (ex instanceof actions_core_1.HTTPError && ex.response.status == 404) {
|
|
154
|
+
const result = await createContact(request, contactProperties);
|
|
155
|
+
transactionContext?.setTransaction('contact_id', result.data.id);
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
throw ex;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
async function createContact(request, contactProperties) {
|
|
163
|
+
return request(`${properties_1.hubSpotBaseURL}/crm/v3/objects/contacts`, {
|
|
164
|
+
method: 'POST',
|
|
165
|
+
json: {
|
|
166
|
+
properties: {
|
|
167
|
+
...contactProperties
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
async function updateContact(request, email, properties) {
|
|
173
|
+
return request(`${properties_1.hubSpotBaseURL}/crm/v3/objects/contacts/${email}?idProperty=email`, {
|
|
174
|
+
method: 'PATCH',
|
|
175
|
+
json: {
|
|
176
|
+
properties: {
|
|
177
|
+
...properties
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
exports.default = action;
|
|
183
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertContact/index.ts"],"names":[],"mappings":";;AAAA,wDAAiD;AAGjD,8CAA8C;AAQ9C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,wCAAwC;IACrD,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,2NAA2N;YAC7N,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,OAAO,EAAE;YACP,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE;gBACP,OAAO,EAAE,kBAAkB;aAC5B;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2BAA2B;YACxC,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;oBAC1C,IAAI,EAAE,EAAE,OAAO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B,GAAG,2BAAc,4BAA4B,KAAK,mBAAmB,EAAE;QACrG,MAAM,EAAE,OAAO;QACf,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,GAAG,UAAU;aACd;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -21,14 +21,39 @@ const destination = {
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
testAuthentication: async (request, { settings, auth }) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if (!auth?.accessToken) {
|
|
25
|
+
throw new Error('Please authenticate via Oauth before updating other settings and/or enabling the destination.');
|
|
26
|
+
}
|
|
27
|
+
let firstRes;
|
|
28
|
+
try {
|
|
29
|
+
firstRes = await request(`https://api.linkedin.com/rest/me`, {
|
|
30
|
+
method: 'GET'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e.message === 'Unauthorized') {
|
|
35
|
+
throw new Error('Invalid LinkedIn Oauth access token. Please reauthenticate to retrieve a valid access token before updating other settings and/or enabling the destination.');
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
const userId = firstRes?.data?.id;
|
|
40
|
+
let secondRes;
|
|
41
|
+
try {
|
|
42
|
+
secondRes = await request(`https://api.linkedin.com/rest/adAccountUsers/account=urn:li:sponsoredAccount:${settings.ad_account_id}&user=urn:li:person:${userId}`, {
|
|
43
|
+
method: 'GET'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (e.message === 'Not Found') {
|
|
48
|
+
throw new Error('Invalid LinkedIn Ad Account id. Please verify that the LinkedIn Ad Account exists and that you have access to it.');
|
|
49
|
+
}
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
const userRole = secondRes?.data.role;
|
|
53
|
+
if (userRole === 'VIEWER') {
|
|
54
|
+
throw new Error("It looks like you don't have access to this LinkedIn Ad Account. Please reach out to a LinkedIn Ad Account Admin on your team to grant access.");
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
32
57
|
},
|
|
33
58
|
refreshAccessToken: async (request, { auth }) => {
|
|
34
59
|
const res = await request('https://www.linkedin.com/oauth/v2/accessToken', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/index.ts"],"names":[],"mappings":";;;;;AAEA,sEAA6C;AAC7C,+DAA4D;AAC5D,kDAAyB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/index.ts"],"names":[],"mappings":";;;;;AAEA,sEAA6C;AAC7C,+DAA4D;AAC5D,kDAAyB;AAiBzB,MAAM,WAAW,GAAoC;IAGnD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,aAAa,EAAE;gBACb,KAAK,EAAE,wBAAwB;gBAC/B,WAAW,EAAE,mEAAmE;gBAChF,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;YACxD,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAA;aACjH;YAED,IAAI,QAAQ,CAAA;YAEZ,IAAI;gBAGF,QAAQ,GAAG,MAAM,OAAO,CAAqB,kCAAkC,EAAE;oBAC/E,MAAM,EAAE,KAAK;iBACd,CAAC,CAAA;aACH;YAAC,OAAO,CAAM,EAAE;gBACf,IAAI,CAAC,CAAC,OAAO,KAAK,cAAc,EAAE;oBAChC,MA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E,CAAC,CAAA;QAElD,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;gBAC5C,kBAAkB,EAAE,0CAAoB;aACzC;YACD,KAAK;SACN,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
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.110.0",
|
|
4
|
+
"version": "3.110.1-alpha.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"lcov"
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "99180bf70823d5a4b742aad7305711ab9afdfe98"
|
|
69
69
|
}
|