coveo.analytics 2.25.3 → 2.26.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/README.md +31 -0
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +291 -105
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analytics.d.ts +4 -0
- package/dist/definitions/coveoua/plugins.d.ts +2 -6
- package/dist/definitions/coveoua/simpleanalytics.d.ts +1 -1
- package/dist/definitions/plugins/BasePlugin.d.ts +8 -3
- package/dist/definitions/plugins/ec.d.ts +1 -0
- package/dist/definitions/plugins/link.d.ts +21 -0
- package/dist/definitions/plugins/svc.d.ts +1 -0
- package/dist/definitions/src/coveoua/plugins.d.ts +2 -6
- package/dist/definitions/src/coveoua/simpleanalytics.d.ts +1 -1
- package/dist/definitions/src/plugins/ec.d.ts +1 -0
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.es.js +233 -88
- package/dist/library.js +294 -108
- package/dist/react-native.es.js +238 -93
- package/package.json +1 -1
- package/src/client/analytics.spec.ts +122 -0
- package/src/client/analytics.ts +33 -1
- package/src/coveoua/plugins.ts +7 -8
- package/src/coveoua/simpleanalytics.spec.ts +15 -10
- package/src/coveoua/simpleanalytics.ts +2 -2
- package/src/plugins/BasePlugin.ts +21 -7
- package/src/plugins/ec.ts +13 -0
- package/src/plugins/link.spec.ts +171 -0
- package/src/plugins/link.ts +109 -0
- package/src/plugins/svc.ts +11 -0
- package/dist/definitions/src/client/location.d.ts +0 -1
package/dist/library.js
CHANGED
|
@@ -562,7 +562,7 @@ function stringToBytes(str) {
|
|
|
562
562
|
}
|
|
563
563
|
|
|
564
564
|
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
565
|
-
const URL$
|
|
565
|
+
const URL$2 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
566
566
|
function v35(name, version, hashfunc) {
|
|
567
567
|
function generateUUID(value, namespace, buf, offset) {
|
|
568
568
|
var _namespace;
|
|
@@ -609,7 +609,7 @@ function v35(name, version, hashfunc) {
|
|
|
609
609
|
|
|
610
610
|
|
|
611
611
|
generateUUID.DNS = DNS;
|
|
612
|
-
generateUUID.URL = URL$
|
|
612
|
+
generateUUID.URL = URL$2;
|
|
613
613
|
return generateUUID;
|
|
614
614
|
}
|
|
615
615
|
|
|
@@ -740,7 +740,224 @@ function sha1(bytes) {
|
|
|
740
740
|
const v5 = v35('v5', 0x50, sha1);
|
|
741
741
|
var uuidv5 = v5;
|
|
742
742
|
|
|
743
|
-
var libVersion = "2.
|
|
743
|
+
var libVersion = "2.26.1" ;
|
|
744
|
+
|
|
745
|
+
var getFormattedLocation = function (location) {
|
|
746
|
+
return location.protocol + "//" + location.hostname + (location.pathname.indexOf('/') === 0 ? location.pathname : "/" + location.pathname) + location.search;
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
var BasePluginEventTypes = {
|
|
750
|
+
pageview: 'pageview',
|
|
751
|
+
event: 'event',
|
|
752
|
+
};
|
|
753
|
+
var Plugin = (function () {
|
|
754
|
+
function Plugin(_a) {
|
|
755
|
+
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
756
|
+
this.client = client;
|
|
757
|
+
this.uuidGenerator = uuidGenerator;
|
|
758
|
+
}
|
|
759
|
+
return Plugin;
|
|
760
|
+
}());
|
|
761
|
+
var BasePlugin = (function (_super) {
|
|
762
|
+
__extends(BasePlugin, _super);
|
|
763
|
+
function BasePlugin(_a) {
|
|
764
|
+
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
765
|
+
var _this = _super.call(this, { client: client, uuidGenerator: uuidGenerator }) || this;
|
|
766
|
+
_this.actionData = {};
|
|
767
|
+
_this.pageViewId = uuidGenerator();
|
|
768
|
+
_this.nextPageViewId = _this.pageViewId;
|
|
769
|
+
_this.currentLocation = getFormattedLocation(window.location);
|
|
770
|
+
_this.lastReferrer = hasDocument() ? document.referrer : '';
|
|
771
|
+
_this.addHooks();
|
|
772
|
+
return _this;
|
|
773
|
+
}
|
|
774
|
+
BasePlugin.prototype.getApi = function (name) {
|
|
775
|
+
switch (name) {
|
|
776
|
+
case 'setAction':
|
|
777
|
+
return this.setAction;
|
|
778
|
+
default:
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
BasePlugin.prototype.setAction = function (action, options) {
|
|
783
|
+
this.action = action;
|
|
784
|
+
this.actionData = options;
|
|
785
|
+
};
|
|
786
|
+
BasePlugin.prototype.clearData = function () {
|
|
787
|
+
this.clearPluginData();
|
|
788
|
+
this.action = undefined;
|
|
789
|
+
this.actionData = {};
|
|
790
|
+
};
|
|
791
|
+
BasePlugin.prototype.getLocationInformation = function (eventType, payload) {
|
|
792
|
+
return __assign({ hitType: eventType }, this.getNextValues(eventType, payload));
|
|
793
|
+
};
|
|
794
|
+
BasePlugin.prototype.updateLocationInformation = function (eventType, payload) {
|
|
795
|
+
this.updateLocationForNextPageView(eventType, payload);
|
|
796
|
+
};
|
|
797
|
+
BasePlugin.prototype.getDefaultContextInformation = function (eventType) {
|
|
798
|
+
var documentContext = {
|
|
799
|
+
title: hasDocument() ? document.title : '',
|
|
800
|
+
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
801
|
+
};
|
|
802
|
+
var screenContext = {
|
|
803
|
+
screenResolution: screen.width + "x" + screen.height,
|
|
804
|
+
screenColor: screen.colorDepth + "-bit",
|
|
805
|
+
};
|
|
806
|
+
var navigatorContext = {
|
|
807
|
+
language: navigator.language,
|
|
808
|
+
userAgent: navigator.userAgent,
|
|
809
|
+
};
|
|
810
|
+
var eventContext = {
|
|
811
|
+
time: Date.now(),
|
|
812
|
+
eventId: this.uuidGenerator(),
|
|
813
|
+
};
|
|
814
|
+
return __assign(__assign(__assign(__assign({}, eventContext), screenContext), navigatorContext), documentContext);
|
|
815
|
+
};
|
|
816
|
+
BasePlugin.prototype.updateLocationForNextPageView = function (eventType, payload) {
|
|
817
|
+
var _a = this.getNextValues(eventType, payload), pageViewId = _a.pageViewId, referrer = _a.referrer, location = _a.location;
|
|
818
|
+
this.lastReferrer = referrer;
|
|
819
|
+
this.pageViewId = pageViewId;
|
|
820
|
+
this.currentLocation = location;
|
|
821
|
+
if (eventType === BasePluginEventTypes.pageview) {
|
|
822
|
+
this.nextPageViewId = this.uuidGenerator();
|
|
823
|
+
this.hasSentFirstPageView = true;
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
BasePlugin.prototype.getNextValues = function (eventType, payload) {
|
|
827
|
+
return {
|
|
828
|
+
pageViewId: eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
829
|
+
referrer: eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
830
|
+
? this.currentLocation
|
|
831
|
+
: this.lastReferrer,
|
|
832
|
+
location: eventType === BasePluginEventTypes.pageview
|
|
833
|
+
? this.getCurrentLocationFromPayload(payload)
|
|
834
|
+
: this.currentLocation,
|
|
835
|
+
};
|
|
836
|
+
};
|
|
837
|
+
BasePlugin.prototype.getCurrentLocationFromPayload = function (payload) {
|
|
838
|
+
if (!!payload.page) {
|
|
839
|
+
var removeStartingSlash = function (page) { return page.replace(/^\/?(.*)$/, '/$1'); };
|
|
840
|
+
var extractHostnamePart = function (location) { return location.split('/').slice(0, 3).join('/'); };
|
|
841
|
+
return "" + extractHostnamePart(this.currentLocation) + removeStartingSlash(payload.page);
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
return getFormattedLocation(window.location);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
return BasePlugin;
|
|
848
|
+
}(Plugin));
|
|
849
|
+
|
|
850
|
+
var CoveoLinkParam = (function () {
|
|
851
|
+
function CoveoLinkParam(clientId, timestamp) {
|
|
852
|
+
if (!validate(clientId))
|
|
853
|
+
throw Error('Not a valid uuid');
|
|
854
|
+
this.clientId = clientId;
|
|
855
|
+
this.creationDate = Math.floor(timestamp / 1000);
|
|
856
|
+
}
|
|
857
|
+
CoveoLinkParam.prototype.toString = function () {
|
|
858
|
+
return this.clientId.replace(/-/g, '') + '.' + this.creationDate.toString();
|
|
859
|
+
};
|
|
860
|
+
Object.defineProperty(CoveoLinkParam.prototype, "expired", {
|
|
861
|
+
get: function () {
|
|
862
|
+
var age = Math.floor(Date.now() / 1000) - this.creationDate;
|
|
863
|
+
return age < 0 || age > CoveoLinkParam.expirationTime;
|
|
864
|
+
},
|
|
865
|
+
enumerable: false,
|
|
866
|
+
configurable: true
|
|
867
|
+
});
|
|
868
|
+
CoveoLinkParam.prototype.validate = function (referrerString, referrerList) {
|
|
869
|
+
return !this.expired && this.matchReferrer(referrerString, referrerList);
|
|
870
|
+
};
|
|
871
|
+
CoveoLinkParam.prototype.matchReferrer = function (referrerString, referrerList) {
|
|
872
|
+
try {
|
|
873
|
+
var url_1 = new URL(referrerString);
|
|
874
|
+
return referrerList.some(function (value) {
|
|
875
|
+
var hostRegExp = new RegExp(value.replace(/\\/g, '\\\\').replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
876
|
+
return hostRegExp.test(url_1.host);
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
catch (error) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
CoveoLinkParam.fromString = function (input) {
|
|
884
|
+
var parts = input.split('.');
|
|
885
|
+
if (parts.length !== 2) {
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
var clientIdPart = parts[0], creationDate = parts[1];
|
|
889
|
+
if (clientIdPart.length !== 32 || isNaN(parseInt(creationDate))) {
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
var clientId = clientIdPart.substring(0, 8) +
|
|
893
|
+
'-' +
|
|
894
|
+
clientIdPart.substring(8, 12) +
|
|
895
|
+
'-' +
|
|
896
|
+
clientIdPart.substring(12, 16) +
|
|
897
|
+
'-' +
|
|
898
|
+
clientIdPart.substring(16, 20) +
|
|
899
|
+
'-' +
|
|
900
|
+
clientIdPart.substring(20, 32);
|
|
901
|
+
if (validate(clientId)) {
|
|
902
|
+
return new CoveoLinkParam(clientId, Number.parseInt(creationDate) * 1000);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
CoveoLinkParam.cvo_cid = 'cvo_cid';
|
|
909
|
+
CoveoLinkParam.expirationTime = 120;
|
|
910
|
+
return CoveoLinkParam;
|
|
911
|
+
}());
|
|
912
|
+
var LinkPlugin = (function (_super) {
|
|
913
|
+
__extends(LinkPlugin, _super);
|
|
914
|
+
function LinkPlugin(_a) {
|
|
915
|
+
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
916
|
+
return _super.call(this, { client: client, uuidGenerator: uuidGenerator }) || this;
|
|
917
|
+
}
|
|
918
|
+
LinkPlugin.prototype.getApi = function (name) {
|
|
919
|
+
switch (name) {
|
|
920
|
+
case 'decorate':
|
|
921
|
+
return this.decorate;
|
|
922
|
+
case 'acceptFrom':
|
|
923
|
+
return this.acceptFrom;
|
|
924
|
+
default:
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
LinkPlugin.prototype.decorate = function (urlString) {
|
|
929
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
930
|
+
var url, clientId;
|
|
931
|
+
return __generator(this, function (_a) {
|
|
932
|
+
switch (_a.label) {
|
|
933
|
+
case 0:
|
|
934
|
+
if (!this.client.getCurrentVisitorId) {
|
|
935
|
+
throw new Error('Could not retrieve current clientId');
|
|
936
|
+
}
|
|
937
|
+
_a.label = 1;
|
|
938
|
+
case 1:
|
|
939
|
+
_a.trys.push([1, 3, , 4]);
|
|
940
|
+
url = new URL(urlString);
|
|
941
|
+
return [4, this.client.getCurrentVisitorId()];
|
|
942
|
+
case 2:
|
|
943
|
+
clientId = _a.sent();
|
|
944
|
+
url.searchParams.set(CoveoLinkParam.cvo_cid, new CoveoLinkParam(clientId, Date.now()).toString());
|
|
945
|
+
return [2, url.toString()];
|
|
946
|
+
case 3:
|
|
947
|
+
_a.sent();
|
|
948
|
+
throw new Error('Invalid URL provided');
|
|
949
|
+
case 4: return [2];
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
});
|
|
953
|
+
};
|
|
954
|
+
LinkPlugin.prototype.acceptFrom = function (acceptedReferrers) {
|
|
955
|
+
this.client.setAcceptedLinkReferrers(acceptedReferrers);
|
|
956
|
+
};
|
|
957
|
+
LinkPlugin.Id = 'link';
|
|
958
|
+
return LinkPlugin;
|
|
959
|
+
}(Plugin));
|
|
960
|
+
var Link = LinkPlugin;
|
|
744
961
|
|
|
745
962
|
var keysOf = Object.keys;
|
|
746
963
|
function isObject(o) {
|
|
@@ -1109,7 +1326,7 @@ var lib$1 = {exports: {}};
|
|
|
1109
1326
|
|
|
1110
1327
|
var publicApi = {};
|
|
1111
1328
|
|
|
1112
|
-
var URL = {exports: {}};
|
|
1329
|
+
var URL$1 = {exports: {}};
|
|
1113
1330
|
|
|
1114
1331
|
var conversions = {};
|
|
1115
1332
|
var lib = conversions;
|
|
@@ -80864,9 +81081,9 @@ module.exports = {
|
|
|
80864
81081
|
Worker: { URL: URL }
|
|
80865
81082
|
}
|
|
80866
81083
|
};
|
|
80867
|
-
}(URL));
|
|
81084
|
+
}(URL$1));
|
|
80868
81085
|
|
|
80869
|
-
publicApi.URL = URL.exports.interface;
|
|
81086
|
+
publicApi.URL = URL$1.exports.interface;
|
|
80870
81087
|
publicApi.serializeURL = urlStateMachine.exports.serializeURL;
|
|
80871
81088
|
publicApi.serializeURLOrigin = urlStateMachine.exports.serializeURLOrigin;
|
|
80872
81089
|
publicApi.basicURLParse = urlStateMachine.exports.basicURLParse;
|
|
@@ -82784,6 +83001,7 @@ function buildBaseUrl(endpoint, apiVersion) {
|
|
|
82784
83001
|
var COVEO_NAMESPACE = '38824e1f-37f5-42d3-8372-a4b8fa9df946';
|
|
82785
83002
|
var CoveoAnalyticsClient = (function () {
|
|
82786
83003
|
function CoveoAnalyticsClient(opts) {
|
|
83004
|
+
this.acceptedLinkReferrers = [];
|
|
82787
83005
|
if (!opts) {
|
|
82788
83006
|
throw new Error('You have to pass options to this constructor');
|
|
82789
83007
|
}
|
|
@@ -82848,18 +83066,24 @@ var CoveoAnalyticsClient = (function () {
|
|
|
82848
83066
|
});
|
|
82849
83067
|
CoveoAnalyticsClient.prototype.determineVisitorId = function () {
|
|
82850
83068
|
return __awaiter(this, void 0, void 0, function () {
|
|
82851
|
-
var err_1;
|
|
82852
|
-
return __generator(this, function (
|
|
82853
|
-
switch (
|
|
83069
|
+
var _a, err_1;
|
|
83070
|
+
return __generator(this, function (_b) {
|
|
83071
|
+
switch (_b.label) {
|
|
82854
83072
|
case 0:
|
|
82855
|
-
|
|
83073
|
+
_b.trys.push([0, 3, , 4]);
|
|
83074
|
+
_a = this.extractClientIdFromLink(window.location.href);
|
|
83075
|
+
if (_a) return [3, 2];
|
|
82856
83076
|
return [4, this.storage.getItem('visitorId')];
|
|
82857
|
-
case 1:
|
|
82858
|
-
|
|
82859
|
-
|
|
83077
|
+
case 1:
|
|
83078
|
+
_a = (_b.sent());
|
|
83079
|
+
_b.label = 2;
|
|
83080
|
+
case 2: return [2, (_a ||
|
|
83081
|
+
v4())];
|
|
83082
|
+
case 3:
|
|
83083
|
+
err_1 = _b.sent();
|
|
82860
83084
|
console.log('Could not get visitor ID from the current runtime environment storage. Using a random ID instead.', err_1);
|
|
82861
83085
|
return [2, v4()];
|
|
82862
|
-
case
|
|
83086
|
+
case 4: return [2];
|
|
82863
83087
|
}
|
|
82864
83088
|
});
|
|
82865
83089
|
});
|
|
@@ -82960,6 +83184,25 @@ var CoveoAnalyticsClient = (function () {
|
|
|
82960
83184
|
enumerable: false,
|
|
82961
83185
|
configurable: true
|
|
82962
83186
|
});
|
|
83187
|
+
CoveoAnalyticsClient.prototype.extractClientIdFromLink = function (urlString) {
|
|
83188
|
+
if (doNotTrack()) {
|
|
83189
|
+
return null;
|
|
83190
|
+
}
|
|
83191
|
+
try {
|
|
83192
|
+
var linkParam = new URL(urlString).searchParams.get(CoveoLinkParam.cvo_cid);
|
|
83193
|
+
if (linkParam == null) {
|
|
83194
|
+
return null;
|
|
83195
|
+
}
|
|
83196
|
+
var linker = CoveoLinkParam.fromString(linkParam);
|
|
83197
|
+
if (!linker || !hasDocument() || !linker.validate(document.referrer, this.acceptedLinkReferrers)) {
|
|
83198
|
+
return null;
|
|
83199
|
+
}
|
|
83200
|
+
return linker.clientId;
|
|
83201
|
+
}
|
|
83202
|
+
catch (error) {
|
|
83203
|
+
}
|
|
83204
|
+
return null;
|
|
83205
|
+
};
|
|
82963
83206
|
CoveoAnalyticsClient.prototype.resolveParameters = function (eventType) {
|
|
82964
83207
|
var payload = [];
|
|
82965
83208
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -83294,6 +83537,12 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83294
83537
|
CoveoAnalyticsClient.prototype.addEventTypeMapping = function (eventType, eventConfig) {
|
|
83295
83538
|
this.eventTypeMapping[eventType] = eventConfig;
|
|
83296
83539
|
};
|
|
83540
|
+
CoveoAnalyticsClient.prototype.setAcceptedLinkReferrers = function (hosts) {
|
|
83541
|
+
if (Array.isArray(hosts) && hosts.every(function (host) { return typeof host == 'string'; }))
|
|
83542
|
+
this.acceptedLinkReferrers = hosts;
|
|
83543
|
+
else
|
|
83544
|
+
throw Error('Parameter should be an array of domain strings');
|
|
83545
|
+
};
|
|
83297
83546
|
CoveoAnalyticsClient.prototype.parseVariableArgumentsPayload = function (fieldsOrder, payload) {
|
|
83298
83547
|
var parsedArguments = {};
|
|
83299
83548
|
for (var i = 0, length_1 = payload.length; i < length_1; i++) {
|
|
@@ -83406,94 +83655,6 @@ var analytics = /*#__PURE__*/Object.freeze({
|
|
|
83406
83655
|
'default': CoveoAnalyticsClient
|
|
83407
83656
|
});
|
|
83408
83657
|
|
|
83409
|
-
var getFormattedLocation = function (location) {
|
|
83410
|
-
return location.protocol + "//" + location.hostname + (location.pathname.indexOf('/') === 0 ? location.pathname : "/" + location.pathname) + location.search;
|
|
83411
|
-
};
|
|
83412
|
-
|
|
83413
|
-
var BasePluginEventTypes = {
|
|
83414
|
-
pageview: 'pageview',
|
|
83415
|
-
event: 'event',
|
|
83416
|
-
};
|
|
83417
|
-
var BasePlugin = (function () {
|
|
83418
|
-
function BasePlugin(_a) {
|
|
83419
|
-
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
83420
|
-
this.actionData = {};
|
|
83421
|
-
this.client = client;
|
|
83422
|
-
this.uuidGenerator = uuidGenerator;
|
|
83423
|
-
this.pageViewId = uuidGenerator();
|
|
83424
|
-
this.nextPageViewId = this.pageViewId;
|
|
83425
|
-
this.currentLocation = getFormattedLocation(window.location);
|
|
83426
|
-
this.lastReferrer = hasDocument() ? document.referrer : '';
|
|
83427
|
-
this.addHooks();
|
|
83428
|
-
}
|
|
83429
|
-
BasePlugin.prototype.setAction = function (action, options) {
|
|
83430
|
-
this.action = action;
|
|
83431
|
-
this.actionData = options;
|
|
83432
|
-
};
|
|
83433
|
-
BasePlugin.prototype.clearData = function () {
|
|
83434
|
-
this.clearPluginData();
|
|
83435
|
-
this.action = undefined;
|
|
83436
|
-
this.actionData = {};
|
|
83437
|
-
};
|
|
83438
|
-
BasePlugin.prototype.getLocationInformation = function (eventType, payload) {
|
|
83439
|
-
return __assign({ hitType: eventType }, this.getNextValues(eventType, payload));
|
|
83440
|
-
};
|
|
83441
|
-
BasePlugin.prototype.updateLocationInformation = function (eventType, payload) {
|
|
83442
|
-
this.updateLocationForNextPageView(eventType, payload);
|
|
83443
|
-
};
|
|
83444
|
-
BasePlugin.prototype.getDefaultContextInformation = function (eventType) {
|
|
83445
|
-
var documentContext = {
|
|
83446
|
-
title: hasDocument() ? document.title : '',
|
|
83447
|
-
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
83448
|
-
};
|
|
83449
|
-
var screenContext = {
|
|
83450
|
-
screenResolution: screen.width + "x" + screen.height,
|
|
83451
|
-
screenColor: screen.colorDepth + "-bit",
|
|
83452
|
-
};
|
|
83453
|
-
var navigatorContext = {
|
|
83454
|
-
language: navigator.language,
|
|
83455
|
-
userAgent: navigator.userAgent,
|
|
83456
|
-
};
|
|
83457
|
-
var eventContext = {
|
|
83458
|
-
time: Date.now(),
|
|
83459
|
-
eventId: this.uuidGenerator(),
|
|
83460
|
-
};
|
|
83461
|
-
return __assign(__assign(__assign(__assign({}, eventContext), screenContext), navigatorContext), documentContext);
|
|
83462
|
-
};
|
|
83463
|
-
BasePlugin.prototype.updateLocationForNextPageView = function (eventType, payload) {
|
|
83464
|
-
var _a = this.getNextValues(eventType, payload), pageViewId = _a.pageViewId, referrer = _a.referrer, location = _a.location;
|
|
83465
|
-
this.lastReferrer = referrer;
|
|
83466
|
-
this.pageViewId = pageViewId;
|
|
83467
|
-
this.currentLocation = location;
|
|
83468
|
-
if (eventType === BasePluginEventTypes.pageview) {
|
|
83469
|
-
this.nextPageViewId = this.uuidGenerator();
|
|
83470
|
-
this.hasSentFirstPageView = true;
|
|
83471
|
-
}
|
|
83472
|
-
};
|
|
83473
|
-
BasePlugin.prototype.getNextValues = function (eventType, payload) {
|
|
83474
|
-
return {
|
|
83475
|
-
pageViewId: eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
83476
|
-
referrer: eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
83477
|
-
? this.currentLocation
|
|
83478
|
-
: this.lastReferrer,
|
|
83479
|
-
location: eventType === BasePluginEventTypes.pageview
|
|
83480
|
-
? this.getCurrentLocationFromPayload(payload)
|
|
83481
|
-
: this.currentLocation,
|
|
83482
|
-
};
|
|
83483
|
-
};
|
|
83484
|
-
BasePlugin.prototype.getCurrentLocationFromPayload = function (payload) {
|
|
83485
|
-
if (!!payload.page) {
|
|
83486
|
-
var removeStartingSlash = function (page) { return page.replace(/^\/?(.*)$/, '/$1'); };
|
|
83487
|
-
var extractHostnamePart = function (location) { return location.split('/').slice(0, 3).join('/'); };
|
|
83488
|
-
return "" + extractHostnamePart(this.currentLocation) + removeStartingSlash(payload.page);
|
|
83489
|
-
}
|
|
83490
|
-
else {
|
|
83491
|
-
return getFormattedLocation(window.location);
|
|
83492
|
-
}
|
|
83493
|
-
};
|
|
83494
|
-
return BasePlugin;
|
|
83495
|
-
}());
|
|
83496
|
-
|
|
83497
83658
|
var ECPluginEventTypes = __assign({}, BasePluginEventTypes);
|
|
83498
83659
|
var allECEventTypes = Object.keys(ECPluginEventTypes).map(function (key) { return ECPluginEventTypes[key]; });
|
|
83499
83660
|
var ECPlugin = (function (_super) {
|
|
@@ -83505,6 +83666,19 @@ var ECPlugin = (function (_super) {
|
|
|
83505
83666
|
_this.impressions = [];
|
|
83506
83667
|
return _this;
|
|
83507
83668
|
}
|
|
83669
|
+
ECPlugin.prototype.getApi = function (name) {
|
|
83670
|
+
var superCall = _super.prototype.getApi.call(this, name);
|
|
83671
|
+
if (superCall !== null)
|
|
83672
|
+
return superCall;
|
|
83673
|
+
switch (name) {
|
|
83674
|
+
case 'addProduct':
|
|
83675
|
+
return this.addProduct;
|
|
83676
|
+
case 'addImpression':
|
|
83677
|
+
return this.addImpression;
|
|
83678
|
+
default:
|
|
83679
|
+
return null;
|
|
83680
|
+
}
|
|
83681
|
+
};
|
|
83508
83682
|
ECPlugin.prototype.addHooks = function () {
|
|
83509
83683
|
this.addHooksForPageView();
|
|
83510
83684
|
this.addHooksForEvent();
|
|
@@ -83632,6 +83806,17 @@ var SVCPlugin = (function (_super) {
|
|
|
83632
83806
|
_this.ticket = {};
|
|
83633
83807
|
return _this;
|
|
83634
83808
|
}
|
|
83809
|
+
SVCPlugin.prototype.getApi = function (name) {
|
|
83810
|
+
var superCall = _super.prototype.getApi.call(this, name);
|
|
83811
|
+
if (superCall !== null)
|
|
83812
|
+
return superCall;
|
|
83813
|
+
switch (name) {
|
|
83814
|
+
case 'setTicket':
|
|
83815
|
+
return this.setTicket;
|
|
83816
|
+
default:
|
|
83817
|
+
return null;
|
|
83818
|
+
}
|
|
83819
|
+
};
|
|
83635
83820
|
SVCPlugin.prototype.addHooks = function () {
|
|
83636
83821
|
this.addHooksForEvent();
|
|
83637
83822
|
this.addHooksForPageView();
|
|
@@ -83702,6 +83887,7 @@ var Plugins = (function () {
|
|
|
83702
83887
|
this.registeredPluginsMap = (_a = {},
|
|
83703
83888
|
_a[EC.Id] = EC,
|
|
83704
83889
|
_a[SVC.Id] = SVC,
|
|
83890
|
+
_a[Link.Id] = Link,
|
|
83705
83891
|
_a);
|
|
83706
83892
|
this.requiredPlugins = {};
|
|
83707
83893
|
}
|
|
@@ -83719,24 +83905,24 @@ var Plugins = (function () {
|
|
|
83719
83905
|
this.requiredPlugins = {};
|
|
83720
83906
|
};
|
|
83721
83907
|
Plugins.prototype.execute = function (name, fn) {
|
|
83722
|
-
var
|
|
83908
|
+
var args = [];
|
|
83723
83909
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
83724
|
-
|
|
83910
|
+
args[_i - 2] = arguments[_i];
|
|
83725
83911
|
}
|
|
83726
83912
|
var plugin = this.requiredPlugins[name];
|
|
83727
83913
|
if (!plugin) {
|
|
83728
83914
|
throw new Error("The plugin \"" + name + "\" is not required. Check that you required it on initialization.");
|
|
83729
83915
|
}
|
|
83730
|
-
var actionFunction = plugin
|
|
83916
|
+
var actionFunction = plugin.getApi(fn);
|
|
83731
83917
|
if (!actionFunction) {
|
|
83732
83918
|
throw new Error("The function \"" + fn + "\" does not exist on the plugin \"" + name + "\".");
|
|
83733
83919
|
}
|
|
83734
83920
|
if (typeof actionFunction !== 'function') {
|
|
83735
83921
|
throw new Error("\"" + fn + "\" of the plugin \"" + name + "\" is not a function.");
|
|
83736
83922
|
}
|
|
83737
|
-
return actionFunction.apply(plugin,
|
|
83923
|
+
return actionFunction.apply(plugin, args);
|
|
83738
83924
|
};
|
|
83739
|
-
Plugins.DefaultPlugins = [EC.Id, SVC.Id];
|
|
83925
|
+
Plugins.DefaultPlugins = [EC.Id, SVC.Id, Link.Id];
|
|
83740
83926
|
return Plugins;
|
|
83741
83927
|
}());
|
|
83742
83928
|
|
|
@@ -83848,7 +84034,7 @@ var CoveoUA = (function () {
|
|
|
83848
84034
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
83849
84035
|
args[_i - 2] = arguments[_i];
|
|
83850
84036
|
}
|
|
83851
|
-
(_a = this.plugins).execute.apply(_a, __spreadArrays([pluginName, fn], args));
|
|
84037
|
+
return (_a = this.plugins).execute.apply(_a, __spreadArrays([pluginName, fn], args));
|
|
83852
84038
|
};
|
|
83853
84039
|
CoveoUA.prototype.reset = function () {
|
|
83854
84040
|
this.client = undefined;
|