coveo.analytics 2.25.3 → 2.26.2
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/coveoua.debug.js
CHANGED
|
@@ -546,7 +546,7 @@
|
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
549
|
-
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
549
|
+
const URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
550
550
|
function v35(name, version, hashfunc) {
|
|
551
551
|
function generateUUID(value, namespace, buf, offset) {
|
|
552
552
|
var _namespace;
|
|
@@ -593,7 +593,7 @@
|
|
|
593
593
|
|
|
594
594
|
|
|
595
595
|
generateUUID.DNS = DNS;
|
|
596
|
-
generateUUID.URL = URL;
|
|
596
|
+
generateUUID.URL = URL$1;
|
|
597
597
|
return generateUUID;
|
|
598
598
|
}
|
|
599
599
|
|
|
@@ -724,7 +724,224 @@
|
|
|
724
724
|
const v5 = v35('v5', 0x50, sha1);
|
|
725
725
|
var uuidv5 = v5;
|
|
726
726
|
|
|
727
|
-
var libVersion = "2.
|
|
727
|
+
var libVersion = "2.26.2" ;
|
|
728
|
+
|
|
729
|
+
var getFormattedLocation = function (location) {
|
|
730
|
+
return location.protocol + "//" + location.hostname + (location.pathname.indexOf('/') === 0 ? location.pathname : "/" + location.pathname) + location.search;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
var BasePluginEventTypes = {
|
|
734
|
+
pageview: 'pageview',
|
|
735
|
+
event: 'event',
|
|
736
|
+
};
|
|
737
|
+
var Plugin = (function () {
|
|
738
|
+
function Plugin(_a) {
|
|
739
|
+
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
740
|
+
this.client = client;
|
|
741
|
+
this.uuidGenerator = uuidGenerator;
|
|
742
|
+
}
|
|
743
|
+
return Plugin;
|
|
744
|
+
}());
|
|
745
|
+
var BasePlugin = (function (_super) {
|
|
746
|
+
__extends(BasePlugin, _super);
|
|
747
|
+
function BasePlugin(_a) {
|
|
748
|
+
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
749
|
+
var _this = _super.call(this, { client: client, uuidGenerator: uuidGenerator }) || this;
|
|
750
|
+
_this.actionData = {};
|
|
751
|
+
_this.pageViewId = uuidGenerator();
|
|
752
|
+
_this.nextPageViewId = _this.pageViewId;
|
|
753
|
+
_this.currentLocation = getFormattedLocation(window.location);
|
|
754
|
+
_this.lastReferrer = hasDocument() ? document.referrer : '';
|
|
755
|
+
_this.addHooks();
|
|
756
|
+
return _this;
|
|
757
|
+
}
|
|
758
|
+
BasePlugin.prototype.getApi = function (name) {
|
|
759
|
+
switch (name) {
|
|
760
|
+
case 'setAction':
|
|
761
|
+
return this.setAction;
|
|
762
|
+
default:
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
BasePlugin.prototype.setAction = function (action, options) {
|
|
767
|
+
this.action = action;
|
|
768
|
+
this.actionData = options;
|
|
769
|
+
};
|
|
770
|
+
BasePlugin.prototype.clearData = function () {
|
|
771
|
+
this.clearPluginData();
|
|
772
|
+
this.action = undefined;
|
|
773
|
+
this.actionData = {};
|
|
774
|
+
};
|
|
775
|
+
BasePlugin.prototype.getLocationInformation = function (eventType, payload) {
|
|
776
|
+
return __assign({ hitType: eventType }, this.getNextValues(eventType, payload));
|
|
777
|
+
};
|
|
778
|
+
BasePlugin.prototype.updateLocationInformation = function (eventType, payload) {
|
|
779
|
+
this.updateLocationForNextPageView(eventType, payload);
|
|
780
|
+
};
|
|
781
|
+
BasePlugin.prototype.getDefaultContextInformation = function (eventType) {
|
|
782
|
+
var documentContext = {
|
|
783
|
+
title: hasDocument() ? document.title : '',
|
|
784
|
+
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
785
|
+
};
|
|
786
|
+
var screenContext = {
|
|
787
|
+
screenResolution: screen.width + "x" + screen.height,
|
|
788
|
+
screenColor: screen.colorDepth + "-bit",
|
|
789
|
+
};
|
|
790
|
+
var navigatorContext = {
|
|
791
|
+
language: navigator.language,
|
|
792
|
+
userAgent: navigator.userAgent,
|
|
793
|
+
};
|
|
794
|
+
var eventContext = {
|
|
795
|
+
time: Date.now(),
|
|
796
|
+
eventId: this.uuidGenerator(),
|
|
797
|
+
};
|
|
798
|
+
return __assign(__assign(__assign(__assign({}, eventContext), screenContext), navigatorContext), documentContext);
|
|
799
|
+
};
|
|
800
|
+
BasePlugin.prototype.updateLocationForNextPageView = function (eventType, payload) {
|
|
801
|
+
var _a = this.getNextValues(eventType, payload), pageViewId = _a.pageViewId, referrer = _a.referrer, location = _a.location;
|
|
802
|
+
this.lastReferrer = referrer;
|
|
803
|
+
this.pageViewId = pageViewId;
|
|
804
|
+
this.currentLocation = location;
|
|
805
|
+
if (eventType === BasePluginEventTypes.pageview) {
|
|
806
|
+
this.nextPageViewId = this.uuidGenerator();
|
|
807
|
+
this.hasSentFirstPageView = true;
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
BasePlugin.prototype.getNextValues = function (eventType, payload) {
|
|
811
|
+
return {
|
|
812
|
+
pageViewId: eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
813
|
+
referrer: eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
814
|
+
? this.currentLocation
|
|
815
|
+
: this.lastReferrer,
|
|
816
|
+
location: eventType === BasePluginEventTypes.pageview
|
|
817
|
+
? this.getCurrentLocationFromPayload(payload)
|
|
818
|
+
: this.currentLocation,
|
|
819
|
+
};
|
|
820
|
+
};
|
|
821
|
+
BasePlugin.prototype.getCurrentLocationFromPayload = function (payload) {
|
|
822
|
+
if (!!payload.page) {
|
|
823
|
+
var removeStartingSlash = function (page) { return page.replace(/^\/?(.*)$/, '/$1'); };
|
|
824
|
+
var extractHostnamePart = function (location) { return location.split('/').slice(0, 3).join('/'); };
|
|
825
|
+
return "" + extractHostnamePart(this.currentLocation) + removeStartingSlash(payload.page);
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
return getFormattedLocation(window.location);
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
return BasePlugin;
|
|
832
|
+
}(Plugin));
|
|
833
|
+
|
|
834
|
+
var CoveoLinkParam = (function () {
|
|
835
|
+
function CoveoLinkParam(clientId, timestamp) {
|
|
836
|
+
if (!validate(clientId))
|
|
837
|
+
throw Error('Not a valid uuid');
|
|
838
|
+
this.clientId = clientId;
|
|
839
|
+
this.creationDate = Math.floor(timestamp / 1000);
|
|
840
|
+
}
|
|
841
|
+
CoveoLinkParam.prototype.toString = function () {
|
|
842
|
+
return this.clientId.replace(/-/g, '') + '.' + this.creationDate.toString();
|
|
843
|
+
};
|
|
844
|
+
Object.defineProperty(CoveoLinkParam.prototype, "expired", {
|
|
845
|
+
get: function () {
|
|
846
|
+
var age = Math.floor(Date.now() / 1000) - this.creationDate;
|
|
847
|
+
return age < 0 || age > CoveoLinkParam.expirationTime;
|
|
848
|
+
},
|
|
849
|
+
enumerable: false,
|
|
850
|
+
configurable: true
|
|
851
|
+
});
|
|
852
|
+
CoveoLinkParam.prototype.validate = function (referrerString, referrerList) {
|
|
853
|
+
return !this.expired && this.matchReferrer(referrerString, referrerList);
|
|
854
|
+
};
|
|
855
|
+
CoveoLinkParam.prototype.matchReferrer = function (referrerString, referrerList) {
|
|
856
|
+
try {
|
|
857
|
+
var url_1 = new URL(referrerString);
|
|
858
|
+
return referrerList.some(function (value) {
|
|
859
|
+
var hostRegExp = new RegExp(value.replace(/\\/g, '\\\\').replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
860
|
+
return hostRegExp.test(url_1.host);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
catch (error) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
CoveoLinkParam.fromString = function (input) {
|
|
868
|
+
var parts = input.split('.');
|
|
869
|
+
if (parts.length !== 2) {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
var clientIdPart = parts[0], creationDate = parts[1];
|
|
873
|
+
if (clientIdPart.length !== 32 || isNaN(parseInt(creationDate))) {
|
|
874
|
+
return null;
|
|
875
|
+
}
|
|
876
|
+
var clientId = clientIdPart.substring(0, 8) +
|
|
877
|
+
'-' +
|
|
878
|
+
clientIdPart.substring(8, 12) +
|
|
879
|
+
'-' +
|
|
880
|
+
clientIdPart.substring(12, 16) +
|
|
881
|
+
'-' +
|
|
882
|
+
clientIdPart.substring(16, 20) +
|
|
883
|
+
'-' +
|
|
884
|
+
clientIdPart.substring(20, 32);
|
|
885
|
+
if (validate(clientId)) {
|
|
886
|
+
return new CoveoLinkParam(clientId, Number.parseInt(creationDate) * 1000);
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
return null;
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
CoveoLinkParam.cvo_cid = 'cvo_cid';
|
|
893
|
+
CoveoLinkParam.expirationTime = 120;
|
|
894
|
+
return CoveoLinkParam;
|
|
895
|
+
}());
|
|
896
|
+
var LinkPlugin = (function (_super) {
|
|
897
|
+
__extends(LinkPlugin, _super);
|
|
898
|
+
function LinkPlugin(_a) {
|
|
899
|
+
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
900
|
+
return _super.call(this, { client: client, uuidGenerator: uuidGenerator }) || this;
|
|
901
|
+
}
|
|
902
|
+
LinkPlugin.prototype.getApi = function (name) {
|
|
903
|
+
switch (name) {
|
|
904
|
+
case 'decorate':
|
|
905
|
+
return this.decorate;
|
|
906
|
+
case 'acceptFrom':
|
|
907
|
+
return this.acceptFrom;
|
|
908
|
+
default:
|
|
909
|
+
return null;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
LinkPlugin.prototype.decorate = function (urlString) {
|
|
913
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
914
|
+
var url, clientId;
|
|
915
|
+
return __generator(this, function (_a) {
|
|
916
|
+
switch (_a.label) {
|
|
917
|
+
case 0:
|
|
918
|
+
if (!this.client.getCurrentVisitorId) {
|
|
919
|
+
throw new Error('Could not retrieve current clientId');
|
|
920
|
+
}
|
|
921
|
+
_a.label = 1;
|
|
922
|
+
case 1:
|
|
923
|
+
_a.trys.push([1, 3, , 4]);
|
|
924
|
+
url = new URL(urlString);
|
|
925
|
+
return [4, this.client.getCurrentVisitorId()];
|
|
926
|
+
case 2:
|
|
927
|
+
clientId = _a.sent();
|
|
928
|
+
url.searchParams.set(CoveoLinkParam.cvo_cid, new CoveoLinkParam(clientId, Date.now()).toString());
|
|
929
|
+
return [2, url.toString()];
|
|
930
|
+
case 3:
|
|
931
|
+
_a.sent();
|
|
932
|
+
throw new Error('Invalid URL provided');
|
|
933
|
+
case 4: return [2];
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
};
|
|
938
|
+
LinkPlugin.prototype.acceptFrom = function (acceptedReferrers) {
|
|
939
|
+
this.client.setAcceptedLinkReferrers(acceptedReferrers);
|
|
940
|
+
};
|
|
941
|
+
LinkPlugin.Id = 'link';
|
|
942
|
+
return LinkPlugin;
|
|
943
|
+
}(Plugin));
|
|
944
|
+
var Link = LinkPlugin;
|
|
728
945
|
|
|
729
946
|
var keysOf = Object.keys;
|
|
730
947
|
function isObject(o) {
|
|
@@ -1271,6 +1488,7 @@
|
|
|
1271
1488
|
var COVEO_NAMESPACE = '38824e1f-37f5-42d3-8372-a4b8fa9df946';
|
|
1272
1489
|
var CoveoAnalyticsClient = (function () {
|
|
1273
1490
|
function CoveoAnalyticsClient(opts) {
|
|
1491
|
+
this.acceptedLinkReferrers = [];
|
|
1274
1492
|
if (!opts) {
|
|
1275
1493
|
throw new Error('You have to pass options to this constructor');
|
|
1276
1494
|
}
|
|
@@ -1335,18 +1553,24 @@
|
|
|
1335
1553
|
});
|
|
1336
1554
|
CoveoAnalyticsClient.prototype.determineVisitorId = function () {
|
|
1337
1555
|
return __awaiter(this, void 0, void 0, function () {
|
|
1338
|
-
var err_1;
|
|
1339
|
-
return __generator(this, function (
|
|
1340
|
-
switch (
|
|
1556
|
+
var _a, err_1;
|
|
1557
|
+
return __generator(this, function (_b) {
|
|
1558
|
+
switch (_b.label) {
|
|
1341
1559
|
case 0:
|
|
1342
|
-
|
|
1560
|
+
_b.trys.push([0, 3, , 4]);
|
|
1561
|
+
_a = this.extractClientIdFromLink(window.location.href);
|
|
1562
|
+
if (_a) return [3, 2];
|
|
1343
1563
|
return [4, this.storage.getItem('visitorId')];
|
|
1344
|
-
case 1:
|
|
1345
|
-
|
|
1346
|
-
|
|
1564
|
+
case 1:
|
|
1565
|
+
_a = (_b.sent());
|
|
1566
|
+
_b.label = 2;
|
|
1567
|
+
case 2: return [2, (_a ||
|
|
1568
|
+
v4())];
|
|
1569
|
+
case 3:
|
|
1570
|
+
err_1 = _b.sent();
|
|
1347
1571
|
console.log('Could not get visitor ID from the current runtime environment storage. Using a random ID instead.', err_1);
|
|
1348
1572
|
return [2, v4()];
|
|
1349
|
-
case
|
|
1573
|
+
case 4: return [2];
|
|
1350
1574
|
}
|
|
1351
1575
|
});
|
|
1352
1576
|
});
|
|
@@ -1447,6 +1671,25 @@
|
|
|
1447
1671
|
enumerable: false,
|
|
1448
1672
|
configurable: true
|
|
1449
1673
|
});
|
|
1674
|
+
CoveoAnalyticsClient.prototype.extractClientIdFromLink = function (urlString) {
|
|
1675
|
+
if (doNotTrack()) {
|
|
1676
|
+
return null;
|
|
1677
|
+
}
|
|
1678
|
+
try {
|
|
1679
|
+
var linkParam = new URL(urlString).searchParams.get(CoveoLinkParam.cvo_cid);
|
|
1680
|
+
if (linkParam == null) {
|
|
1681
|
+
return null;
|
|
1682
|
+
}
|
|
1683
|
+
var linker = CoveoLinkParam.fromString(linkParam);
|
|
1684
|
+
if (!linker || !hasDocument() || !linker.validate(document.referrer, this.acceptedLinkReferrers)) {
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1687
|
+
return linker.clientId;
|
|
1688
|
+
}
|
|
1689
|
+
catch (error) {
|
|
1690
|
+
}
|
|
1691
|
+
return null;
|
|
1692
|
+
};
|
|
1450
1693
|
CoveoAnalyticsClient.prototype.resolveParameters = function (eventType) {
|
|
1451
1694
|
var payload = [];
|
|
1452
1695
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -1781,6 +2024,12 @@
|
|
|
1781
2024
|
CoveoAnalyticsClient.prototype.addEventTypeMapping = function (eventType, eventConfig) {
|
|
1782
2025
|
this.eventTypeMapping[eventType] = eventConfig;
|
|
1783
2026
|
};
|
|
2027
|
+
CoveoAnalyticsClient.prototype.setAcceptedLinkReferrers = function (hosts) {
|
|
2028
|
+
if (Array.isArray(hosts) && hosts.every(function (host) { return typeof host == 'string'; }))
|
|
2029
|
+
this.acceptedLinkReferrers = hosts;
|
|
2030
|
+
else
|
|
2031
|
+
throw Error('Parameter should be an array of domain strings');
|
|
2032
|
+
};
|
|
1784
2033
|
CoveoAnalyticsClient.prototype.parseVariableArgumentsPayload = function (fieldsOrder, payload) {
|
|
1785
2034
|
var parsedArguments = {};
|
|
1786
2035
|
for (var i = 0, length_1 = payload.length; i < length_1; i++) {
|
|
@@ -1893,94 +2142,6 @@
|
|
|
1893
2142
|
'default': CoveoAnalyticsClient
|
|
1894
2143
|
});
|
|
1895
2144
|
|
|
1896
|
-
var getFormattedLocation = function (location) {
|
|
1897
|
-
return location.protocol + "//" + location.hostname + (location.pathname.indexOf('/') === 0 ? location.pathname : "/" + location.pathname) + location.search;
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
var BasePluginEventTypes = {
|
|
1901
|
-
pageview: 'pageview',
|
|
1902
|
-
event: 'event',
|
|
1903
|
-
};
|
|
1904
|
-
var BasePlugin = (function () {
|
|
1905
|
-
function BasePlugin(_a) {
|
|
1906
|
-
var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
|
|
1907
|
-
this.actionData = {};
|
|
1908
|
-
this.client = client;
|
|
1909
|
-
this.uuidGenerator = uuidGenerator;
|
|
1910
|
-
this.pageViewId = uuidGenerator();
|
|
1911
|
-
this.nextPageViewId = this.pageViewId;
|
|
1912
|
-
this.currentLocation = getFormattedLocation(window.location);
|
|
1913
|
-
this.lastReferrer = hasDocument() ? document.referrer : '';
|
|
1914
|
-
this.addHooks();
|
|
1915
|
-
}
|
|
1916
|
-
BasePlugin.prototype.setAction = function (action, options) {
|
|
1917
|
-
this.action = action;
|
|
1918
|
-
this.actionData = options;
|
|
1919
|
-
};
|
|
1920
|
-
BasePlugin.prototype.clearData = function () {
|
|
1921
|
-
this.clearPluginData();
|
|
1922
|
-
this.action = undefined;
|
|
1923
|
-
this.actionData = {};
|
|
1924
|
-
};
|
|
1925
|
-
BasePlugin.prototype.getLocationInformation = function (eventType, payload) {
|
|
1926
|
-
return __assign({ hitType: eventType }, this.getNextValues(eventType, payload));
|
|
1927
|
-
};
|
|
1928
|
-
BasePlugin.prototype.updateLocationInformation = function (eventType, payload) {
|
|
1929
|
-
this.updateLocationForNextPageView(eventType, payload);
|
|
1930
|
-
};
|
|
1931
|
-
BasePlugin.prototype.getDefaultContextInformation = function (eventType) {
|
|
1932
|
-
var documentContext = {
|
|
1933
|
-
title: hasDocument() ? document.title : '',
|
|
1934
|
-
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
1935
|
-
};
|
|
1936
|
-
var screenContext = {
|
|
1937
|
-
screenResolution: screen.width + "x" + screen.height,
|
|
1938
|
-
screenColor: screen.colorDepth + "-bit",
|
|
1939
|
-
};
|
|
1940
|
-
var navigatorContext = {
|
|
1941
|
-
language: navigator.language,
|
|
1942
|
-
userAgent: navigator.userAgent,
|
|
1943
|
-
};
|
|
1944
|
-
var eventContext = {
|
|
1945
|
-
time: Date.now(),
|
|
1946
|
-
eventId: this.uuidGenerator(),
|
|
1947
|
-
};
|
|
1948
|
-
return __assign(__assign(__assign(__assign({}, eventContext), screenContext), navigatorContext), documentContext);
|
|
1949
|
-
};
|
|
1950
|
-
BasePlugin.prototype.updateLocationForNextPageView = function (eventType, payload) {
|
|
1951
|
-
var _a = this.getNextValues(eventType, payload), pageViewId = _a.pageViewId, referrer = _a.referrer, location = _a.location;
|
|
1952
|
-
this.lastReferrer = referrer;
|
|
1953
|
-
this.pageViewId = pageViewId;
|
|
1954
|
-
this.currentLocation = location;
|
|
1955
|
-
if (eventType === BasePluginEventTypes.pageview) {
|
|
1956
|
-
this.nextPageViewId = this.uuidGenerator();
|
|
1957
|
-
this.hasSentFirstPageView = true;
|
|
1958
|
-
}
|
|
1959
|
-
};
|
|
1960
|
-
BasePlugin.prototype.getNextValues = function (eventType, payload) {
|
|
1961
|
-
return {
|
|
1962
|
-
pageViewId: eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
1963
|
-
referrer: eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
1964
|
-
? this.currentLocation
|
|
1965
|
-
: this.lastReferrer,
|
|
1966
|
-
location: eventType === BasePluginEventTypes.pageview
|
|
1967
|
-
? this.getCurrentLocationFromPayload(payload)
|
|
1968
|
-
: this.currentLocation,
|
|
1969
|
-
};
|
|
1970
|
-
};
|
|
1971
|
-
BasePlugin.prototype.getCurrentLocationFromPayload = function (payload) {
|
|
1972
|
-
if (!!payload.page) {
|
|
1973
|
-
var removeStartingSlash = function (page) { return page.replace(/^\/?(.*)$/, '/$1'); };
|
|
1974
|
-
var extractHostnamePart = function (location) { return location.split('/').slice(0, 3).join('/'); };
|
|
1975
|
-
return "" + extractHostnamePart(this.currentLocation) + removeStartingSlash(payload.page);
|
|
1976
|
-
}
|
|
1977
|
-
else {
|
|
1978
|
-
return getFormattedLocation(window.location);
|
|
1979
|
-
}
|
|
1980
|
-
};
|
|
1981
|
-
return BasePlugin;
|
|
1982
|
-
}());
|
|
1983
|
-
|
|
1984
2145
|
var ECPluginEventTypes = __assign({}, BasePluginEventTypes);
|
|
1985
2146
|
var allECEventTypes = Object.keys(ECPluginEventTypes).map(function (key) { return ECPluginEventTypes[key]; });
|
|
1986
2147
|
var ECPlugin = (function (_super) {
|
|
@@ -1992,6 +2153,19 @@
|
|
|
1992
2153
|
_this.impressions = [];
|
|
1993
2154
|
return _this;
|
|
1994
2155
|
}
|
|
2156
|
+
ECPlugin.prototype.getApi = function (name) {
|
|
2157
|
+
var superCall = _super.prototype.getApi.call(this, name);
|
|
2158
|
+
if (superCall !== null)
|
|
2159
|
+
return superCall;
|
|
2160
|
+
switch (name) {
|
|
2161
|
+
case 'addProduct':
|
|
2162
|
+
return this.addProduct;
|
|
2163
|
+
case 'addImpression':
|
|
2164
|
+
return this.addImpression;
|
|
2165
|
+
default:
|
|
2166
|
+
return null;
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
1995
2169
|
ECPlugin.prototype.addHooks = function () {
|
|
1996
2170
|
this.addHooksForPageView();
|
|
1997
2171
|
this.addHooksForEvent();
|
|
@@ -2119,6 +2293,17 @@
|
|
|
2119
2293
|
_this.ticket = {};
|
|
2120
2294
|
return _this;
|
|
2121
2295
|
}
|
|
2296
|
+
SVCPlugin.prototype.getApi = function (name) {
|
|
2297
|
+
var superCall = _super.prototype.getApi.call(this, name);
|
|
2298
|
+
if (superCall !== null)
|
|
2299
|
+
return superCall;
|
|
2300
|
+
switch (name) {
|
|
2301
|
+
case 'setTicket':
|
|
2302
|
+
return this.setTicket;
|
|
2303
|
+
default:
|
|
2304
|
+
return null;
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2122
2307
|
SVCPlugin.prototype.addHooks = function () {
|
|
2123
2308
|
this.addHooksForEvent();
|
|
2124
2309
|
this.addHooksForPageView();
|
|
@@ -2189,6 +2374,7 @@
|
|
|
2189
2374
|
this.registeredPluginsMap = (_a = {},
|
|
2190
2375
|
_a[EC.Id] = EC,
|
|
2191
2376
|
_a[SVC.Id] = SVC,
|
|
2377
|
+
_a[Link.Id] = Link,
|
|
2192
2378
|
_a);
|
|
2193
2379
|
this.requiredPlugins = {};
|
|
2194
2380
|
}
|
|
@@ -2206,24 +2392,24 @@
|
|
|
2206
2392
|
this.requiredPlugins = {};
|
|
2207
2393
|
};
|
|
2208
2394
|
Plugins.prototype.execute = function (name, fn) {
|
|
2209
|
-
var
|
|
2395
|
+
var args = [];
|
|
2210
2396
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
2211
|
-
|
|
2397
|
+
args[_i - 2] = arguments[_i];
|
|
2212
2398
|
}
|
|
2213
2399
|
var plugin = this.requiredPlugins[name];
|
|
2214
2400
|
if (!plugin) {
|
|
2215
2401
|
throw new Error("The plugin \"" + name + "\" is not required. Check that you required it on initialization.");
|
|
2216
2402
|
}
|
|
2217
|
-
var actionFunction = plugin
|
|
2403
|
+
var actionFunction = plugin.getApi(fn);
|
|
2218
2404
|
if (!actionFunction) {
|
|
2219
2405
|
throw new Error("The function \"" + fn + "\" does not exist on the plugin \"" + name + "\".");
|
|
2220
2406
|
}
|
|
2221
2407
|
if (typeof actionFunction !== 'function') {
|
|
2222
2408
|
throw new Error("\"" + fn + "\" of the plugin \"" + name + "\" is not a function.");
|
|
2223
2409
|
}
|
|
2224
|
-
return actionFunction.apply(plugin,
|
|
2410
|
+
return actionFunction.apply(plugin, args);
|
|
2225
2411
|
};
|
|
2226
|
-
Plugins.DefaultPlugins = [EC.Id, SVC.Id];
|
|
2412
|
+
Plugins.DefaultPlugins = [EC.Id, SVC.Id, Link.Id];
|
|
2227
2413
|
return Plugins;
|
|
2228
2414
|
}());
|
|
2229
2415
|
|
|
@@ -2335,7 +2521,7 @@
|
|
|
2335
2521
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
2336
2522
|
args[_i - 2] = arguments[_i];
|
|
2337
2523
|
}
|
|
2338
|
-
(_a = this.plugins).execute.apply(_a, __spreadArrays([pluginName, fn], args));
|
|
2524
|
+
return (_a = this.plugins).execute.apply(_a, __spreadArrays([pluginName, fn], args));
|
|
2339
2525
|
};
|
|
2340
2526
|
CoveoUA.prototype.reset = function () {
|
|
2341
2527
|
this.client = undefined;
|