@segment/action-destinations 3.333.0-staging.0 → 3.334.0-staging.1

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 (30) hide show
  1. package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.d.ts +1 -1
  2. package/dist/destinations/engage/sendgrid/Profile.d.ts +6 -0
  3. package/dist/destinations/engage/sendgrid/Profile.js +3 -0
  4. package/dist/destinations/engage/sendgrid/Profile.js.map +1 -0
  5. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +21 -0
  6. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +174 -0
  7. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +1 -0
  8. package/dist/destinations/facebook-conversions-api/fb-capi-app-data.js +1 -1
  9. package/dist/destinations/mixpanel/utils.d.ts +13 -0
  10. package/dist/destinations/mixpanel/utils.js +117 -0
  11. package/dist/destinations/mixpanel/utils.js.map +1 -0
  12. package/dist/destinations/tiktok-offline-conversions/common_fields.d.ts +2 -0
  13. package/dist/destinations/tiktok-offline-conversions/common_fields.js +85 -0
  14. package/dist/destinations/tiktok-offline-conversions/common_fields.js.map +1 -0
  15. package/dist/destinations/tiktok-offline-conversions/formatter.d.ts +2 -0
  16. package/dist/destinations/tiktok-offline-conversions/formatter.js +33 -0
  17. package/dist/destinations/tiktok-offline-conversions/formatter.js.map +1 -0
  18. package/dist/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/generated-types.d.ts +10 -0
  19. package/dist/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/generated-types.js +3 -0
  20. package/dist/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/generated-types.js.map +1 -0
  21. package/dist/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/index.d.ts +5 -0
  22. package/dist/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/index.js +41 -0
  23. package/dist/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/index.js.map +1 -0
  24. package/dist/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/generated-types.d.ts +20 -0
  25. package/dist/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/generated-types.js +3 -0
  26. package/dist/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/generated-types.js.map +1 -0
  27. package/dist/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/index.d.ts +5 -0
  28. package/dist/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/index.js +137 -0
  29. package/dist/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/index.js.map +1 -0
  30. package/package.json +1 -1
@@ -9,7 +9,7 @@ export declare const dateStringToFuzzyDate: (dateString: string | number) => fal
9
9
  y: string;
10
10
  };
11
11
  export declare const augmentFieldsWithConstituentFields: (fields: Record<string, InputField>) => Record<string, InputField>;
12
- export declare const splitConstituentPayload: (payload: CreateOrUpdateIndividualConstituentPayload) => (Partial<Address> | Partial<OnlinePresence> | Partial<Phone> | Partial<Constituent>)[];
12
+ export declare const splitConstituentPayload: (payload: CreateOrUpdateIndividualConstituentPayload) => (Partial<Constituent> | Partial<Address> | Partial<OnlinePresence> | Partial<Phone>)[];
13
13
  export declare const buildConstituentPayloadFromPayload: (payload: StringIndexedObject) => Partial<CreateOrUpdateIndividualConstituentPayload>;
14
14
  export declare const buildGiftDataFromPayload: (constituentId: string, payload: CreateGiftPayload) => Partial<Gift>;
15
15
  export declare const buildConstituentActionDataFromPayload: (constituentId: string, payload: CreateConstituentAction) => Partial<ConstituentAction>;
@@ -0,0 +1,6 @@
1
+ export interface Profile {
2
+ user_id?: string;
3
+ anonymous_id?: string;
4
+ email?: string;
5
+ traits: Record<string, string>;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Profile.js","sourceRoot":"","sources":["../../../../src/destinations/engage/sendgrid/Profile.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { InputField } from '@segment/actions-core';
2
+ import { RequestClient } from '@segment/actions-core';
3
+ import { Logger, StatsClient, DataFeedCache } from '@segment/actions-core/destination-kit';
4
+ import type { Settings } from '../generated-types';
5
+ import { Profile } from '../Profile';
6
+ export declare type ApiLookupConfig = {
7
+ id?: string | undefined;
8
+ name: string;
9
+ url: string;
10
+ method: string;
11
+ cacheTtl: number;
12
+ body?: string | undefined;
13
+ headers?: object | undefined;
14
+ responseType: string;
15
+ };
16
+ export declare const getRequestId: ({ method, url, body, headers }: ApiLookupConfig) => string;
17
+ export declare const getCachedResponse: ({ responseType }: ApiLookupConfig, requestId: string, dataFeedCache: DataFeedCache, datafeedTags: string[]) => Promise<any>;
18
+ export declare const performApiLookup: (request: RequestClient, apiLookupConfig: ApiLookupConfig, profile: Profile, statsClient: StatsClient | undefined, tags: string[], settings: Settings, logger?: Logger | undefined, dataFeedCache?: DataFeedCache | undefined) => Promise<any>;
19
+ export declare const apiLookupActionFields: Record<string, InputField>;
20
+ export declare const apiLookupLiquidKey = "lookups";
21
+ export declare const FLAGON_NAME_DATA_FEEDS = "is-datafeeds-enabled";
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FLAGON_NAME_DATA_FEEDS = exports.apiLookupLiquidKey = exports.apiLookupActionFields = exports.performApiLookup = exports.getCachedResponse = exports.getRequestId = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const actions_core_1 = require("@segment/actions-core");
6
+ const liquidjs_1 = require("liquidjs");
7
+ const Liquid = new liquidjs_1.Liquid();
8
+ const maxResponseSizeBytes = 1000000;
9
+ const renderLiquidFields = async ({ id, url, body }, profile, datafeedTags, settings, logger) => {
10
+ let renderedUrl;
11
+ let renderedBody;
12
+ try {
13
+ renderedUrl = await Liquid.parseAndRender(url, { profile });
14
+ }
15
+ catch (error) {
16
+ logger?.error(`TE Messaging: Email datafeed url parse failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
17
+ datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:rendering_failure', 'rendering:url');
18
+ throw new actions_core_1.IntegrationError('Unable to parse email api lookup url', 'api lookup url parse failure', 400);
19
+ }
20
+ try {
21
+ renderedBody = body ? await Liquid.parseAndRender(body, { profile }) : undefined;
22
+ }
23
+ catch (error) {
24
+ logger?.error(`TE Messaging: Email datafeed body parse failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
25
+ datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:rendering_failure', 'rendering:body');
26
+ throw new actions_core_1.IntegrationError('Unable to parse email api lookup body', 'api lookup body parse failure', 400);
27
+ }
28
+ return {
29
+ renderedUrl,
30
+ renderedBody
31
+ };
32
+ };
33
+ const getRequestId = ({ method, url, body, headers }) => {
34
+ const requestHash = crypto_1.createHash('sha256');
35
+ requestHash.update(`${method}${url}${body}${JSON.stringify(headers)}`);
36
+ const requestId = requestHash.digest('hex');
37
+ return requestId;
38
+ };
39
+ exports.getRequestId = getRequestId;
40
+ const getCachedResponse = async ({ responseType }, requestId, dataFeedCache, datafeedTags) => {
41
+ const cachedResponse = await dataFeedCache?.getRequestResponse(requestId);
42
+ if (!cachedResponse) {
43
+ datafeedTags.push('cache_hit:false');
44
+ return;
45
+ }
46
+ datafeedTags.push('cache_hit:true');
47
+ if (responseType === 'json') {
48
+ return JSON.parse(cachedResponse);
49
+ }
50
+ return cachedResponse;
51
+ };
52
+ exports.getCachedResponse = getCachedResponse;
53
+ const performApiLookup = async (request, apiLookupConfig, profile, statsClient, tags, settings, logger, dataFeedCache) => {
54
+ const { id, method, headers, cacheTtl, name } = apiLookupConfig;
55
+ const datafeedTags = [
56
+ ...tags,
57
+ `datafeed_id:${id}`,
58
+ `datafeed_name:${name}`,
59
+ `space_id:${settings.spaceId}`,
60
+ `cache_ttl_greater_than_0:${cacheTtl > 0}`
61
+ ];
62
+ try {
63
+ const { renderedUrl, renderedBody } = await renderLiquidFields(apiLookupConfig, profile, datafeedTags, settings, logger);
64
+ const requestId = exports.getRequestId({ ...apiLookupConfig, url: renderedUrl, body: renderedBody });
65
+ if (cacheTtl > 0 && dataFeedCache) {
66
+ const cachedResponse = await exports.getCachedResponse(apiLookupConfig, requestId, dataFeedCache, datafeedTags);
67
+ if (cachedResponse) {
68
+ datafeedTags.push('error:false');
69
+ return cachedResponse;
70
+ }
71
+ }
72
+ let data;
73
+ try {
74
+ const res = await request(renderedUrl, {
75
+ headers: headers ?? undefined,
76
+ timeout: 3000,
77
+ method: method,
78
+ body: renderedBody,
79
+ skipResponseCloning: true
80
+ });
81
+ data = await res.data;
82
+ }
83
+ catch (error) {
84
+ const respError = error.response;
85
+ logger?.error(`TE Messaging: Email api lookup failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
86
+ datafeedTags.push(`error:true`, `error_message:${error.message}`, `error_status:${respError?.status}`, 'reason:api_call_failure');
87
+ throw error;
88
+ }
89
+ const dataString = JSON.stringify(data);
90
+ const size = Buffer.byteLength(dataString, 'utf-8');
91
+ datafeedTags.push(`response_size_greater_than_mb:${size > maxResponseSizeBytes}`);
92
+ if (cacheTtl > 0) {
93
+ if (size <= maxResponseSizeBytes) {
94
+ try {
95
+ await dataFeedCache?.setRequestResponse(requestId, dataString, cacheTtl / 1000);
96
+ datafeedTags.push('cache_set:true');
97
+ }
98
+ catch (err) {
99
+ logger?.error(`TE Messaging: Email api lookup cache set failure - api lookup id: ${id} - ${settings.spaceId} - [${err}]`);
100
+ datafeedTags.push('cache_set:false');
101
+ datafeedTags.push('error:true', 'reason:cache_set_failure', `error_message:${err?.message}`);
102
+ throw err;
103
+ }
104
+ }
105
+ else {
106
+ datafeedTags.push('cache_set:false');
107
+ }
108
+ }
109
+ return data;
110
+ }
111
+ catch (error) {
112
+ const isErrorCapturedInTags = datafeedTags.find((str) => str.includes('error:true'));
113
+ if (!isErrorCapturedInTags) {
114
+ datafeedTags.push('error:true', `error_message:${error?.message}`, 'reason:unknown');
115
+ }
116
+ tags.push('reason:datafeed_failure');
117
+ logger?.error(`TE Messaging: Email api lookup failure - api lookup id: ${id} - ${settings.spaceId} - [${error}]`);
118
+ throw error;
119
+ }
120
+ finally {
121
+ statsClient?.incr('datafeed-execution', 1, datafeedTags);
122
+ }
123
+ };
124
+ exports.performApiLookup = performApiLookup;
125
+ exports.apiLookupActionFields = {
126
+ id: {
127
+ label: 'ID',
128
+ description: 'The id of the API lookup for use in logging & observability',
129
+ type: 'string'
130
+ },
131
+ name: {
132
+ label: 'Name',
133
+ description: 'The name of the API lookup referenced in liquid syntax',
134
+ type: 'string',
135
+ required: true
136
+ },
137
+ url: {
138
+ label: 'URL',
139
+ description: 'The URL endpoint to call',
140
+ type: 'string',
141
+ required: true
142
+ },
143
+ method: {
144
+ label: 'Request Method',
145
+ description: 'The request method, e.g. GET/POST/etc.',
146
+ type: 'string',
147
+ required: true
148
+ },
149
+ cacheTtl: {
150
+ label: 'Cache TTL',
151
+ description: 'The cache TTL in ms',
152
+ type: 'integer',
153
+ required: true
154
+ },
155
+ body: {
156
+ label: 'Request Body',
157
+ description: 'The request body for use with POST/PUT/PATCH requests',
158
+ type: 'string'
159
+ },
160
+ headers: {
161
+ label: 'Request Headers',
162
+ description: 'Headers in JSON to be sent with the request',
163
+ type: 'object'
164
+ },
165
+ responseType: {
166
+ label: 'Response Type',
167
+ description: 'The response type of the request. Currently only supporting JSON.',
168
+ type: 'string',
169
+ required: true
170
+ }
171
+ };
172
+ exports.apiLookupLiquidKey = 'lookups';
173
+ exports.FLAGON_NAME_DATA_FEEDS = 'is-datafeeds-enabled';
174
+ //# sourceMappingURL=api-lookups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-lookups.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/sendgrid/previewApiLookup/api-lookups.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,wDAAwD;AAKxD,uCAA6C;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,QAAQ,EAAE,IAAI;KACf;CACF,CAAA;AAEY,QAAA,kBAAkB,GAAG,SAAS,CAAA;AAE9B,QAAA,sBAAsB,GAAG,sBAAsB,CAAA"}
@@ -31,7 +31,7 @@ const generate_app_data = (app_data) => {
31
31
  exports.generate_app_data = generate_app_data;
32
32
  exports.app_data_field = {
33
33
  label: 'App Events Fields',
34
- description: `These fields support sending app events to Facebook through the Conversions API. For more information about app events support in the Conversions API, see the Facebook docs [here](https://developers.facebook.com/docs/marketing-api/conversions-api/app-events).
34
+ description: `These fields support sending app events to Facebook through the Conversions API. For more information about app events support in the Conversions API, see the Facebook docs [here](https://developers.facebook.com/docs/marketing-api/conversions-api/app-events) -- stage test.
35
35
  App events sent through the Conversions API must be associated with a dataset.
36
36
  Instructions for creating a dataset can be found [here](https://www.facebook.com/business/help/750785952855662?id=490360542427371). Once a dataset is created, the dataset ID
37
37
  can be substituted for the pixel ID in the destination settings.`,
@@ -0,0 +1,13 @@
1
+ export declare enum ApiRegions {
2
+ US = "US \uD83C\uDDFA\uD83C\uDDF8",
3
+ EU = "EU \uD83C\uDDEA\uD83C\uDDFA"
4
+ }
5
+ export declare enum StrictMode {
6
+ ON = "1",
7
+ OFF = "0"
8
+ }
9
+ export declare function getConcatenatedName(firstName: unknown, lastName: unknown, name: unknown): unknown;
10
+ export declare function getApiServerUrl(apiRegion: string | undefined): "https://api-eu.mixpanel.com" | "https://api.mixpanel.com";
11
+ export declare function getBrowser(userAgent: string): string;
12
+ export declare function getBrowserVersion(userAgent: string): string | undefined;
13
+ export declare function cheapGuid(maxlen?: number): string;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cheapGuid = exports.getBrowserVersion = exports.getBrowser = exports.getApiServerUrl = exports.getConcatenatedName = exports.StrictMode = exports.ApiRegions = void 0;
4
+ var ApiRegions;
5
+ (function (ApiRegions) {
6
+ ApiRegions["US"] = "US \uD83C\uDDFA\uD83C\uDDF8";
7
+ ApiRegions["EU"] = "EU \uD83C\uDDEA\uD83C\uDDFA";
8
+ })(ApiRegions = exports.ApiRegions || (exports.ApiRegions = {}));
9
+ var StrictMode;
10
+ (function (StrictMode) {
11
+ StrictMode["ON"] = "1";
12
+ StrictMode["OFF"] = "0";
13
+ })(StrictMode = exports.StrictMode || (exports.StrictMode = {}));
14
+ function getConcatenatedName(firstName, lastName, name) {
15
+ return name ?? (firstName && lastName ? `${firstName} ${lastName}` : undefined);
16
+ }
17
+ exports.getConcatenatedName = getConcatenatedName;
18
+ function getApiServerUrl(apiRegion) {
19
+ if (apiRegion == ApiRegions.EU) {
20
+ return 'https://api-eu.mixpanel.com';
21
+ }
22
+ return 'https://api.mixpanel.com';
23
+ }
24
+ exports.getApiServerUrl = getApiServerUrl;
25
+ function getBrowser(userAgent) {
26
+ if (userAgent.includes(' OPR/')) {
27
+ if (userAgent.includes('Mini')) {
28
+ return 'Opera Mini';
29
+ }
30
+ return 'Opera';
31
+ }
32
+ else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {
33
+ return 'BlackBerry';
34
+ }
35
+ else if (userAgent.includes('IEMobile') || userAgent.includes('WPDesktop')) {
36
+ return 'Internet Explorer Mobile';
37
+ }
38
+ else if (userAgent.includes('SamsungBrowser/')) {
39
+ return 'Samsung Internet';
40
+ }
41
+ else if (userAgent.includes('Edge') || userAgent.includes('Edg/')) {
42
+ return 'Microsoft Edge';
43
+ }
44
+ else if (userAgent.includes('FBIOS')) {
45
+ return 'Facebook Mobile';
46
+ }
47
+ else if (userAgent.includes('Chrome')) {
48
+ return 'Chrome';
49
+ }
50
+ else if (userAgent.includes('CriOS')) {
51
+ return 'Chrome iOS';
52
+ }
53
+ else if (userAgent.includes('UCWEB') || userAgent.includes('UCBrowser')) {
54
+ return 'UC Browser';
55
+ }
56
+ else if (userAgent.includes('FxiOS')) {
57
+ return 'Firefox iOS';
58
+ }
59
+ else if (userAgent.includes('Safari')) {
60
+ return 'Safari';
61
+ }
62
+ else if (userAgent.includes('Android')) {
63
+ return 'Android Mobile';
64
+ }
65
+ else if (userAgent.includes('Konqueror')) {
66
+ return 'Konqueror';
67
+ }
68
+ else if (userAgent.includes('Firefox')) {
69
+ return 'Firefox';
70
+ }
71
+ else if (userAgent.includes('MSIE') || userAgent.includes('Trident/')) {
72
+ return 'Internet Explorer';
73
+ }
74
+ else if (userAgent.includes('Gecko')) {
75
+ return 'Mozilla';
76
+ }
77
+ else {
78
+ return '';
79
+ }
80
+ }
81
+ exports.getBrowser = getBrowser;
82
+ function getBrowserVersion(userAgent) {
83
+ const browser = getBrowser(userAgent);
84
+ const versionRegexs = {
85
+ 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
86
+ 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
87
+ Chrome: /Chrome\/(\d+(\.\d+)?)/,
88
+ 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
89
+ 'UC Browser': /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
90
+ Safari: /Version\/(\d+(\.\d+)?)/,
91
+ 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
92
+ Opera: /(Opera|OPR)\/(\d+(\.\d+)?)/,
93
+ Firefox: /Firefox\/(\d+(\.\d+)?)/,
94
+ 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
95
+ Konqueror: /Konqueror:(\d+(\.\d+)?)/,
96
+ BlackBerry: /BlackBerry (\d+(\.\d+)?)/,
97
+ 'Android Mobile': /android\s(\d+(\.\d+)?)/,
98
+ 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
99
+ 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
100
+ Mozilla: /rv:(\d+(\.\d+)?)/
101
+ };
102
+ const regex = versionRegexs[browser];
103
+ if (!regex)
104
+ return regex;
105
+ const matches = regex.exec(userAgent);
106
+ if (!matches) {
107
+ return undefined;
108
+ }
109
+ return matches[matches.length - 2];
110
+ }
111
+ exports.getBrowserVersion = getBrowserVersion;
112
+ function cheapGuid(maxlen) {
113
+ const guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
114
+ return maxlen ? guid.substring(0, maxlen) : guid;
115
+ }
116
+ exports.cheapGuid = cheapGuid;
117
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/destinations/mixpanel/utils.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,gDAAc,CAAA;IACd,gDAAc,CAAA;AAChB,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,sBAAQ,CAAA;IACR,uBAAS,CAAA;AACX,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAED,SAAgB,mBAAmB,CAAC,SAAkB,EAAE,QAAiB,EAAE,IAAa;IACtF,OAAO,IAAI,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AACjF,CAAC;AAFD,kDAEC;AAED,SAAgB,eAAe,CAAC,SAA6B;IAC3D,IAAI,SAAS,IAAI,UAAU,CAAC,EAAE,EAAE;QAC9B,OAAO,6BAA6B,CAAA;KACrC;IACD,OAAO,0BAA0B,CAAA;AACnC,CAAC;AALD,0CAKC;AAED,SAAgB,UAAU,CAAC,SAAiB;IAC1C,IAAI,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QAC/B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YAC9B,OAAO,YAAY,CAAA;SACpB;QACD,OAAO,OAAO,CAAA;KACf;SAAM,IAAI,6BAA6B,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QACxD,OAAO,YAAY,CAAA;KACpB;SAAM,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,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACtG,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClD,CAAC;AAHD,8BAGC"}
@@ -0,0 +1,2 @@
1
+ import { InputField } from '@segment/actions-core';
2
+ export declare const commonFields: Record<string, InputField>;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commonFields = void 0;
4
+ exports.commonFields = {
5
+ event: {
6
+ label: 'Event Name',
7
+ type: 'string',
8
+ required: true,
9
+ description: 'Conversion event name. Please refer to the "Supported Offline Events" section on in TikTok’s [Offline Events API documentation](https://ads.tiktok.com/marketing_api/docs?id=1758053486938113) for accepted event names.'
10
+ },
11
+ event_id: {
12
+ label: 'Event ID',
13
+ type: 'string',
14
+ description: 'A unique value for each event. This ID can be used to match data between partner and TikTok. We suggest it is a String of 32 characters, including numeric digits (0-9), uppercase letters (A-Z), and lowercase letters (a-z).',
15
+ default: {
16
+ '@path': '$.messageId'
17
+ }
18
+ },
19
+ timestamp: {
20
+ label: 'Event Timestamp',
21
+ type: 'string',
22
+ required: true,
23
+ description: 'Timestamp that the event took place, in ISO 8601 format. e.g. 2019-06-12T19:11:01.152Z',
24
+ default: {
25
+ '@path': '$.timestamp'
26
+ }
27
+ },
28
+ phone_numbers: {
29
+ label: 'Phone Numbers',
30
+ description: 'A single phone number or array of phone numbers in E.164 standard format. Segment will hash this value before sending to TikTok. At least one phone number is required if no value is provided in the Emails field.',
31
+ type: 'string',
32
+ multiple: true,
33
+ default: {
34
+ '@if': {
35
+ exists: { '@path': '$.properties.phone' },
36
+ then: { '@path': '$.properties.phone' },
37
+ else: { '@path': '$.traits.phone' }
38
+ }
39
+ }
40
+ },
41
+ email_addresses: {
42
+ label: 'Emails',
43
+ description: 'A single email address or an array of email addresses. Segment will hash this value before sending to TikTok. At least one email is required if no value is provided in the Phone Numbers field.',
44
+ type: 'string',
45
+ multiple: true,
46
+ default: {
47
+ '@if': {
48
+ exists: { '@path': '$.properties.email' },
49
+ then: { '@path': '$.properties.email' },
50
+ else: { '@path': '$.traits.email' }
51
+ }
52
+ }
53
+ },
54
+ order_id: {
55
+ label: 'Order ID',
56
+ type: 'string',
57
+ description: 'The order id',
58
+ default: {
59
+ '@path': '$.properties.order_id'
60
+ }
61
+ },
62
+ shop_id: {
63
+ label: 'Shop ID',
64
+ type: 'string',
65
+ description: 'The shop id',
66
+ default: {
67
+ '@path': '$.properties.shop_id'
68
+ }
69
+ },
70
+ event_channel: {
71
+ label: 'Event channel',
72
+ type: 'string',
73
+ description: 'Event channel of the offline conversion event. Accepted values are: email, website, phone_call, in_store, crm, other. Any other value will be rejected',
74
+ choices: [
75
+ { label: 'Email', value: 'email' },
76
+ { label: 'Website', value: 'website' },
77
+ { label: 'Phone call', value: 'phone_call' },
78
+ { label: 'In store', value: 'in_store' },
79
+ { label: 'CRM', value: 'crm' },
80
+ { label: 'Other', value: 'other' }
81
+ ],
82
+ default: 'in_store'
83
+ }
84
+ };
85
+ //# sourceMappingURL=common_fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common_fields.js","sourceRoot":"","sources":["../../../src/destinations/tiktok-offline-conversions/common_fields.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAA+B;IACtD,KAAK,EAAE;QACL,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,WAAW,EACT,0NAA0N;KAC7N;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,gOAAgO;QAClO,OAAO,EAAE;YACP,OAAO,EAAE,aAAa;SACvB;KACF;IACD,SAAS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EAAE,OAAO,EAAE;YAClC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;YACtC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;YAC5C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;YACxC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;YAC9B,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;SACnC;QACD,OAAO,EAAE,UAAU;KACpB;CACF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const formatEmails: (email_addresses: string[] | undefined) => string[];
2
+ export declare const formatPhones: (phone_numbers: string[] | undefined) => string[];
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPhones = exports.formatEmails = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const formatEmails = (email_addresses) => {
6
+ const result = [];
7
+ if (email_addresses) {
8
+ email_addresses.forEach((email) => {
9
+ result.push(hashAndEncode(email.toLowerCase()));
10
+ });
11
+ }
12
+ return result;
13
+ };
14
+ exports.formatEmails = formatEmails;
15
+ const formatPhones = (phone_numbers) => {
16
+ const result = [];
17
+ if (!phone_numbers)
18
+ return result;
19
+ phone_numbers.forEach((phone) => {
20
+ const validatedPhone = phone.match(/[0-9]{0,14}/g);
21
+ if (validatedPhone === null) {
22
+ throw new Error(`${phone} is not a valid E.164 phone number.`);
23
+ }
24
+ const formattedPhone = `+${phone.replace(/[^0-9]/g, '')}`;
25
+ result.push(hashAndEncode(formattedPhone.substring(0, 15)));
26
+ });
27
+ return result;
28
+ };
29
+ exports.formatPhones = formatPhones;
30
+ function hashAndEncode(property) {
31
+ return crypto_1.createHash('sha256').update(property).digest('hex');
32
+ }
33
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["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,10 @@
1
+ export interface Payload {
2
+ event: string;
3
+ event_id?: string;
4
+ timestamp: string;
5
+ phone_numbers?: string[];
6
+ email_addresses?: string[];
7
+ order_id?: string;
8
+ shop_id?: string;
9
+ event_channel?: string;
10
+ }
@@ -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/tiktok-offline-conversions/trackNonPaymentOfflineConversion/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const common_fields_1 = require("../common_fields");
5
+ const formatter_1 = require("../formatter");
6
+ const action = {
7
+ title: 'Track Non Payment Offline Conversion',
8
+ description: 'Send a non payment related event to the TikTok Offline Conversions API',
9
+ fields: {
10
+ ...common_fields_1.commonFields
11
+ },
12
+ perform: (request, { payload, settings }) => {
13
+ const phone_numbers = formatter_1.formatPhones(payload.phone_numbers);
14
+ const emails = formatter_1.formatEmails(payload.email_addresses);
15
+ if (phone_numbers.length < 1 && emails.length < 1)
16
+ throw new actions_core_1.PayloadValidationError('TikTok Offline Conversions API requires an email address and/or phone number');
17
+ return request('https://business-api.tiktok.com/open_api/v1.3/offline/track/', {
18
+ method: 'post',
19
+ json: {
20
+ event_set_id: settings.eventSetID,
21
+ event: payload.event,
22
+ event_id: payload.event_id ? `${payload.event_id}` : undefined,
23
+ timestamp: payload.timestamp,
24
+ context: {
25
+ user: {
26
+ phone_numbers,
27
+ emails
28
+ }
29
+ },
30
+ properties: {
31
+ order_id: payload.order_id,
32
+ shop_id: payload.shop_id,
33
+ event_channel: payload.event_channel
34
+ },
35
+ partner_name: 'Segment'
36
+ }
37
+ });
38
+ }
39
+ };
40
+ exports.default = action;
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-offline-conversions/trackNonPaymentOfflineConversion/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAGhF,oDAA+C;AAC/C,4CAAyD;AAEzD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,sCAAsC;IAC7C,WAAW,EAAE,wEAAwE;IACrF,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,MAAM,aAAa,GAAG,wBAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QACzD,MAAM,MAAM,GAAG,wBAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QAEpD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAC/C,MAAM,IAAI,qCAAsB,CAAC,8EAA8E,CAAC,CAAA;QAElH,OAAO,OAAO,CAAC,8DAA8D,EAAE;YAC7E,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,YAAY,EAAE,QAAQ,CAAC,UAAU;gBACjC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;gBAC9D,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,aAAa;wBACb,MAAM;qBACP;iBACF;gBACD,UAAU,EAAE;oBACV,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,aAAa,EAAE,OAAO,CAAC,aAAa;iBACrC;gBACD,YAAY,EAAE,SAAS;aACxB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,20 @@
1
+ export interface Payload {
2
+ event: string;
3
+ event_id?: string;
4
+ timestamp?: string;
5
+ phone_numbers?: string[];
6
+ email_addresses?: string[];
7
+ order_id?: string;
8
+ shop_id?: string;
9
+ event_channel?: string;
10
+ contents?: {
11
+ price?: number;
12
+ quantity?: number;
13
+ content_type?: string;
14
+ content_id?: string;
15
+ content_name?: string;
16
+ content_category?: string;
17
+ }[];
18
+ currency: string;
19
+ value: number;
20
+ }
@@ -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/tiktok-offline-conversions/trackPaymentOfflineConversion/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const common_fields_1 = require("../common_fields");
5
+ const formatter_1 = require("../formatter");
6
+ const action = {
7
+ title: 'Track Payment Offline Conversion',
8
+ description: 'Send details of an in-store purchase or console purchase to the Tiktok Offline Events API',
9
+ fields: {
10
+ ...common_fields_1.commonFields,
11
+ timestamp: {
12
+ label: 'Event Timestamp',
13
+ type: 'string',
14
+ description: 'Timestamp that the event took place, in ISO 8601 format. e.g. 2019-06-12T19:11:01.152Z',
15
+ default: {
16
+ '@path': '$.timestamp'
17
+ }
18
+ },
19
+ contents: {
20
+ label: 'Contents',
21
+ type: 'object',
22
+ multiple: true,
23
+ description: 'Array of product or content items for the offline event.',
24
+ properties: {
25
+ price: {
26
+ label: 'Price',
27
+ description: 'Price of the product or content item. Price is a required field for all content items.',
28
+ type: 'number'
29
+ },
30
+ quantity: {
31
+ label: 'Quantity',
32
+ description: 'Quantity of this product ot item in the offline event. Quantity is a required field for all content items.',
33
+ type: 'number'
34
+ },
35
+ content_type: {
36
+ label: 'Content Type',
37
+ description: 'Product type',
38
+ type: 'string'
39
+ },
40
+ content_id: {
41
+ label: 'Content ID',
42
+ description: 'Product or content item identifier. Content ID is a required field for all product or content items.',
43
+ type: 'string'
44
+ },
45
+ content_name: {
46
+ label: 'Content Name',
47
+ description: 'Name of the product or content item.',
48
+ type: 'string'
49
+ },
50
+ content_category: {
51
+ label: 'Content Category',
52
+ description: 'Category of the product or content item.',
53
+ type: 'string'
54
+ }
55
+ },
56
+ default: {
57
+ '@arrayPath': [
58
+ '$.properties.products',
59
+ {
60
+ price: {
61
+ '@path': 'price'
62
+ },
63
+ quantity: {
64
+ '@path': 'quantity'
65
+ },
66
+ content_type: {
67
+ '@path': 'type'
68
+ },
69
+ content_id: {
70
+ '@path': 'product_id'
71
+ },
72
+ content_name: {
73
+ '@path': 'name'
74
+ },
75
+ content_category: {
76
+ '@path': 'category'
77
+ }
78
+ }
79
+ ]
80
+ }
81
+ },
82
+ currency: {
83
+ label: 'Currency',
84
+ type: 'string',
85
+ required: true,
86
+ description: 'ISO 4217 code. Required for revenue reporting. Example: "USD".List of currencies currently supported: AED, ARS, AUD, BDT, BHD, BIF, BOB, BRL, CAD, CHF, CLP, CNY, COP, CRC, CZK, DKK, DZD, EGP, EUR, GBP, GTQ, HKD, HNL, HUF, IDR, ILS, INR, ISK, JPY, KES, KHR, KRW, KWD, KZT, MAD, MOP, MXN, MYR, NGN, NIO, NOK, NZD, OMR, PEN, PHP, PHP, PKR, PLN, PYG, QAR, RON, RUB, SAR, SEK, SGD, THB, TRY, TWD, UAH, USD, VES, VND, ZAR.',
87
+ default: {
88
+ '@path': '$.properties.currency'
89
+ }
90
+ },
91
+ value: {
92
+ label: 'Value',
93
+ type: 'number',
94
+ required: true,
95
+ description: 'Revenue of total products or content items. Required for revenue reporting. Must be a number. e.g. 101.99 and not "101.99 USD"',
96
+ default: {
97
+ '@if': {
98
+ exists: { '@path': '$.properties.value' },
99
+ then: { '@path': '$.properties.value' },
100
+ else: { '@path': '$.properties.revenue' }
101
+ }
102
+ }
103
+ }
104
+ },
105
+ perform: (request, { payload, settings }) => {
106
+ const phone_numbers = formatter_1.formatPhones(payload.phone_numbers);
107
+ const emails = formatter_1.formatEmails(payload.email_addresses);
108
+ if (phone_numbers.length < 1 && emails.length < 1)
109
+ throw new actions_core_1.PayloadValidationError('TikTok Offline Conversions API requires an email address and/or phone number');
110
+ return request('https://business-api.tiktok.com/open_api/v1.3/offline/track/', {
111
+ method: 'post',
112
+ json: {
113
+ event_set_id: settings.eventSetID,
114
+ event: payload.event,
115
+ event_id: payload.event_id ? `${payload.event_id}` : undefined,
116
+ timestamp: payload.timestamp,
117
+ context: {
118
+ user: {
119
+ phone_numbers,
120
+ emails
121
+ }
122
+ },
123
+ properties: {
124
+ order_id: payload.order_id,
125
+ shop_id: payload.shop_id,
126
+ contents: payload.contents,
127
+ currency: payload.currency,
128
+ value: payload.value,
129
+ event_channel: payload.event_channel
130
+ },
131
+ partner_name: 'Segment'
132
+ }
133
+ });
134
+ }
135
+ };
136
+ exports.default = action;
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-offline-conversions/trackPaymentOfflineConversion/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAGhF,oDAA+C;AAC/C,4CAAyD;AAEzD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kCAAkC;IACzC,WAAW,EAAE,2FAA2F;IACxG,MAAM,EAAE;QACN,GAAG,4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ACP,IAAI,EAAE;wBACJ,aAAa;wBACb,MAAM;qBACP;iBACF;gBACD,UAAU,EAAE;oBACV,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,aAAa,EAAE,OAAO,CAAC,aAAa;iBACrC;gBACD,YAAY,EAAE,SAAS;aACxB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,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.333.0-staging.0",
4
+ "version": "3.334.0-staging.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/action-destinations",