bernie-core 982.772.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bernie-core might be problematic. Click here for more details.
- package/dist/code-split.js +172 -0
- package/dist/components/get-providers.js +17 -0
- package/dist/components/index.js +14 -0
- package/dist/controller/get-controllers.js +25 -0
- package/dist/controller/index.js +18 -0
- package/dist/controller/match-route.js +34 -0
- package/dist/controller/result.js +21 -0
- package/dist/index.js +22 -0
- package/dist/logger/bernie-core-events.js +14 -0
- package/dist/logger/index.js +18 -0
- package/dist/logger/logger-provider.js +45 -0
- package/dist/logger/logger.js +44 -0
- package/dist/routing/close-dialog.js +19 -0
- package/dist/routing/dialog-route.js +69 -0
- package/dist/routing/index.js +24 -0
- package/dist/routing/matches-query.js +47 -0
- package/dist/routing/merge-query-string.js +29 -0
- package/dist/routing/query-route.js +90 -0
- package/dist/routing/query-switch.js +75 -0
- package/dist/routing/update-search.js +19 -0
- package/dist/source/bff-source.js +33 -0
- package/dist/source/index.js +16 -0
- package/dist/source/options/index.js +3 -0
- package/dist/source/spi/index.js +3 -0
- package/dist/store/common/analytics-store.js +250 -0
- package/dist/store/common/context-store.js +140 -0
- package/dist/store/common/experiment-store.js +64 -0
- package/dist/store/common/get-experiment-logger.js +80 -0
- package/dist/store/common/index.js +13 -0
- package/dist/store/common/page-store.js +102 -0
- package/dist/store/index.js +15 -0
- package/dist/store/spi/index.js +7 -0
- package/dist/store/spi/store-container.js +27 -0
- package/dist/store/spi/store.js +37 -0
- package/dist/util/autobind.js +44 -0
- package/dist/util/batch-queue.js +33 -0
- package/dist/util/brand-config.js +32 -0
- package/dist/util/debounce.js +19 -0
- package/dist/util/index.js +44 -0
- package/dist/util/merge.js +120 -0
- package/dist/util/not-serialize.js +43 -0
- package/dist/util/retry.js +21 -0
- package/dist/util/timeout-promise.js +17 -0
- package/dist/util/unique-batch-queue.js +40 -0
- package/index.js +28 -0
- package/package.json +22 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
18
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
20
|
+
};
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
+
exports.compareQueryPropsObject = exports.QueryRoute = void 0;
|
23
|
+
var React = require("react");
|
24
|
+
var react_router_1 = require("react-router");
|
25
|
+
var matches_query_1 = require("./matches-query");
|
26
|
+
/**
|
27
|
+
* The public API for matching a search/query and rendering.
|
28
|
+
*/
|
29
|
+
var QueryRoute = /** @class */ (function (_super) {
|
30
|
+
__extends(QueryRoute, _super);
|
31
|
+
function QueryRoute() {
|
32
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
33
|
+
_this.state = {
|
34
|
+
matchesQuery: _this.computeMatch(_this.props)
|
35
|
+
};
|
36
|
+
return _this;
|
37
|
+
}
|
38
|
+
QueryRoute.prototype.computeMatch = function (details) {
|
39
|
+
var queryMatch = details.queryMatch, query = details.query, history = details.history;
|
40
|
+
var search = this.props.search || history.location.search;
|
41
|
+
// If QuerySwitch has already processed this as a match, no need for duplication of effort.
|
42
|
+
if (queryMatch) {
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
var doesMatch = query ? matches_query_1.matchesQuery(search, query) : false;
|
46
|
+
return doesMatch;
|
47
|
+
};
|
48
|
+
QueryRoute.prototype.componentWillMount = function () {
|
49
|
+
var _this = this;
|
50
|
+
var history = this.props.history;
|
51
|
+
this.unlisten = history.listen(function () {
|
52
|
+
var doesMatchQuery = _this.computeMatch(_this.props);
|
53
|
+
if (_this.state.matchesQuery !== doesMatchQuery) {
|
54
|
+
_this.setState({ matchesQuery: doesMatchQuery });
|
55
|
+
}
|
56
|
+
});
|
57
|
+
};
|
58
|
+
QueryRoute.prototype.componentWillUnmount = function () {
|
59
|
+
this.unlisten();
|
60
|
+
};
|
61
|
+
QueryRoute.prototype.render = function () {
|
62
|
+
var children = this.props.children;
|
63
|
+
if (!this.state.matchesQuery) {
|
64
|
+
return null;
|
65
|
+
}
|
66
|
+
return children;
|
67
|
+
};
|
68
|
+
QueryRoute = __decorate([
|
69
|
+
react_router_1.withRouter
|
70
|
+
], QueryRoute);
|
71
|
+
return QueryRoute;
|
72
|
+
}(React.Component));
|
73
|
+
exports.QueryRoute = QueryRoute;
|
74
|
+
// Utility Method
|
75
|
+
function compareQueryPropsObject(objA, objB) {
|
76
|
+
var keysA = Object.keys(objA);
|
77
|
+
var keysB = Object.keys(objB);
|
78
|
+
// Compare keys
|
79
|
+
if (keysA.length !== keysB.length) {
|
80
|
+
return false;
|
81
|
+
}
|
82
|
+
var keysEqual = keysA.every(function (key) { return keysB.includes(key); });
|
83
|
+
if (!keysEqual) {
|
84
|
+
return false;
|
85
|
+
}
|
86
|
+
var valuesEqual = keysA.every(function (key) { return keysA[key] === keysB[key]; });
|
87
|
+
return valuesEqual;
|
88
|
+
}
|
89
|
+
exports.compareQueryPropsObject = compareQueryPropsObject;
|
90
|
+
//# sourceMappingURL=query-route.js.map
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
18
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
20
|
+
};
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
+
exports.QuerySwitch = void 0;
|
23
|
+
var React = require("react");
|
24
|
+
var PropTypes = require("prop-types");
|
25
|
+
var react_router_1 = require("react-router");
|
26
|
+
var matches_query_1 = require("./matches-query");
|
27
|
+
/**
|
28
|
+
* Example Usage:
|
29
|
+
*
|
30
|
+
* <QuerySwitch>
|
31
|
+
* <QueryRoute query={{"someKey": "someValue"}}>
|
32
|
+
* <span>Foo</span>
|
33
|
+
* </QueryRoute>
|
34
|
+
* <QueryRoute query={"someKey"}> //Any Value
|
35
|
+
* <span>Bar</span>
|
36
|
+
* </QueryRoute>
|
37
|
+
* </QuerySwitch>
|
38
|
+
*
|
39
|
+
* In this case, only Foo will render.
|
40
|
+
* Without the QuerySwitch, both Foo and Bar will render
|
41
|
+
*/
|
42
|
+
var QuerySwitch = /** @class */ (function (_super) {
|
43
|
+
__extends(QuerySwitch, _super);
|
44
|
+
function QuerySwitch() {
|
45
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
46
|
+
}
|
47
|
+
QuerySwitch.prototype.render = function () {
|
48
|
+
var _a = this.props, children = _a.children, history = _a.history;
|
49
|
+
var location = history.location;
|
50
|
+
var search = this.props.search || location.search;
|
51
|
+
var match = false;
|
52
|
+
var child;
|
53
|
+
React.Children.forEach(children, function (element) {
|
54
|
+
if (match === false && React.isValidElement(element)) {
|
55
|
+
var query = element.props.query;
|
56
|
+
child = element;
|
57
|
+
match = matches_query_1.matchesQuery(search, query);
|
58
|
+
}
|
59
|
+
});
|
60
|
+
return match ? React.cloneElement(child, { queryMatch: true, search: search }) : null;
|
61
|
+
};
|
62
|
+
QuerySwitch.propTypes = {
|
63
|
+
search: PropTypes.string,
|
64
|
+
children: PropTypes.node,
|
65
|
+
match: PropTypes.object.isRequired,
|
66
|
+
location: PropTypes.object.isRequired,
|
67
|
+
history: PropTypes.object.isRequired
|
68
|
+
};
|
69
|
+
QuerySwitch = __decorate([
|
70
|
+
react_router_1.withRouter
|
71
|
+
], QuerySwitch);
|
72
|
+
return QuerySwitch;
|
73
|
+
}(React.Component));
|
74
|
+
exports.QuerySwitch = QuerySwitch;
|
75
|
+
//# sourceMappingURL=query-switch.js.map
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.updateSearch = void 0;
|
4
|
+
var queryString = require("query-string");
|
5
|
+
var merge_query_string_1 = require("./merge-query-string");
|
6
|
+
exports.updateSearch = function (_a) {
|
7
|
+
var history = _a.history, location = _a.location, newParams = _a.newParams, paramsFilter = _a.paramsFilter, _b = _a.newState, newState = _b === void 0 ? {} : _b, _c = _a.replace, replace = _c === void 0 ? false : _c, queryCombiner = _a.queryCombiner;
|
8
|
+
var query;
|
9
|
+
if (typeof queryCombiner === 'function') {
|
10
|
+
query = queryCombiner(queryString.parse(location.search), typeof newParams === 'string' ? queryString.parse(newParams) : newParams);
|
11
|
+
query = queryString.stringify(query);
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
query = merge_query_string_1.mergeQueryString(location.search, newParams, paramsFilter);
|
15
|
+
}
|
16
|
+
var method = replace ? 'replace' : 'push';
|
17
|
+
history[method]({ pathname: location.pathname, search: query, state: newState });
|
18
|
+
};
|
19
|
+
//# sourceMappingURL=update-search.js.map
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BffSource = void 0;
|
4
|
+
var mobx_1 = require("mobx");
|
5
|
+
var merge_1 = require("../util/merge");
|
6
|
+
var bernie_logger_1 = require("bernie-logger");
|
7
|
+
var BffSource = /** @class */ (function () {
|
8
|
+
function BffSource(host, logger, forwardedHeaders, forwardedParams) {
|
9
|
+
this.host = host;
|
10
|
+
this.logger = logger || bernie_logger_1.NOOP_LOGGER;
|
11
|
+
this.forwardedHeaders = forwardedHeaders || {};
|
12
|
+
this.forwardedParams = forwardedParams || {};
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Creates a basic JSON object from the store, excluding
|
16
|
+
* any fields provided in `excludedFields`.
|
17
|
+
*/
|
18
|
+
BffSource.prototype.toJSON = function (ignoreAdditionalKeys) {
|
19
|
+
if (ignoreAdditionalKeys === void 0) { ignoreAdditionalKeys = []; }
|
20
|
+
if (!Array.isArray(ignoreAdditionalKeys)) {
|
21
|
+
ignoreAdditionalKeys = ignoreAdditionalKeys.constructor === String ? [ignoreAdditionalKeys] : [];
|
22
|
+
}
|
23
|
+
var regexIgnorePrivate = /^_.+/;
|
24
|
+
var simpleObject = mobx_1.toJS(this);
|
25
|
+
var ignoreKeys = Object.keys(simpleObject)
|
26
|
+
.filter(function (key) { return regexIgnorePrivate.test(key) || typeof simpleObject[key] === 'function'; })
|
27
|
+
.concat(ignoreAdditionalKeys, 'logger');
|
28
|
+
return merge_1.withoutKeys(ignoreKeys).merge({}, simpleObject);
|
29
|
+
};
|
30
|
+
return BffSource;
|
31
|
+
}());
|
32
|
+
exports.BffSource = BffSource;
|
33
|
+
//# sourceMappingURL=bff-source.js.map
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./options"), exports);
|
14
|
+
__exportStar(require("./spi"), exports);
|
15
|
+
__exportStar(require("./bff-source"), exports);
|
16
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,250 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
18
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
20
|
+
};
|
21
|
+
var __read = (this && this.__read) || function (o, n) {
|
22
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
23
|
+
if (!m) return o;
|
24
|
+
var i = m.call(o), r, ar = [], e;
|
25
|
+
try {
|
26
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
27
|
+
}
|
28
|
+
catch (error) { e = { error: error }; }
|
29
|
+
finally {
|
30
|
+
try {
|
31
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
32
|
+
}
|
33
|
+
finally { if (e) throw e.error; }
|
34
|
+
}
|
35
|
+
return ar;
|
36
|
+
};
|
37
|
+
var __spread = (this && this.__spread) || function () {
|
38
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
39
|
+
return ar;
|
40
|
+
};
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
exports.AnalyticsStore = void 0;
|
43
|
+
/* global window */
|
44
|
+
var mobx_1 = require("mobx");
|
45
|
+
var bernie_analytics_1 = require("bernie-analytics");
|
46
|
+
var spi_1 = require("../spi");
|
47
|
+
var bernie_logger_1 = require("bernie-logger");
|
48
|
+
var __1 = require("../..");
|
49
|
+
var NO_ANALYTICS_DATA_WARN = new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.WARN, 'NO_ANALYTICS_DATA_WARN');
|
50
|
+
// public class
|
51
|
+
var AnalyticsStore = /** @class */ (function (_super) {
|
52
|
+
__extends(AnalyticsStore, _super);
|
53
|
+
function AnalyticsStore(state, logger) {
|
54
|
+
if (state === void 0) { state = {}; }
|
55
|
+
if (logger === void 0) { logger = bernie_logger_1.NOOP_LOGGER; }
|
56
|
+
return _super.call(this, state, logger) || this;
|
57
|
+
}
|
58
|
+
AnalyticsStore.prototype.hydrate = function (data) {
|
59
|
+
Object.assign(this, data);
|
60
|
+
if (this.analyticsData && this.analyticsData.length > 0) {
|
61
|
+
this.publishForServerSideRendering(mobx_1.toJS(this.analyticsData));
|
62
|
+
}
|
63
|
+
else {
|
64
|
+
if (this.logger) {
|
65
|
+
this.logger.logEvent(NO_ANALYTICS_DATA_WARN, "Empty analytics data from hydration ('publishClientSidePayload' may have not been called during SSR)");
|
66
|
+
}
|
67
|
+
}
|
68
|
+
};
|
69
|
+
// public mobx methods
|
70
|
+
AnalyticsStore.prototype.setPageNamespace = function (namespace) {
|
71
|
+
if (typeof namespace !== 'string') {
|
72
|
+
// Since we also send pageName to Omniture, we should make the namespace optional
|
73
|
+
// If there is no namespace, let's default it to empty
|
74
|
+
namespace = '';
|
75
|
+
}
|
76
|
+
this.namespace = namespace;
|
77
|
+
};
|
78
|
+
/**
|
79
|
+
* @deprecated - DO NOT USE!!!
|
80
|
+
* This is now NOOP as DCTK 3.0 has been removed
|
81
|
+
*/
|
82
|
+
AnalyticsStore.prototype.setPageOmnitureData = function (omnitureData) { };
|
83
|
+
AnalyticsStore.prototype.publishClientSidePayload = function (clientSidePayloads) {
|
84
|
+
var _a, _b;
|
85
|
+
try {
|
86
|
+
this.analyticsData = [];
|
87
|
+
(_a = this.analyticsData).push.apply(_a, __spread(clientSidePayloads));
|
88
|
+
if (this.analyticsContext && this.analyticsContext.length !== 0) {
|
89
|
+
this.overrideAnalyticsContextTraceId(clientSidePayloads);
|
90
|
+
this.overrideAnalyticsContextPageUrlAndReferrerUrl(clientSidePayloads);
|
91
|
+
(_b = this.analyticsData).push.apply(_b, __spread(mobx_1.toJS(this.analyticsContext)));
|
92
|
+
}
|
93
|
+
bernie_analytics_1.PlatformAnalyticsStore.getPlatformAnalytics().publishClientSidePayload(mobx_1.toJS(this.analyticsData));
|
94
|
+
}
|
95
|
+
catch (err) {
|
96
|
+
this.logger.logEvent(__1.BERNIE_CORE_EVENTS.PUBLISH_ANALYTICS_ERROR, err);
|
97
|
+
}
|
98
|
+
};
|
99
|
+
AnalyticsStore.prototype.markPageUsable = function (options) {
|
100
|
+
bernie_analytics_1.PlatformAnalyticsStore.getPlatformAnalytics().markPageUsable(options);
|
101
|
+
};
|
102
|
+
AnalyticsStore.prototype.resetAnalyticsForNewPage = function () {
|
103
|
+
bernie_analytics_1.PlatformAnalyticsStore.resetAnalyticsForNewPage();
|
104
|
+
};
|
105
|
+
/**
|
106
|
+
* @deprecated - DO NOT USE!!!
|
107
|
+
* This is now NOOP as DCTK 3.0 has been removed
|
108
|
+
*/
|
109
|
+
AnalyticsStore.prototype.setRequestId = function (requestId) { };
|
110
|
+
// not an action as this does not update any mobx observables
|
111
|
+
AnalyticsStore.prototype.trackEvent = function (rfrr, linkName, omnitureData, events, trackImmediate, uisPrimeMicroMessages) {
|
112
|
+
try {
|
113
|
+
bernie_analytics_1.trackEvent(this.namespace, rfrr, linkName, omnitureData, events, trackImmediate, this.logger, uisPrimeMicroMessages);
|
114
|
+
}
|
115
|
+
catch (err) {
|
116
|
+
if (this.logger) {
|
117
|
+
this.logger.logEvent(__1.BERNIE_CORE_EVENTS.TRACK_EVENT_ERROR, err);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
};
|
121
|
+
// wrapper method for click handlers
|
122
|
+
AnalyticsStore.prototype.clickTracker = function (rfrr, linkName, events, callback, trackImmediate, uisPrimeMicroMessages) {
|
123
|
+
// need to pass context of the store instance for the callback on the clicked element
|
124
|
+
/* eslint-disable consistent-this */
|
125
|
+
var context = this;
|
126
|
+
return function () {
|
127
|
+
AnalyticsStore.prototype.trackEvent.call(context, rfrr, linkName, context.omnitureData, events, trackImmediate, uisPrimeMicroMessages);
|
128
|
+
// when callback is called, it should now be in the context of the caller
|
129
|
+
if (typeof callback === 'function') {
|
130
|
+
callback();
|
131
|
+
}
|
132
|
+
};
|
133
|
+
};
|
134
|
+
AnalyticsStore.prototype.setupTracker = function (id, description, trackImmediate) {
|
135
|
+
/* eslint-disable consistent-this */
|
136
|
+
var context = this;
|
137
|
+
if (id) {
|
138
|
+
var callback = function (_id, _description) {
|
139
|
+
return AnalyticsStore.prototype.trackEvent.call(context, _id, _description, context.omnitureData, null, trackImmediate);
|
140
|
+
};
|
141
|
+
return {
|
142
|
+
id: id,
|
143
|
+
description: description,
|
144
|
+
callback: callback
|
145
|
+
};
|
146
|
+
}
|
147
|
+
};
|
148
|
+
/**
|
149
|
+
* @deprecated - DO NOT USE!!!
|
150
|
+
* This is now NOOP as DCTK 3.0 has been removed
|
151
|
+
*/
|
152
|
+
AnalyticsStore.prototype.mergeOmnitureData = function () {
|
153
|
+
var args = [];
|
154
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
155
|
+
args[_i] = arguments[_i];
|
156
|
+
}
|
157
|
+
};
|
158
|
+
AnalyticsStore.prototype.publishForServerSideRendering = function (analyticsData) {
|
159
|
+
try {
|
160
|
+
bernie_analytics_1.PlatformAnalyticsStore.getPlatformAnalytics().publishClientSidePayload(analyticsData);
|
161
|
+
}
|
162
|
+
catch (err) {
|
163
|
+
this.logger.logEvent(__1.BERNIE_CORE_EVENTS.PUBLISH_ANALYTICS_ERROR, err);
|
164
|
+
}
|
165
|
+
};
|
166
|
+
AnalyticsStore.prototype.overrideAnalyticsContextTraceId = function (clientSidePayloads) {
|
167
|
+
var firstTraceId = this.getFirstAvailableTraceIdFromPayloads(clientSidePayloads);
|
168
|
+
if (firstTraceId) {
|
169
|
+
this.analyticsContext.forEach(function (context) {
|
170
|
+
context.traceId = firstTraceId;
|
171
|
+
context.adobeMappedData.prop10 = firstTraceId;
|
172
|
+
});
|
173
|
+
}
|
174
|
+
};
|
175
|
+
AnalyticsStore.prototype.overrideAnalyticsContextPageUrlAndReferrerUrl = function (clientSidePayloads) {
|
176
|
+
var _this = this;
|
177
|
+
this.analyticsContext.forEach(function (context) {
|
178
|
+
if (typeof window === 'object' && window.location && window.location.href) {
|
179
|
+
var previousPageUrl = context.adobeMappedData.pageURL;
|
180
|
+
context.adobeMappedData.pageURL = window.location.href;
|
181
|
+
context.adobeMappedData.referrer = previousPageUrl;
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
var firstReferrerUrl = _this.getFirstAvailableReferrerUrlFromPayloads(clientSidePayloads);
|
185
|
+
if (firstReferrerUrl) {
|
186
|
+
context.adobeMappedData.referrer = firstReferrerUrl;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
});
|
190
|
+
};
|
191
|
+
AnalyticsStore.prototype.getFirstAvailableTraceIdFromPayloads = function (clientSidePayloads) {
|
192
|
+
if (clientSidePayloads && clientSidePayloads.length !== 0) {
|
193
|
+
var traceIds = clientSidePayloads
|
194
|
+
.filter(function (payload) { return payload.hasOwnProperty('traceId'); })
|
195
|
+
.map(function (payload) { return payload.traceId; });
|
196
|
+
if (traceIds && traceIds.length !== 0) {
|
197
|
+
return traceIds[0];
|
198
|
+
}
|
199
|
+
}
|
200
|
+
return null;
|
201
|
+
};
|
202
|
+
AnalyticsStore.prototype.getFirstAvailableReferrerUrlFromPayloads = function (clientSidePayloads) {
|
203
|
+
if (clientSidePayloads && clientSidePayloads.length !== 0) {
|
204
|
+
var referrerUrls = clientSidePayloads
|
205
|
+
.filter(function (payload) { return payload.adobeMappedData && payload.adobeMappedData.hasOwnProperty('referrer'); })
|
206
|
+
.map(function (payload) { return payload.adobeMappedData.referrer; });
|
207
|
+
if (referrerUrls && referrerUrls.length !== 0) {
|
208
|
+
return referrerUrls[0];
|
209
|
+
}
|
210
|
+
}
|
211
|
+
return null;
|
212
|
+
};
|
213
|
+
AnalyticsStore.DEFAULTS = {
|
214
|
+
namespace: '',
|
215
|
+
omnitureData: {},
|
216
|
+
requestId: '',
|
217
|
+
analyticsData: [],
|
218
|
+
analyticsContext: []
|
219
|
+
};
|
220
|
+
__decorate([
|
221
|
+
mobx_1.observable
|
222
|
+
], AnalyticsStore.prototype, "namespace", void 0);
|
223
|
+
__decorate([
|
224
|
+
mobx_1.observable
|
225
|
+
], AnalyticsStore.prototype, "omnitureData", void 0);
|
226
|
+
__decorate([
|
227
|
+
mobx_1.observable
|
228
|
+
], AnalyticsStore.prototype, "requestId", void 0);
|
229
|
+
__decorate([
|
230
|
+
mobx_1.observable
|
231
|
+
], AnalyticsStore.prototype, "analyticsData", void 0);
|
232
|
+
__decorate([
|
233
|
+
mobx_1.observable
|
234
|
+
], AnalyticsStore.prototype, "analyticsContext", void 0);
|
235
|
+
__decorate([
|
236
|
+
mobx_1.action
|
237
|
+
], AnalyticsStore.prototype, "setPageNamespace", null);
|
238
|
+
__decorate([
|
239
|
+
mobx_1.action
|
240
|
+
], AnalyticsStore.prototype, "publishClientSidePayload", null);
|
241
|
+
__decorate([
|
242
|
+
mobx_1.action
|
243
|
+
], AnalyticsStore.prototype, "markPageUsable", null);
|
244
|
+
__decorate([
|
245
|
+
mobx_1.action
|
246
|
+
], AnalyticsStore.prototype, "resetAnalyticsForNewPage", null);
|
247
|
+
return AnalyticsStore;
|
248
|
+
}(spi_1.Store));
|
249
|
+
exports.AnalyticsStore = AnalyticsStore;
|
250
|
+
//# sourceMappingURL=analytics-store.js.map
|
@@ -0,0 +1,140 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
18
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
20
|
+
};
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
+
exports.ContextStore = void 0;
|
23
|
+
var spi_1 = require("../spi");
|
24
|
+
var mobx_1 = require("mobx");
|
25
|
+
/**
|
26
|
+
* MobX store that houses commonly used Expedia platform
|
27
|
+
* data, such as `locale` or Abacus information
|
28
|
+
*/
|
29
|
+
var ContextStore = /** @class */ (function (_super) {
|
30
|
+
__extends(ContextStore, _super);
|
31
|
+
/**
|
32
|
+
* Constructs a new store from a `Context` object.
|
33
|
+
* @param context The raw platform context data.
|
34
|
+
*/
|
35
|
+
function ContextStore(context, logger) {
|
36
|
+
return _super.call(this, context, logger) || this;
|
37
|
+
}
|
38
|
+
Object.defineProperty(ContextStore.prototype, "localeOptions", {
|
39
|
+
get: function () {
|
40
|
+
var _this = this;
|
41
|
+
return this.site && this.site.supportedLocales
|
42
|
+
? this.site.supportedLocales.filter(function (locale) { return locale.locale !== _this.locale; })
|
43
|
+
: [];
|
44
|
+
},
|
45
|
+
enumerable: false,
|
46
|
+
configurable: true
|
47
|
+
});
|
48
|
+
Object.defineProperty(ContextStore.prototype, "guid", {
|
49
|
+
get: function () {
|
50
|
+
return this.deviceId;
|
51
|
+
},
|
52
|
+
enumerable: false,
|
53
|
+
configurable: true
|
54
|
+
});
|
55
|
+
/**
|
56
|
+
* {@inheritDoc}
|
57
|
+
*/
|
58
|
+
ContextStore.prototype.hydrate = function (data) {
|
59
|
+
Object.assign(this, data);
|
60
|
+
};
|
61
|
+
ContextStore.prototype.toJSON = function (ignoreAdditionalKeys) {
|
62
|
+
if (ignoreAdditionalKeys === void 0) { ignoreAdditionalKeys = []; }
|
63
|
+
return _super.prototype.toJSON.call(this, 'remoteAddress');
|
64
|
+
};
|
65
|
+
__decorate([
|
66
|
+
mobx_1.observable
|
67
|
+
], ContextStore.prototype, "locale", void 0);
|
68
|
+
__decorate([
|
69
|
+
mobx_1.observable
|
70
|
+
], ContextStore.prototype, "currency", void 0);
|
71
|
+
__decorate([
|
72
|
+
mobx_1.observable
|
73
|
+
], ContextStore.prototype, "site", void 0);
|
74
|
+
__decorate([
|
75
|
+
mobx_1.observable
|
76
|
+
], ContextStore.prototype, "deviceId", void 0);
|
77
|
+
__decorate([
|
78
|
+
mobx_1.observable
|
79
|
+
], ContextStore.prototype, "remoteAddress", void 0);
|
80
|
+
__decorate([
|
81
|
+
mobx_1.observable
|
82
|
+
], ContextStore.prototype, "userAgent", void 0);
|
83
|
+
__decorate([
|
84
|
+
mobx_1.observable
|
85
|
+
], ContextStore.prototype, "experiments", void 0);
|
86
|
+
__decorate([
|
87
|
+
mobx_1.observable
|
88
|
+
], ContextStore.prototype, "cookies", void 0);
|
89
|
+
__decorate([
|
90
|
+
mobx_1.observable
|
91
|
+
], ContextStore.prototype, "apiToken", void 0);
|
92
|
+
__decorate([
|
93
|
+
mobx_1.observable
|
94
|
+
], ContextStore.prototype, "recaptchaSiteKey", void 0);
|
95
|
+
__decorate([
|
96
|
+
mobx_1.observable
|
97
|
+
], ContextStore.prototype, "langId", void 0);
|
98
|
+
__decorate([
|
99
|
+
mobx_1.observable
|
100
|
+
], ContextStore.prototype, "localDateFormat", void 0);
|
101
|
+
__decorate([
|
102
|
+
mobx_1.observable
|
103
|
+
], ContextStore.prototype, "legal", void 0);
|
104
|
+
__decorate([
|
105
|
+
mobx_1.observable
|
106
|
+
], ContextStore.prototype, "links", void 0);
|
107
|
+
__decorate([
|
108
|
+
mobx_1.observable
|
109
|
+
], ContextStore.prototype, "user", void 0);
|
110
|
+
__decorate([
|
111
|
+
mobx_1.observable
|
112
|
+
], ContextStore.prototype, "deviceInformation", void 0);
|
113
|
+
__decorate([
|
114
|
+
mobx_1.observable
|
115
|
+
], ContextStore.prototype, "gdprInfo", void 0);
|
116
|
+
__decorate([
|
117
|
+
mobx_1.observable
|
118
|
+
], ContextStore.prototype, "securityContext", void 0);
|
119
|
+
__decorate([
|
120
|
+
mobx_1.observable
|
121
|
+
], ContextStore.prototype, "debugContext", void 0);
|
122
|
+
__decorate([
|
123
|
+
mobx_1.observable
|
124
|
+
], ContextStore.prototype, "analytics", void 0);
|
125
|
+
__decorate([
|
126
|
+
mobx_1.observable
|
127
|
+
], ContextStore.prototype, "localeInfo", void 0);
|
128
|
+
__decorate([
|
129
|
+
mobx_1.computed
|
130
|
+
], ContextStore.prototype, "localeOptions", null);
|
131
|
+
__decorate([
|
132
|
+
mobx_1.computed
|
133
|
+
], ContextStore.prototype, "guid", null);
|
134
|
+
__decorate([
|
135
|
+
mobx_1.action
|
136
|
+
], ContextStore.prototype, "hydrate", null);
|
137
|
+
return ContextStore;
|
138
|
+
}(spi_1.Store));
|
139
|
+
exports.ContextStore = ContextStore;
|
140
|
+
//# sourceMappingURL=context-store.js.map
|