@pipedream/google_ads 0.1.0 → 0.2.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.
@@ -1,14 +1,16 @@
1
1
  import crypto from "crypto";
2
2
  import googleAds from "../../google_ads.app.mjs";
3
+ import common from "../common/common.mjs";
3
4
 
4
5
  export default {
6
+ ...common,
5
7
  key: "google_ads-add-contact-to-list-by-email",
6
8
  name: "Add Contact to Customer List by Email",
7
9
  description: "Adds a contact to a specific customer list in Google Ads. Lists typically update in 6 to 12 hours after operation. [See the documentation](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/customer-match/get-started)",
8
- version: "0.0.1",
10
+ version: "0.1.0",
9
11
  type: "action",
10
12
  props: {
11
- googleAds,
13
+ ...common.props,
12
14
  contactEmail: {
13
15
  propDefinition: [
14
16
  googleAds,
@@ -19,23 +21,37 @@ export default {
19
21
  propDefinition: [
20
22
  googleAds,
21
23
  "userListId",
24
+ ({
25
+ accountId, customerClientId,
26
+ }) => ({
27
+ accountId,
28
+ customerClientId,
29
+ }),
22
30
  ],
23
31
  },
24
32
  },
25
33
  async run({ $ }) {
26
- const offlineUserDataJob = await this.googleAds.createOfflineUserDataJob({
34
+ const {
35
+ googleAds, accountId, customerClientId, contactEmail, userListId,
36
+ } = this;
37
+ const offlineUserDataJob = await googleAds.createOfflineUserDataJob({
38
+ $,
39
+ accountId,
40
+ customerClientId,
27
41
  data: {
28
42
  job: {
29
43
  customerMatchUserListMetadata: {
30
- userList: `customers/${this.googleAds.$auth.login_customer_id}/userLists/${this.userListId}`,
44
+ userList: `customers/${customerClientId ?? accountId}/userLists/${userListId}`,
31
45
  },
32
46
  type: "CUSTOMER_MATCH_USER_LIST",
33
47
  },
34
48
  },
35
49
  });
36
50
 
37
- await this.googleAds.addContactToCustomerList({
51
+ await googleAds.addContactToCustomerList({
38
52
  $,
53
+ accountId,
54
+ customerClientId,
39
55
  path: offlineUserDataJob.resourceName,
40
56
  data: {
41
57
  operations: [
@@ -43,7 +59,7 @@ export default {
43
59
  create: {
44
60
  userIdentifiers: [
45
61
  {
46
- hashedEmail: crypto.createHash("sha256").update(this.contactEmail)
62
+ hashedEmail: crypto.createHash("sha256").update(contactEmail)
47
63
  .digest("hex"),
48
64
  },
49
65
  ],
@@ -53,12 +69,14 @@ export default {
53
69
  },
54
70
  });
55
71
 
56
- const response = await this.googleAds.runOfflineUserDataJob({
72
+ const response = await googleAds.runOfflineUserDataJob({
57
73
  $,
74
+ accountId,
75
+ customerClientId,
58
76
  path: offlineUserDataJob.resourceName,
59
77
  });
60
78
 
61
- $.export("$summary", `Added contact ${this.contactEmail} to the user list ${this.userListId}`);
79
+ $.export("$summary", `Added contact ${contactEmail} to user list ${userListId}`);
62
80
  return response;
63
81
  },
64
82
  };
@@ -0,0 +1,5 @@
1
+ import props from "../../common/props.mjs";
2
+
3
+ export default {
4
+ props,
5
+ };
@@ -0,0 +1,15 @@
1
+ const DEFAULT_DOCS =
2
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList";
3
+
4
+ export const getAdditionalFields = (docsLink = DEFAULT_DOCS) => ({
5
+ type: "object",
6
+ label: "Additional Fields",
7
+ description: `Additional fields and values to be created. [See the documentation](${docsLink}) for available fields. Values will be parsed as JSON where applicable.`,
8
+ optional: true,
9
+ });
10
+
11
+ export const getListTypeInfo = (docsLink = DEFAULT_DOCS) => ({
12
+ type: "alert",
13
+ alertType: "info",
14
+ content: `[See the documentation](${docsLink}) for more information on this type of customer list.`,
15
+ });
@@ -0,0 +1,234 @@
1
+ import countryCodeOptions from "./common-country-code-options.mjs";
2
+
3
+ export const USER_LIST_TYPES = {
4
+ CRM_BASED: "crmBasedUserList",
5
+ RULE_BASED: "ruleBasedUserList",
6
+ LOGICAL: "logicalUserList",
7
+ BASIC: "basicUserList",
8
+ LOOKALIKE: "lookalikeUserList",
9
+ };
10
+
11
+ const USER_LIST_CRM_BASED_PROPS = {
12
+ uploadKeyType: {
13
+ type: "string",
14
+ label: "Upload Key Type",
15
+ description:
16
+ "Matching key type of the list. Mixed data types are not allowed on the same list.",
17
+ options: [
18
+ {
19
+ label:
20
+ "Members are matched from customer info such as email address, phone number or physical address.",
21
+ value: "CONTACT_INFO",
22
+ },
23
+ {
24
+ label:
25
+ "Members are matched from a user id generated and assigned by the advertiser.",
26
+ value: "CRM_ID",
27
+ },
28
+ {
29
+ label: "Members are matched from mobile advertising IDs.",
30
+ value: "MOBILE_ADVERTISING_ID",
31
+ },
32
+ ],
33
+ },
34
+ dataSourceType: {
35
+ type: "string",
36
+ label: "Data Source Type",
37
+ description:
38
+ "Data source of the list. Only customers on the allow-list can create third-party sourced CRM lists.",
39
+ optional: true,
40
+ default: "FIRST_PARTY",
41
+ options: [
42
+ {
43
+ label: "The uploaded data is first-party data.",
44
+ value: "FIRST_PARTY",
45
+ },
46
+ {
47
+ label: "The uploaded data is from a third-party credit bureau,",
48
+ value: "THIRD_PARTY_CREDIT_BUREAU",
49
+ },
50
+ {
51
+ label: "The uploaded data is from a third-party voter file.",
52
+ value: "THIRD_PARTY_VOTER_FILE",
53
+ },
54
+ ],
55
+ },
56
+ appId: {
57
+ type: "string",
58
+ label: "App ID",
59
+ description:
60
+ "A string that uniquely identifies a mobile application from which the data was collected. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#CrmBasedUserListInfo) for more details.",
61
+ optional: true,
62
+ },
63
+ };
64
+
65
+ const USER_LIST_RULE_BASED_PROPS = {
66
+ prepopulationStatus: {
67
+ type: "boolean",
68
+ label: "Request Prepopulation",
69
+ description:
70
+ "If true, past site visitors or app users who match the list definition will be included in the list. This will only add past users from within the last 30 days, depending on the list's membership duration and the date when the remarketing tag is added.",
71
+ optional: true,
72
+ },
73
+ flexibleRuleUserList: {
74
+ type: "object",
75
+ label: "Flexible Rule Customer List",
76
+ description:
77
+ "Flexible rule representation of visitors with one or multiple actions. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#FlexibleRuleUserListInfo) on how to build this object. Values will be parsed as JSON where applicable.",
78
+ optional: true,
79
+ },
80
+ };
81
+
82
+ const USER_LIST_LOGICAL_PROPS = {
83
+ rules: {
84
+ type: "string[]",
85
+ label: "Rules",
86
+ description:
87
+ "Logical list rules that define this customer list. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#UserListLogicalRuleInfo) on how to build each object. Values will be parsed as JSON where applicable.",
88
+ },
89
+ };
90
+
91
+ const USER_LIST_BASIC_PROPS = {
92
+ conversionActions: {
93
+ type: "string[]",
94
+ label: "Conversion action(s)",
95
+ description: "One or more [conversion actions](https://developers.google.com/google-ads/api/rest/reference/rest/v16/ConversionAction) to build the list with.",
96
+ optional: true,
97
+ options: async() => {
98
+ const {
99
+ accountId, customerClientId,
100
+ } = this;
101
+ const response = await this.googleAds.listConversionActions({
102
+ accountId,
103
+ customerClientId,
104
+ });
105
+ return response?.map(({
106
+ conversionAction: {
107
+ resourceName, name,
108
+ },
109
+ }) => ({
110
+ label: name,
111
+ value: resourceName,
112
+ }));
113
+ },
114
+ },
115
+ remarketingActions: {
116
+ type: "string[]",
117
+ label: "Remarketing action(s)",
118
+ description: "One or more [remarketing actions](https://developers.google.com/google-ads/api/rest/reference/rest/v16/RemarketingAction).",
119
+ optional: true,
120
+ options: async() => {
121
+ const {
122
+ accountId, customerClientId,
123
+ } = this;
124
+ const response = await this.googleAds.listRemarketingActions({
125
+ accountId,
126
+ customerClientId,
127
+ });
128
+ return response?.map(({
129
+ remarketingAction: {
130
+ resourceName, name,
131
+ },
132
+ }) => ({
133
+ label: name,
134
+ value: resourceName,
135
+ }));
136
+ },
137
+ },
138
+ };
139
+
140
+ const USER_LIST_LOOKALIKE_PROPS = {
141
+ seedUserListIds: {
142
+ type: "string[]",
143
+ label: "Seed User List(s)",
144
+ description: "One or more customer lists from which this list is derived.",
145
+ options: async() => {
146
+ const {
147
+ accountId, customerClientId,
148
+ } = this;
149
+ const response = await this.googleAds.listUserLists({
150
+ accountId,
151
+ customerClientId,
152
+ });
153
+ return response?.map(({
154
+ userList: {
155
+ id, name,
156
+ },
157
+ }) => ({
158
+ label: name,
159
+ value: id,
160
+ }));
161
+ },
162
+ },
163
+ expansionLevel: {
164
+ type: "string",
165
+ label: "Expansion Level",
166
+ description:
167
+ "Expansion level, reflecting the size of the lookalike audience",
168
+ optional: true,
169
+ options: [
170
+ {
171
+ label:
172
+ "Expansion to a small set of users that are similar to the seed lists",
173
+ value: "NARROW",
174
+ },
175
+ {
176
+ label:
177
+ "Expansion to a medium set of users that are similar to the seed lists. Includes all users of NARROW, and more.",
178
+ value: "BALANCED",
179
+ },
180
+ {
181
+ label:
182
+ "Expansion to a large set of users that are similar to the seed lists. Includes all users of BALANCED, and more.",
183
+ value: "BROAD",
184
+ },
185
+ ],
186
+ },
187
+ countryCodes: {
188
+ type: "string[]",
189
+ label: "Country Codes",
190
+ description: "Countries targeted by the Lookalike.",
191
+ optional: true,
192
+ options: countryCodeOptions,
193
+ },
194
+ };
195
+
196
+ export const USER_LIST_TYPE_OPTIONS = [
197
+ {
198
+ label: "CRM-based - a list of provided customers",
199
+ value: USER_LIST_TYPES.CRM_BASED,
200
+ docsLink:
201
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#CrmBasedUserListInfo",
202
+ props: USER_LIST_CRM_BASED_PROPS,
203
+ },
204
+ {
205
+ label: "Rule-Based - a customer list generated by a rule",
206
+ value: USER_LIST_TYPES.RULE_BASED,
207
+ docsLink:
208
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#RuleBasedUserListInfo",
209
+ props: USER_LIST_RULE_BASED_PROPS,
210
+ },
211
+ {
212
+ label: "Logical - a custom combination of customer lists",
213
+ value: USER_LIST_TYPES.LOGICAL,
214
+ docsLink:
215
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#LogicalUserListInfo",
216
+ props: USER_LIST_LOGICAL_PROPS,
217
+ },
218
+ {
219
+ label:
220
+ "Basic - a customer list targeting as a collection of conversions or remarketing actions",
221
+ value: USER_LIST_TYPES.BASIC,
222
+ docsLink:
223
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#BasicUserListInfo",
224
+ props: USER_LIST_BASIC_PROPS,
225
+ },
226
+ {
227
+ label:
228
+ "Lookalike - a list composed of customers similar to those of a configurable seed",
229
+ value: USER_LIST_TYPES.LOOKALIKE,
230
+ docsLink:
231
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#LookalikeUserListInfo",
232
+ props: USER_LIST_LOOKALIKE_PROPS,
233
+ },
234
+ ];