@constructor-io/constructorio-client-javascript 2.71.1 → 2.71.3

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.
@@ -29,6 +29,8 @@ function applyParams(parameters, options) {
29
29
  host = _helpers$getWindowLoc.host,
30
30
  pathname = _helpers$getWindowLoc.pathname,
31
31
  search = _helpers$getWindowLoc.search;
32
+ var canonicalUrl = helpers.getCanonicalUrl();
33
+ var documentReferrer = helpers.getDocumentReferrer();
32
34
  var sendReferrerWithTrackingEvents = options.sendReferrerWithTrackingEvents === false ? false : true; // Defaults to 'true'
33
35
  var aggregateParams = Object.assign(parameters);
34
36
  if (version) {
@@ -49,6 +51,12 @@ function applyParams(parameters, options) {
49
51
  if (apiKey) {
50
52
  aggregateParams.key = apiKey;
51
53
  }
54
+ if (documentReferrer) {
55
+ aggregateParams.document_referrer = documentReferrer;
56
+ }
57
+ if (canonicalUrl) {
58
+ aggregateParams.canonical_url = canonicalUrl;
59
+ }
52
60
  if (testCells) {
53
61
  Object.keys(testCells).forEach(function (testCellKey) {
54
62
  aggregateParams["ef-".concat(testCellKey)] = testCells[testCellKey];
@@ -84,6 +84,30 @@ var utils = {
84
84
  }
85
85
  return {};
86
86
  },
87
+ getDocumentReferrer: function getDocumentReferrer() {
88
+ if (utils.canUseDOM()) {
89
+ var _document;
90
+ return (_document = document) === null || _document === void 0 ? void 0 : _document.referrer;
91
+ }
92
+ return null;
93
+ },
94
+ getCanonicalUrl: function getCanonicalUrl() {
95
+ var canonicalURL = null;
96
+ try {
97
+ if (utils.canUseDOM()) {
98
+ var _document2;
99
+ var linkEle = (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('link[rel="canonical"]');
100
+ var href = linkEle === null || linkEle === void 0 ? void 0 : linkEle.getAttribute('href');
101
+ if (href) {
102
+ var url = new URL(href, document.location.href);
103
+ canonicalURL = url.toString();
104
+ }
105
+ }
106
+ } catch (e) {
107
+ // do nothing
108
+ }
109
+ return canonicalURL;
110
+ },
87
111
  dispatchEvent: function dispatchEvent(event) {
88
112
  if (utils.canUseDOM()) {
89
113
  window.dispatchEvent(event);
package/lib/version.js CHANGED
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = exports["default"] = '2.71.1';
7
+ var _default = exports["default"] = '2.71.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.71.1",
3
+ "version": "2.71.3",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",
package/lib/.DS_Store DELETED
Binary file