@segment/action-destinations 3.172.0 → 3.174.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/acoustic/Utility/eventprocessing.d.ts +1 -5
- package/dist/destinations/acoustic/Utility/eventprocessing.js +66 -62
- package/dist/destinations/acoustic/Utility/eventprocessing.js.map +1 -1
- package/dist/destinations/acoustic/Utility/tablemaintutilities.d.ts +13 -1
- package/dist/destinations/acoustic/Utility/tablemaintutilities.js +108 -59
- package/dist/destinations/acoustic/Utility/tablemaintutilities.js.map +1 -1
- package/dist/destinations/acoustic/generated-types.d.ts +5 -4
- package/dist/destinations/acoustic/index.js +18 -26
- package/dist/destinations/acoustic/index.js.map +1 -1
- package/dist/destinations/acoustic/receiveEvents/generated-types.d.ts +6 -0
- package/dist/destinations/acoustic/receiveEvents/index.js +33 -19
- package/dist/destinations/acoustic/receiveEvents/index.js.map +1 -1
- package/dist/destinations/canny-functions/constants/api.d.ts +1 -0
- package/dist/destinations/canny-functions/constants/api.js +5 -0
- package/dist/destinations/canny-functions/constants/api.js.map +1 -0
- package/dist/destinations/canny-functions/constants/traits.d.ts +2 -0
- package/dist/destinations/canny-functions/constants/traits.js +6 -0
- package/dist/destinations/canny-functions/constants/traits.js.map +1 -0
- package/dist/destinations/canny-functions/generated-types.d.ts +3 -0
- package/dist/destinations/canny-functions/generated-types.js +3 -0
- package/dist/destinations/canny-functions/generated-types.js.map +1 -0
- package/dist/destinations/canny-functions/group/generated-types.d.ts +7 -0
- package/dist/destinations/canny-functions/group/generated-types.js +3 -0
- package/dist/destinations/canny-functions/group/generated-types.js.map +1 -0
- package/dist/destinations/canny-functions/group/index.d.ts +5 -0
- package/dist/destinations/canny-functions/group/index.js +46 -0
- package/dist/destinations/canny-functions/group/index.js.map +1 -0
- package/dist/destinations/canny-functions/identify/generated-types.d.ts +15 -0
- package/dist/destinations/canny-functions/identify/generated-types.js +3 -0
- package/dist/destinations/canny-functions/identify/generated-types.js.map +1 -0
- package/dist/destinations/canny-functions/identify/index.d.ts +5 -0
- package/dist/destinations/canny-functions/identify/index.js +95 -0
- package/dist/destinations/canny-functions/identify/index.js.map +1 -0
- package/dist/destinations/canny-functions/index.d.ts +4 -0
- package/dist/destinations/canny-functions/index.js +60 -0
- package/dist/destinations/canny-functions/index.js.map +1 -0
- package/dist/destinations/heap/trackEvent/index.js +2 -2
- package/dist/destinations/heap/trackEvent/index.js.map +1 -1
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/koala/generated-types.d.ts +3 -0
- package/dist/destinations/koala/generated-types.js +3 -0
- package/dist/destinations/koala/generated-types.js.map +1 -0
- package/dist/destinations/koala/identify/generated-types.d.ts +12 -0
- package/dist/destinations/koala/identify/generated-types.js +3 -0
- package/dist/destinations/koala/identify/generated-types.js.map +1 -0
- package/dist/destinations/koala/identify/index.d.ts +5 -0
- package/dist/destinations/koala/identify/index.js +85 -0
- package/dist/destinations/koala/identify/index.js.map +1 -0
- package/dist/destinations/koala/index.d.ts +5 -0
- package/dist/destinations/koala/index.js +52 -0
- package/dist/destinations/koala/index.js.map +1 -0
- package/dist/destinations/koala/lib/ajs-detection.d.ts +6 -0
- package/dist/destinations/koala/lib/ajs-detection.js +8 -0
- package/dist/destinations/koala/lib/ajs-detection.js.map +1 -0
- package/dist/destinations/koala/track/generated-types.d.ts +16 -0
- package/dist/destinations/koala/track/generated-types.js +3 -0
- package/dist/destinations/koala/track/generated-types.js.map +1 -0
- package/dist/destinations/koala/track/index.d.ts +5 -0
- package/dist/destinations/koala/track/index.js +103 -0
- package/dist/destinations/koala/track/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { RequestClient } from '@segment/actions-core';
|
|
2
|
-
import { Settings } from '../generated-types';
|
|
3
1
|
import { Payload } from '../receiveEvents/generated-types';
|
|
4
|
-
import { AuthTokens } from '@segment/actions-core/src/destination-kit/parse-settings';
|
|
5
2
|
export declare function parseSections(section: {
|
|
6
3
|
[key: string]: string;
|
|
7
4
|
}, nestDepth: number): {
|
|
8
5
|
[key: string]: string;
|
|
9
6
|
};
|
|
10
|
-
export declare function addUpdateEvents(payload: Payload, email: string, limit: number): string
|
|
11
|
-
export declare const postUpdates: (request: RequestClient, settings: Settings, auth: AuthTokens, xmlRows: string, i: number) => Promise<Response>;
|
|
7
|
+
export declare function addUpdateEvents(payload: Payload, email: string, limit: number): string;
|
|
@@ -3,26 +3,30 @@ 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.
|
|
6
|
+
exports.addUpdateEvents = exports.parseSections = void 0;
|
|
7
7
|
const actions_core_1 = require("@segment/actions-core");
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
-
const tablemaintutilities_1 = require("./tablemaintutilities");
|
|
10
9
|
function parseSections(section, nestDepth) {
|
|
11
10
|
const parseResults = {};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
try {
|
|
12
|
+
if (nestDepth > 10)
|
|
13
|
+
throw new actions_core_1.IntegrationError('Event data exceeds nesting depth. Use Mapping to avoid nesting data attributes more than 3 levels deep', 'NESTING_DEPTH_EXCEEDED', 400);
|
|
14
|
+
for (const key of Object.keys(section)) {
|
|
15
|
+
if (typeof section[key] === 'object') {
|
|
16
|
+
nestDepth++;
|
|
17
|
+
const nested = parseSections(section[key], nestDepth);
|
|
18
|
+
for (const nestedKey of Object.keys(nested)) {
|
|
19
|
+
parseResults[`${key}.${nestedKey}`] = nested[nestedKey];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
parseResults[key] = section[key];
|
|
20
24
|
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
parseResults[key] = section[key];
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new actions_core_1.IntegrationError(`Unexpected Exception while parsing Event payload.\n ${e}`, 'UNEXPECTED_EVENT_PARSING_EXCEPTION', 400);
|
|
29
|
+
}
|
|
26
30
|
return parseResults;
|
|
27
31
|
}
|
|
28
32
|
exports.parseSections = parseSections;
|
|
@@ -33,32 +37,57 @@ function addUpdateEvents(payload, email, limit) {
|
|
|
33
37
|
const eventSource = get_1.default(payload, 'type', 'Null') + ' Event';
|
|
34
38
|
const timestamp = get_1.default(payload, 'timestamp', 'Null');
|
|
35
39
|
let propertiesTraitsKV = {};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
try {
|
|
41
|
+
if (payload.key_value_pairs)
|
|
42
|
+
propertiesTraitsKV = {
|
|
43
|
+
...propertiesTraitsKV,
|
|
44
|
+
...parseSections(payload.key_value_pairs, 0)
|
|
45
|
+
};
|
|
46
|
+
if (payload.array_data)
|
|
47
|
+
propertiesTraitsKV = {
|
|
48
|
+
...propertiesTraitsKV,
|
|
49
|
+
...parseSections(payload.array_data, 0)
|
|
50
|
+
};
|
|
51
|
+
if (payload.traits)
|
|
52
|
+
propertiesTraitsKV = {
|
|
53
|
+
...propertiesTraitsKV,
|
|
54
|
+
...parseSections(payload.traits, 0)
|
|
55
|
+
};
|
|
56
|
+
if (payload.properties)
|
|
57
|
+
propertiesTraitsKV = {
|
|
58
|
+
...propertiesTraitsKV,
|
|
59
|
+
...parseSections(payload.properties, 0)
|
|
60
|
+
};
|
|
61
|
+
if (payload.context)
|
|
62
|
+
propertiesTraitsKV = {
|
|
63
|
+
...propertiesTraitsKV,
|
|
64
|
+
...parseSections(payload.context, 0)
|
|
65
|
+
};
|
|
66
|
+
if (Object.keys(propertiesTraitsKV).length > limit) {
|
|
67
|
+
throw new actions_core_1.IntegrationError('Properties Exceed Max. Use Mapping to limit the number of Attributes (Properties, Traits) present and thereby reduce the Campaign Relational Table Rows consumed.', 'EXCEEDS_MAX_PROPERTIES_MAX', 400);
|
|
68
|
+
}
|
|
54
69
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
catch (e) {
|
|
71
|
+
throw new actions_core_1.IntegrationError('Unexpected Exception processing payload \n ${e}', 'UNEXPECTED_EXCEPTION_PROCESSING_PAYLOAD', 400);
|
|
72
|
+
}
|
|
73
|
+
let ak = '';
|
|
74
|
+
let av = '';
|
|
75
|
+
const getValue = (o, part) => Object.entries(o).find(([k, _v]) => k.includes(part))?.[1];
|
|
76
|
+
if (getValue(propertiesTraitsKV, 'computation_class')) {
|
|
77
|
+
ak = getValue(propertiesTraitsKV, 'computation_key');
|
|
78
|
+
av = getValue(propertiesTraitsKV, `${ak}`);
|
|
79
|
+
}
|
|
80
|
+
if (getValue(propertiesTraitsKV, 'audience_key')) {
|
|
81
|
+
ak = getValue(propertiesTraitsKV, 'audience_key');
|
|
82
|
+
av = getValue(propertiesTraitsKV, `${ak}`);
|
|
83
|
+
}
|
|
84
|
+
if (av !== '') {
|
|
85
|
+
let audiStatus = av;
|
|
86
|
+
eventValue = audiStatus;
|
|
87
|
+
audiStatus = audiStatus.toString().toLowerCase();
|
|
88
|
+
if (audiStatus === 'true')
|
|
60
89
|
eventValue = 'Audience Entered';
|
|
61
|
-
if (
|
|
90
|
+
if (audiStatus === 'false')
|
|
62
91
|
eventValue = 'Audience Exited';
|
|
63
92
|
eventName = ak;
|
|
64
93
|
xmlRows += `
|
|
@@ -85,29 +114,4 @@ function addUpdateEvents(payload, email, limit) {
|
|
|
85
114
|
return xmlRows;
|
|
86
115
|
}
|
|
87
116
|
exports.addUpdateEvents = addUpdateEvents;
|
|
88
|
-
const postUpdates = async (request, settings, auth, xmlRows, i) => {
|
|
89
|
-
const pup = await request(`https://api-campaign-${settings.a_region}-${settings.a_pod}.goacoustic.com/XMLAPI`, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers: {
|
|
92
|
-
Authorization: `Bearer ${auth?.accessToken}`,
|
|
93
|
-
'Content-Type': 'text/xml',
|
|
94
|
-
'user-agent': `Segment Action (Acoustic Destination) ${i}`,
|
|
95
|
-
Connection: 'keep-alive',
|
|
96
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
97
|
-
Accept: '*/*'
|
|
98
|
-
},
|
|
99
|
-
body: `<Envelope>
|
|
100
|
-
<Body>
|
|
101
|
-
<InsertUpdateRelationalTable>
|
|
102
|
-
<TABLE_ID>${tablemaintutilities_1.eventTableListId} </TABLE_ID>
|
|
103
|
-
<ROWS>
|
|
104
|
-
${xmlRows}
|
|
105
|
-
</ROWS>
|
|
106
|
-
</InsertUpdateRelationalTable>
|
|
107
|
-
</Body>
|
|
108
|
-
</Envelope>`
|
|
109
|
-
});
|
|
110
|
-
return pup;
|
|
111
|
-
};
|
|
112
|
-
exports.postUpdates = postUpdates;
|
|
113
117
|
//# sourceMappingURL=eventprocessing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventprocessing.js","sourceRoot":"","sources":["../../../../src/destinations/acoustic/Utility/eventprocessing.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAwD;
|
|
1
|
+
{"version":3,"file":"eventprocessing.js","sourceRoot":"","sources":["../../../../src/destinations/acoustic/Utility/eventprocessing.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAwD;AACxD,qDAA4B;AAG5B,SAAgB,aAAa,CAAC,OAAkC,EAAE,SAAiB;IACjF,MAAM,YAAY,GAA8B,EAAE,CAAA;IAClD,IAAI;QAEF,IAAI,SAAS,GAA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ment/actions-core';
|
|
1
2
|
import { RequestClient } from '@segment/actions-core';
|
|
2
3
|
import { Settings } from '../generated-types';
|
|
3
4
|
import { AuthTokens } from '@segment/actions-core/src/destination-kit/parse-settings';
|
|
4
5
|
export declare let eventTableListId: string;
|
|
6
|
+
export interface accessResp {
|
|
7
|
+
access_token: string;
|
|
8
|
+
token_type: string;
|
|
9
|
+
refresh_token: string;
|
|
10
|
+
expires_in: number;
|
|
11
|
+
}
|
|
12
|
+
export declare let authCreds: OAuth2ClientCredentials;
|
|
13
|
+
export declare function getAuthCreds(): OAuth2ClientCredentials;
|
|
14
|
+
export declare function getEventTableListId(): string;
|
|
15
|
+
export declare function getAccessToken(request: RequestClient, settings: Settings): Promise<RefreshAccessTokenResult>;
|
|
16
|
+
export declare function doPOST(request: RequestClient, settings: Settings, auth: AuthTokens, body: string, action: string): Promise<string>;
|
|
5
17
|
export declare function preChecksAndMaint(request: RequestClient, settings: Settings, auth: AuthTokens): Promise<string>;
|
|
6
18
|
export declare function checkRTExist(request: RequestClient, settings: Settings, auth: AuthTokens): Promise<string>;
|
|
7
|
-
export declare function createSegmentEventsTable(request: RequestClient, settings: Settings, auth: AuthTokens): Promise<
|
|
19
|
+
export declare function createSegmentEventsTable(request: RequestClient, settings: Settings, auth: AuthTokens): Promise<string>;
|
|
@@ -1,8 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSegmentEventsTable = exports.checkRTExist = exports.preChecksAndMaint = exports.eventTableListId = void 0;
|
|
3
|
+
exports.createSegmentEventsTable = exports.checkRTExist = exports.preChecksAndMaint = exports.doPOST = exports.getAccessToken = exports.getEventTableListId = exports.getAuthCreds = exports.authCreds = exports.eventTableListId = void 0;
|
|
4
4
|
const actions_core_1 = require("@segment/actions-core");
|
|
5
5
|
exports.eventTableListId = '';
|
|
6
|
+
exports.authCreds = {
|
|
7
|
+
accessToken: '',
|
|
8
|
+
clientId: '',
|
|
9
|
+
clientSecret: '',
|
|
10
|
+
refreshToken: '',
|
|
11
|
+
refreshTokenUrl: ''
|
|
12
|
+
};
|
|
13
|
+
function getAuthCreds() {
|
|
14
|
+
return exports.authCreds;
|
|
15
|
+
}
|
|
16
|
+
exports.getAuthCreds = getAuthCreds;
|
|
17
|
+
function getEventTableListId() {
|
|
18
|
+
return exports.eventTableListId;
|
|
19
|
+
}
|
|
20
|
+
exports.getEventTableListId = getEventTableListId;
|
|
21
|
+
async function getAccessToken(request, settings) {
|
|
22
|
+
exports.authCreds = getAuthCreds();
|
|
23
|
+
exports.authCreds.accessToken = '';
|
|
24
|
+
exports.authCreds.clientId = settings.a_clientId;
|
|
25
|
+
exports.authCreds.clientSecret = settings.a_clientSecret;
|
|
26
|
+
exports.authCreds.refreshToken = settings.a_refreshToken;
|
|
27
|
+
exports.authCreds.refreshTokenUrl = `https://api-campaign-${settings.region}-${settings.pod}.goacoustic.com/oauth/token`;
|
|
28
|
+
const requestAToken = await request(exports.authCreds.refreshTokenUrl, {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
body: new URLSearchParams({
|
|
31
|
+
refresh_token: exports.authCreds.refreshToken,
|
|
32
|
+
client_id: exports.authCreds.clientId,
|
|
33
|
+
client_secret: exports.authCreds.clientSecret,
|
|
34
|
+
grant_type: 'refresh_token'
|
|
35
|
+
}),
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
38
|
+
'User-Agent': 'Segment Action (Acoustic Destination) "GetAccessToken"'
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const ratResp = (await requestAToken.data);
|
|
42
|
+
exports.authCreds.accessToken = ratResp.access_token;
|
|
43
|
+
return { accessToken: exports.authCreds.accessToken, refreshToken: exports.authCreds.refreshToken };
|
|
44
|
+
}
|
|
45
|
+
exports.getAccessToken = getAccessToken;
|
|
46
|
+
async function doPOST(request, settings, auth, body, action) {
|
|
47
|
+
if (!auth.accessToken) {
|
|
48
|
+
if (!exports.authCreds.accessToken) {
|
|
49
|
+
const ratr = await getAccessToken(request, settings);
|
|
50
|
+
auth = {
|
|
51
|
+
accessToken: ratr.accessToken,
|
|
52
|
+
refreshToken: ratr.refreshToken,
|
|
53
|
+
refreshTokenURL: `https://api-campaign-${settings.region}-${settings.pod}.goacoustic.com/XMLAPI`
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
auth.accessToken = exports.authCreds.accessToken;
|
|
58
|
+
}
|
|
59
|
+
let resultTxt = '';
|
|
60
|
+
try {
|
|
61
|
+
const postResults = await request(`https://api-campaign-${settings.region}-${settings.pod}.goacoustic.com/XMLAPI`, {
|
|
62
|
+
method: 'POST',
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: `Bearer ${auth?.accessToken}`,
|
|
65
|
+
'Content-Type': 'text/xml',
|
|
66
|
+
'user-agent': `Segment Action (Acoustic Destination) ${action}`,
|
|
67
|
+
Connection: 'keep-alive',
|
|
68
|
+
'Accept-Encoding': 'gzip, deflate, br',
|
|
69
|
+
Accept: '*/*'
|
|
70
|
+
},
|
|
71
|
+
body: `${body}`
|
|
72
|
+
});
|
|
73
|
+
const res = await postResults.data;
|
|
74
|
+
resultTxt = res;
|
|
75
|
+
if (resultTxt.indexOf('<SUCCESS>FALSE</SUCCESS>') > -1 || resultTxt.indexOf('<SUCCESS>false</SUCCESS>') > -1) {
|
|
76
|
+
const rx = /<FaultString>(.*)<\/FaultString>/gm;
|
|
77
|
+
const r = rx.exec(resultTxt);
|
|
78
|
+
if (r.indexOf('max number of concurrent') > -1)
|
|
79
|
+
throw new actions_core_1.RetryableError('Currently exceeding Max number of concurrent authenticated requests via API, retrying', 429);
|
|
80
|
+
resultTxt = '';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
throw new actions_core_1.IntegrationError(`Unexpected Request Exception \n${e}`, 'UNEXPECTED_REQUEST_EXCEPTION', 400);
|
|
85
|
+
}
|
|
86
|
+
return resultTxt;
|
|
87
|
+
}
|
|
88
|
+
exports.doPOST = doPOST;
|
|
6
89
|
async function preChecksAndMaint(request, settings, auth) {
|
|
7
90
|
exports.eventTableListId = await checkRTExist(request, settings, auth);
|
|
8
91
|
if (exports.eventTableListId === '') {
|
|
@@ -15,24 +98,13 @@ async function preChecksAndMaint(request, settings, auth) {
|
|
|
15
98
|
}
|
|
16
99
|
exports.preChecksAndMaint = preChecksAndMaint;
|
|
17
100
|
async function checkRTExist(request, settings, auth) {
|
|
18
|
-
if (settings.
|
|
19
|
-
const
|
|
20
|
-
method: 'POST',
|
|
21
|
-
headers: {
|
|
22
|
-
Authorization: `Bearer ${auth?.accessToken}`,
|
|
23
|
-
'Content-Type': 'text/xml',
|
|
24
|
-
'user-agent': `Segment Action (Acoustic Destination)`,
|
|
25
|
-
Connection: 'keep-alive',
|
|
26
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
27
|
-
Accept: '*/*'
|
|
28
|
-
},
|
|
29
|
-
body: `
|
|
101
|
+
if (settings.tableListId != '') {
|
|
102
|
+
const checkDefinedTableId = `
|
|
30
103
|
<Envelope> <Body>
|
|
31
|
-
<GetListMetaData> <LIST_ID>${settings.
|
|
104
|
+
<GetListMetaData> <LIST_ID>${settings.tableListId}</LIST_ID>
|
|
32
105
|
</GetListMetaData> </Body>
|
|
33
|
-
</Envelope
|
|
34
|
-
|
|
35
|
-
const respText = await chkListId.text();
|
|
106
|
+
</Envelope>`;
|
|
107
|
+
const respText = (await doPOST(request, settings, auth, checkDefinedTableId, 'CheckDefinedTable')) ?? '';
|
|
36
108
|
const rx = /<SUCCESS>TRUE<\/SUCCESS>(?:\s)*<ID>(.*)<\/ID/gm;
|
|
37
109
|
if (respText != null) {
|
|
38
110
|
const r = rx.exec(respText);
|
|
@@ -43,28 +115,17 @@ async function checkRTExist(request, settings, auth) {
|
|
|
43
115
|
}
|
|
44
116
|
}
|
|
45
117
|
else {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<Body>
|
|
58
|
-
<GetLists>
|
|
59
|
-
<VISIBILITY>1 </VISIBILITY>
|
|
60
|
-
<LIST_TYPE> 15 </LIST_TYPE>
|
|
61
|
-
<INCLUDE_ALL_LISTS> True </INCLUDE_ALL_LISTS>
|
|
62
|
-
</GetLists>
|
|
63
|
-
</Body>
|
|
64
|
-
</Envelope>`
|
|
65
|
-
});
|
|
66
|
-
await chkExist.data;
|
|
67
|
-
const lists = chkExist.content;
|
|
118
|
+
const getTableList = `<Envelope>
|
|
119
|
+
<Body>
|
|
120
|
+
<GetLists>
|
|
121
|
+
<VISIBILITY>1 </VISIBILITY>
|
|
122
|
+
<LIST_TYPE> 15 </LIST_TYPE>
|
|
123
|
+
<INCLUDE_ALL_LISTS> True </INCLUDE_ALL_LISTS>
|
|
124
|
+
</GetLists>
|
|
125
|
+
</Body>
|
|
126
|
+
</Envelope>`;
|
|
127
|
+
const respText = (await doPOST(request, settings, auth, getTableList, 'GetTableList')) ?? '';
|
|
128
|
+
const lists = respText;
|
|
68
129
|
if (lists.indexOf('Segment Events Table') > 0) {
|
|
69
130
|
const simplify = lists.substring(lists.indexOf('Segment Events Table') - 40, lists.indexOf('Segment Events Table') + 40);
|
|
70
131
|
const rx = /<ID>(.*)<\/ID>/gm;
|
|
@@ -80,13 +141,13 @@ async function checkRTExist(request, settings, auth) {
|
|
|
80
141
|
}
|
|
81
142
|
exports.checkRTExist = checkRTExist;
|
|
82
143
|
async function createSegmentEventsTable(request, settings, auth) {
|
|
83
|
-
const
|
|
144
|
+
const createSET = `<Envelope>
|
|
84
145
|
<Body>
|
|
85
146
|
<CreateTable>
|
|
86
|
-
<TABLE_NAME
|
|
147
|
+
<TABLE_NAME>${settings.tableName}</TABLE_NAME>
|
|
87
148
|
<COLUMNS>
|
|
88
149
|
<COLUMN>
|
|
89
|
-
<NAME>
|
|
150
|
+
<NAME>EmailId</NAME>
|
|
90
151
|
<TYPE>EMAIL</TYPE>
|
|
91
152
|
<IS_REQUIRED>true</IS_REQUIRED>
|
|
92
153
|
<KEY_COLUMN>TRUE</KEY_COLUMN>
|
|
@@ -110,7 +171,7 @@ async function createSegmentEventsTable(request, settings, auth) {
|
|
|
110
171
|
<KEY_COLUMN>FALSE</KEY_COLUMN>
|
|
111
172
|
</COLUMN>
|
|
112
173
|
<COLUMN>
|
|
113
|
-
<NAME>
|
|
174
|
+
<NAME>EventTimestamp</NAME>
|
|
114
175
|
<TYPE>DATE_TIME</TYPE>
|
|
115
176
|
<IS_REQUIRED>TRUE</IS_REQUIRED>
|
|
116
177
|
<KEY_COLUMN>FALSE</KEY_COLUMN>
|
|
@@ -119,28 +180,16 @@ async function createSegmentEventsTable(request, settings, auth) {
|
|
|
119
180
|
</CreateTable>
|
|
120
181
|
</Body>
|
|
121
182
|
</Envelope>`;
|
|
122
|
-
const
|
|
123
|
-
method: 'POST',
|
|
124
|
-
headers: {
|
|
125
|
-
Authorization: `Bearer ${auth?.accessToken}`,
|
|
126
|
-
'Content-Type': 'text/xml',
|
|
127
|
-
'user-agent': `Segment Action (Acoustic Destination)`,
|
|
128
|
-
Connection: 'keep-alive',
|
|
129
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
130
|
-
Accept: '*/*'
|
|
131
|
-
},
|
|
132
|
-
body: createEventsXML
|
|
133
|
-
});
|
|
134
|
-
const respText = await createSegmentEventsTable.text();
|
|
183
|
+
const cset = (await doPOST(request, settings, auth, createSET, 'CreateSegmentEventsTable')) ?? '';
|
|
135
184
|
const rx = /<SUCCESS>TRUE<\/SUCCESS>(?:\s)*<TABLE_ID>(.*)<\/TABLE_ID/gm;
|
|
136
185
|
let tid = '';
|
|
137
|
-
if (
|
|
138
|
-
const r = rx.exec(
|
|
186
|
+
if (cset != null) {
|
|
187
|
+
const r = rx.exec(cset);
|
|
139
188
|
if (r)
|
|
140
189
|
tid = r[1];
|
|
141
190
|
}
|
|
142
191
|
exports.eventTableListId = tid;
|
|
143
|
-
return
|
|
192
|
+
return exports.eventTableListId;
|
|
144
193
|
}
|
|
145
194
|
exports.createSegmentEventsTable = createSegmentEventsTable;
|
|
146
195
|
//# sourceMappingURL=tablemaintutilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tablemaintutilities.js","sourceRoot":"","sources":["../../../../src/destinations/acoustic/Utility/tablemaintutilities.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"tablemaintutilities.js","sourceRoot":"","sources":["../../../../src/destinations/acoustic/Utility/tablemaintutilities.ts"],"names":[],"mappings":";;;AAAA,wDAK8B;AAKnB,QAAA,gBAAgB,GAAG,EAAE,CAAA;AAOrB,QAAA,SAAS,GAAG;IACrB,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE;CACO,CAAA;AAuB5B,SAAgB,YAAY;IAC1B,OAAO,iBAAS,CAAA;AAClB,CAAC;AAFD,oCAEC;AAED,SAAgB,mBAAmB;IACjC,OAAO,wBAAgB,CAAA;AACzB,CAAC;AAFD,kDAEC;AAEM,KAAK,UAAU,cAAc,CAClC,OAAsB,EACtB,QAAkB;IAGlB,iBAAS,GAAG,YAAY,EAAE,CAAA;IAC1B,iBAAS,CAAC,WAAW,GAAG,EAAE,CAAA;IAC1B,iBAAS,CAAC,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAA;IACxC,iBAAS,CAAC,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAA;IAChD,iBAAS,CAAC,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAA;IAChD,iBAAS,CAAC,eAAe,GAAG,wBAAwB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,GAAG,6BAA6B,CAAA;IAEhH,MAAM,aAAa,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ableName: string;
|
|
5
|
+
tableListId: string;
|
|
5
6
|
a_clientId: string;
|
|
6
7
|
a_clientSecret: string;
|
|
7
8
|
a_refreshToken: string;
|
|
8
|
-
|
|
9
|
+
attributesMax?: number;
|
|
9
10
|
}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const actions_core_1 = require("@segment/actions-core");
|
|
7
7
|
const receiveEvents_1 = __importDefault(require("./receiveEvents"));
|
|
8
|
+
const tablemaintutilities_1 = require("./Utility/tablemaintutilities");
|
|
8
9
|
const presets = [
|
|
9
10
|
{
|
|
10
11
|
name: 'Track Calls',
|
|
@@ -44,14 +45,14 @@ const destination = {
|
|
|
44
45
|
authentication: {
|
|
45
46
|
scheme: 'oauth2',
|
|
46
47
|
fields: {
|
|
47
|
-
|
|
48
|
+
pod: {
|
|
48
49
|
label: 'Pod',
|
|
49
50
|
description: 'Pod Number of Campaign Instance',
|
|
50
51
|
default: '2',
|
|
51
52
|
type: 'string',
|
|
52
53
|
required: true
|
|
53
54
|
},
|
|
54
|
-
|
|
55
|
+
region: {
|
|
55
56
|
label: 'Region',
|
|
56
57
|
description: 'Region where Pod is hosted, either US, EU, AP, or CA',
|
|
57
58
|
choices: [
|
|
@@ -64,12 +65,19 @@ const destination = {
|
|
|
64
65
|
type: 'string',
|
|
65
66
|
required: true
|
|
66
67
|
},
|
|
67
|
-
|
|
68
|
-
label: 'Acoustic Segment
|
|
69
|
-
description: 'The Segment
|
|
70
|
-
default: '',
|
|
68
|
+
tableName: {
|
|
69
|
+
label: 'Acoustic Segment Table Name',
|
|
70
|
+
description: 'The Segment Table Name in Acoustic Campaign Data dialog.',
|
|
71
|
+
default: 'Segment Events Table',
|
|
71
72
|
type: 'string',
|
|
72
|
-
required:
|
|
73
|
+
required: true
|
|
74
|
+
},
|
|
75
|
+
tableListId: {
|
|
76
|
+
label: 'Acoustic Segment Table List Id',
|
|
77
|
+
description: 'The Segment Table List Id from the Database-Relational Table dialog in Acoustic Campaign',
|
|
78
|
+
default: ' ',
|
|
79
|
+
type: 'string',
|
|
80
|
+
required: true
|
|
73
81
|
},
|
|
74
82
|
a_clientId: {
|
|
75
83
|
label: 'Acoustic app definition ClientId',
|
|
@@ -92,32 +100,16 @@ const destination = {
|
|
|
92
100
|
type: 'password',
|
|
93
101
|
required: true
|
|
94
102
|
},
|
|
95
|
-
|
|
103
|
+
attributesMax: {
|
|
96
104
|
label: 'Properties Max',
|
|
97
|
-
description: 'Note: Before increasing the default max number, consult the Acoustic Destination documentation.',
|
|
105
|
+
description: 'A safety against mapping too many attributes into the Event, ignore Event if number of Event Attributes exceeds this maximum. Note: Before increasing the default max number, consult the Acoustic Destination documentation.',
|
|
98
106
|
default: 30,
|
|
99
107
|
type: 'number',
|
|
100
108
|
required: false
|
|
101
109
|
}
|
|
102
110
|
},
|
|
103
111
|
refreshAccessToken: async (request, { settings }) => {
|
|
104
|
-
|
|
105
|
-
method: 'POST',
|
|
106
|
-
body: new URLSearchParams({
|
|
107
|
-
refresh_token: settings.a_refreshToken,
|
|
108
|
-
client_id: settings.a_clientId,
|
|
109
|
-
client_secret: settings.a_clientSecret,
|
|
110
|
-
grant_type: 'refresh_token'
|
|
111
|
-
}),
|
|
112
|
-
headers: {
|
|
113
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
114
|
-
'user-agent': `Segment Action (Acoustic Destination)`,
|
|
115
|
-
Connection: 'keep-alive',
|
|
116
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
117
|
-
Accept: '*/*'
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
return { accessToken: at.data.access_token };
|
|
112
|
+
return await tablemaintutilities_1.getAccessToken(request, settings);
|
|
121
113
|
}
|
|
122
114
|
},
|
|
123
115
|
presets,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/acoustic/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4E;AAE5E,oEAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/acoustic/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4E;AAE5E,oEAA2C;AAC3C,uEAA8D;AAW9D,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,eAAe;QAC9B,OAAO,EAAE;YACP,GAAG,4BAAa,CAAC,uBAAa,CAAC,MAAM,CAAC;YACtC,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;oBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;oBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;iBAC5C;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,mBAAmB;QAC9B,aAAa,EAAE,eAAe;QAC9B,OAAO,EAAE;YACP,GAAG,4BAAa,CAAC,uBAAa,CAAC,MAAM,CAAC;YACtC,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE;oBACrC,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE;oBACnC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;iBAC5C;aACF;SACF;KACF;CACF,CAAA;AAED,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,GAAG,EAAE;gBACH,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,iCAAiC;gBAC9C,OAAO,EAAE,GAAG;gBACZ,IAAI,EAAE,QAAQ;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