@blotoutio/providers-facebook-sdk 0.47.0 → 0.47.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.
- package/index.cjs.js +64 -10
- package/index.js +64 -10
- package/index.mjs +64 -10
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -3,13 +3,64 @@
|
|
|
3
3
|
const packageName = 'facebook';
|
|
4
4
|
const sdkUrl = 'https://connect.facebook.net/en_US/fbevents.js';
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
7
6
|
const getFbq = () => {
|
|
8
7
|
if (!window || !window.fbq) {
|
|
9
8
|
return null;
|
|
10
9
|
}
|
|
11
10
|
return window.fbq;
|
|
12
11
|
};
|
|
12
|
+
const getUserData = () => {
|
|
13
|
+
var _a;
|
|
14
|
+
const data = {};
|
|
15
|
+
try {
|
|
16
|
+
const user = (_a = JSON.parse(window.sessionStorage.getItem('_workerStore') || '{}')) === null || _a === void 0 ? void 0 : _a.kv;
|
|
17
|
+
if (!user) {
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
if (user.email) {
|
|
21
|
+
data['em'] = user.email;
|
|
22
|
+
}
|
|
23
|
+
if (user.phone) {
|
|
24
|
+
data['ph'] = user.phone;
|
|
25
|
+
}
|
|
26
|
+
if (user.firstName) {
|
|
27
|
+
data['fn'] = user.firstName;
|
|
28
|
+
}
|
|
29
|
+
if (user.lastName) {
|
|
30
|
+
data['ln'] = user.lastName;
|
|
31
|
+
}
|
|
32
|
+
if (user.city) {
|
|
33
|
+
data['ct'] = user.city;
|
|
34
|
+
}
|
|
35
|
+
if (user.state) {
|
|
36
|
+
data['st'] = user.state;
|
|
37
|
+
}
|
|
38
|
+
if (user.country) {
|
|
39
|
+
data['country'] = user.country;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.error(e);
|
|
44
|
+
}
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
const runInit = (pixelId, userId) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const wrapper = getFbq();
|
|
50
|
+
if (!wrapper) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if ((_b = (_a = wrapper.instance) === null || _a === void 0 ? void 0 : _a.pixelsByID) === null || _b === void 0 ? void 0 : _b[pixelId]) {
|
|
54
|
+
wrapper.instance.pixelsByID[pixelId].userData = null;
|
|
55
|
+
}
|
|
56
|
+
wrapper('init', pixelId, {
|
|
57
|
+
external_id: userId,
|
|
58
|
+
...getUserData(),
|
|
59
|
+
});
|
|
60
|
+
wrapper.disablePushState = true;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
13
64
|
const snippet = () => {
|
|
14
65
|
if (!window || !document || window.fbq) {
|
|
15
66
|
return;
|
|
@@ -43,14 +94,7 @@ const init = ({ manifest, userId }) => {
|
|
|
43
94
|
return;
|
|
44
95
|
}
|
|
45
96
|
snippet();
|
|
46
|
-
|
|
47
|
-
if (!wrapper) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
wrapper('init', manifest.variables['pixelId'], {
|
|
51
|
-
external_id: userId,
|
|
52
|
-
});
|
|
53
|
-
wrapper.disablePushState = true;
|
|
97
|
+
runInit(manifest.variables['pixelId'], userId);
|
|
54
98
|
};
|
|
55
99
|
|
|
56
100
|
const getProductIdFromMapping = (item, productIdMapping) => {
|
|
@@ -133,7 +177,7 @@ const prepareData = (data, productIdMapping) => {
|
|
|
133
177
|
};
|
|
134
178
|
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
135
179
|
const payload = {
|
|
136
|
-
sdkVersion: "0.47.
|
|
180
|
+
sdkVersion: "0.47.1" ,
|
|
137
181
|
};
|
|
138
182
|
if (window.fbq &&
|
|
139
183
|
!!manifestVariables['pixelId'] &&
|
|
@@ -149,11 +193,21 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
149
193
|
return payload;
|
|
150
194
|
};
|
|
151
195
|
|
|
196
|
+
const user = ({ userId, manifestVariables }) => {
|
|
197
|
+
if (!manifestVariables ||
|
|
198
|
+
!manifestVariables['pixelId'] ||
|
|
199
|
+
manifestVariables['enableBrowser'] !== '1') {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
runInit(manifestVariables['pixelId'], userId);
|
|
203
|
+
};
|
|
204
|
+
|
|
152
205
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
153
206
|
const data = {
|
|
154
207
|
name: packageName,
|
|
155
208
|
tag,
|
|
156
209
|
init,
|
|
210
|
+
user,
|
|
157
211
|
};
|
|
158
212
|
try {
|
|
159
213
|
if (window) {
|
package/index.js
CHANGED
|
@@ -4,13 +4,64 @@ var ProvidersFacebookSdk = (function () {
|
|
|
4
4
|
const packageName = 'facebook';
|
|
5
5
|
const sdkUrl = 'https://connect.facebook.net/en_US/fbevents.js';
|
|
6
6
|
|
|
7
|
-
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
8
7
|
const getFbq = () => {
|
|
9
8
|
if (!window || !window.fbq) {
|
|
10
9
|
return null;
|
|
11
10
|
}
|
|
12
11
|
return window.fbq;
|
|
13
12
|
};
|
|
13
|
+
const getUserData = () => {
|
|
14
|
+
var _a;
|
|
15
|
+
const data = {};
|
|
16
|
+
try {
|
|
17
|
+
const user = (_a = JSON.parse(window.sessionStorage.getItem('_workerStore') || '{}')) === null || _a === void 0 ? void 0 : _a.kv;
|
|
18
|
+
if (!user) {
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
if (user.email) {
|
|
22
|
+
data['em'] = user.email;
|
|
23
|
+
}
|
|
24
|
+
if (user.phone) {
|
|
25
|
+
data['ph'] = user.phone;
|
|
26
|
+
}
|
|
27
|
+
if (user.firstName) {
|
|
28
|
+
data['fn'] = user.firstName;
|
|
29
|
+
}
|
|
30
|
+
if (user.lastName) {
|
|
31
|
+
data['ln'] = user.lastName;
|
|
32
|
+
}
|
|
33
|
+
if (user.city) {
|
|
34
|
+
data['ct'] = user.city;
|
|
35
|
+
}
|
|
36
|
+
if (user.state) {
|
|
37
|
+
data['st'] = user.state;
|
|
38
|
+
}
|
|
39
|
+
if (user.country) {
|
|
40
|
+
data['country'] = user.country;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error(e);
|
|
45
|
+
}
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
const runInit = (pixelId, userId) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
const wrapper = getFbq();
|
|
51
|
+
if (!wrapper) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if ((_b = (_a = wrapper.instance) === null || _a === void 0 ? void 0 : _a.pixelsByID) === null || _b === void 0 ? void 0 : _b[pixelId]) {
|
|
55
|
+
wrapper.instance.pixelsByID[pixelId].userData = null;
|
|
56
|
+
}
|
|
57
|
+
wrapper('init', pixelId, {
|
|
58
|
+
external_id: userId,
|
|
59
|
+
...getUserData(),
|
|
60
|
+
});
|
|
61
|
+
wrapper.disablePushState = true;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
14
65
|
const snippet = () => {
|
|
15
66
|
if (!window || !document || window.fbq) {
|
|
16
67
|
return;
|
|
@@ -44,14 +95,7 @@ var ProvidersFacebookSdk = (function () {
|
|
|
44
95
|
return;
|
|
45
96
|
}
|
|
46
97
|
snippet();
|
|
47
|
-
|
|
48
|
-
if (!wrapper) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
wrapper('init', manifest.variables['pixelId'], {
|
|
52
|
-
external_id: userId,
|
|
53
|
-
});
|
|
54
|
-
wrapper.disablePushState = true;
|
|
98
|
+
runInit(manifest.variables['pixelId'], userId);
|
|
55
99
|
};
|
|
56
100
|
|
|
57
101
|
const getProductIdFromMapping = (item, productIdMapping) => {
|
|
@@ -134,7 +178,7 @@ var ProvidersFacebookSdk = (function () {
|
|
|
134
178
|
};
|
|
135
179
|
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
136
180
|
const payload = {
|
|
137
|
-
sdkVersion: "0.47.
|
|
181
|
+
sdkVersion: "0.47.1" ,
|
|
138
182
|
};
|
|
139
183
|
if (window.fbq &&
|
|
140
184
|
!!manifestVariables['pixelId'] &&
|
|
@@ -150,11 +194,21 @@ var ProvidersFacebookSdk = (function () {
|
|
|
150
194
|
return payload;
|
|
151
195
|
};
|
|
152
196
|
|
|
197
|
+
const user = ({ userId, manifestVariables }) => {
|
|
198
|
+
if (!manifestVariables ||
|
|
199
|
+
!manifestVariables['pixelId'] ||
|
|
200
|
+
manifestVariables['enableBrowser'] !== '1') {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
runInit(manifestVariables['pixelId'], userId);
|
|
204
|
+
};
|
|
205
|
+
|
|
153
206
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
154
207
|
const data = {
|
|
155
208
|
name: packageName,
|
|
156
209
|
tag,
|
|
157
210
|
init,
|
|
211
|
+
user,
|
|
158
212
|
};
|
|
159
213
|
try {
|
|
160
214
|
if (window) {
|
package/index.mjs
CHANGED
|
@@ -1,13 +1,64 @@
|
|
|
1
1
|
const packageName = 'facebook';
|
|
2
2
|
const sdkUrl = 'https://connect.facebook.net/en_US/fbevents.js';
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
5
4
|
const getFbq = () => {
|
|
6
5
|
if (!window || !window.fbq) {
|
|
7
6
|
return null;
|
|
8
7
|
}
|
|
9
8
|
return window.fbq;
|
|
10
9
|
};
|
|
10
|
+
const getUserData = () => {
|
|
11
|
+
var _a;
|
|
12
|
+
const data = {};
|
|
13
|
+
try {
|
|
14
|
+
const user = (_a = JSON.parse(window.sessionStorage.getItem('_workerStore') || '{}')) === null || _a === void 0 ? void 0 : _a.kv;
|
|
15
|
+
if (!user) {
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
if (user.email) {
|
|
19
|
+
data['em'] = user.email;
|
|
20
|
+
}
|
|
21
|
+
if (user.phone) {
|
|
22
|
+
data['ph'] = user.phone;
|
|
23
|
+
}
|
|
24
|
+
if (user.firstName) {
|
|
25
|
+
data['fn'] = user.firstName;
|
|
26
|
+
}
|
|
27
|
+
if (user.lastName) {
|
|
28
|
+
data['ln'] = user.lastName;
|
|
29
|
+
}
|
|
30
|
+
if (user.city) {
|
|
31
|
+
data['ct'] = user.city;
|
|
32
|
+
}
|
|
33
|
+
if (user.state) {
|
|
34
|
+
data['st'] = user.state;
|
|
35
|
+
}
|
|
36
|
+
if (user.country) {
|
|
37
|
+
data['country'] = user.country;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.error(e);
|
|
42
|
+
}
|
|
43
|
+
return data;
|
|
44
|
+
};
|
|
45
|
+
const runInit = (pixelId, userId) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
const wrapper = getFbq();
|
|
48
|
+
if (!wrapper) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if ((_b = (_a = wrapper.instance) === null || _a === void 0 ? void 0 : _a.pixelsByID) === null || _b === void 0 ? void 0 : _b[pixelId]) {
|
|
52
|
+
wrapper.instance.pixelsByID[pixelId].userData = null;
|
|
53
|
+
}
|
|
54
|
+
wrapper('init', pixelId, {
|
|
55
|
+
external_id: userId,
|
|
56
|
+
...getUserData(),
|
|
57
|
+
});
|
|
58
|
+
wrapper.disablePushState = true;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
11
62
|
const snippet = () => {
|
|
12
63
|
if (!window || !document || window.fbq) {
|
|
13
64
|
return;
|
|
@@ -41,14 +92,7 @@ const init = ({ manifest, userId }) => {
|
|
|
41
92
|
return;
|
|
42
93
|
}
|
|
43
94
|
snippet();
|
|
44
|
-
|
|
45
|
-
if (!wrapper) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
wrapper('init', manifest.variables['pixelId'], {
|
|
49
|
-
external_id: userId,
|
|
50
|
-
});
|
|
51
|
-
wrapper.disablePushState = true;
|
|
95
|
+
runInit(manifest.variables['pixelId'], userId);
|
|
52
96
|
};
|
|
53
97
|
|
|
54
98
|
const getProductIdFromMapping = (item, productIdMapping) => {
|
|
@@ -131,7 +175,7 @@ const prepareData = (data, productIdMapping) => {
|
|
|
131
175
|
};
|
|
132
176
|
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
133
177
|
const payload = {
|
|
134
|
-
sdkVersion: "0.47.
|
|
178
|
+
sdkVersion: "0.47.1" ,
|
|
135
179
|
};
|
|
136
180
|
if (window.fbq &&
|
|
137
181
|
!!manifestVariables['pixelId'] &&
|
|
@@ -147,11 +191,21 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
147
191
|
return payload;
|
|
148
192
|
};
|
|
149
193
|
|
|
194
|
+
const user = ({ userId, manifestVariables }) => {
|
|
195
|
+
if (!manifestVariables ||
|
|
196
|
+
!manifestVariables['pixelId'] ||
|
|
197
|
+
manifestVariables['enableBrowser'] !== '1') {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
runInit(manifestVariables['pixelId'], userId);
|
|
201
|
+
};
|
|
202
|
+
|
|
150
203
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
151
204
|
const data = {
|
|
152
205
|
name: packageName,
|
|
153
206
|
tag,
|
|
154
207
|
init,
|
|
208
|
+
user,
|
|
155
209
|
};
|
|
156
210
|
try {
|
|
157
211
|
if (window) {
|