@builder.io/sdk 3.0.6 → 3.0.7

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/dist/index.cjs.js CHANGED
@@ -958,7 +958,7 @@ function toError(err) {
958
958
 
959
959
  var DEFAULT_API_VERSION = 'v3';
960
960
 
961
- var SDK_VERSION = '3.0.6';
961
+ var SDK_VERSION = '3.0.7';
962
962
 
963
963
  function datePlusMinutes(minutes) {
964
964
  if (minutes === void 0) { minutes = 30; }
@@ -1448,9 +1448,7 @@ var Builder = /** @class */ (function () {
1448
1448
  getFetch()("".concat(host, "/api/v1/track"), {
1449
1449
  method: 'POST',
1450
1450
  body: JSON.stringify({ events: events }),
1451
- headers: {
1452
- 'content-type': 'application/json',
1453
- },
1451
+ headers: tslib.__assign({ 'content-type': 'application/json' }, this.getSdkHeaders()),
1454
1452
  mode: 'cors',
1455
1453
  }).catch(function () {
1456
1454
  // Not the end of the world
@@ -2249,7 +2247,7 @@ var Builder = /** @class */ (function () {
2249
2247
  // even though we only use `fetch()` now, we prefer to keep the old behavior and use the `fetch` that comes from
2250
2248
  // the core SDK for consistency
2251
2249
  Builder.prototype.requestUrl = function (url, options) {
2252
- return getFetch()(url, options).then(function (res) { return res.json(); });
2250
+ return getFetch()(url, this.addSdkHeaders(options)).then(function (res) { return res.json(); });
2253
2251
  };
2254
2252
  Object.defineProperty(Builder.prototype, "host", {
2255
2253
  get: function () {
@@ -2278,8 +2276,21 @@ var Builder = /** @class */ (function () {
2278
2276
  enumerable: false,
2279
2277
  configurable: true
2280
2278
  });
2279
+ Builder.prototype.getSdkHeaders = function () {
2280
+ if (!Builder.sdkInfo) {
2281
+ return {};
2282
+ }
2283
+ return {
2284
+ 'X-Builder-SDK': Builder.sdkInfo.name,
2285
+ 'X-Builder-SDK-GEN': '1',
2286
+ 'X-Builder-SDK-Version': Builder.sdkInfo.version,
2287
+ };
2288
+ };
2289
+ Builder.prototype.addSdkHeaders = function (fetchOptions) {
2290
+ return tslib.__assign(tslib.__assign({}, fetchOptions), { headers: tslib.__assign(tslib.__assign({}, fetchOptions.headers), this.getSdkHeaders()) });
2291
+ };
2281
2292
  Builder.prototype.makeFetchApiCall = function (url, requestOptions) {
2282
- return getFetch()(url, requestOptions);
2293
+ return getFetch()(url, this.addSdkHeaders(requestOptions));
2283
2294
  };
2284
2295
  Builder.prototype.flattenMongoQuery = function (obj, _current, _res) {
2285
2296
  if (_res === void 0) { _res = {}; }
@@ -2678,6 +2689,7 @@ var Builder = /** @class */ (function () {
2678
2689
  (location.search.indexOf('builder.preview=') !== -1 ||
2679
2690
  location.search.indexOf('builder.frameEditing=') !== -1));
2680
2691
  Builder.isReact = false;
2692
+ Builder.sdkInfo = undefined;
2681
2693
  Builder.overrideUserAttributes = {};
2682
2694
  return Builder;
2683
2695
  }());