@blotoutio/providers-omnisend-sdk 1.27.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/README.md +11 -0
- package/index.cjs.js +171 -0
- package/index.d.ts +1 -0
- package/index.js +174 -0
- package/index.mjs +169 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# providers-omnisend-sdk
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build providers-omnisend-sdk` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test providers-omnisend-sdk` to execute the unit tests via [Jest](https://jestjs.io).
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const packageName = 'omnisend';
|
|
4
|
+
|
|
5
|
+
const OMNISEND_SCRIPT_SRC = 'https://omnisnippet1.com/inshop/launcher-v2.js';
|
|
6
|
+
const snippet = (brandId) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
if (typeof window === 'undefined' ||
|
|
9
|
+
typeof document === 'undefined' ||
|
|
10
|
+
window.omnisend) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
(_a = window.omnisend) !== null && _a !== void 0 ? _a : (window.omnisend = []);
|
|
14
|
+
window.omnisend.push(['brandID', brandId]);
|
|
15
|
+
const script = document.createElement('script');
|
|
16
|
+
script.type = 'text/javascript';
|
|
17
|
+
script.async = true;
|
|
18
|
+
script.src = OMNISEND_SCRIPT_SRC;
|
|
19
|
+
const firstScript = document.getElementsByTagName('script')[0];
|
|
20
|
+
(_b = firstScript === null || firstScript === void 0 ? void 0 : firstScript.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(script, firstScript);
|
|
21
|
+
};
|
|
22
|
+
const init = ({ manifest }) => {
|
|
23
|
+
var _a;
|
|
24
|
+
if (!((_a = manifest.variables) === null || _a === void 0 ? void 0 : _a['brandId'])) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
snippet(manifest.variables['brandId']);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getEventData = (eventId, eventName, data) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
switch (eventName) {
|
|
33
|
+
case 'ViewContent': {
|
|
34
|
+
const viewContentData = (_a = data['contents']) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
35
|
+
return {
|
|
36
|
+
eventID: eventId,
|
|
37
|
+
eventName,
|
|
38
|
+
eventVersion: 'v4',
|
|
39
|
+
origin: 'api',
|
|
40
|
+
properties: {
|
|
41
|
+
product: {
|
|
42
|
+
id: item['id'],
|
|
43
|
+
title: item['title'],
|
|
44
|
+
price: item['item_price'],
|
|
45
|
+
currency: data['currency'],
|
|
46
|
+
imageUrl: item['image'],
|
|
47
|
+
url: item['url'],
|
|
48
|
+
description: item['description'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return viewContentData;
|
|
54
|
+
}
|
|
55
|
+
case 'AddToCart':
|
|
56
|
+
case 'InitiateCheckout': {
|
|
57
|
+
const eventData = (_b = data['contents']) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
58
|
+
const properties = getEventProperties(item);
|
|
59
|
+
return {
|
|
60
|
+
eventID: eventId,
|
|
61
|
+
eventName,
|
|
62
|
+
origin: 'api',
|
|
63
|
+
eventVersion: '',
|
|
64
|
+
...properties,
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return eventData;
|
|
68
|
+
}
|
|
69
|
+
default:
|
|
70
|
+
return [data];
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const getEventProperties = (payloadData) => {
|
|
74
|
+
const { currency, contents, value } = payloadData;
|
|
75
|
+
const properties = {
|
|
76
|
+
currency: currency || '',
|
|
77
|
+
totalPrice: value,
|
|
78
|
+
lineItems: getLineItems(contents),
|
|
79
|
+
};
|
|
80
|
+
return properties;
|
|
81
|
+
};
|
|
82
|
+
const getLineItems = (contents) => contents === null || contents === void 0 ? void 0 : contents.map(({ id, description, image, sku, title, url, variantId, quantity, item_price, }) => ({
|
|
83
|
+
productID: id,
|
|
84
|
+
productQuantity: quantity,
|
|
85
|
+
productPrice: item_price,
|
|
86
|
+
productDescription: description,
|
|
87
|
+
productImageURL: image,
|
|
88
|
+
productSKU: parseNumber(sku),
|
|
89
|
+
productVariantID: variantId,
|
|
90
|
+
productTitle: title,
|
|
91
|
+
productURL: url,
|
|
92
|
+
}));
|
|
93
|
+
const parseNumber = (str) => {
|
|
94
|
+
const num = Number(str);
|
|
95
|
+
if (Number.isNaN(num)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return num;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const EVENT_MAP = {
|
|
102
|
+
PageView: '$pageViewed',
|
|
103
|
+
ViewContent: 'viewed product',
|
|
104
|
+
AddToCart: 'added product to cart',
|
|
105
|
+
InitiateCheckout: 'started checkout',
|
|
106
|
+
// Custom events
|
|
107
|
+
RemoveFromCart: 'removed product from cart',
|
|
108
|
+
Purchase: 'placed order',
|
|
109
|
+
Lead: 'lead',
|
|
110
|
+
Search: 'searched',
|
|
111
|
+
Subscribe: 'subscribed',
|
|
112
|
+
AddShippingInfo: 'added shipping info',
|
|
113
|
+
AddPaymentInfo: 'added payment info',
|
|
114
|
+
SessionStart: 'session started',
|
|
115
|
+
};
|
|
116
|
+
const tag = ({ data, eventName, eventId, manifestVariables }) => {
|
|
117
|
+
const result = { sdkVersion: "1.27.0" };
|
|
118
|
+
if (window.omnisend && manifestVariables['enableBrowser'] === '1') {
|
|
119
|
+
const name = EVENT_MAP[eventName];
|
|
120
|
+
if (eventName === 'PageView') {
|
|
121
|
+
window.omnisend.push(['track', name]);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const eventData = getEventData(eventId, eventName, data);
|
|
125
|
+
if (Array.isArray(eventData)) {
|
|
126
|
+
for (const item of eventData) {
|
|
127
|
+
window.omnisend.push(['track', name, item]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const user = ({ data }) => {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
if (typeof window === 'undefined' || !window.omnisend || !data) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const contact = {};
|
|
141
|
+
if (data['email']) {
|
|
142
|
+
contact.email = data['email'];
|
|
143
|
+
}
|
|
144
|
+
if (data['phone']) {
|
|
145
|
+
contact.phone = data['phone'];
|
|
146
|
+
}
|
|
147
|
+
if (Object.keys(contact).length) {
|
|
148
|
+
(_b = (_a = window.omnisend).identifyContact) === null || _b === void 0 ? void 0 : _b.call(_a, contact);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
153
|
+
const data = {
|
|
154
|
+
name: packageName,
|
|
155
|
+
tag,
|
|
156
|
+
init,
|
|
157
|
+
user,
|
|
158
|
+
};
|
|
159
|
+
try {
|
|
160
|
+
if (window) {
|
|
161
|
+
if (!window.edgetagProviders) {
|
|
162
|
+
window.edgetagProviders = [];
|
|
163
|
+
}
|
|
164
|
+
window.edgetagProviders.push(data);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// No window
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = data;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '@blotoutio/providers-omnisend-sdk'
|
package/index.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
var ProvidersOmnisendSdk = (function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const packageName = 'omnisend';
|
|
5
|
+
|
|
6
|
+
const OMNISEND_SCRIPT_SRC = 'https://omnisnippet1.com/inshop/launcher-v2.js';
|
|
7
|
+
const snippet = (brandId) => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
if (typeof window === 'undefined' ||
|
|
10
|
+
typeof document === 'undefined' ||
|
|
11
|
+
window.omnisend) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
(_a = window.omnisend) !== null && _a !== void 0 ? _a : (window.omnisend = []);
|
|
15
|
+
window.omnisend.push(['brandID', brandId]);
|
|
16
|
+
const script = document.createElement('script');
|
|
17
|
+
script.type = 'text/javascript';
|
|
18
|
+
script.async = true;
|
|
19
|
+
script.src = OMNISEND_SCRIPT_SRC;
|
|
20
|
+
const firstScript = document.getElementsByTagName('script')[0];
|
|
21
|
+
(_b = firstScript === null || firstScript === void 0 ? void 0 : firstScript.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(script, firstScript);
|
|
22
|
+
};
|
|
23
|
+
const init = ({ manifest }) => {
|
|
24
|
+
var _a;
|
|
25
|
+
if (!((_a = manifest.variables) === null || _a === void 0 ? void 0 : _a['brandId'])) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
snippet(manifest.variables['brandId']);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getEventData = (eventId, eventName, data) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
switch (eventName) {
|
|
34
|
+
case 'ViewContent': {
|
|
35
|
+
const viewContentData = (_a = data['contents']) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
36
|
+
return {
|
|
37
|
+
eventID: eventId,
|
|
38
|
+
eventName,
|
|
39
|
+
eventVersion: 'v4',
|
|
40
|
+
origin: 'api',
|
|
41
|
+
properties: {
|
|
42
|
+
product: {
|
|
43
|
+
id: item['id'],
|
|
44
|
+
title: item['title'],
|
|
45
|
+
price: item['item_price'],
|
|
46
|
+
currency: data['currency'],
|
|
47
|
+
imageUrl: item['image'],
|
|
48
|
+
url: item['url'],
|
|
49
|
+
description: item['description'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
return viewContentData;
|
|
55
|
+
}
|
|
56
|
+
case 'AddToCart':
|
|
57
|
+
case 'InitiateCheckout': {
|
|
58
|
+
const eventData = (_b = data['contents']) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
59
|
+
const properties = getEventProperties(item);
|
|
60
|
+
return {
|
|
61
|
+
eventID: eventId,
|
|
62
|
+
eventName,
|
|
63
|
+
origin: 'api',
|
|
64
|
+
eventVersion: '',
|
|
65
|
+
...properties,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return eventData;
|
|
69
|
+
}
|
|
70
|
+
default:
|
|
71
|
+
return [data];
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const getEventProperties = (payloadData) => {
|
|
75
|
+
const { currency, contents, value } = payloadData;
|
|
76
|
+
const properties = {
|
|
77
|
+
currency: currency || '',
|
|
78
|
+
totalPrice: value,
|
|
79
|
+
lineItems: getLineItems(contents),
|
|
80
|
+
};
|
|
81
|
+
return properties;
|
|
82
|
+
};
|
|
83
|
+
const getLineItems = (contents) => contents === null || contents === void 0 ? void 0 : contents.map(({ id, description, image, sku, title, url, variantId, quantity, item_price, }) => ({
|
|
84
|
+
productID: id,
|
|
85
|
+
productQuantity: quantity,
|
|
86
|
+
productPrice: item_price,
|
|
87
|
+
productDescription: description,
|
|
88
|
+
productImageURL: image,
|
|
89
|
+
productSKU: parseNumber(sku),
|
|
90
|
+
productVariantID: variantId,
|
|
91
|
+
productTitle: title,
|
|
92
|
+
productURL: url,
|
|
93
|
+
}));
|
|
94
|
+
const parseNumber = (str) => {
|
|
95
|
+
const num = Number(str);
|
|
96
|
+
if (Number.isNaN(num)) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return num;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const EVENT_MAP = {
|
|
103
|
+
PageView: '$pageViewed',
|
|
104
|
+
ViewContent: 'viewed product',
|
|
105
|
+
AddToCart: 'added product to cart',
|
|
106
|
+
InitiateCheckout: 'started checkout',
|
|
107
|
+
// Custom events
|
|
108
|
+
RemoveFromCart: 'removed product from cart',
|
|
109
|
+
Purchase: 'placed order',
|
|
110
|
+
Lead: 'lead',
|
|
111
|
+
Search: 'searched',
|
|
112
|
+
Subscribe: 'subscribed',
|
|
113
|
+
AddShippingInfo: 'added shipping info',
|
|
114
|
+
AddPaymentInfo: 'added payment info',
|
|
115
|
+
SessionStart: 'session started',
|
|
116
|
+
};
|
|
117
|
+
const tag = ({ data, eventName, eventId, manifestVariables }) => {
|
|
118
|
+
const result = { sdkVersion: "1.27.0" };
|
|
119
|
+
if (window.omnisend && manifestVariables['enableBrowser'] === '1') {
|
|
120
|
+
const name = EVENT_MAP[eventName];
|
|
121
|
+
if (eventName === 'PageView') {
|
|
122
|
+
window.omnisend.push(['track', name]);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const eventData = getEventData(eventId, eventName, data);
|
|
126
|
+
if (Array.isArray(eventData)) {
|
|
127
|
+
for (const item of eventData) {
|
|
128
|
+
window.omnisend.push(['track', name, item]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const user = ({ data }) => {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
if (typeof window === 'undefined' || !window.omnisend || !data) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const contact = {};
|
|
142
|
+
if (data['email']) {
|
|
143
|
+
contact.email = data['email'];
|
|
144
|
+
}
|
|
145
|
+
if (data['phone']) {
|
|
146
|
+
contact.phone = data['phone'];
|
|
147
|
+
}
|
|
148
|
+
if (Object.keys(contact).length) {
|
|
149
|
+
(_b = (_a = window.omnisend).identifyContact) === null || _b === void 0 ? void 0 : _b.call(_a, contact);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
154
|
+
const data = {
|
|
155
|
+
name: packageName,
|
|
156
|
+
tag,
|
|
157
|
+
init,
|
|
158
|
+
user,
|
|
159
|
+
};
|
|
160
|
+
try {
|
|
161
|
+
if (window) {
|
|
162
|
+
if (!window.edgetagProviders) {
|
|
163
|
+
window.edgetagProviders = [];
|
|
164
|
+
}
|
|
165
|
+
window.edgetagProviders.push(data);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// No window
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return data;
|
|
173
|
+
|
|
174
|
+
})();
|
package/index.mjs
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const packageName = 'omnisend';
|
|
2
|
+
|
|
3
|
+
const OMNISEND_SCRIPT_SRC = 'https://omnisnippet1.com/inshop/launcher-v2.js';
|
|
4
|
+
const snippet = (brandId) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (typeof window === 'undefined' ||
|
|
7
|
+
typeof document === 'undefined' ||
|
|
8
|
+
window.omnisend) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
(_a = window.omnisend) !== null && _a !== void 0 ? _a : (window.omnisend = []);
|
|
12
|
+
window.omnisend.push(['brandID', brandId]);
|
|
13
|
+
const script = document.createElement('script');
|
|
14
|
+
script.type = 'text/javascript';
|
|
15
|
+
script.async = true;
|
|
16
|
+
script.src = OMNISEND_SCRIPT_SRC;
|
|
17
|
+
const firstScript = document.getElementsByTagName('script')[0];
|
|
18
|
+
(_b = firstScript === null || firstScript === void 0 ? void 0 : firstScript.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(script, firstScript);
|
|
19
|
+
};
|
|
20
|
+
const init = ({ manifest }) => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (!((_a = manifest.variables) === null || _a === void 0 ? void 0 : _a['brandId'])) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
snippet(manifest.variables['brandId']);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getEventData = (eventId, eventName, data) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
switch (eventName) {
|
|
31
|
+
case 'ViewContent': {
|
|
32
|
+
const viewContentData = (_a = data['contents']) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
33
|
+
return {
|
|
34
|
+
eventID: eventId,
|
|
35
|
+
eventName,
|
|
36
|
+
eventVersion: 'v4',
|
|
37
|
+
origin: 'api',
|
|
38
|
+
properties: {
|
|
39
|
+
product: {
|
|
40
|
+
id: item['id'],
|
|
41
|
+
title: item['title'],
|
|
42
|
+
price: item['item_price'],
|
|
43
|
+
currency: data['currency'],
|
|
44
|
+
imageUrl: item['image'],
|
|
45
|
+
url: item['url'],
|
|
46
|
+
description: item['description'],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
return viewContentData;
|
|
52
|
+
}
|
|
53
|
+
case 'AddToCart':
|
|
54
|
+
case 'InitiateCheckout': {
|
|
55
|
+
const eventData = (_b = data['contents']) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
56
|
+
const properties = getEventProperties(item);
|
|
57
|
+
return {
|
|
58
|
+
eventID: eventId,
|
|
59
|
+
eventName,
|
|
60
|
+
origin: 'api',
|
|
61
|
+
eventVersion: '',
|
|
62
|
+
...properties,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
return eventData;
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
return [data];
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const getEventProperties = (payloadData) => {
|
|
72
|
+
const { currency, contents, value } = payloadData;
|
|
73
|
+
const properties = {
|
|
74
|
+
currency: currency || '',
|
|
75
|
+
totalPrice: value,
|
|
76
|
+
lineItems: getLineItems(contents),
|
|
77
|
+
};
|
|
78
|
+
return properties;
|
|
79
|
+
};
|
|
80
|
+
const getLineItems = (contents) => contents === null || contents === void 0 ? void 0 : contents.map(({ id, description, image, sku, title, url, variantId, quantity, item_price, }) => ({
|
|
81
|
+
productID: id,
|
|
82
|
+
productQuantity: quantity,
|
|
83
|
+
productPrice: item_price,
|
|
84
|
+
productDescription: description,
|
|
85
|
+
productImageURL: image,
|
|
86
|
+
productSKU: parseNumber(sku),
|
|
87
|
+
productVariantID: variantId,
|
|
88
|
+
productTitle: title,
|
|
89
|
+
productURL: url,
|
|
90
|
+
}));
|
|
91
|
+
const parseNumber = (str) => {
|
|
92
|
+
const num = Number(str);
|
|
93
|
+
if (Number.isNaN(num)) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return num;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const EVENT_MAP = {
|
|
100
|
+
PageView: '$pageViewed',
|
|
101
|
+
ViewContent: 'viewed product',
|
|
102
|
+
AddToCart: 'added product to cart',
|
|
103
|
+
InitiateCheckout: 'started checkout',
|
|
104
|
+
// Custom events
|
|
105
|
+
RemoveFromCart: 'removed product from cart',
|
|
106
|
+
Purchase: 'placed order',
|
|
107
|
+
Lead: 'lead',
|
|
108
|
+
Search: 'searched',
|
|
109
|
+
Subscribe: 'subscribed',
|
|
110
|
+
AddShippingInfo: 'added shipping info',
|
|
111
|
+
AddPaymentInfo: 'added payment info',
|
|
112
|
+
SessionStart: 'session started',
|
|
113
|
+
};
|
|
114
|
+
const tag = ({ data, eventName, eventId, manifestVariables }) => {
|
|
115
|
+
const result = { sdkVersion: "1.27.0" };
|
|
116
|
+
if (window.omnisend && manifestVariables['enableBrowser'] === '1') {
|
|
117
|
+
const name = EVENT_MAP[eventName];
|
|
118
|
+
if (eventName === 'PageView') {
|
|
119
|
+
window.omnisend.push(['track', name]);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const eventData = getEventData(eventId, eventName, data);
|
|
123
|
+
if (Array.isArray(eventData)) {
|
|
124
|
+
for (const item of eventData) {
|
|
125
|
+
window.omnisend.push(['track', name, item]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const user = ({ data }) => {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
if (typeof window === 'undefined' || !window.omnisend || !data) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const contact = {};
|
|
139
|
+
if (data['email']) {
|
|
140
|
+
contact.email = data['email'];
|
|
141
|
+
}
|
|
142
|
+
if (data['phone']) {
|
|
143
|
+
contact.phone = data['phone'];
|
|
144
|
+
}
|
|
145
|
+
if (Object.keys(contact).length) {
|
|
146
|
+
(_b = (_a = window.omnisend).identifyContact) === null || _b === void 0 ? void 0 : _b.call(_a, contact);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
151
|
+
const data = {
|
|
152
|
+
name: packageName,
|
|
153
|
+
tag,
|
|
154
|
+
init,
|
|
155
|
+
user,
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
if (window) {
|
|
159
|
+
if (!window.edgetagProviders) {
|
|
160
|
+
window.edgetagProviders = [];
|
|
161
|
+
}
|
|
162
|
+
window.edgetagProviders.push(data);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
// No window
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export { data as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blotoutio/providers-omnisend-sdk",
|
|
3
|
+
"version": "1.27.0",
|
|
4
|
+
"description": "Omnisend Browser SDK for EdgeTag",
|
|
5
|
+
"author": "Blotout",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/blotoutio/edgetag-sdk",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"main": "./index.cjs.js",
|
|
12
|
+
"module": "./index.mjs",
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/blotoutio/edgetag-sdk.git"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"index.js",
|
|
20
|
+
"index.d.ts",
|
|
21
|
+
"index.cjs.js",
|
|
22
|
+
"index.mjs",
|
|
23
|
+
"package.json",
|
|
24
|
+
"README.md"
|
|
25
|
+
]
|
|
26
|
+
}
|