@segment/action-destinations 3.65.1-alpha.2 → 3.65.1-alpha.3

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 (28) hide show
  1. package/dist/destinations/amplitude/index.js +2 -10
  2. package/dist/destinations/amplitude/index.js.map +1 -1
  3. package/dist/destinations/amplitude/logEvent/generated-types.d.ts +8 -0
  4. package/dist/destinations/amplitude/logEvent/index.d.ts +0 -3
  5. package/dist/destinations/amplitude/logEvent/index.js +171 -113
  6. package/dist/destinations/amplitude/logEvent/index.js.map +1 -1
  7. package/dist/destinations/index.js +1 -0
  8. package/dist/destinations/index.js.map +1 -1
  9. package/dist/destinations/snap-conversions-api/generated-types.d.ts +5 -0
  10. package/dist/destinations/{amplitude/logPurchase → snap-conversions-api}/generated-types.js +0 -0
  11. package/dist/destinations/snap-conversions-api/generated-types.js.map +1 -0
  12. package/dist/destinations/snap-conversions-api/index.d.ts +4 -0
  13. package/dist/destinations/snap-conversions-api/index.js +177 -0
  14. package/dist/destinations/snap-conversions-api/index.js.map +1 -0
  15. package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.d.ts +25 -0
  16. package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.js +3 -0
  17. package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.js.map +1 -0
  18. package/dist/destinations/{amplitude/logPurchase → snap-conversions-api/reportConversionEvent}/index.d.ts +0 -0
  19. package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js +51 -0
  20. package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js.map +1 -0
  21. package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +27 -0
  22. package/dist/destinations/snap-conversions-api/snap-capi-properties.js +227 -0
  23. package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +1 -0
  24. package/package.json +2 -2
  25. package/dist/destinations/amplitude/logPurchase/generated-types.d.ts +0 -64
  26. package/dist/destinations/amplitude/logPurchase/generated-types.js.map +0 -1
  27. package/dist/destinations/amplitude/logPurchase/index.js +0 -95
  28. package/dist/destinations/amplitude/logPurchase/index.js.map +0 -1
@@ -6,23 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const actions_core_1 = require("@segment/actions-core");
7
7
  const identifyUser_1 = __importDefault(require("./identifyUser"));
8
8
  const logEvent_1 = __importDefault(require("./logEvent"));
9
- const logPurchase_1 = __importDefault(require("./logPurchase"));
10
9
  const mapUser_1 = __importDefault(require("./mapUser"));
11
10
  const groupIdentifyUser_1 = __importDefault(require("./groupIdentifyUser"));
12
11
  const regional_endpoints_1 = require("./regional-endpoints");
13
12
  const presets = [
14
13
  {
15
14
  name: 'Track Calls',
16
- subscribe: 'type = "track" and event != "Order Completed"',
15
+ subscribe: 'type = "track"',
17
16
  partnerAction: 'logEvent',
18
17
  mapping: actions_core_1.defaultValues(logEvent_1.default.fields)
19
18
  },
20
- {
21
- name: 'Order Completed Calls',
22
- subscribe: 'type = "track" and event = "Order Completed"',
23
- partnerAction: 'logPurchase',
24
- mapping: actions_core_1.defaultValues(logPurchase_1.default.fields)
25
- },
26
19
  {
27
20
  name: 'Page Calls',
28
21
  subscribe: 'type = "page"',
@@ -118,8 +111,7 @@ const destination = {
118
111
  logEvent: logEvent_1.default,
119
112
  identifyUser: identifyUser_1.default,
120
113
  mapUser: mapUser_1.default,
121
- groupIdentifyUser: groupIdentifyUser_1.default,
122
- logPurchase: logPurchase_1.default
114
+ groupIdentifyUser: groupIdentifyUser_1.default
123
115
  }
124
116
  };
125
117
  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,gEAAuC;AACvC,wDAA+B;AAC/B,4EAAmD;AAEnD,6DAA0D;AAG1D,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,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iB,EAAjB,2BAAiB;QACjB,WAAW,EAAX,qBAAW;KACZ;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
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;AAEnD,6DAA0D;AAG1D,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,UAAU;QACzB,OAAO,EAAE,4BAAa,CAAC,kBAAQ,CAAC,MAAM,CAAC;KACxC;IACD;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE,eAAe;QAC1B,aAAa,EAAE,UAAU;QACzB,OAAO,EAAE;YACP,GAAG,4BAAa,CAAC,kBAAQ,CAAC,MAAM,CAAC;YACjC,UAAU,EAAE;gBACV,WAAW,EAAE,iBAAiB;aAC/B;SACF;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,iBAAiB;QAC5B,aAAa,EAAE,UAAU;QACzB,OAAO,EAAE;YACP,GAAG,4BAAa,CAAC,kBAAQ,CAAC,MAAM,CAAC;YACjC,UAAU,EAAE;gBACV,WAAW,EAAE,iBAAiB;aAC/B;SACF;KACF;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,mBAAmB;QAC9B,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,4BAAa,CAAC,sBAAY,CAAC,MAAM,CAAC;KAC5C;IACD;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,0FAA0F;QACrG,aAAa,EAAE,WAAW;QAC1B,OAAO,EAAE,EAAE;KACZ;CACF,CAAA;AAED,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB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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;KAClB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export interface Payload {
2
+ trackRevenuePerProduct?: boolean;
2
3
  user_id?: string | null;
3
4
  device_id?: string;
4
5
  event_type: string;
@@ -41,6 +42,13 @@ export interface Payload {
41
42
  event_id?: number;
42
43
  insert_id?: string;
43
44
  library?: string;
45
+ products?: {
46
+ price?: number;
47
+ quantity?: number;
48
+ revenue?: number;
49
+ productId?: string;
50
+ revenueType?: string;
51
+ }[];
44
52
  use_batch_endpoint?: boolean;
45
53
  userAgent?: string;
46
54
  userAgentParsing?: boolean;
@@ -1,7 +1,6 @@
1
1
  import type { ActionDefinition } from '@segment/actions-core';
2
2
  import type { Settings } from '../generated-types';
3
3
  import type { Payload } from './generated-types';
4
- import { InputField } from '@segment/actions-core';
5
4
  export interface AmplitudeEvent extends Omit<Payload, 'products' | 'trackRevenuePerProduct' | 'time' | 'session_id'> {
6
5
  library?: string;
7
6
  time?: number;
@@ -10,7 +9,5 @@ export interface AmplitudeEvent extends Omit<Payload, 'products' | 'trackRevenue
10
9
  min_id_length: number;
11
10
  };
12
11
  }
13
- export declare function doPerform(request: Function, payload: Payload, settings: Settings, eventFunction: Function): any;
14
- export declare const fields: Record<string, InputField>;
15
12
  declare const action: ActionDefinition<Settings, Payload>;
16
13
  export default action;
@@ -3,7 +3,6 @@ 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
- exports.fields = exports.doPerform = void 0;
7
6
  const actions_core_1 = require("@segment/actions-core");
8
7
  const dayjs_1 = __importDefault(require("../../../lib/dayjs"));
9
8
  const event_schema_1 = require("../event-schema");
@@ -12,128 +11,187 @@ const referrer_1 = require("../referrer");
12
11
  const merge_user_properties_1 = require("../merge-user-properties");
13
12
  const user_agent_1 = require("../user-agent");
14
13
  const regional_endpoints_1 = require("../regional-endpoints");
15
- function getEvents(payload, properties) {
16
- const events = [
17
- {
18
- ...(payload.userAgentParsing && user_agent_1.parseUserAgentProperties(payload.userAgent)),
19
- ...actions_core_1.removeUndefined(properties),
20
- library: 'segment'
21
- }
22
- ];
23
- return events;
24
- }
25
- function doPerform(request, payload, settings, eventFunction) {
26
- const { time, session_id, userAgent, userAgentParsing, utm_properties, referrer, min_id_length, library, ...rest } = payload;
27
- const properties = rest;
28
- let options;
29
- if (properties.platform) {
30
- properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android');
31
- }
32
- if (library) {
33
- if (library === 'analytics.js')
34
- properties.platform = 'Web';
35
- }
36
- if (time && dayjs_1.default.utc(time).isValid()) {
37
- properties.time = dayjs_1.default.utc(time).valueOf();
38
- }
39
- if (session_id && dayjs_1.default.utc(session_id).isValid()) {
40
- properties.session_id = dayjs_1.default.utc(session_id).valueOf();
14
+ const revenueKeys = ['revenue', 'price', 'productId', 'quantity', 'revenueType'];
15
+ function getRevenueProperties(payload) {
16
+ if (typeof payload.revenue !== 'number') {
17
+ return {};
41
18
  }
42
- if (Object.keys(payload.utm_properties ?? {}).length || payload.referrer) {
43
- properties.user_properties = merge_user_properties_1.mergeUserProperties(utm_1.convertUTMProperties({ utm_properties }), referrer_1.convertReferrerProperty({ referrer }), actions_core_1.omit(properties.user_properties ?? {}, ['utm_properties', 'referrer']));
44
- }
45
- if (min_id_length && min_id_length > 0) {
46
- options = { min_id_length };
47
- }
48
- const events = eventFunction(payload, properties);
49
- const endpoint = regional_endpoints_1.getEndpointByRegion(payload.use_batch_endpoint ? 'batch' : 'httpapi', settings.endpoint);
50
- return request(endpoint, {
51
- method: 'post',
52
- json: {
53
- api_key: settings.apiKey,
54
- events,
55
- options
56
- }
57
- });
19
+ return {
20
+ revenue: payload.revenue,
21
+ revenueType: payload.revenueType ?? 'Purchase',
22
+ quantity: typeof payload.quantity === 'number' ? Math.round(payload.quantity) : undefined,
23
+ price: payload.price,
24
+ productId: payload.productId
25
+ };
58
26
  }
59
- exports.doPerform = doPerform;
60
- exports.fields = {
61
- ...event_schema_1.eventSchema,
62
- use_batch_endpoint: {
63
- label: 'Use Batch Endpoint',
64
- 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).",
65
- type: 'boolean',
66
- default: false
67
- },
68
- userAgent: {
69
- label: 'User Agent',
70
- type: 'string',
71
- description: 'The user agent of the device sending the event.',
72
- default: {
73
- '@path': '$.context.userAgent'
74
- }
75
- },
76
- userAgentParsing: {
77
- label: 'User Agent Parsing',
78
- type: 'boolean',
79
- 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',
80
- default: true
81
- },
82
- utm_properties: {
83
- label: 'UTM Properties',
84
- type: 'object',
85
- description: 'UTM Tracking Properties',
86
- properties: {
87
- utm_source: {
88
- label: 'UTM Source',
89
- type: 'string'
90
- },
91
- utm_medium: {
92
- label: 'UTM Medium',
93
- type: 'string'
94
- },
95
- utm_campaign: {
96
- label: 'UTM Campaign',
97
- type: 'string'
27
+ const action = {
28
+ title: 'Log Event',
29
+ description: 'Send an event to Amplitude.',
30
+ defaultSubscription: 'type = "track"',
31
+ fields: {
32
+ trackRevenuePerProduct: {
33
+ label: 'Track Revenue Per Product',
34
+ description: 'When enabled, track revenue with each product within the event. When disabled, track total revenue once for the event.',
35
+ type: 'boolean',
36
+ default: false
37
+ },
38
+ ...event_schema_1.eventSchema,
39
+ products: {
40
+ label: 'Products',
41
+ description: 'The list of products purchased.',
42
+ type: 'object',
43
+ multiple: true,
44
+ properties: {
45
+ price: {
46
+ label: 'Price',
47
+ type: 'number',
48
+ 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.'
49
+ },
50
+ quantity: {
51
+ label: 'Quantity',
52
+ type: 'integer',
53
+ description: 'The quantity of the item purchased. Defaults to 1 if not specified.'
54
+ },
55
+ revenue: {
56
+ label: 'Revenue',
57
+ type: 'number',
58
+ 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.'
59
+ },
60
+ productId: {
61
+ label: 'Product ID',
62
+ type: 'string',
63
+ description: 'An identifier for the item purchased. You must send a price and quantity or revenue with this field.'
64
+ },
65
+ revenueType: {
66
+ label: 'Revenue Type',
67
+ type: 'string',
68
+ description: 'The type of revenue for the item purchased. You must send a price and quantity or revenue with this field.'
69
+ }
98
70
  },
99
- utm_term: {
100
- label: 'UTM Term',
101
- type: 'string'
71
+ default: {
72
+ '@path': '$.properties.products'
73
+ }
74
+ },
75
+ use_batch_endpoint: {
76
+ label: 'Use Batch Endpoint',
77
+ 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).",
78
+ type: 'boolean',
79
+ default: false
80
+ },
81
+ userAgent: {
82
+ label: 'User Agent',
83
+ type: 'string',
84
+ description: 'The user agent of the device sending the event.',
85
+ default: {
86
+ '@path': '$.context.userAgent'
87
+ }
88
+ },
89
+ userAgentParsing: {
90
+ label: 'User Agent Parsing',
91
+ type: 'boolean',
92
+ 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',
93
+ default: true
94
+ },
95
+ utm_properties: {
96
+ label: 'UTM Properties',
97
+ type: 'object',
98
+ description: 'UTM Tracking Properties',
99
+ properties: {
100
+ utm_source: {
101
+ label: 'UTM Source',
102
+ type: 'string'
103
+ },
104
+ utm_medium: {
105
+ label: 'UTM Medium',
106
+ type: 'string'
107
+ },
108
+ utm_campaign: {
109
+ label: 'UTM Campaign',
110
+ type: 'string'
111
+ },
112
+ utm_term: {
113
+ label: 'UTM Term',
114
+ type: 'string'
115
+ },
116
+ utm_content: {
117
+ label: 'UTM Content',
118
+ type: 'string'
119
+ }
102
120
  },
103
- utm_content: {
104
- label: 'UTM Content',
105
- type: 'string'
121
+ default: {
122
+ utm_source: { '@path': '$.context.campaign.source' },
123
+ utm_medium: { '@path': '$.context.campaign.medium' },
124
+ utm_campaign: { '@path': '$.context.campaign.name' },
125
+ utm_term: { '@path': '$.context.campaign.term' },
126
+ utm_content: { '@path': '$.context.campaign.content' }
127
+ }
128
+ },
129
+ referrer: {
130
+ label: 'Referrer',
131
+ type: 'string',
132
+ description: 'The referrer of the web request. Sent to Amplitude as both last touch “referrer” and first touch “initial_referrer”',
133
+ default: {
134
+ '@path': '$.context.page.referrer'
106
135
  }
107
136
  },
108
- default: {
109
- utm_source: { '@path': '$.context.campaign.source' },
110
- utm_medium: { '@path': '$.context.campaign.medium' },
111
- utm_campaign: { '@path': '$.context.campaign.name' },
112
- utm_term: { '@path': '$.context.campaign.term' },
113
- utm_content: { '@path': '$.context.campaign.content' }
137
+ min_id_length: {
138
+ label: 'Minimum ID Length',
139
+ description: 'Amplitude has a default minimum id lenght of 5 characters for user_id and device_id fields. This field allows the minimum to be overridden to allow shorter id lengths.',
140
+ allowNull: true,
141
+ type: 'integer'
114
142
  }
115
143
  },
116
- referrer: {
117
- label: 'Referrer',
118
- type: 'string',
119
- description: 'The referrer of the web request. Sent to Amplitude as both last touch “referrer” and first touch “initial_referrer”',
120
- default: {
121
- '@path': '$.context.page.referrer'
144
+ perform: (request, { payload, settings }) => {
145
+ const { products = [], trackRevenuePerProduct, time, session_id, userAgent, userAgentParsing, utm_properties, referrer, min_id_length, library, ...rest } = actions_core_1.omit(payload, revenueKeys);
146
+ const properties = rest;
147
+ let options;
148
+ if (properties.platform) {
149
+ properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android');
122
150
  }
123
- },
124
- min_id_length: {
125
- label: 'Minimum ID Length',
126
- description: 'Amplitude has a default minimum id lenght of 5 characters for user_id and device_id fields. This field allows the minimum to be overridden to allow shorter id lengths.',
127
- allowNull: true,
128
- type: 'integer'
151
+ if (library) {
152
+ if (library === 'analytics.js')
153
+ properties.platform = 'Web';
154
+ }
155
+ if (time && dayjs_1.default.utc(time).isValid()) {
156
+ properties.time = dayjs_1.default.utc(time).valueOf();
157
+ }
158
+ if (session_id && dayjs_1.default.utc(session_id).isValid()) {
159
+ properties.session_id = dayjs_1.default.utc(session_id).valueOf();
160
+ }
161
+ if (Object.keys(payload.utm_properties ?? {}).length || payload.referrer) {
162
+ properties.user_properties = merge_user_properties_1.mergeUserProperties(utm_1.convertUTMProperties({ utm_properties }), referrer_1.convertReferrerProperty({ referrer }), actions_core_1.omit(properties.user_properties ?? {}, ['utm_properties', 'referrer']));
163
+ }
164
+ if (min_id_length && min_id_length > 0) {
165
+ options = { min_id_length };
166
+ }
167
+ const events = [
168
+ {
169
+ ...(userAgentParsing && user_agent_1.parseUserAgentProperties(userAgent)),
170
+ ...actions_core_1.removeUndefined(properties),
171
+ ...(products.length && trackRevenuePerProduct ? {} : getRevenueProperties(payload)),
172
+ library: 'segment'
173
+ }
174
+ ];
175
+ for (const product of products) {
176
+ events.push({
177
+ ...properties,
178
+ ...(trackRevenuePerProduct ? getRevenueProperties(product) : {}),
179
+ event_properties: product,
180
+ event_type: 'Product Purchased',
181
+ insert_id: properties.insert_id ? `${properties.insert_id}-${events.length + 1}` : undefined,
182
+ library: 'segment'
183
+ });
184
+ }
185
+ const endpoint = regional_endpoints_1.getEndpointByRegion(payload.use_batch_endpoint ? 'batch' : 'httpapi', settings.endpoint);
186
+ return request(endpoint, {
187
+ method: 'post',
188
+ json: {
189
+ api_key: settings.apiKey,
190
+ events,
191
+ options
192
+ }
193
+ });
129
194
  }
130
195
  };
131
- const action = {
132
- title: 'Log Event',
133
- description: 'Send an event to Amplitude.',
134
- defaultSubscription: 'type = "track" and event != "Order Completed"',
135
- fields: exports.fields,
136
- perform: (request, { payload, settings }) => doPerform(request, payload, settings, getEvents)
137
- };
138
196
  exports.default = action;
139
197
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amplitude/logEvent/index.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA6D;AAC7D,+DAAsC;AACtC,kDAA6C;AAI7C,gCAA6C;AAC7C,0CAAqD;AACrD,oEAA8D;AAC9D,8CAAwD;AACxD,8DAA2D;AAW3D,SAAS,SAAS,CAAC,OAAgB,EAAE,UAA0B;IAC7D,MAAM,MAAM,GAAqB;QAC/B;YAEE,GAAG,CAAC,OAAO,CAAC,gBAAgB,IAAI,qCAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAE5E,GAAG,8BAAe,CAAC,UAAU,CAAC;YAC9B,OAAO,EAAE,SAAS;SACnB;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAgB,SAAS,CAAC,OAAiB,EAAE,OAAgB,EAAE,QAAkB,EAAE,aAAuB;IACxG,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAChH,OAAO,CAAA;IACT,MAAM,UAAU,GAAG,IAAsB,CAAA;IACzC,IAAI,OAAO,CAAA;IAEX,IAAI,UAAU,CAAC,QAAQ,EAAE;QACvB,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;KAChG;IAED,IAAI,OAAO,EAAE;Q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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"}
@@ -50,6 +50,7 @@ register('6116a41e2e8fc680d8daf821', './personas-messaging-twilio');
50
50
  register('5f7dd8191ad74f868ab1fc48', './pipedrive');
51
51
  register('61957755c4d820be968457de', './salesforce');
52
52
  register('5f7dd8e302173ff732db5cc4', './slack');
53
+ register('6261a8b6cb4caa70e19116e8', './snap-conversions-api');
53
54
  register('6234b137d3b6404a64f2a0f0', './talon-one');
54
55
  register('615cae349d109d6b7496a131', './tiktok-conversions');
55
56
  register('602efa1f249b9a5e2bf8a813', './twilio');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/destinations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,wDAAmD;AACnD,gDAAuB;AAWV,QAAA,YAAY,GAA0C,EAAE,CAAA;AACxD,QAAA,QAAQ,GAAsC,EAAE,CAAA;AAU7D,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAA;AAChD,QAAQ,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAA;AACtD,QAAQ,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAA;AACnD,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;AAC/C,QAAQ,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAA;AACnD,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;AAC/C,QAAQ,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAA;AACjD,QAAQ,CAAC,0BAA0B,EAAE,oBAAoB,CAAC,CAAA;AAC1D,QAAQ,CAAC,0BAA0B,EAAE,cAAc,CAAC,CAAA;AACpD,QAAQ,C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AAO,IAAI,CAAA;KACZ;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,GAAW;IAChD,MAAM,WAAW,GAAG,oBAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,IAAI,CAAA;KACZ;IAGD,OAAO,IAAI,0BAAW,CAAC,WAAyC,CAAC,CAAA;AACnE,CAAC;AAED,SAAgB,kBAAkB,CAAC,EAAU;IAC3C,MAAM,WAAW,GAAG,gBAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE;QAC5B,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,IAAI,0BAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AARD,gDAQC;AAEM,KAAK,UAAU,uBAAuB,CAAC,WAAmB;IAC/D,OAAO,kBAAkB,CAAC,WAAW,CAAC,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAA;AAChF,CAAC;AAFD,0DAEC"}
@@ -0,0 +1,5 @@
1
+ export interface Settings {
2
+ pixel_id?: string;
3
+ snap_app_id?: string;
4
+ app_id?: string;
5
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/snap-conversions-api/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { DestinationDefinition } from '@segment/actions-core';
2
+ import type { Settings } from './generated-types';
3
+ declare const destination: DestinationDefinition<Settings>;
4
+ export default destination;
@@ -0,0 +1,177 @@
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 reportConversionEvent_1 = __importDefault(require("./reportConversionEvent"));
8
+ const defaultVals = { ...actions_core_1.defaultValues(reportConversionEvent_1.default.fields) };
9
+ const presets = [
10
+ {
11
+ name: 'Add Billing',
12
+ subscribe: 'event = "Payment Info Entered"',
13
+ partnerAction: 'reportConversionEvent',
14
+ mapping: {
15
+ ...defaultVals,
16
+ event_type: 'ADD_BILLING'
17
+ }
18
+ },
19
+ {
20
+ name: 'Add to Cart',
21
+ subscribe: 'event = "Product Added"',
22
+ partnerAction: 'reportConversionEvent',
23
+ mapping: {
24
+ ...defaultVals,
25
+ event_type: 'ADD_CART'
26
+ }
27
+ },
28
+ {
29
+ name: 'Add to Wishlist',
30
+ subscribe: 'event = "Product Added to Wishlist"',
31
+ partnerAction: 'reportConversionEvent',
32
+ mapping: {
33
+ ...defaultVals,
34
+ event_type: 'ADD_TO_WISHLIST'
35
+ }
36
+ },
37
+ {
38
+ name: 'App Install',
39
+ subscribe: 'event = "Application Installed"',
40
+ partnerAction: 'reportConversionEvent',
41
+ mapping: {
42
+ ...defaultVals,
43
+ event_type: 'APP_INSTALL'
44
+ }
45
+ },
46
+ {
47
+ name: 'App Open',
48
+ subscribe: 'event = "Application Opened"',
49
+ partnerAction: 'reportConversionEvent',
50
+ mapping: {
51
+ ...defaultVals,
52
+ event_type: 'APP_OPEN'
53
+ }
54
+ },
55
+ {
56
+ name: 'Login',
57
+ subscribe: 'event = "Signed In"',
58
+ partnerAction: 'reportConversionEvent',
59
+ mapping: {
60
+ ...defaultVals,
61
+ event_type: 'LOGIN'
62
+ }
63
+ },
64
+ {
65
+ name: 'Page View',
66
+ subscribe: 'type = "page"',
67
+ partnerAction: 'reportConversionEvent',
68
+ mapping: {
69
+ ...defaultVals,
70
+ event_type: 'PAGE_VIEW'
71
+ }
72
+ },
73
+ {
74
+ name: 'Purchase',
75
+ subscribe: 'event = "Order Completed"',
76
+ partnerAction: 'reportConversionEvent',
77
+ mapping: {
78
+ ...defaultVals,
79
+ event_type: 'PURCHASE'
80
+ }
81
+ },
82
+ {
83
+ name: 'Search',
84
+ subscribe: 'event = "Products Searched"',
85
+ partnerAction: 'reportConversionEvent',
86
+ mapping: {
87
+ ...defaultVals,
88
+ event_type: 'SEARCH'
89
+ }
90
+ },
91
+ {
92
+ name: 'Share',
93
+ subscribe: 'event = "Product Shared"',
94
+ partnerAction: 'reportConversionEvent',
95
+ mapping: {
96
+ ...defaultVals,
97
+ event_type: 'SHARE'
98
+ }
99
+ },
100
+ {
101
+ name: 'Sign Up',
102
+ subscribe: 'event = "Signed Up"',
103
+ partnerAction: 'reportConversionEvent',
104
+ mapping: {
105
+ ...defaultVals,
106
+ event_type: 'SIGN_UP'
107
+ }
108
+ },
109
+ {
110
+ name: 'Start Checkout',
111
+ subscribe: 'event = "Checkout Started"',
112
+ partnerAction: 'reportConversionEvent',
113
+ mapping: {
114
+ ...defaultVals,
115
+ event_type: 'START_CHECKOUT'
116
+ }
117
+ },
118
+ {
119
+ name: 'View Content',
120
+ subscribe: 'event = "Product Viewed"',
121
+ partnerAction: 'reportConversionEvent',
122
+ mapping: {
123
+ ...defaultVals,
124
+ event_type: 'VIEW_CONTENT'
125
+ }
126
+ }
127
+ ];
128
+ const destination = {
129
+ name: 'Snap Conversions Api',
130
+ slug: 'actions-snap-conversions',
131
+ mode: 'cloud',
132
+ authentication: {
133
+ scheme: 'oauth2',
134
+ fields: {
135
+ pixel_id: {
136
+ label: 'Pixel ID',
137
+ description: 'The Pixel ID for your Snapchat Ad Account. Required for web and offline events.',
138
+ type: 'string'
139
+ },
140
+ snap_app_id: {
141
+ label: 'Snap App ID',
142
+ description: 'The Snap App ID associated with your app. This is a unique code generated in Snapchat Ads Manager and included in your MMP dashboard. Required for app events.',
143
+ type: 'string'
144
+ },
145
+ app_id: {
146
+ label: 'App ID',
147
+ description: 'The unique ID assigned for a given application. It should be numeric for iOS, and the human interpretable string for Android. Required for app events.',
148
+ type: 'string'
149
+ }
150
+ },
151
+ refreshAccessToken: async (request, { auth }) => {
152
+ const res = await request('https://accounts.snapchat.com/login/oauth2/access_token', {
153
+ method: 'POST',
154
+ body: new URLSearchParams({
155
+ refresh_token: auth.refreshToken,
156
+ client_id: auth.clientId,
157
+ client_secret: auth.clientSecret,
158
+ grant_type: 'refresh_token'
159
+ })
160
+ });
161
+ return { accessToken: res.data.access_token };
162
+ }
163
+ },
164
+ extendRequest({ auth }) {
165
+ return {
166
+ headers: {
167
+ authorization: `Bearer ${auth?.accessToken}`
168
+ }
169
+ };
170
+ },
171
+ presets,
172
+ actions: {
173
+ reportConversionEvent: reportConversionEvent_1.default
174
+ }
175
+ };
176
+ exports.default = destination;
177
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/snap-conversions-api/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4E;AAG5E,oFAA2D;AAE3D,MAAM,WAAW,GAAG,EAAE,GAAG,4BAAa,CAAC,+BAAqB,CAAC,MAAM,CAAC,EAAE,CAAA;AAOtE,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,gCAAgC;QAC3C,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,WAAW;YACd,UAAU,EAAE,aAAa;SAC1B;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,yBAAyB;QACpC,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,WAAW;YACd,UAAU,EAAE,UAAU;SACvB;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE,qCAAqC;QAChD,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,WAAW;YACd,UAAU,EAAE,iBAAiB;SAC9B;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,iCAAiC;QAC5C,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,WAAW;YACd,UAAU,E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O,EAAE;QACP,qBAAqB,EAArB,+BAAqB;KACtB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,25 @@
1
+ export interface Payload {
2
+ event_type: string;
3
+ event_conversion_type: string;
4
+ event_tag?: string;
5
+ timestamp: string;
6
+ email?: string;
7
+ mobile_ad_id?: string;
8
+ uuid_c1?: string;
9
+ idfv?: string;
10
+ phone_number?: string;
11
+ user_agent?: string;
12
+ ip_address?: string;
13
+ item_category?: string;
14
+ item_ids?: string;
15
+ description?: string;
16
+ number_items?: string;
17
+ price?: number;
18
+ currency?: string;
19
+ transaction_id?: string;
20
+ level?: string;
21
+ client_dedup_id?: string;
22
+ search_string?: string;
23
+ page_url?: string;
24
+ sign_up_method?: string;
25
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/reportConversionEvent/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const snap_capi_properties_1 = require("../snap-capi-properties");
4
+ const action = {
5
+ title: 'Report Conversion Event',
6
+ description: 'TODO',
7
+ fields: {
8
+ event_type: { ...snap_capi_properties_1.event_type, required: true },
9
+ event_conversion_type: { ...snap_capi_properties_1.event_conversion_type, required: true },
10
+ event_tag: snap_capi_properties_1.event_tag,
11
+ timestamp: { ...snap_capi_properties_1.timestamp, required: true },
12
+ email: snap_capi_properties_1.email,
13
+ mobile_ad_id: snap_capi_properties_1.mobile_ad_id,
14
+ uuid_c1: snap_capi_properties_1.uuid_c1,
15
+ idfv: snap_capi_properties_1.idfv,
16
+ phone_number: snap_capi_properties_1.phone_number,
17
+ user_agent: snap_capi_properties_1.user_agent,
18
+ ip_address: snap_capi_properties_1.ip_address,
19
+ item_category: snap_capi_properties_1.item_category,
20
+ item_ids: snap_capi_properties_1.item_ids,
21
+ description: snap_capi_properties_1.description,
22
+ number_items: snap_capi_properties_1.number_items,
23
+ price: snap_capi_properties_1.price,
24
+ currency: snap_capi_properties_1.currency,
25
+ transaction_id: snap_capi_properties_1.transaction_id,
26
+ level: snap_capi_properties_1.level,
27
+ client_dedup_id: snap_capi_properties_1.client_dedup_id,
28
+ search_string: snap_capi_properties_1.search_string,
29
+ page_url: snap_capi_properties_1.page_url,
30
+ sign_up_method: snap_capi_properties_1.sign_up_method
31
+ },
32
+ perform: (request, data) => {
33
+ const payload = snap_capi_properties_1.formatPayload(data.payload);
34
+ if (data.payload.event_conversion_type === 'MOBILE_APP') {
35
+ delete data.settings?.pixel_id;
36
+ }
37
+ else {
38
+ delete data.settings?.snap_app_id;
39
+ delete data.settings?.app_id;
40
+ }
41
+ return request('https://tr.snapchat.com/v2/conversion', {
42
+ method: 'post',
43
+ json: {
44
+ ...payload,
45
+ ...data.settings
46
+ }
47
+ });
48
+ }
49
+ };
50
+ exports.default = action;
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/reportConversionEvent/index.ts"],"names":[],"mappings":";;AAGA,kEAyBgC;AAEhC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE;QACN,UAAU,EAAE,EAAE,GAAG,iCAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC7C,qBAAqB,EAAE,EAAE,GAAG,4CAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnE,SAAS,EAAE,gCAAS;QACpB,SAAS,EAAE,EAAE,GAAG,gCAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3C,KAAK,EAAE,4BAAK;QACZ,YAAY,EAAE,mCAAY;QAC1B,OAAO,EAAE,8BAAO;QAChB,IAAI,EAAE,2BAAI;QACV,YAAY,EAAE,mCAAY;QAC1B,UAAU,EAAE,iCAAU;QACtB,UAAU,EAAE,iCAAU;QACtB,aAAa,EAAE,oCAAa;QAC5B,QAAQ,EAAE,+BAAQ;QAClB,WAAW,EAAE,kCAAW;QACxB,YAAY,EAAE,mCAAY;QAC1B,KAAK,EAAE,4BAAK;QACZ,QAAQ,EAAE,+BAAQ;QAClB,cAAc,EAAE,qCAAc;QAC9B,KAAK,EAAE,4BAAK;QACZ,eAAe,EAAE,sCAAe;QAChC,aAAa,EAAE,oCAAa;QAC5B,QAAQ,EAAE,+BAAQ;QAClB,cAAc,EAAE,qCAAc;KAC/B;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QAEzB,MAAM,OAAO,GAAW,oCAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAGnD,IAAI,IAAI,CAAC,OAAO,CAAC,qBAAqB,KAAK,YAAY,EAAE;YACvD,OAAO,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAA;SAC/B;aAAM;YACL,OAAO,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAA;YACjC,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAA;SAC7B;QAKD,OAAO,OAAO,CAAC,uCAAuC,EAAE;YACtD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,GAAG,OAAO;gBACV,GAAG,IAAI,CAAC,QAAQ;aACjB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { InputField } from '@segment/actions-core/src/destination-kit/types';
2
+ import { Payload } from './reportConversionEvent/generated-types';
3
+ export declare const event_type: InputField;
4
+ export declare const event_conversion_type: InputField;
5
+ export declare const event_tag: InputField;
6
+ export declare const timestamp: InputField;
7
+ export declare const email: InputField;
8
+ export declare const mobile_ad_id: InputField;
9
+ export declare const uuid_c1: InputField;
10
+ export declare const idfv: InputField;
11
+ export declare const phone_number: InputField;
12
+ export declare const user_agent: InputField;
13
+ export declare const ip_address: InputField;
14
+ export declare const item_category: InputField;
15
+ export declare const item_ids: InputField;
16
+ export declare const description: InputField;
17
+ export declare const number_items: InputField;
18
+ export declare const price: InputField;
19
+ export declare const currency: InputField;
20
+ export declare const transaction_id: InputField;
21
+ export declare const level: InputField;
22
+ export declare const client_dedup_id: InputField;
23
+ export declare const search_string: InputField;
24
+ export declare const page_url: InputField;
25
+ export declare const sign_up_method: InputField;
26
+ export declare const hash: (value: string | undefined) => string | undefined;
27
+ export declare const formatPayload: (payload: Payload) => Object;
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPayload = exports.hash = exports.sign_up_method = exports.page_url = exports.search_string = exports.client_dedup_id = exports.level = exports.transaction_id = exports.currency = exports.price = exports.number_items = exports.description = exports.item_ids = exports.item_category = exports.ip_address = exports.user_agent = exports.phone_number = exports.idfv = exports.uuid_c1 = exports.mobile_ad_id = exports.email = exports.timestamp = exports.event_tag = exports.event_conversion_type = exports.event_type = void 0;
4
+ const crypto_1 = require("crypto");
5
+ exports.event_type = {
6
+ label: 'Event Type',
7
+ description: "The conversion event type. Please refer to the possible event types in [Snapchat Marketing API docs](https://marketingapi.snapchat.com/docs/conversion.html#conversion-parameters).",
8
+ type: 'string',
9
+ };
10
+ exports.event_conversion_type = {
11
+ label: "Event Conversion Type",
12
+ description: 'Where the event took place. This must be OFFLINE, WEB, or MOBILE_APP.',
13
+ type: 'string',
14
+ choices: [
15
+ { label: 'Offline', value: "OFFLINE" },
16
+ { label: 'Web', value: 'WEB' },
17
+ { label: 'Mobile App', value: 'MOBILE_APP' }
18
+ ]
19
+ };
20
+ exports.event_tag = {
21
+ label: 'Event Tag',
22
+ description: 'Custom event label',
23
+ type: 'string',
24
+ };
25
+ exports.timestamp = {
26
+ label: 'Event Timestamp',
27
+ description: 'The Epoch timestamp for when the conversion happened. The timestamp cannot be more than 28 days in the past',
28
+ type: 'string',
29
+ default: {
30
+ '@path': '$.timestamp'
31
+ }
32
+ };
33
+ exports.email = {
34
+ label: 'Email',
35
+ description: 'Email address of the user who triggered the conversion event. Segment will normalize and hash this value before sending to Snapchat.',
36
+ type: 'string',
37
+ default: {
38
+ '@if': {
39
+ exists: { '@path': '$properties.email' },
40
+ then: { '@path': '$properties.email' },
41
+ else: { '@path': '$traits.email' }
42
+ }
43
+ }
44
+ };
45
+ exports.mobile_ad_id = {
46
+ label: 'Mobile Ad Indeentifier',
47
+ description: 'Mobile ad identifier (IDFA or AAID) of the user who triggered the conversion event. Segment will normalize and hash this value before sending to Snapchat.',
48
+ type: 'string',
49
+ default: {
50
+ '@path': '$context.device.advertisingId'
51
+ }
52
+ };
53
+ exports.uuid_c1 = {
54
+ label: "uuid_c1 Cookie",
55
+ description: 'Unique user ID cookie. If you are using the Pixel SDK, you can access a cookie1 by looking at the _scid value.',
56
+ type: 'string'
57
+ };
58
+ exports.idfv = {
59
+ label: 'Indentifier for Vendor',
60
+ description: 'IDFV of the user’s device. Segment will normalize and hash this value before sending to Snapchat.',
61
+ type: 'string',
62
+ default: {
63
+ '@path': '$context.device.id'
64
+ }
65
+ };
66
+ exports.phone_number = {
67
+ label: 'Phone Number',
68
+ description: 'Phone number of the user who triggered the conversion event. Segment will normalize and hash this value before sending to Snapchat.',
69
+ type: 'string',
70
+ default: {
71
+ '@if': {
72
+ exists: { '@path': '$properties.phone' },
73
+ then: { '@path': '$properties.phone' },
74
+ else: { '@path': '$traits.phone' }
75
+ }
76
+ }
77
+ };
78
+ exports.user_agent = {
79
+ label: 'User Agent',
80
+ description: 'User agent from the user’s device.',
81
+ type: 'string',
82
+ default: {
83
+ '@path': '$context.userAgent'
84
+ }
85
+ };
86
+ exports.ip_address = {
87
+ label: 'IP Address',
88
+ description: 'IP address of the device or browser. Segment will normalize and hash this value before sending to Snapchat.',
89
+ type: 'string',
90
+ default: {
91
+ '@path': '$context.ip'
92
+ }
93
+ };
94
+ exports.item_category = {
95
+ label: 'Item Category',
96
+ description: 'Category of the item.',
97
+ type: 'string',
98
+ default: {
99
+ '@path': '$properties.category'
100
+ }
101
+ };
102
+ exports.item_ids = {
103
+ label: 'Item IDs',
104
+ description: 'International Article Number (EAN) when applicable, or other product or category identifier. ',
105
+ type: 'string',
106
+ default: {
107
+ '@path': '$properties.product_id'
108
+ }
109
+ };
110
+ exports.description = {
111
+ label: 'Description',
112
+ description: 'A string description for additional info.',
113
+ type: 'string'
114
+ };
115
+ exports.number_items = {
116
+ label: 'Number of Items',
117
+ description: 'Number of items.',
118
+ type: 'string',
119
+ default: {
120
+ '@path': '$properties.quantity'
121
+ }
122
+ };
123
+ exports.price = {
124
+ label: 'Price',
125
+ description: 'Value of the purchase.',
126
+ type: 'number',
127
+ default: {
128
+ '@if': {
129
+ exists: { '@path': '$properties.price' },
130
+ then: { '@path': '$properties.price' },
131
+ else: { '@path': '$properties.value' }
132
+ }
133
+ }
134
+ };
135
+ exports.currency = {
136
+ label: 'Currency',
137
+ description: 'Currency for the value specified as ISO 4217 code.',
138
+ type: 'string',
139
+ default: {
140
+ '@path': '$.properties.currency'
141
+ }
142
+ };
143
+ exports.transaction_id = {
144
+ label: 'Transaction ID',
145
+ description: 'Transaction ID or order ID tied to the conversion event. Please refer to the [Snapchat Marketing API docs](https://marketingapi.snapchat.com/docs/conversion.html#deduplication) for information on how this field is used for deduplication against Snap Pixel SDK and App Adds Kit events.',
146
+ type: 'string',
147
+ default: {
148
+ '@path': '$.properties.order_id'
149
+ }
150
+ };
151
+ exports.level = {
152
+ label: 'Level',
153
+ description: 'Represents a level in the context of a game.',
154
+ type: 'string',
155
+ };
156
+ exports.client_dedup_id = {
157
+ label: 'Client Deduplication ID',
158
+ description: 'If you are reporting events via more than one method (Snap Pixel, App Ads Kit, Conversions API) you should use the same client_dedup_id across all methods. Please refer to the [Snapchat Marketing API docs](https://marketingapi.snapchat.com/docs/conversion.html#deduplication) for information on how this field is used for deduplication against Snap Pixel SDK and App Adds Kit events.',
159
+ type: 'string',
160
+ };
161
+ exports.search_string = {
162
+ label: 'Search String',
163
+ description: 'The text string that was searched for.',
164
+ type: 'string',
165
+ default: {
166
+ '@path': '$.properties.query'
167
+ }
168
+ };
169
+ exports.page_url = {
170
+ label: 'Page URL',
171
+ description: 'The URL of the web page where the event took place.',
172
+ type: 'string',
173
+ default: {
174
+ '@path': '$.context.page.url'
175
+ }
176
+ };
177
+ exports.sign_up_method = {
178
+ label: 'Sign Up Method',
179
+ description: 'A string indicating the sign up method.',
180
+ type: 'string'
181
+ };
182
+ const hash = (value) => {
183
+ if (value === undefined)
184
+ return;
185
+ const hash = crypto_1.createHash('sha256');
186
+ hash.update(value);
187
+ return hash.digest('hex');
188
+ };
189
+ exports.hash = hash;
190
+ const formatPayload = (payload) => {
191
+ if (payload.email) {
192
+ payload.email = payload.email.replace(/\s/g, '').toLowerCase();
193
+ }
194
+ if (payload.phone_number) {
195
+ payload.phone_number = payload.phone_number.replace(/\D|^0+/g, '');
196
+ }
197
+ if (payload.mobile_ad_id) {
198
+ payload.mobile_ad_id = payload.mobile_ad_id.toLowerCase();
199
+ }
200
+ return {
201
+ event_type: payload?.event_type,
202
+ event_conversion_type: payload?.event_conversion_type,
203
+ event_tag: payload?.event_tag,
204
+ timestamp: Date.parse(payload?.timestamp),
205
+ hashed_email: exports.hash(payload?.email),
206
+ mobile_ad_id: exports.hash(payload?.mobile_ad_id),
207
+ uuid_c1: payload?.uuid_c1,
208
+ hashed_idfv: exports.hash(payload?.idfv),
209
+ hashed_phone_number: exports.hash(payload?.phone_number),
210
+ user_agent: payload?.user_agent,
211
+ hashed_ip_address: exports.hash(payload?.ip_address),
212
+ item_category: payload?.item_category,
213
+ item_ids: payload?.item_ids,
214
+ description: payload?.description,
215
+ number_items: payload?.number_items,
216
+ price: payload?.price,
217
+ currency: payload?.currency,
218
+ transaction_id: payload?.transaction_id,
219
+ level: payload?.level,
220
+ client_dedup_id: payload?.client_dedup_id,
221
+ search_string: payload?.search_string,
222
+ page_url: payload?.page_url,
223
+ sign_up_method: payload?.sign_up_method
224
+ };
225
+ };
226
+ exports.formatPayload = formatPayload;
227
+ //# sourceMappingURL=snap-capi-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snap-capi-properties.js","sourceRoot":"","sources":["../../../src/destinations/snap-conversions-api/snap-capi-properties.ts"],"names":[],"mappings":";;;AACA,mCAAmC;AAKtB,QAAA,UAAU,GAAe;IAClC,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,qLAAqL;IAClM,IAAI,EAAE,QAAQ;CAGjB,CAAA;AAEY,QAAA,qBAAqB,GAAe;IAC7C,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EAAE,uEAAuE;IACpF,IAAI,EAAE,QAAQ;IAEd,OAAO,EAAE;QACL,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;QACtC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;QAC9B,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;KAC/C;CACJ,CAAA;AAEY,QAAA,SAAS,GAAe;IACjC,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,oBAAoB;IACjC,IAAI,EAAE,QAAQ;CAGjB,CAAA;AAGY,QAAA,SAAS,GAAe;IACjC,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,8GAA8G;IAC3H,IAAI,EAAE,QAAQ;IAEd,OAAO,EAAE;QACL,OAAO,EAAE,aAAa;KACzB;CACJ,CAAA;AAEY,QAAA,KAAK,GAAe;IAC7B,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,sIAAsI;IACnJ,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACL,KAAK,EAAE;YACH,MAAM,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;YACxC,IAAI,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;YACtC,IAAI,EAAE,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E;QAEtB,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAA;KAC5D;IAED,OAAO;QACH,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,qBAAqB,EAAE,OAAO,EAAE,qBAAqB;QACrD,SAAS,EAAE,OAAO,EAAE,SAAS;QAC7B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC;QACzC,YAAY,EAAE,YAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAClC,YAAY,EAAE,YAAI,CAAC,OAAO,EAAE,YAAY,CAAC;QACzC,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,WAAW,EAAE,YAAI,CAAC,OAAO,EAAE,IAAI,CAAC;QAChC,mBAAmB,EAAE,YAAI,CAAC,OAAO,EAAE,YAAY,CAAC;QAChD,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,iBAAiB,EAAE,YAAI,CAAC,OAAO,EAAE,UAAU,CAAC;QAC5C,aAAa,EAAE,OAAO,EAAE,aAAa;QACrC,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,YAAY,EAAE,OAAO,EAAE,YAAY;QACnC,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,cAAc,EAAE,OAAO,EAAE,cAAc;QACvC,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,aAAa,EAAE,OAAO,EAAE,aAAa;QACrC,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,cAAc,EAAE,OAAO,EAAE,cAAc;KAC1C,CAAA;AAIL,CAAC,CAAA;AA7CY,QAAA,aAAa,iBA6CzB"}
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.65.1-alpha.2",
4
+ "version": "3.65.1-alpha.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/action-destinations",
@@ -62,5 +62,5 @@
62
62
  "<rootDir>/test/setup-after-env.ts"
63
63
  ]
64
64
  },
65
- "gitHead": "74398773721b79c87c155f93f55c3a1382d0d5fc"
65
+ "gitHead": "e008bff5784161e2aa41857e234879e4ac178f14"
66
66
  }
@@ -1,64 +0,0 @@
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
- use_batch_endpoint?: boolean;
45
- userAgent?: string;
46
- userAgentParsing?: boolean;
47
- utm_properties?: {
48
- utm_source?: string;
49
- utm_medium?: string;
50
- utm_campaign?: string;
51
- utm_term?: string;
52
- utm_content?: string;
53
- };
54
- referrer?: string;
55
- min_id_length?: number | null;
56
- trackRevenuePerProduct?: boolean;
57
- products?: {
58
- price?: number;
59
- quantity?: number;
60
- revenue?: number;
61
- productId?: string;
62
- revenueType?: string;
63
- }[];
64
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/amplitude/logPurchase/generated-types.ts"],"names":[],"mappings":""}
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const actions_core_1 = require("@segment/actions-core");
4
- const user_agent_1 = require("../user-agent");
5
- const logEvent_1 = require("../logEvent");
6
- const logEvent_2 = require("../logEvent");
7
- const revenueKeys = ['revenue', 'price', 'productId', 'quantity', 'revenueType'];
8
- function getRevenueProperties(payload) {
9
- if (typeof payload.revenue !== 'number') {
10
- return {};
11
- }
12
- return {
13
- revenue: payload.revenue,
14
- revenueType: payload.revenueType ?? 'Purchase',
15
- quantity: typeof payload.quantity === 'number' ? Math.round(payload.quantity) : undefined,
16
- price: payload.price,
17
- productId: payload.productId
18
- };
19
- }
20
- function getEvents(payload, properties) {
21
- const { products = [], userAgent, userAgentParsing, trackRevenuePerProduct } = payload;
22
- properties = actions_core_1.omit(properties, revenueKeys);
23
- const events = [
24
- {
25
- ...(userAgentParsing && user_agent_1.parseUserAgentProperties(userAgent)),
26
- ...actions_core_1.removeUndefined(properties),
27
- ...(products?.length && trackRevenuePerProduct ? {} : getRevenueProperties(payload)),
28
- library: 'segment'
29
- }
30
- ];
31
- for (const product of products) {
32
- events.push({
33
- ...properties,
34
- ...(trackRevenuePerProduct ? getRevenueProperties(product) : {}),
35
- event_properties: product,
36
- event_type: 'Product Purchased',
37
- insert_id: properties.insert_id ? `${properties.insert_id}-${events.length + 1}` : undefined,
38
- library: 'segment'
39
- });
40
- }
41
- return events;
42
- }
43
- const action = {
44
- title: 'Log Purchase',
45
- description: 'Send an event to Amplitude.',
46
- defaultSubscription: 'type = "track" and event = "Order Completed"',
47
- fields: {
48
- ...logEvent_2.fields,
49
- trackRevenuePerProduct: {
50
- label: 'Track Revenue Per Product',
51
- description: 'When enabled, track revenue with each product within the event. When disabled, track total revenue once for the event.',
52
- type: 'boolean',
53
- default: false
54
- },
55
- products: {
56
- label: 'Products',
57
- description: 'The list of products purchased.',
58
- type: 'object',
59
- multiple: true,
60
- properties: {
61
- price: {
62
- label: 'Price',
63
- type: 'number',
64
- 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.'
65
- },
66
- quantity: {
67
- label: 'Quantity',
68
- type: 'integer',
69
- description: 'The quantity of the item purchased. Defaults to 1 if not specified.'
70
- },
71
- revenue: {
72
- label: 'Revenue',
73
- type: 'number',
74
- 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.'
75
- },
76
- productId: {
77
- label: 'Product ID',
78
- type: 'string',
79
- description: 'An identifier for the item purchased. You must send a price and quantity or revenue with this field.'
80
- },
81
- revenueType: {
82
- label: 'Revenue Type',
83
- type: 'string',
84
- description: 'The type of revenue for the item purchased. You must send a price and quantity or revenue with this field.'
85
- }
86
- },
87
- default: {
88
- '@path': '$.properties.products'
89
- }
90
- }
91
- },
92
- perform: (request, { payload, settings }) => logEvent_1.doPerform(request, payload, settings, getEvents)
93
- };
94
- exports.default = action;
95
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amplitude/logPurchase/index.ts"],"names":[],"mappings":";;AAAA,wDAA6D;AAI7D,8CAAwD;AACxD,0CAAuD;AACvD,0CAAsD;AAEtD,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;AAShF,SAAS,oBAAoB,CAAC,OAAqB;IACjD,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE;QACvC,OAAO,EAAE,CAAA;KACV;IAED,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,UAAU;QAC9C,QAAQ,EAAE,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC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