ng-miam 8.1.6 → 8.1.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.
@@ -2074,7 +2074,10 @@
2074
2074
  ]).pipe(operators.skipWhile(function (_d) {
2075
2075
  var _e = __read(_d, 2), _pos = _e[0], loading = _e[1];
2076
2076
  return loading;
2077
- }), operators.map(function (pos) { return pos !== undefined; }));
2077
+ }), operators.map(function (_d) {
2078
+ var _e = __read(_d, 2), pos = _e[0], _isLoading = _e[1];
2079
+ return pos !== undefined;
2080
+ }));
2078
2081
  };
2079
2082
  PointOfSalesService.prototype.loadPosWithExtId = function (extId) {
2080
2083
  var _this = this;
@@ -2950,9 +2953,13 @@
2950
2953
  this.abTestkey = key;
2951
2954
  };
2952
2955
  AnalyticsService.prototype.event = function (name, path, props) {
2956
+ var _a;
2953
2957
  if (this.abTestkey) {
2954
2958
  props.abTestKey = this.abTestkey;
2955
2959
  }
2960
+ if (((_a = localStorage.getItem('_miam/affiliate')) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2961
+ props.affiliate = localStorage.getItem('_miam/affiliate');
2962
+ }
2956
2963
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
2957
2964
  plausible(name, { u: this.url(path), props: props });
2958
2965
  this.eventEmitter.emit(JSON.stringify({
@@ -3796,6 +3803,7 @@
3796
3803
  if (eventTrace === void 0) { eventTrace = { originPath: '', props: {} }; }
3797
3804
  console.log('[Miam] resetting basket');
3798
3805
  this.analyticsService.sendEventWhenReady(this.analyticsService.EVENT_RECIPE_RESET, eventTrace.originPath, eventTrace.props);
3806
+ localStorage.removeItem('_miam/affiliate');
3799
3807
  this.ignoredBasketsService.resetIgnoredIngredients();
3800
3808
  return this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) { return _this.waitForBasket.pipe(operators.tap(function (basket) { return _this.analyticsService.sendEventsOfResetBasket(basket, eventTrace); }), operators.switchMap(function () { return _this.get("reset?point_of_sale_id=" + pos.id + "&fields[baskets]=" + BASKET_SPARSE_FIELDS.baskets.join(',')).pipe(operators.skipWhile(function (basket) { return basket.is_loading; }), operators.switchMap(function (basket) { return _this.updateLocalBasket(basket); })); })); }));
3801
3809
  };
@@ -3819,6 +3827,7 @@
3819
3827
  console.log("[Miam] send push analytics event if > 0: " + JSON.stringify(confirmedBasket.totalPrice) + " " + JSON.stringify(confirmedBasket));
3820
3828
  if (confirmedBasket.totalPrice > 0 && confirmedBasket.token) {
3821
3829
  _this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_BASKET_CONFIRMED, null, _this.eventProps(confirmedBasket, totalPrice));
3830
+ localStorage.removeItem('_miam/affiliate');
3822
3831
  }
3823
3832
  _this._basket$.next(undefined);
3824
3833
  return _this.resetBasket();
@@ -8378,26 +8387,28 @@
8378
8387
  };
8379
8388
  BasketTransferService.prototype.applyBasketTransfer = function (params) {
8380
8389
  var _this = this;
8381
- return this.callHookbackIfNotLogged().pipe(operators.skipWhile(function (isLogged) { return !isLogged; }), operators.switchMap(function () { return _this.forcePosIfUnset(params.posExtId); }), operators.skipWhile(function (isPosSet) { return !isPosSet; }), operators.switchMap(function () {
8382
- return _this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) { return _this.basketsService.waitForBasket
8383
- .pipe(operators.map(function () { return pos; })); }), operators.switchMap(function (pos) {
8384
- var posId = pos.id;
8385
- var transferBasketUrl = environment$1.miamAPI + "/api/v1/baskets/transfer?point_of_sale_id=" + posId + "&transferred_basket_token=" + params.basketToken;
8386
- _this.clearTransferSessionData();
8387
- sessionStorage.setItem('_miam/basketActionInterrupted', 'true');
8388
- return _this.http.patch(transferBasketUrl, {}).pipe(operators.switchMap(function () {
8389
- var getCurrentBasketUrl = environment$1.miamAPI + "/api/v1/baskets/current?point_of_sale_id=" + posId;
8390
- return _this.http.get(getCurrentBasketUrl, {}).pipe(operators.switchMap(function () {
8391
- sessionStorage.removeItem('_miam/basketActionInterrupted');
8392
- return rxjs.of(true);
8393
- }));
8390
+ return this.callHookbackIfNotLogged().pipe(operators.skipWhile(function (isLogged) { return !isLogged; }), operators.switchMap(function () { return _this.forcePosIfUnset(params.posExtId); }), operators.skipWhile(function (isPosSet) { return !isPosSet; }), operators.switchMap(function () { return _this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) { return _this.basketsService.waitForBasket
8391
+ .pipe(operators.map(function () { return pos; })); }), operators.switchMap(function (pos) {
8392
+ var posId = pos.id;
8393
+ var transferBasketUrl = environment$1.miamAPI + "/api/v1/baskets/transfer?point_of_sale_id=" + posId + "&transferred_basket_token=" + params.basketToken;
8394
+ _this.clearTransferSessionData();
8395
+ sessionStorage.setItem('_miam/basketActionInterrupted', 'true');
8396
+ return _this.http.patch(transferBasketUrl, {}).pipe(operators.switchMap(function () {
8397
+ var getCurrentBasketUrl = environment$1.miamAPI + "/api/v1/baskets/current?point_of_sale_id=" + posId;
8398
+ return _this.http.get(getCurrentBasketUrl, {}).pipe(operators.switchMap(function () {
8399
+ sessionStorage.removeItem('_miam/basketActionInterrupted');
8400
+ return rxjs.of(true);
8394
8401
  }));
8395
8402
  }));
8396
- }));
8403
+ })); }));
8397
8404
  };
8398
8405
  BasketTransferService.prototype.setSessionData = function (params) {
8406
+ var _a;
8399
8407
  sessionStorage.setItem('_miam/transferredBasketToken', params.basketToken);
8400
8408
  sessionStorage.setItem('_miam/posOfSaleExtId', params.posExtId);
8409
+ if (((_a = params.affiliate) === null || _a === void 0 ? void 0 : _a.length) > 0) {
8410
+ localStorage.setItem('_miam/affiliate', params.affiliate);
8411
+ }
8401
8412
  };
8402
8413
  BasketTransferService.prototype.clearTransferSessionData = function () {
8403
8414
  sessionStorage.removeItem('_miam/transferredBasketToken');
@@ -8426,8 +8437,8 @@
8426
8437
  return rxjs.combineLatest([
8427
8438
  this.userService.isLogged$,
8428
8439
  this.posService.posWasInitialized()
8429
- ]).pipe(operators.take(1), operators.map(function (_a) {
8430
- var _b = __read(_a, 2), isLogged = _b[0], isPosValid = _b[1];
8440
+ ]).pipe(operators.take(1), operators.map(function (_b) {
8441
+ var _c = __read(_b, 2), isLogged = _c[0], isPosValid = _c[1];
8431
8442
  return _this.contextService.hookCallback(isLogged, isPosValid);
8432
8443
  }));
8433
8444
  };
@@ -8442,19 +8453,31 @@
8442
8453
  }));
8443
8454
  };
8444
8455
  BasketTransferService.prototype.getTransferData = function () {
8456
+ var _a;
8445
8457
  var currentUrl = window.location.href;
8446
8458
  var urlParams = new URL(currentUrl).searchParams;
8447
8459
  var basketToken = urlParams.get('transferred_basket_token') || sessionStorage.getItem('_miam/transferredBasketToken');
8448
8460
  var posExtId = urlParams.get('point_of_sale_ext_id') || sessionStorage.getItem('_miam/posOfSaleExtId');
8449
- var urlWithoutParams = currentUrl.split('?')[0];
8450
- history.replaceState({}, document.title, urlWithoutParams);
8461
+ var affiliate = (_a = urlParams.get('utm_source')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
8451
8462
  if (basketToken && posExtId) {
8452
- return { basketToken: basketToken, posExtId: posExtId };
8463
+ this.removeTransferParamsFromUrl();
8464
+ return { basketToken: basketToken, posExtId: posExtId, affiliate: affiliate };
8453
8465
  }
8454
8466
  else {
8455
8467
  return null;
8456
8468
  }
8457
8469
  };
8470
+ BasketTransferService.prototype.removeTransferParamsFromUrl = function () {
8471
+ var currentUrl = window.location.href;
8472
+ var urlQuery = currentUrl.split('?')[1];
8473
+ if (urlQuery) {
8474
+ var urlParams = new URLSearchParams(urlQuery);
8475
+ urlParams.delete('transferred_basket_token');
8476
+ urlParams.delete('point_of_sale_ext_id');
8477
+ var newUrl = currentUrl.split('?')[0] + (urlParams.toString().length > 0 ? '?' + urlParams.toString() : '');
8478
+ history.replaceState({}, document.title, newUrl);
8479
+ }
8480
+ };
8458
8481
  return BasketTransferService;
8459
8482
  }());
8460
8483
  BasketTransferService.ɵfac = function BasketTransferService_Factory(t) { return new (t || BasketTransferService)(i0__namespace.ɵɵinject(BasketsService), i0__namespace.ɵɵinject(ContextService), i0__namespace.ɵɵinject(PointOfSalesService), i0__namespace.ɵɵinject(i1__namespace.HttpClient), i0__namespace.ɵɵinject(UserService)); };
@@ -8526,7 +8549,7 @@
8526
8549
  request = request.clone({
8527
8550
  setHeaders: {
8528
8551
  'miam-origin': this.context.origin.value,
8529
- 'miam-front-version': '8.1.6',
8552
+ 'miam-front-version': '8.1.7',
8530
8553
  'miam-front-type': 'web',
8531
8554
  'miam-api-version': '4.7.0'
8532
8555
  }