@builder.io/sdk 3.0.2-1 → 3.0.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.
Files changed (35) hide show
  1. package/.yarnrc.yml +1 -0
  2. package/CHANGELOG.md +6 -0
  3. package/dist/index.browser.js +13 -20
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.cjs.js +13 -20
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.esm.js +13 -20
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.umd.js +13 -20
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/package.json +3 -3
  12. package/dist/src/builder.class.js +12 -6
  13. package/dist/src/builder.class.js.map +1 -1
  14. package/dist/src/classes/cookies.class.js +0 -2
  15. package/dist/src/classes/cookies.class.js.map +1 -1
  16. package/dist/src/classes/promise.class.js +154 -150
  17. package/dist/src/classes/query-string.class.js +74 -73
  18. package/dist/src/classes/query-string.class.test.js +20 -20
  19. package/dist/src/functions/assign.function.js +19 -19
  20. package/dist/src/functions/fetch.function.js +75 -97
  21. package/dist/src/functions/finder.function.js +274 -389
  22. package/dist/src/functions/next-tick.function.js +23 -26
  23. package/dist/src/functions/omit.function.js +13 -13
  24. package/dist/src/functions/server-only-require.function.js +9 -10
  25. package/dist/src/functions/throttle.function.js +37 -35
  26. package/dist/src/functions/to-error.js +6 -5
  27. package/dist/src/functions/uuid.js +8 -9
  28. package/dist/src/types/api-version.js +3 -3
  29. package/dist/src/types/element.js +3 -3
  30. package/dist/src/url.test.js +118 -222
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +5 -6
  33. package/dist/src/functions/get-top-level-domain.d.ts +0 -6
  34. package/dist/src/functions/get-top-level-domain.js +0 -17
  35. package/dist/src/functions/get-top-level-domain.js.map +0 -1
package/dist/index.umd.js CHANGED
@@ -152,7 +152,7 @@
152
152
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
153
153
  }
154
154
 
155
- var version = "3.0.2-0";
155
+ var version = "3.0.2";
156
156
 
157
157
  var Subscription = /** @class */ (function () {
158
158
  function Subscription(listeners, listener) {
@@ -767,19 +767,6 @@
767
767
  return Animator;
768
768
  }());
769
769
 
770
- /**
771
- * Only gets one level up from hostname
772
- * wwww.example.com -> example.com
773
- * www.example.co.uk -> example.co.uk
774
- */
775
- function getTopLevelDomain(host) {
776
- var parts = host.split('.');
777
- if (parts.length > 2) {
778
- return parts.slice(1).join('.');
779
- }
780
- return host;
781
- }
782
-
783
770
  /**
784
771
  * RegExp to match field-content in RFC 7230 sec 3.2
785
772
  *
@@ -824,7 +811,6 @@
824
811
  if (opts && 'secure' in opts) {
825
812
  cookie.secure = !!opts.secure;
826
813
  }
827
- cookie.domain = req.headers.host && getTopLevelDomain(req.headers.host);
828
814
  pushCookie(headers, cookie);
829
815
  var setHeader = res.setHeader;
830
816
  setHeader.call(res, 'Set-Cookie', headers);
@@ -1149,7 +1135,6 @@
1149
1135
  (value || '') +
1150
1136
  expiresString +
1151
1137
  '; path=/' +
1152
- "; domain=".concat(getTopLevelDomain(location.hostname)) +
1153
1138
  (secure ? '; secure; SameSite=None' : '');
1154
1139
  }
1155
1140
  catch (err) {
@@ -1317,6 +1302,17 @@
1317
1302
  this.setTestsFromUrl();
1318
1303
  // TODO: do this on every request send?
1319
1304
  this.getOverridesFromQueryString();
1305
+ // cookies used in personalization container script, so need to set before hydration to match script result
1306
+ var userAttrCookie = this.getCookie(Builder.attributesCookieName);
1307
+ if (userAttrCookie) {
1308
+ try {
1309
+ var attributes = JSON.parse(userAttrCookie);
1310
+ this.setUserAttributes(attributes);
1311
+ }
1312
+ catch (err) {
1313
+ console.debug('Error parsing user attributes cookie', err);
1314
+ }
1315
+ }
1320
1316
  }
1321
1317
  }
1322
1318
  Builder.register = function (type, info) {
@@ -2206,12 +2202,9 @@
2206
2202
  };
2207
2203
  Builder.prototype.setUserAttributes = function (options) {
2208
2204
  assign(Builder.overrideUserAttributes, options);
2209
- try {
2205
+ if (this.canTrack) {
2210
2206
  this.setCookie(Builder.attributesCookieName, JSON.stringify(this.getUserAttributes()));
2211
2207
  }
2212
- catch (_a) {
2213
- // Ignore
2214
- }
2215
2208
  this.userAttributesChanged.next(options);
2216
2209
  };
2217
2210
  /**