@constructor-io/constructorio-client-javascript 2.26.6 → 2.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/lib/constructorio.js +22 -6
- package/package.json +4 -6
package/lib/constructorio.js
CHANGED
|
@@ -25,7 +25,23 @@ var EventDispatcher = require('./utils/event-dispatcher');
|
|
|
25
25
|
var helpers = require('./utils/helpers');
|
|
26
26
|
|
|
27
27
|
var _require = require('../package.json'),
|
|
28
|
-
packageVersion = _require.version;
|
|
28
|
+
packageVersion = _require.version; // Compute package version string
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var computePackageVersion = function computePackageVersion() {
|
|
32
|
+
var versionPrefix = 'ciojs-client-';
|
|
33
|
+
var versionModifiers = [];
|
|
34
|
+
|
|
35
|
+
if (!helpers.canUseDOM()) {
|
|
36
|
+
versionModifiers.push('domless');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof process.env !== 'undefined' && process.env.BUNDLED) {
|
|
40
|
+
versionModifiers.push('bundled');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return "".concat(versionPrefix).concat(versionModifiers.join('-')).concat(versionModifiers.length ? '-' : '').concat(packageVersion);
|
|
44
|
+
};
|
|
29
45
|
/**
|
|
30
46
|
* Class to instantiate the ConstructorIO client.
|
|
31
47
|
*/
|
|
@@ -61,9 +77,8 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
61
77
|
function ConstructorIO() {
|
|
62
78
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
63
79
|
(0, _classCallCheck2["default"])(this, ConstructorIO);
|
|
64
|
-
var canUseDOM = helpers.canUseDOM();
|
|
65
80
|
var apiKey = options.apiKey,
|
|
66
|
-
|
|
81
|
+
versionFromOptions = options.version,
|
|
67
82
|
serviceUrl = options.serviceUrl,
|
|
68
83
|
segments = options.segments,
|
|
69
84
|
testCells = options.testCells,
|
|
@@ -84,9 +99,10 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
84
99
|
}
|
|
85
100
|
|
|
86
101
|
var session_id;
|
|
87
|
-
var client_id;
|
|
102
|
+
var client_id;
|
|
103
|
+
var versionFromGlobal = typeof global !== 'undefined' && global.CLIENT_VERSION; // Initialize ID session if DOM context is available
|
|
88
104
|
|
|
89
|
-
if (canUseDOM) {
|
|
105
|
+
if (helpers.canUseDOM()) {
|
|
90
106
|
var _ConstructorioID = new ConstructorioID(idOptions || {});
|
|
91
107
|
|
|
92
108
|
session_id = _ConstructorioID.session_id;
|
|
@@ -105,7 +121,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
105
121
|
|
|
106
122
|
this.options = {
|
|
107
123
|
apiKey: apiKey,
|
|
108
|
-
version:
|
|
124
|
+
version: versionFromOptions || versionFromGlobal || computePackageVersion(),
|
|
109
125
|
serviceUrl: serviceUrl && serviceUrl.replace(/\/$/, '') || 'https://ac.cnstrc.com',
|
|
110
126
|
sessionId: sessionId || session_id,
|
|
111
127
|
clientId: clientId || client_id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-client-javascript",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
4
4
|
"description": "Constructor.io JavaScript client",
|
|
5
5
|
"main": "lib/constructorio.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"docs": "jsdoc --configure ./.jsdoc.json ./README.md --recurse ./src --destination ./docs",
|
|
19
19
|
"compile": "babel src/ -d lib/",
|
|
20
20
|
"prepublish": "npm run compile",
|
|
21
|
-
"bundle": "rm -rf ./dist/* && npm run compile && node bundle.js"
|
|
21
|
+
"bundle": "rm -rf ./dist/* && npm run compile && node bundle.js",
|
|
22
|
+
"prepare": "husky install"
|
|
22
23
|
},
|
|
23
24
|
"repository": {
|
|
24
25
|
"type": "git",
|
|
@@ -30,9 +31,6 @@
|
|
|
30
31
|
"url": "https://github.com/Constructor-io/constructorio-client-javascript/issues"
|
|
31
32
|
},
|
|
32
33
|
"homepage": "https://github.com/Constructor-io/constructorio-client-javascript#readme",
|
|
33
|
-
"pre-push": [
|
|
34
|
-
"lint"
|
|
35
|
-
],
|
|
36
34
|
"files": [
|
|
37
35
|
"lib/**/*"
|
|
38
36
|
],
|
|
@@ -49,6 +47,7 @@
|
|
|
49
47
|
"eslint": "^8.0.1",
|
|
50
48
|
"eslint-config-airbnb-base": "^13.1.0",
|
|
51
49
|
"eslint-plugin-import": "^2.25.2",
|
|
50
|
+
"husky": "^7.0.4",
|
|
52
51
|
"jsdoc": "^3.6.7",
|
|
53
52
|
"jsdom": "^15.1.1",
|
|
54
53
|
"license-checker": "^25.0.1",
|
|
@@ -57,7 +56,6 @@
|
|
|
57
56
|
"mocha": "^9.1.3",
|
|
58
57
|
"mocha-jsdom": "^2.0.0",
|
|
59
58
|
"nyc": "^15.1.0",
|
|
60
|
-
"pre-push": "^0.1.1",
|
|
61
59
|
"serve": "^13.0.2",
|
|
62
60
|
"sinon": "^7.5.0",
|
|
63
61
|
"sinon-chai": "^3.7.0"
|