@segment/action-destinations 3.148.1-optimizely-experimentation.9 → 3.148.1-optimizely-lrucache.13
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/customerio/createUpdateObject/index.js +6 -1
- package/dist/destinations/customerio/createUpdateObject/index.js.map +1 -1
- package/dist/destinations/customerio/createUpdatePerson/index.js +8 -1
- package/dist/destinations/customerio/createUpdatePerson/index.js.map +1 -1
- package/dist/destinations/index.js +1 -1
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/insider/cartViewedEvent/generated-types.d.ts +44 -0
- package/dist/destinations/insider/cartViewedEvent/generated-types.js +3 -0
- package/dist/destinations/insider/cartViewedEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/cartViewedEvent/index.d.ts +5 -0
- package/dist/destinations/insider/cartViewedEvent/index.js +27 -0
- package/dist/destinations/insider/cartViewedEvent/index.js.map +1 -0
- package/dist/destinations/insider/checkoutEvent/generated-types.d.ts +44 -0
- package/dist/destinations/insider/checkoutEvent/generated-types.js +3 -0
- package/dist/destinations/insider/checkoutEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/checkoutEvent/index.d.ts +5 -0
- package/dist/destinations/insider/checkoutEvent/index.js +27 -0
- package/dist/destinations/insider/checkoutEvent/index.js.map +1 -0
- package/dist/destinations/insider/generated-types.d.ts +4 -0
- package/dist/destinations/insider/generated-types.js +3 -0
- package/dist/destinations/insider/generated-types.js.map +1 -0
- package/dist/destinations/insider/index.d.ts +4 -0
- package/dist/destinations/insider/index.js +66 -0
- package/dist/destinations/insider/index.js.map +1 -0
- package/dist/destinations/insider/insider-helpers.d.ts +57 -0
- package/dist/destinations/insider/insider-helpers.js +153 -0
- package/dist/destinations/insider/insider-helpers.js.map +1 -0
- package/dist/destinations/insider/insider-properties.d.ts +13 -0
- package/dist/destinations/insider/insider-properties.js +456 -0
- package/dist/destinations/insider/insider-properties.js.map +1 -0
- package/dist/destinations/insider/orderCompletedEvent/generated-types.d.ts +44 -0
- package/dist/destinations/insider/orderCompletedEvent/generated-types.js +3 -0
- package/dist/destinations/insider/orderCompletedEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/orderCompletedEvent/index.d.ts +5 -0
- package/dist/destinations/insider/orderCompletedEvent/index.js +27 -0
- package/dist/destinations/insider/orderCompletedEvent/index.js.map +1 -0
- package/dist/destinations/insider/productAddedEvent/generated-types.d.ts +41 -0
- package/dist/destinations/insider/productAddedEvent/generated-types.js +3 -0
- package/dist/destinations/insider/productAddedEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/productAddedEvent/index.d.ts +5 -0
- package/dist/destinations/insider/productAddedEvent/index.js +39 -0
- package/dist/destinations/insider/productAddedEvent/index.js.map +1 -0
- package/dist/destinations/insider/productListViewedEvent/generated-types.d.ts +34 -0
- package/dist/destinations/insider/productListViewedEvent/generated-types.js +3 -0
- package/dist/destinations/insider/productListViewedEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/productListViewedEvent/index.d.ts +5 -0
- package/dist/destinations/insider/productListViewedEvent/index.js +26 -0
- package/dist/destinations/insider/productListViewedEvent/index.js.map +1 -0
- package/dist/destinations/insider/productRemovedEvent/generated-types.d.ts +41 -0
- package/dist/destinations/insider/productRemovedEvent/generated-types.js +3 -0
- package/dist/destinations/insider/productRemovedEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/productRemovedEvent/index.d.ts +5 -0
- package/dist/destinations/insider/productRemovedEvent/index.js +39 -0
- package/dist/destinations/insider/productRemovedEvent/index.js.map +1 -0
- package/dist/destinations/insider/productViewedEvent/generated-types.d.ts +41 -0
- package/dist/destinations/insider/productViewedEvent/generated-types.js +3 -0
- package/dist/destinations/insider/productViewedEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/productViewedEvent/index.d.ts +5 -0
- package/dist/destinations/insider/productViewedEvent/index.js +39 -0
- package/dist/destinations/insider/productViewedEvent/index.js.map +1 -0
- package/dist/destinations/insider/trackEvent/generated-types.d.ts +56 -0
- package/dist/destinations/insider/trackEvent/generated-types.js +3 -0
- package/dist/destinations/insider/trackEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/trackEvent/index.d.ts +5 -0
- package/dist/destinations/insider/trackEvent/index.js +28 -0
- package/dist/destinations/insider/trackEvent/index.js.map +1 -0
- package/dist/destinations/insider/updateUserProfile/generated-types.d.ts +19 -0
- package/dist/destinations/insider/updateUserProfile/generated-types.js +3 -0
- package/dist/destinations/insider/updateUserProfile/generated-types.js.map +1 -0
- package/dist/destinations/insider/updateUserProfile/index.d.ts +5 -0
- package/dist/destinations/insider/updateUserProfile/index.js +141 -0
- package/dist/destinations/insider/updateUserProfile/index.js.map +1 -0
- package/dist/destinations/insider/userRegisteredEvent/generated-types.d.ts +28 -0
- package/dist/destinations/insider/userRegisteredEvent/generated-types.js +3 -0
- package/dist/destinations/insider/userRegisteredEvent/generated-types.js.map +1 -0
- package/dist/destinations/insider/userRegisteredEvent/index.d.ts +5 -0
- package/dist/destinations/insider/userRegisteredEvent/index.js +25 -0
- package/dist/destinations/insider/userRegisteredEvent/index.js.map +1 -0
- package/dist/destinations/insider-audiences/generated-types.d.ts +4 -0
- package/dist/destinations/insider-audiences/generated-types.js +3 -0
- package/dist/destinations/insider-audiences/generated-types.js.map +1 -0
- package/dist/destinations/insider-audiences/index.d.ts +4 -0
- package/dist/destinations/insider-audiences/index.js +47 -0
- package/dist/destinations/insider-audiences/index.js.map +1 -0
- package/dist/destinations/insider-audiences/insider-helpers.d.ts +6 -0
- package/dist/destinations/insider-audiences/insider-helpers.js +179 -0
- package/dist/destinations/insider-audiences/insider-helpers.js.map +1 -0
- package/dist/destinations/insider-audiences/insiderAudiences/generated-types.d.ts +14 -0
- package/dist/destinations/insider-audiences/insiderAudiences/generated-types.js +3 -0
- package/dist/destinations/insider-audiences/insiderAudiences/generated-types.js.map +1 -0
- package/dist/destinations/insider-audiences/insiderAudiences/index.d.ts +5 -0
- package/dist/destinations/insider-audiences/insiderAudiences/index.js +123 -0
- package/dist/destinations/insider-audiences/insiderAudiences/index.js.map +1 -0
- package/dist/destinations/optimizely-feature-experimentation-actions/generated-types.d.ts +1 -0
- package/dist/destinations/optimizely-feature-experimentation-actions/index.js +10 -3
- package/dist/destinations/optimizely-feature-experimentation-actions/index.js.map +1 -1
- package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.d.ts +17 -3
- package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.js +75 -1
- package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.js.map +1 -1
- package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/index.js +4 -6
- package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/index.js.map +1 -1
- package/dist/destinations/optimizely-feature-experimentation-actions/types.d.ts +5 -0
- package/dist/destinations/optimizely-feature-experimentation-actions/utils.d.ts +5 -0
- package/dist/destinations/optimizely-feature-experimentation-actions/utils.js +10 -0
- package/dist/destinations/optimizely-feature-experimentation-actions/utils.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/insider-audiences/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 insiderAudiences_1 = __importDefault(require("./insiderAudiences"));
|
|
8
|
+
const destination = {
|
|
9
|
+
name: 'Insider Audiences',
|
|
10
|
+
slug: 'actions-insider-audiences',
|
|
11
|
+
mode: 'cloud',
|
|
12
|
+
authentication: {
|
|
13
|
+
scheme: 'custom',
|
|
14
|
+
fields: {
|
|
15
|
+
account_name: {
|
|
16
|
+
label: 'Account Name',
|
|
17
|
+
description: 'You can get your Account Name via Insider Inone Panel > Settings > Inone Settings > Account Preferences.',
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
ucd_key: {
|
|
22
|
+
label: 'API Key',
|
|
23
|
+
description: 'You can get your API Key via Insider Inone Panel > Settings > Preferences > Integration Settings',
|
|
24
|
+
type: 'password',
|
|
25
|
+
required: true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
extendRequest: ({ settings }) => {
|
|
30
|
+
return {
|
|
31
|
+
headers: { 'X-PARTNER-NAME': settings.account_name, 'X-REQUEST-TOKEN': settings.ucd_key }
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
insiderAudiences: insiderAudiences_1.default
|
|
36
|
+
},
|
|
37
|
+
presets: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Sync Engage Audience to Insider',
|
|
40
|
+
subscribe: 'type = "track" or type = "identify"',
|
|
41
|
+
partnerAction: 'insiderAudiences',
|
|
42
|
+
mapping: actions_core_1.defaultValues(insiderAudiences_1.default.fields)
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
exports.default = destination;
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/insider-audiences/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4E;AAG5E,0EAAiD;AAEjD,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,KAAK,EAAE,cAAc;gBACrB,WAAW,EACT,0GAA0G;gBAC5G,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,kGAAkG;gBAC/G,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,IAAI;aACf;SACF;KACF;IACD,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC9B,OAAO;YACL,OAAO,EAAE,EAAE,gBAAgB,EAAE,QAAQ,CAAC,YAAY,EAAE,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE;SAC1F,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,gBAAgB,EAAhB,0BAAgB;KACjB;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,iCAAiC;YACvC,SAAS,EAAE,qCAAqC;YAChD,aAAa,EAAE,kBAAkB;YACjC,OAAO,EAAE,4BAAa,CAAC,0BAAgB,CAAC,MAAM,CAAC;SAChD;KACF;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModifiedResponse, RequestOptions } from '@segment/actions-core';
|
|
2
|
+
import { Payload } from './insiderAudiences/generated-types';
|
|
3
|
+
export declare const API_BASE = "https://unification.useinsider.com/api/";
|
|
4
|
+
export declare const UPSERT_ENDPOINT = "user/v1/upsert";
|
|
5
|
+
export declare const DELETE_ATTRIBUTE_ENDPOINT = "user/v1/attribute/delete";
|
|
6
|
+
export declare const processPayload: (request: <Data = unknown>(url: string, options?: RequestOptions | undefined) => Promise<ModifiedResponse<Data>>, payload: Payload[]) => Promise<ModifiedResponse<unknown>[]>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processPayload = exports.DELETE_ATTRIBUTE_ENDPOINT = exports.UPSERT_ENDPOINT = exports.API_BASE = void 0;
|
|
4
|
+
exports.API_BASE = 'https://unification.useinsider.com/api/';
|
|
5
|
+
exports.UPSERT_ENDPOINT = 'user/v1/upsert';
|
|
6
|
+
exports.DELETE_ATTRIBUTE_ENDPOINT = 'user/v1/attribute/delete';
|
|
7
|
+
const AUDIENCE_TYPE = 'audience';
|
|
8
|
+
const IDENTIFY = 'identify';
|
|
9
|
+
const TRACK = 'track';
|
|
10
|
+
const COMPUTED_TRAIT_TYPE = 'trait';
|
|
11
|
+
class PayloadValidationError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'PayloadValidationError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const computedTraitsPayloadForIdentifyCall = function (data, request) {
|
|
18
|
+
const identifiers = getIdentifiers(data);
|
|
19
|
+
const attributes = getTraitAttributes(data);
|
|
20
|
+
const payload = {
|
|
21
|
+
users: [
|
|
22
|
+
{
|
|
23
|
+
identifiers,
|
|
24
|
+
attributes
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
return request(exports.API_BASE + exports.UPSERT_ENDPOINT, {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
json: payload
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const computedTraitsPayloadForTrackCall = function (data, request) {
|
|
34
|
+
const identifiers = getIdentifiers(data);
|
|
35
|
+
const events = getEvents(data);
|
|
36
|
+
const payload = {
|
|
37
|
+
users: [
|
|
38
|
+
{
|
|
39
|
+
identifiers,
|
|
40
|
+
events
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
return request(exports.API_BASE + exports.UPSERT_ENDPOINT, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
json: payload
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const computedAudiencesPayloadForIdentifyCall = function (data, request) {
|
|
50
|
+
if (data.traits_or_props[data.custom_audience_name] === false) {
|
|
51
|
+
return request(exports.API_BASE + exports.DELETE_ATTRIBUTE_ENDPOINT, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
json: deleteAttributePartial(data)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const identifiers = getIdentifiers(data);
|
|
57
|
+
const attributes = getAttributes(data);
|
|
58
|
+
const payload = {
|
|
59
|
+
users: [
|
|
60
|
+
{
|
|
61
|
+
identifiers,
|
|
62
|
+
attributes
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
return request(exports.API_BASE + exports.UPSERT_ENDPOINT, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
json: payload
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const computedAudiencePayloadForTrackCall = function (data, request) {
|
|
72
|
+
const identifiers = getIdentifiers(data);
|
|
73
|
+
const events = getEvents(data);
|
|
74
|
+
const payload = {
|
|
75
|
+
users: [
|
|
76
|
+
{
|
|
77
|
+
identifiers,
|
|
78
|
+
events
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
};
|
|
82
|
+
return request(exports.API_BASE + exports.UPSERT_ENDPOINT, {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
json: payload
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const deleteAttributePartial = function (data) {
|
|
88
|
+
const identifiers = getIdentifiers(data);
|
|
89
|
+
const computationKey = data.custom_audience_name;
|
|
90
|
+
return {
|
|
91
|
+
users: [
|
|
92
|
+
{
|
|
93
|
+
identifiers,
|
|
94
|
+
custom: {
|
|
95
|
+
partial: {
|
|
96
|
+
segment_audience_name: [computationKey]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const getIdentifiers = function (data) {
|
|
104
|
+
const identifiers = {
|
|
105
|
+
email: data.email
|
|
106
|
+
};
|
|
107
|
+
if (data.user_id) {
|
|
108
|
+
identifiers['uuid'] = data.user_id;
|
|
109
|
+
}
|
|
110
|
+
if (data.anonymous_id) {
|
|
111
|
+
identifiers['custom'] = {
|
|
112
|
+
segment_anonymous_id: data.anonymous_id
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (data.phone) {
|
|
116
|
+
identifiers['phone_number'] = data.phone;
|
|
117
|
+
}
|
|
118
|
+
return identifiers;
|
|
119
|
+
};
|
|
120
|
+
const getAttributes = function (data) {
|
|
121
|
+
const computationKey = data.custom_audience_name;
|
|
122
|
+
const attributes = {
|
|
123
|
+
custom: {
|
|
124
|
+
segment_audience_name: [computationKey]
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return attributes;
|
|
128
|
+
};
|
|
129
|
+
const getTraitAttributes = function (data) {
|
|
130
|
+
const computationKey = 'segment_io_' + data.custom_audience_name;
|
|
131
|
+
const attributes = { custom: {} };
|
|
132
|
+
attributes.custom[computationKey] = data.traits_or_props[data.custom_audience_name];
|
|
133
|
+
return attributes;
|
|
134
|
+
};
|
|
135
|
+
const getEvents = function (data) {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
event_name: data.event_name?.toLowerCase().replace(/ /g, '_'),
|
|
139
|
+
timestamp: data.timestamp,
|
|
140
|
+
event_params: {
|
|
141
|
+
custom: {
|
|
142
|
+
segment_engage_name: data.custom_audience_name
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
];
|
|
147
|
+
};
|
|
148
|
+
const handleAudienceData = async function (data, request) {
|
|
149
|
+
if (data.event_type === IDENTIFY) {
|
|
150
|
+
return computedAudiencesPayloadForIdentifyCall(data, request);
|
|
151
|
+
}
|
|
152
|
+
if (data.event_type === TRACK) {
|
|
153
|
+
return computedAudiencePayloadForTrackCall(data, request);
|
|
154
|
+
}
|
|
155
|
+
throw new PayloadValidationError('API call must be a track() or identify() call');
|
|
156
|
+
};
|
|
157
|
+
const handleComputationData = async function (data, request) {
|
|
158
|
+
if (data.event_type === IDENTIFY) {
|
|
159
|
+
return computedTraitsPayloadForIdentifyCall(data, request);
|
|
160
|
+
}
|
|
161
|
+
if (data.event_type === TRACK) {
|
|
162
|
+
return computedTraitsPayloadForTrackCall(data, request);
|
|
163
|
+
}
|
|
164
|
+
throw new PayloadValidationError('API call must be a track() or identify() call');
|
|
165
|
+
};
|
|
166
|
+
const processPayload = async function (request, payload) {
|
|
167
|
+
const promises = payload.map((data) => {
|
|
168
|
+
if (data.segment_computation_action === AUDIENCE_TYPE) {
|
|
169
|
+
return handleAudienceData(data, request);
|
|
170
|
+
}
|
|
171
|
+
if (data.segment_computation_action === COMPUTED_TRAIT_TYPE) {
|
|
172
|
+
return handleComputationData(data, request);
|
|
173
|
+
}
|
|
174
|
+
throw new PayloadValidationError('API call must be an Audience or Computed Trait track() or identify() call');
|
|
175
|
+
});
|
|
176
|
+
return Promise.all(promises);
|
|
177
|
+
};
|
|
178
|
+
exports.processPayload = processPayload;
|
|
179
|
+
//# sourceMappingURL=insider-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insider-helpers.js","sourceRoot":"","sources":["../../../src/destinations/insider-audiences/insider-helpers.ts"],"names":[],"mappings":";;;AAGa,QAAA,QAAQ,GAAG,yCAAyC,CAAA;AACpD,QAAA,eAAe,GAAG,gBAAgB,CAAA;AAClC,QAAA,yBAAyB,GAAG,0BAA0B,CAAA;AACnE,MAAM,aAAa,GAAG,UAAU,CAAA;AAChC,MAAM,QAAQ,GAAG,UAAU,CAAA;AAC3B,MAAM,KAAK,GAAG,OAAO,CAAA;AACrB,MAAM,mBAAmB,GAAG,OAAO,CAAA;AAEnC,MAAM,sBAAuB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,CAAC;CACF;AAGD,MAAM,oCAAoC,GAAG,UAC3C,IAAa,EACb,OAA+G;IAE/G,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,kBAA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AI,CAAC,UAAU,KAAK,QAAQ,EAAE;QAChC,OAAO,oCAAoC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;KAC3D;IAED,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE;QAC7B,OAAO,iCAAiC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;KACxD;IAED,MAAM,IAAI,sBAAsB,CAAC,+CAA+C,CAAC,CAAA;AACnF,CAAC,CAAA;AAGM,MAAM,cAAc,GAAG,KAAK,WACjC,OAA+G,EAC/G,OAAkB;IAElB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,IAAI,IAAI,CAAC,0BAA0B,KAAK,aAAa,EAAE;YACrD,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SACzC;QAED,IAAI,IAAI,CAAC,0BAA0B,KAAK,mBAAmB,EAAE;YAC3D,OAAO,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SAC5C;QAED,MAAM,IAAI,sBAAsB,CAAC,2EAA2E,CAAC,CAAA;IAC/G,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC9B,CAAC,CAAA;AAjBY,QAAA,cAAc,kBAiB1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
custom_audience_name: string;
|
|
3
|
+
segment_computation_action: string;
|
|
4
|
+
email: string;
|
|
5
|
+
phone?: string;
|
|
6
|
+
traits_or_props: {
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
user_id?: string;
|
|
10
|
+
anonymous_id?: string;
|
|
11
|
+
event_type: string;
|
|
12
|
+
event_name?: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/insider-audiences/insiderAudiences/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const insider_helpers_1 = require("../insider-helpers");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Insider Audiences',
|
|
6
|
+
description: 'Sync Audiences and Computed Traits from Segment to Insider InOne',
|
|
7
|
+
defaultSubscription: 'type = "track" or type = "identify"',
|
|
8
|
+
fields: {
|
|
9
|
+
custom_audience_name: {
|
|
10
|
+
label: 'Custom Audience Name',
|
|
11
|
+
description: 'Name of custom audience list to which emails should added/removed',
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true,
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.context.personas.computation_key'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
segment_computation_action: {
|
|
19
|
+
label: 'Segment Computation Action',
|
|
20
|
+
description: "Segment computation class used to determine if action is an 'Engage-Audience'",
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true,
|
|
23
|
+
default: {
|
|
24
|
+
'@path': '$.context.personas.computation_class'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
email: {
|
|
28
|
+
label: 'Email',
|
|
29
|
+
description: "User's email address for including/excluding from custom audience",
|
|
30
|
+
type: 'string',
|
|
31
|
+
format: 'email',
|
|
32
|
+
required: true,
|
|
33
|
+
default: {
|
|
34
|
+
'@if': {
|
|
35
|
+
exists: { '@path': '$.context.traits.email' },
|
|
36
|
+
then: { '@path': '$.context.traits.email' },
|
|
37
|
+
else: { '@path': '$.traits.email' }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
phone: {
|
|
42
|
+
label: 'Phone',
|
|
43
|
+
description: "User's phone number for including/excluding from custom audience",
|
|
44
|
+
type: 'string',
|
|
45
|
+
format: 'text',
|
|
46
|
+
required: false,
|
|
47
|
+
default: {
|
|
48
|
+
'@if': {
|
|
49
|
+
exists: { '@path': '$.context.traits.phone' },
|
|
50
|
+
then: { '@path': '$.context.traits.phone' },
|
|
51
|
+
else: { '@path': '$.traits.phone' }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
traits_or_props: {
|
|
56
|
+
label: 'traits or properties object',
|
|
57
|
+
description: 'Object which will be computed differently for track and identify events',
|
|
58
|
+
type: 'object',
|
|
59
|
+
required: true,
|
|
60
|
+
default: {
|
|
61
|
+
'@if': {
|
|
62
|
+
exists: { '@path': '$.properties' },
|
|
63
|
+
then: { '@path': '$.properties' },
|
|
64
|
+
else: { '@path': '$.traits' }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
user_id: {
|
|
69
|
+
label: 'User ID',
|
|
70
|
+
description: 'Known user identifier for the user',
|
|
71
|
+
type: 'string',
|
|
72
|
+
required: false,
|
|
73
|
+
default: {
|
|
74
|
+
'@path': '$.userId'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
anonymous_id: {
|
|
78
|
+
label: 'Anonymous ID',
|
|
79
|
+
description: 'Anonymous user identifier for the user',
|
|
80
|
+
type: 'string',
|
|
81
|
+
required: false,
|
|
82
|
+
default: {
|
|
83
|
+
'@path': '$.anonymousId'
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
event_type: {
|
|
87
|
+
label: 'Event Type',
|
|
88
|
+
description: 'Type of event',
|
|
89
|
+
type: 'string',
|
|
90
|
+
required: true,
|
|
91
|
+
default: {
|
|
92
|
+
'@path': '$.type'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
event_name: {
|
|
96
|
+
label: 'Event Name',
|
|
97
|
+
description: 'Name of event',
|
|
98
|
+
type: 'string',
|
|
99
|
+
required: false,
|
|
100
|
+
default: {
|
|
101
|
+
'@if': {
|
|
102
|
+
exists: { '@path': '$.event' },
|
|
103
|
+
then: { '@path': '$.event' },
|
|
104
|
+
else: { '@path': '$.name' }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
timestamp: {
|
|
109
|
+
label: 'Timestamp',
|
|
110
|
+
description: 'Timestamp of event',
|
|
111
|
+
type: 'string',
|
|
112
|
+
required: true,
|
|
113
|
+
default: {
|
|
114
|
+
'@path': '$.timestamp'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
perform: (request, { payload }) => {
|
|
119
|
+
return insider_helpers_1.processPayload(request, [payload]);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.default = action;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/insider-audiences/insiderAudiences/index.ts"],"names":[],"mappings":";;AAGA,wDAAmD;AAEnD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,kEAAkE;IAC/E,mBAAmB,EAAE,qCAAqC;IAC1D,MAAM,EAAE;QACN,oBAAoB,EAAE;YACpB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,mEAAmE;YAChF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,oCAAoC;aAC9C;SACF;QACD,0BAA0B,EAAE;YAC1B,KAAK,EAAE,4BAA4B;YACnC,WAAW,EAAE,+EAA+E;YAC5F,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,sCAAsC;aAChD;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,mEAAmE;YAChF,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,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QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,QAAQ;aAClB;SACF;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,eAAe;YAC5B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;oBAC9B,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;oBAC5B,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;iBAC5B;aACF;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,OAAO,gCAAc,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -22,14 +22,21 @@ const destination = {
|
|
|
22
22
|
label: 'Optimizely Account Id',
|
|
23
23
|
type: 'string',
|
|
24
24
|
required: true,
|
|
25
|
-
description: 'In order to use Optimizely
|
|
25
|
+
description: 'In order to use Optimizely Feature Experimentation (Actions) via server side, you must enter your Account ID from your Optimizely account. You can find this ID by visiting https://app.optimizely.com/v2/accountsettings/account/plan'
|
|
26
26
|
},
|
|
27
27
|
dataFileUrl: {
|
|
28
28
|
label: 'Datafile URL',
|
|
29
29
|
type: 'string',
|
|
30
30
|
required: true,
|
|
31
31
|
format: 'uri',
|
|
32
|
-
description: 'In order to use Optimizely
|
|
32
|
+
description: 'In order to use Optimizely Feature Experimentation (Actions) server side, you must enter the entire URL for your datafile. It should look something like https://cdn.optimizely.com/json/9218021209.json'
|
|
33
|
+
},
|
|
34
|
+
cacheExp: {
|
|
35
|
+
label: 'Cach Exp',
|
|
36
|
+
type: 'number',
|
|
37
|
+
required: false,
|
|
38
|
+
default: 300,
|
|
39
|
+
description: 'To optimize the server side integration, we will cache the fetched Datafile that you have provided for this amount of time (in seconds) in Redis. Since the datafile should not change unless you modified the conditions or variation rules of your experiments, it is advised to have a minimum floor of 300 seconds (5 minutes).'
|
|
33
40
|
}
|
|
34
41
|
},
|
|
35
42
|
testAuthentication: (request, { settings }) => {
|
|
@@ -39,7 +46,7 @@ const destination = {
|
|
|
39
46
|
},
|
|
40
47
|
onDelete: async (request, { settings }) => {
|
|
41
48
|
if (!settings.accessToken) {
|
|
42
|
-
throw new actions_core_1.IntegrationError('Access Token is required for user deletion.');
|
|
49
|
+
throw new actions_core_1.IntegrationError('Access Token is required for user deletion.', 'REQUIRED_ACCESS_TOKEN', 400);
|
|
43
50
|
}
|
|
44
51
|
return request('https://api.optimizely.com/v2/subject-access-requests', {
|
|
45
52
|
method: 'post',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/optimizely-feature-experimentation-actions/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAwD;AAGxD,8DAAqC;AAErC,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,8CAA8C;IACpD,IAAI,EAAE,kDAAkD;IACxD,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,WAAW,EAAE;gBACX,KAAK,EAAE,uBAAuB;gBAC9B,WAAW,EAAE,wDAAwD;gBACrE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,KAAK;aAChB;YACD,SAAS,EAAE;gBACT,KAAK,EAAE,uBAAuB;gBAC9B,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"index.js","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AAuD,EAAE;YACtE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,QAAQ,EAAE,WAAW,EAAE,EAAE;YAC7D,IAAI,EAAE;gBACJ,SAAS,EAAE,SAAS;gBACpB,UAAU,EAAE,QAAQ,CAAC,SAAS;gBAC9B,eAAe,EAAE,QAAQ;gBACzB,YAAY,EAAE,QAAQ;aACvB;SACF,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE;QACP,UAAU,EAAV,oBAAU;KACX;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { VisitorAttribute, Event, ProjectConfig, dataFile } from '../types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { LruCache } from '@segment/actions-core/src/destination-kit';
|
|
5
|
+
export declare function buildVisitorAttributes(configObj: dataFile, userAttributes?: {
|
|
3
6
|
[key: string]: unknown;
|
|
4
7
|
}): VisitorAttribute[];
|
|
5
|
-
export declare function getEventId(configObj:
|
|
8
|
+
export declare function getEventId(configObj: dataFile, eventKey: string): string | undefined;
|
|
9
|
+
export declare function getDatafileFieldsToCache(dataFile: ProjectConfig): Promise<{
|
|
10
|
+
events: Event[];
|
|
11
|
+
attributes: {
|
|
12
|
+
id: string;
|
|
13
|
+
key: string;
|
|
14
|
+
}[];
|
|
15
|
+
botFiltering: boolean | undefined;
|
|
16
|
+
accountId: string;
|
|
17
|
+
anonymizeIP: boolean | null | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function getDatafile(settings: Settings, request: RequestClient, lruCache?: LruCache): Promise<any>;
|
package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.js
CHANGED
|
@@ -3,7 +3,8 @@ 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.getEventId = exports.buildVisitorAttributes = void 0;
|
|
6
|
+
exports.getDatafile = exports.getDatafileFieldsToCache = exports.getEventId = exports.buildVisitorAttributes = void 0;
|
|
7
|
+
const utils_1 = require("../utils");
|
|
7
8
|
const reduceRight_1 = __importDefault(require("lodash/reduceRight"));
|
|
8
9
|
function buildVisitorAttributes(configObj, userAttributes) {
|
|
9
10
|
if (!userAttributes)
|
|
@@ -38,4 +39,77 @@ exports.getEventId = getEventId;
|
|
|
38
39
|
function isValidValue(value) {
|
|
39
40
|
return ['string', 'number', 'boolean'].includes(typeof value);
|
|
40
41
|
}
|
|
42
|
+
async function getDatafileFieldsToCache(dataFile) {
|
|
43
|
+
return {
|
|
44
|
+
events: dataFile.events,
|
|
45
|
+
attributes: dataFile.attributes,
|
|
46
|
+
botFiltering: dataFile.botFiltering,
|
|
47
|
+
accountId: dataFile.accountId,
|
|
48
|
+
anonymizeIP: dataFile.anonymizeIP
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.getDatafileFieldsToCache = getDatafileFieldsToCache;
|
|
52
|
+
async function getDatafile(settings, request, lruCache) {
|
|
53
|
+
let dataFileJSON;
|
|
54
|
+
const { dataFileUrl } = settings;
|
|
55
|
+
const exp = (settings.cacheExp || 300) * 1000;
|
|
56
|
+
const cacheKey = dataFileUrl;
|
|
57
|
+
let cacheEntry = lruCache?.getCache(cacheKey);
|
|
58
|
+
if (!isCacheReady(cacheEntry, exp)) {
|
|
59
|
+
if (!cacheEntry) {
|
|
60
|
+
cacheEntry = { state: utils_1.CacheEntryStates.STATE_UPDATING };
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
dataFileJSON = await loadDatafile(dataFileUrl, cacheEntry, request);
|
|
64
|
+
cacheEntry.date = new Date();
|
|
65
|
+
cacheEntry.state = utils_1.CacheEntryStates.STATE_UPDATED;
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
cacheEntry.state = utils_1.CacheEntryStates.STATE_FAILED;
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
71
|
+
lruCache?.setCache(cacheKey, cacheEntry);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
if (typeof dataFileJSON === 'string') {
|
|
75
|
+
dataFileJSON = JSON.parse(dataFileJSON);
|
|
76
|
+
}
|
|
77
|
+
return dataFileJSON;
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
const err = new Error(`Could not parse datafile ${dataFileUrl}. Please ensure the file is a valid JSON file.`);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.getDatafile = getDatafile;
|
|
85
|
+
async function loadDatafile(dataFileUrl, cacheEntry, request) {
|
|
86
|
+
let res;
|
|
87
|
+
if (cacheEntry.date) {
|
|
88
|
+
res = await request(dataFileUrl, {
|
|
89
|
+
headers: {
|
|
90
|
+
'If-Modified-Since': cacheEntry.date.toUTCString()
|
|
91
|
+
},
|
|
92
|
+
throwHttpErrors: true
|
|
93
|
+
});
|
|
94
|
+
if (res.status === 304) {
|
|
95
|
+
return cacheEntry.dataFile;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
res = await request(dataFileUrl);
|
|
100
|
+
}
|
|
101
|
+
const data = res.data;
|
|
102
|
+
const fieldsToCache = await getDatafileFieldsToCache(data);
|
|
103
|
+
cacheEntry.dataFile = fieldsToCache;
|
|
104
|
+
return fieldsToCache;
|
|
105
|
+
}
|
|
106
|
+
function isCacheReady(cacheEntry, ttl) {
|
|
107
|
+
if (!cacheEntry || cacheEntry.state === utils_1.CacheEntryStates.STATE_FAILED) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (cacheEntry.state === utils_1.CacheEntryStates.STATE_UPDATED && cacheEntry.date) {
|
|
111
|
+
return cacheEntry.date.getTime() + ttl >= Date.now();
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
41
115
|
//# sourceMappingURL=functions.js.map
|
package/dist/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../src/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../src/destinations/optimizely-feature-experimentation-actions/trackEvent/functions.ts"],"names":[],"mappings":";;;;;;AAEA,oCAA2C;AAE3C,qEAA4C;AAG5C,SAAgB,sBAAsB,CACpC,SAAmB,EACnB,cAA2C;IAE3C,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAA;IAC9B,MAAM,eAAe,GAAgD,qBAAW,CAC9E,SAAS,CAAC,UAAU,EACpB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACb,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;YACzB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC,EACD,EAAE,CACH,CAAA;IAED,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;SACxB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;SAE3E,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;SAClD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACb,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE;QAClC,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,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AAG,EAAE;YACtB,OAAO,UAAU,CAAC,QAAQ,CAAA;SAC3B;KACF;SAAM;QACL,GAAG,GAAG,MAAM,OAAO,CAAgB,WAAW,CAAC,CAAA;KAChD;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IACrB,MAAM,aAAa,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,CAAA;IAC1D,UAAU,CAAC,QAAQ,GAAG,aAAa,CAAA;IAEnC,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,SAAS,YAAY,CAAC,UAAuB,EAAE,GAAW;IACxD,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,KAAK,KAAK,wBAAgB,CAAC,YAAY,EAAE;QACrE,OAAO,KAAK,CAAA;KACb;IACD,IAAI,UAAU,CAAC,KAAK,KAAK,wBAAgB,CAAC,aAAa,IAAI,UAAU,CAAC,IAAI,EAAE;QAC1E,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;KACrD;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -5,7 +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 functions_1 = require("./functions");
|
|
8
|
-
const
|
|
8
|
+
const functions_2 = require("./functions");
|
|
9
9
|
const dayjs_1 = __importDefault(require("../../../lib/dayjs"));
|
|
10
10
|
const action = {
|
|
11
11
|
title: 'Track Event',
|
|
@@ -97,12 +97,11 @@ const action = {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
-
perform: async (request, { settings, payload }) => {
|
|
101
|
-
const
|
|
102
|
-
const dataFile = result.data;
|
|
100
|
+
perform: async (request, { settings, payload, lruCache }) => {
|
|
101
|
+
const dataFile = await functions_2.getDatafile(settings, request, lruCache);
|
|
103
102
|
const eventId = functions_1.getEventId(dataFile, payload.eventKey);
|
|
104
103
|
if (!eventId) {
|
|
105
|
-
throw new
|
|
104
|
+
throw new actions_core_1.PayloadValidationError(`Event with name ${payload.eventKey} is not defined`);
|
|
106
105
|
}
|
|
107
106
|
const eventTags = actions_core_1.omit(payload.eventTags, ['revenue', 'value']);
|
|
108
107
|
const visitors = [
|
|
@@ -141,7 +140,6 @@ const action = {
|
|
|
141
140
|
account_id: dataFile.accountId,
|
|
142
141
|
anonymize_ip: dataFile.anonymizeIP,
|
|
143
142
|
client_name: 'Segment',
|
|
144
|
-
client_version: '1.0.01',
|
|
145
143
|
enrich_decisions: true,
|
|
146
144
|
visitors: [...visitors]
|
|
147
145
|
}
|