@adobe/alloy 2.14.0-alpha.11 → 2.14.0-alpha.12
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/libEs5/components/Context/injectDevice.js +25 -12
- package/libEs5/components/Context/injectEnvironment.js +10 -3
- package/libEs5/components/Identity/visitorService/injectGetEcidFromVisitor.js +2 -1
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/utils/toInteger.js +14 -2
- package/libEs6/components/Context/injectDevice.js +26 -13
- package/libEs6/components/Context/injectEnvironment.js +11 -4
- package/libEs6/components/Identity/visitorService/injectGetEcidFromVisitor.js +2 -1
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/utils/toInteger.js +13 -3
- package/package.json +2 -2
|
@@ -36,12 +36,14 @@ var getScreenOrientationViaProperty = function getScreenOrientationViaProperty(w
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
var getScreenOrientationViaMediaQuery = function getScreenOrientationViaMediaQuery(window) {
|
|
39
|
-
if (window.matchMedia
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if ((0, _utils.isFunction)(window.matchMedia)) {
|
|
40
|
+
if (window.matchMedia("(orientation: portrait)").matches) {
|
|
41
|
+
return "portrait";
|
|
42
|
+
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (window.matchMedia("(orientation: landscape)").matches) {
|
|
45
|
+
return "landscape";
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
return null;
|
|
@@ -52,19 +54,30 @@ var _default = function _default(window) {
|
|
|
52
54
|
var _window$screen = window.screen,
|
|
53
55
|
width = _window$screen.width,
|
|
54
56
|
height = _window$screen.height;
|
|
55
|
-
var device = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
var device = {};
|
|
58
|
+
var screenHeight = (0, _utils.toInteger)(height);
|
|
59
|
+
|
|
60
|
+
if (screenHeight >= 0) {
|
|
61
|
+
device.screenHeight = screenHeight;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var screenWidth = (0, _utils.toInteger)(width);
|
|
65
|
+
|
|
66
|
+
if (screenWidth >= 0) {
|
|
67
|
+
device.screenWidth = screenWidth;
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
var orientation = getScreenOrientationViaProperty(window) || getScreenOrientationViaMediaQuery(window);
|
|
60
71
|
|
|
61
72
|
if (orientation) {
|
|
62
73
|
device.screenOrientation = orientation;
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
if (Object.keys(device).length > 0) {
|
|
77
|
+
(0, _utils.deepAssign)(xdm, {
|
|
78
|
+
device: device
|
|
79
|
+
});
|
|
80
|
+
}
|
|
68
81
|
};
|
|
69
82
|
};
|
|
70
83
|
|
|
@@ -24,14 +24,21 @@ var _default = function _default(window) {
|
|
|
24
24
|
var environment = {
|
|
25
25
|
type: "browser"
|
|
26
26
|
};
|
|
27
|
+
var viewportWidth = (0, _utils.toInteger)(clientWidth);
|
|
27
28
|
|
|
28
|
-
if (
|
|
29
|
+
if (viewportWidth >= 0) {
|
|
29
30
|
environment.browserDetails = {
|
|
30
|
-
viewportWidth:
|
|
31
|
-
viewportHeight: Math.round(clientHeight)
|
|
31
|
+
viewportWidth: viewportWidth
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
var viewportHeight = (0, _utils.toInteger)(clientHeight);
|
|
36
|
+
|
|
37
|
+
if (viewportHeight >= 0) {
|
|
38
|
+
environment.browserDetails = environment.browserDetails || {};
|
|
39
|
+
environment.browserDetails.viewportHeight = viewportHeight;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
(0, _utils.deepAssign)(xdm, {
|
|
36
43
|
environment: environment
|
|
37
44
|
});
|
|
@@ -19,8 +19,9 @@ var _default = function _default(_ref) {
|
|
|
19
19
|
var logger = _ref.logger,
|
|
20
20
|
orgId = _ref.orgId,
|
|
21
21
|
awaitVisitorOptIn = _ref.awaitVisitorOptIn;
|
|
22
|
-
var Visitor = (0, _getVisitor.default)(window);
|
|
23
22
|
return function () {
|
|
23
|
+
var Visitor = (0, _getVisitor.default)(window);
|
|
24
|
+
|
|
24
25
|
if (Visitor) {
|
|
25
26
|
// Need to explicitly wait for optIn because visitor will call callback
|
|
26
27
|
// with invalid values prior to optIn being approved
|
|
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
|
|
|
15
15
|
*/
|
|
16
16
|
// The __VERSION__ keyword will be replace at alloy build time with the package.json version.
|
|
17
17
|
// see babel-plugin-version
|
|
18
|
-
var _default = "2.14.0-alpha.
|
|
18
|
+
var _default = "2.14.0-alpha.12";
|
|
19
19
|
exports.default = _default;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
+
var _isNumber = require("./isNumber");
|
|
6
|
+
|
|
7
|
+
var _isString = require("./isString");
|
|
8
|
+
|
|
5
9
|
/*
|
|
6
10
|
Copyright 2022 Adobe. All rights reserved.
|
|
7
11
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -16,11 +20,19 @@ governing permissions and limitations under the License.
|
|
|
16
20
|
|
|
17
21
|
/*
|
|
18
22
|
* coerce `value` to a number or return `defaultValue` if it cannot be.
|
|
23
|
+
*
|
|
24
|
+
* The coersion is attempted if value is a number or string.
|
|
19
25
|
*/
|
|
20
26
|
var _default = function _default(value, defaultValue) {
|
|
21
|
-
|
|
27
|
+
if ((0, _isNumber.default)(value) || (0, _isString.default)(value)) {
|
|
28
|
+
var n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
|
|
29
|
+
|
|
30
|
+
if (!isNaN(n)) {
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
|
|
23
|
-
return
|
|
35
|
+
return defaultValue;
|
|
24
36
|
};
|
|
25
37
|
|
|
26
38
|
exports.default = _default;
|
|
@@ -9,7 +9,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { deepAssign } from "../../utils";
|
|
12
|
+
import { deepAssign, isFunction, toInteger } from "../../utils";
|
|
13
13
|
|
|
14
14
|
const getScreenOrientationViaProperty = window => {
|
|
15
15
|
const {
|
|
@@ -36,12 +36,14 @@ const getScreenOrientationViaProperty = window => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const getScreenOrientationViaMediaQuery = window => {
|
|
39
|
-
if (window.matchMedia
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if (isFunction(window.matchMedia)) {
|
|
40
|
+
if (window.matchMedia("(orientation: portrait)").matches) {
|
|
41
|
+
return "portrait";
|
|
42
|
+
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (window.matchMedia("(orientation: landscape)").matches) {
|
|
45
|
+
return "landscape";
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
return null;
|
|
@@ -55,18 +57,29 @@ export default (window => {
|
|
|
55
57
|
height
|
|
56
58
|
}
|
|
57
59
|
} = window;
|
|
58
|
-
const device = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const device = {};
|
|
61
|
+
const screenHeight = toInteger(height);
|
|
62
|
+
|
|
63
|
+
if (screenHeight >= 0) {
|
|
64
|
+
device.screenHeight = screenHeight;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const screenWidth = toInteger(width);
|
|
68
|
+
|
|
69
|
+
if (screenWidth >= 0) {
|
|
70
|
+
device.screenWidth = screenWidth;
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
const orientation = getScreenOrientationViaProperty(window) || getScreenOrientationViaMediaQuery(window);
|
|
63
74
|
|
|
64
75
|
if (orientation) {
|
|
65
76
|
device.screenOrientation = orientation;
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
if (Object.keys(device).length > 0) {
|
|
80
|
+
deepAssign(xdm, {
|
|
81
|
+
device
|
|
82
|
+
});
|
|
83
|
+
}
|
|
71
84
|
};
|
|
72
85
|
});
|
|
@@ -9,7 +9,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { deepAssign,
|
|
12
|
+
import { deepAssign, toInteger } from "../../utils";
|
|
13
13
|
export default (window => {
|
|
14
14
|
return xdm => {
|
|
15
15
|
const {
|
|
@@ -23,14 +23,21 @@ export default (window => {
|
|
|
23
23
|
const environment = {
|
|
24
24
|
type: "browser"
|
|
25
25
|
};
|
|
26
|
+
const viewportWidth = toInteger(clientWidth);
|
|
26
27
|
|
|
27
|
-
if (
|
|
28
|
+
if (viewportWidth >= 0) {
|
|
28
29
|
environment.browserDetails = {
|
|
29
|
-
viewportWidth
|
|
30
|
-
viewportHeight: Math.round(clientHeight)
|
|
30
|
+
viewportWidth
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
const viewportHeight = toInteger(clientHeight);
|
|
35
|
+
|
|
36
|
+
if (viewportHeight >= 0) {
|
|
37
|
+
environment.browserDetails = environment.browserDetails || {};
|
|
38
|
+
environment.browserDetails.viewportHeight = viewportHeight;
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
deepAssign(xdm, {
|
|
35
42
|
environment
|
|
36
43
|
});
|
|
@@ -15,8 +15,9 @@ export default (({
|
|
|
15
15
|
orgId,
|
|
16
16
|
awaitVisitorOptIn
|
|
17
17
|
}) => {
|
|
18
|
-
const Visitor = getVisitor(window);
|
|
19
18
|
return () => {
|
|
19
|
+
const Visitor = getVisitor(window);
|
|
20
|
+
|
|
20
21
|
if (Visitor) {
|
|
21
22
|
// Need to explicitly wait for optIn because visitor will call callback
|
|
22
23
|
// with invalid values prior to optIn being approved
|
|
@@ -9,12 +9,22 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
import isNumber from "./isNumber";
|
|
13
|
+
import isString from "./isString";
|
|
13
14
|
/*
|
|
14
15
|
* coerce `value` to a number or return `defaultValue` if it cannot be.
|
|
16
|
+
*
|
|
17
|
+
* The coersion is attempted if value is a number or string.
|
|
15
18
|
*/
|
|
19
|
+
|
|
16
20
|
export default ((value, defaultValue) => {
|
|
17
|
-
|
|
21
|
+
if (isNumber(value) || isString(value)) {
|
|
22
|
+
const n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
|
|
23
|
+
|
|
24
|
+
if (!isNaN(n)) {
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
18
28
|
|
|
19
|
-
return
|
|
29
|
+
return defaultValue;
|
|
20
30
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.14.0-alpha.
|
|
3
|
+
"version": "2.14.0-alpha.12",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"main": "libEs5/index.js",
|
|
6
6
|
"module": "libEs6/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"uuid": "^3.3.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@adobe/alloy": "^2.14.0-alpha.
|
|
67
|
+
"@adobe/alloy": "^2.14.0-alpha.11",
|
|
68
68
|
"@babel/cli": "^7.12.8",
|
|
69
69
|
"@babel/core": "^7.2.2",
|
|
70
70
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|