@xsolla/payment-client-core 0.5.0 → 0.5.1

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 (23) hide show
  1. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +17 -9
  2. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +20 -10
  3. package/esm2022/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.mjs +19 -8
  4. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +40 -15
  5. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +32 -13
  6. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.mjs +8 -1
  7. package/esm2022/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +14 -8
  8. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.mjs +21 -9
  9. package/esm2022/lib/core/user-behaviour-analytics/user-behaviour-analytics.interface.mjs +1 -1
  10. package/esm2022/lib/version.mjs +2 -2
  11. package/fesm2022/xsolla-payment-client-core.mjs +153 -55
  12. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  13. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +4 -3
  14. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +4 -3
  15. package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +4 -3
  16. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +1 -3
  17. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +1 -3
  18. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.d.ts +4 -0
  19. package/lib/core/sdk-payment-systems/google-pay/google-pay.service.d.ts +4 -3
  20. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +5 -3
  21. package/lib/core/user-behaviour-analytics/user-behaviour-analytics.interface.d.ts +12 -0
  22. package/lib/version.d.ts +1 -1
  23. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Inject, Injectable, isDevMode, Pipe, NgModule } from '@angular/core';
3
- import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, take, of, interval, throwError, share } from 'rxjs';
3
+ import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, take, of, interval, throwError, share, merge } from 'rxjs';
4
4
  import * as i1 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS, provideHttpClient } from '@angular/common/http';
6
6
  import { UntypedFormGroup, Validators, UntypedFormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
@@ -13,7 +13,7 @@ import { CommonModule } from '@angular/common';
13
13
  import { provideTranslateHttpLoader } from '@ngx-translate/http-loader';
14
14
 
15
15
  // eslint-disable-next-line @typescript-eslint/naming-convention
16
- const PAYMENT_CLIENT_CORE_VERSION = '0.5.0';
16
+ const PAYMENT_CLIENT_CORE_VERSION = '0.5.1';
17
17
 
18
18
  class TranslateHelper {
19
19
  static init(service) {
@@ -9476,6 +9476,7 @@ class ApplePaySessionHandlerAbstract {
9476
9476
  constructor() {
9477
9477
  this.payment = new Subject();
9478
9478
  this._errorSubject = new Subject();
9479
+ this._analyticsEventSubject = new Subject();
9479
9480
  }
9480
9481
  get error$() {
9481
9482
  return this._errorSubject.asObservable();
@@ -9483,9 +9484,15 @@ class ApplePaySessionHandlerAbstract {
9483
9484
  get payment$() {
9484
9485
  return this.payment.asObservable();
9485
9486
  }
9487
+ get analyticsEvent$() {
9488
+ return this._analyticsEventSubject.asObservable();
9489
+ }
9486
9490
  emitError(error) {
9487
9491
  this._errorSubject.next(error);
9488
9492
  }
9493
+ emitAnalyticsEvent(event) {
9494
+ this._analyticsEventSubject.next(event);
9495
+ }
9489
9496
  buildPaymentRequest(params) {
9490
9497
  return {
9491
9498
  total: {
@@ -9512,12 +9519,15 @@ class ApplePayCartService {
9512
9519
  get cartRecalculationRequest$() {
9513
9520
  return this.cartRecalculationRequest.asObservable();
9514
9521
  }
9515
- constructor(userBehaviourAnalyticsService, summaryFinanceDetailsAdapterService) {
9516
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9522
+ get analyticsEvent$() {
9523
+ return this.analyticsEvent.asObservable();
9524
+ }
9525
+ constructor(summaryFinanceDetailsAdapterService) {
9517
9526
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
9518
9527
  this.cartSuccessfulRecalculated = new Subject();
9519
9528
  this.cartErrorRecalculated = new Subject();
9520
9529
  this.cartRecalculationRequest = new Subject();
9530
+ this.analyticsEvent = new Subject();
9521
9531
  }
9522
9532
  recalculateCartTaxes(shippingContact) {
9523
9533
  const zip = shippingContact.postalCode;
@@ -9531,7 +9541,9 @@ class ApplePayCartService {
9531
9541
  zip: parsedZip,
9532
9542
  country,
9533
9543
  });
9534
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartTaxes, 'manual', {
9544
+ this.analyticsEvent.next({
9545
+ eventName: UserBehaviourEventName.applePayRecalculateCartTaxes,
9546
+ eventType: userBehaviourEventTypes.manual,
9535
9547
  dimension1: country,
9536
9548
  dimension2: parsedZip || '',
9537
9549
  });
@@ -9558,7 +9570,10 @@ class ApplePayCartService {
9558
9570
  this.cartSuccessfulRecalculated.next(updatedPrice);
9559
9571
  }
9560
9572
  sendErrorRecalculatedCart(error) {
9561
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartError, 'manual');
9573
+ this.analyticsEvent.next({
9574
+ eventName: UserBehaviourEventName.applePayRecalculateCartError,
9575
+ eventType: userBehaviourEventTypes.manual,
9576
+ });
9562
9577
  this.cartErrorRecalculated.next(error);
9563
9578
  }
9564
9579
  isZipCountry(country) {
@@ -9593,7 +9608,7 @@ class ApplePayCartService {
9593
9608
  getTotalAmount(finance) {
9594
9609
  return finance?.grand_total?.amount ?? finance?.total?.amount;
9595
9610
  }
9596
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, deps: [{ token: UserBehaviourAnalyticsService }, { token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9611
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9597
9612
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
9598
9613
  }
9599
9614
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, decorators: [{
@@ -9601,15 +9616,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9601
9616
  args: [{
9602
9617
  providedIn: 'root',
9603
9618
  }]
9604
- }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }, { type: SummaryFinanceDetailsAdapterService }] });
9619
+ }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
9605
9620
 
9606
9621
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9607
- constructor(window, loggerService, applePayCartService, userBehaviourAnalyticsService) {
9622
+ constructor(window, loggerService, applePayCartService) {
9608
9623
  super();
9609
9624
  this.window = window;
9610
9625
  this.loggerService = loggerService;
9611
9626
  this.applePayCartService = applePayCartService;
9612
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9613
9627
  this.paymentClient = null;
9614
9628
  }
9615
9629
  setClient(client) {
@@ -9639,18 +9653,30 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9639
9653
  if (!session)
9640
9654
  return;
9641
9655
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
9642
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
9656
+ this.emitAnalyticsEvent({
9657
+ eventName: UserBehaviourEventName.applePayBraintreeStartSession,
9658
+ eventType: userBehaviourEventTypes.manual,
9659
+ });
9643
9660
  session.onshippingcontactselected = (event) => {
9644
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeSelectShipping, 'manual');
9661
+ this.emitAnalyticsEvent({
9662
+ eventName: UserBehaviourEventName.applePayBraintreeSelectShipping,
9663
+ eventType: userBehaviourEventTypes.manual,
9664
+ });
9645
9665
  this.applePayCartService.cartSuccessfulRecalculated$
9646
9666
  .pipe(take(1))
9647
9667
  .subscribe((updatedPrice) => {
9648
9668
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9649
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated, 'manual');
9669
+ this.emitAnalyticsEvent({
9670
+ eventName: UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated,
9671
+ eventType: userBehaviourEventTypes.manual,
9672
+ });
9650
9673
  session.completeShippingContactSelection(contactUpdate);
9651
9674
  });
9652
9675
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9653
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartErrorRecalculated, 'manual');
9676
+ this.emitAnalyticsEvent({
9677
+ eventName: UserBehaviourEventName.applePayBraintreeCartErrorRecalculated,
9678
+ eventType: userBehaviourEventTypes.manual,
9679
+ });
9654
9680
  session.completeShippingContactSelection({
9655
9681
  errors: [error],
9656
9682
  newTotal: {
@@ -9663,7 +9689,9 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9663
9689
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9664
9690
  };
9665
9691
  session.onvalidatemerchant = (event) => {
9666
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchant, 'manual', {
9692
+ this.emitAnalyticsEvent({
9693
+ eventName: UserBehaviourEventName.applePayBraintreeValidateMerchant,
9694
+ eventType: userBehaviourEventTypes.manual,
9667
9695
  value: event.validationURL,
9668
9696
  extraValue: params.totalLabel,
9669
9697
  });
@@ -9681,14 +9709,20 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9681
9709
  session.completeMerchantValidation(merchantSession);
9682
9710
  })
9683
9711
  .catch((error) => {
9684
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchantError, 'manual');
9712
+ this.emitAnalyticsEvent({
9713
+ eventName: UserBehaviourEventName.applePayBraintreeValidateMerchantError,
9714
+ eventType: userBehaviourEventTypes.manual,
9715
+ });
9685
9716
  console.error(ApplePayErrors.merchantValidationError, error);
9686
9717
  session.abort();
9687
9718
  applePayFinallyCallback();
9688
9719
  });
9689
9720
  };
9690
9721
  session.onpaymentauthorized = (event) => {
9691
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentAuthorized, 'manual');
9722
+ this.emitAnalyticsEvent({
9723
+ eventName: UserBehaviourEventName.applePayBraintreePaymentAuthorized,
9724
+ eventType: userBehaviourEventTypes.manual,
9725
+ });
9692
9726
  this.paymentClient
9693
9727
  ?.tokenize({ token: event.payment.token })
9694
9728
  .then((response) => {
@@ -9701,21 +9735,27 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9701
9735
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9702
9736
  })
9703
9737
  .catch((error) => {
9704
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentTokenizationError, 'manual');
9738
+ this.emitAnalyticsEvent({
9739
+ eventName: UserBehaviourEventName.applePayBraintreePaymentTokenizationError,
9740
+ eventType: userBehaviourEventTypes.manual,
9741
+ });
9705
9742
  console.error('Apple Pay: Tokenization error', error);
9706
9743
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
9707
9744
  applePayFinallyCallback();
9708
9745
  });
9709
9746
  };
9710
9747
  session.oncancel = (event) => {
9711
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentCancel, 'manual');
9748
+ this.emitAnalyticsEvent({
9749
+ eventName: UserBehaviourEventName.applePayBraintreePaymentCancel,
9750
+ eventType: userBehaviourEventTypes.manual,
9751
+ });
9712
9752
  console.error(ApplePayErrors.cancelled, event);
9713
9753
  this.emitError(ApplePayErrors.cancelled);
9714
9754
  applePayFinallyCallback();
9715
9755
  };
9716
9756
  session.begin();
9717
9757
  }
9718
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9758
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9719
9759
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler }); }
9720
9760
  }
9721
9761
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -9723,16 +9763,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9723
9763
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9724
9764
  type: Inject,
9725
9765
  args: [windowToken]
9726
- }] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9766
+ }] }, { type: LoggerService }, { type: ApplePayCartService }] });
9727
9767
 
9728
9768
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9729
- constructor(window, http, loggerService, applePayCartService, userBehaviourAnalyticsService) {
9769
+ constructor(window, http, loggerService, applePayCartService) {
9730
9770
  super();
9731
9771
  this.window = window;
9732
9772
  this.http = http;
9733
9773
  this.loggerService = loggerService;
9734
9774
  this.applePayCartService = applePayCartService;
9735
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9736
9775
  }
9737
9776
  startSession(params, additionalParams, applePayFinallyCallback) {
9738
9777
  const request = this.buildPaymentRequest(params);
@@ -9750,16 +9789,25 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9750
9789
  if (!session)
9751
9790
  return;
9752
9791
  session.onshippingcontactselected = (event) => {
9753
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
9792
+ this.emitAnalyticsEvent({
9793
+ eventName: UserBehaviourEventName.applePayCheckoutSelectShipping,
9794
+ eventType: userBehaviourEventTypes.manual,
9795
+ });
9754
9796
  this.applePayCartService.cartSuccessfulRecalculated$
9755
9797
  .pipe(take(1))
9756
9798
  .subscribe((updatedPrice) => {
9757
9799
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9758
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated, 'manual');
9800
+ this.emitAnalyticsEvent({
9801
+ eventName: UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated,
9802
+ eventType: userBehaviourEventTypes.manual,
9803
+ });
9759
9804
  session.completeShippingContactSelection(contactUpdate);
9760
9805
  });
9761
9806
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9762
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartErrorRecalculated, 'manual');
9807
+ this.emitAnalyticsEvent({
9808
+ eventName: UserBehaviourEventName.applePayCheckoutCartErrorRecalculated,
9809
+ eventType: userBehaviourEventTypes.manual,
9810
+ });
9763
9811
  session.completeShippingContactSelection({
9764
9812
  errors: [error],
9765
9813
  newTotal: {
@@ -9772,7 +9820,9 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9772
9820
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9773
9821
  };
9774
9822
  session.onvalidatemerchant = (event) => {
9775
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchant, 'manual', {
9823
+ this.emitAnalyticsEvent({
9824
+ eventName: UserBehaviourEventName.applePayCheckoutValidateMerchant,
9825
+ eventType: userBehaviourEventTypes.manual,
9776
9826
  value: event.validationURL,
9777
9827
  extraValue: params.totalLabel,
9778
9828
  });
@@ -9795,7 +9845,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9795
9845
  session.completeMerchantValidation(response.merchantSession);
9796
9846
  },
9797
9847
  error: (error) => {
9798
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchantError, 'manual');
9848
+ this.emitAnalyticsEvent({
9849
+ eventName: UserBehaviourEventName.applePayCheckoutValidateMerchantError,
9850
+ eventType: userBehaviourEventTypes.manual,
9851
+ });
9799
9852
  console.error(ApplePayErrors.merchantValidationError, error);
9800
9853
  session.abort();
9801
9854
  applePayFinallyCallback();
@@ -9803,7 +9856,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9803
9856
  });
9804
9857
  };
9805
9858
  session.onpaymentauthorized = (event) => {
9806
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentAuthorized, 'manual');
9859
+ this.emitAnalyticsEvent({
9860
+ eventName: UserBehaviourEventName.applePayCheckoutPaymentAuthorized,
9861
+ eventType: userBehaviourEventTypes.manual,
9862
+ });
9807
9863
  this.payment.next(JSON.stringify({
9808
9864
  token: event.payment.token ?? '',
9809
9865
  email: event.payment.billingContact?.emailAddress ?? null,
@@ -9813,14 +9869,17 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9813
9869
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9814
9870
  };
9815
9871
  session.oncancel = (event) => {
9816
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentCancel, 'manual');
9872
+ this.emitAnalyticsEvent({
9873
+ eventName: UserBehaviourEventName.applePayCheckoutPaymentCancel,
9874
+ eventType: userBehaviourEventTypes.manual,
9875
+ });
9817
9876
  console.error(ApplePayErrors.cancelled, event);
9818
9877
  this.emitError(ApplePayErrors.cancelled);
9819
9878
  applePayFinallyCallback();
9820
9879
  };
9821
9880
  session.begin();
9822
9881
  }
9823
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: LoggerService }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9882
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: LoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9824
9883
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler }); }
9825
9884
  }
9826
9885
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -9828,7 +9887,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9828
9887
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9829
9888
  type: Inject,
9830
9889
  args: [windowToken]
9831
- }] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9890
+ }] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }] });
9832
9891
 
9833
9892
  class PaymentBehaviourModule {
9834
9893
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
@@ -10054,11 +10113,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10054
10113
  }] }] });
10055
10114
 
10056
10115
  class GooglePayCheckoutPaymentService {
10057
- constructor(paymentSystemProcessingService, userBehaviourAnalyticsService, loggerService) {
10116
+ constructor(paymentSystemProcessingService, loggerService) {
10058
10117
  this.paymentSystemProcessingService = paymentSystemProcessingService;
10059
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10060
10118
  this.loggerService = loggerService;
10061
10119
  this.checkout = null;
10120
+ this.analyticsEvent = new Subject();
10121
+ }
10122
+ get analyticsEvent$() {
10123
+ return this.analyticsEvent.asObservable();
10062
10124
  }
10063
10125
  preparePayment({ initParams, checkDeviceData, }) {
10064
10126
  if (!initParams || !checkDeviceData.base64checkoutData) {
@@ -10103,7 +10165,11 @@ class GooglePayCheckoutPaymentService {
10103
10165
  return paymentDataRequest.allowedPaymentMethods;
10104
10166
  }
10105
10167
  handleSuccessfulPayment(response) {
10106
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleSuccessfulPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '' });
10168
+ this.analyticsEvent.next({
10169
+ eventName: UserBehaviourEventName.googlePayHandleSuccessfulPayment,
10170
+ eventType: userBehaviourEventTypes.manual,
10171
+ value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '',
10172
+ });
10107
10173
  if (!this.checkout)
10108
10174
  return;
10109
10175
  let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
@@ -10112,7 +10178,11 @@ class GooglePayCheckoutPaymentService {
10112
10178
  this.paymentSystemProcessingService.emitStatusUrl(returnUrl);
10113
10179
  }
10114
10180
  handleFailedPayment(error) {
10115
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleFailedPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '' });
10181
+ this.analyticsEvent.next({
10182
+ eventName: UserBehaviourEventName.googlePayHandleFailedPayment,
10183
+ eventType: userBehaviourEventTypes.manual,
10184
+ value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '',
10185
+ });
10116
10186
  if (!this.checkout)
10117
10187
  return;
10118
10188
  const statusCode = error?.statusCode;
@@ -10125,7 +10195,7 @@ class GooglePayCheckoutPaymentService {
10125
10195
  isCancelledStatus(statusCode) {
10126
10196
  return statusCode.toLowerCase() === 'canceled';
10127
10197
  }
10128
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: UserBehaviourAnalyticsService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10198
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10129
10199
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
10130
10200
  }
10131
10201
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -10133,7 +10203,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10133
10203
  args: [{
10134
10204
  providedIn: 'root',
10135
10205
  }]
10136
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }, { type: LoggerService }] });
10206
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: LoggerService }] });
10137
10207
 
10138
10208
  class GooglePayInstantPaymentService {
10139
10209
  constructor(summaryFinanceDetailsAdapterService, loggerService) {
@@ -10267,19 +10337,19 @@ class GooglePayService {
10267
10337
  get googlePaymentClientWasInitialized() {
10268
10338
  return !!this.googlePaymentClient;
10269
10339
  }
10270
- constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector, userBehaviourAnalyticsService) {
10340
+ constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector) {
10271
10341
  this.window = window;
10272
10342
  this.loggerService = loggerService;
10273
10343
  this.paymentSystemProcessingService = paymentSystemProcessingService;
10274
10344
  this.googlePayCheckoutPaymentService = googlePayCheckoutPaymentService;
10275
10345
  this.googlePayInstantPaymentService = googlePayInstantPaymentService;
10276
10346
  this.injector = injector;
10277
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10278
10347
  this.googlePayScriptUrl = 'https://pay.google.com/gp/p/js/pay.js';
10279
10348
  this.readyToPay = new BehaviorSubject(null);
10280
10349
  this.paymentWindowIsReady = new Subject();
10281
10350
  this.paymentWindowIsClose = new Subject();
10282
10351
  this.error = new Subject();
10352
+ this.analyticsEvent = new Subject();
10283
10353
  this.paymentInProgress = false;
10284
10354
  this.googlePaymentClient = null;
10285
10355
  this.paymentService = null;
@@ -10296,6 +10366,9 @@ class GooglePayService {
10296
10366
  get error$() {
10297
10367
  return this.error.asObservable();
10298
10368
  }
10369
+ get analyticsEvent$() {
10370
+ return merge(this.analyticsEvent.asObservable(), this.googlePayCheckoutPaymentService.analyticsEvent$);
10371
+ }
10299
10372
  isReadyToPay() {
10300
10373
  return this.readyToPay.getValue();
10301
10374
  }
@@ -10368,7 +10441,11 @@ class GooglePayService {
10368
10441
  return Promise.resolve(null);
10369
10442
  }
10370
10443
  if (this.initParams.isInstantPayFlow) {
10371
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.sysInstantFlowOpen, userBehaviourEventTypes.open, { instanceId: googlePay });
10444
+ this.analyticsEvent.next({
10445
+ eventName: UserBehaviourEventName.sysInstantFlowOpen,
10446
+ eventType: userBehaviourEventTypes.open,
10447
+ instanceId: googlePay,
10448
+ });
10372
10449
  }
10373
10450
  const paymentDataRequest = this.paymentService.getPaymentRequest();
10374
10451
  if (!paymentDataRequest) {
@@ -10516,7 +10593,7 @@ class GooglePayService {
10516
10593
  }
10517
10594
  return allowedLocales.find((locale) => locale === userLocale) ?? 'en';
10518
10595
  }
10519
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: LoggerService }, { token: PaymentSystemProcessingService }, { token: GooglePayCheckoutPaymentService }, { token: GooglePayInstantPaymentService }, { token: i0.Injector }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10596
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: LoggerService }, { token: PaymentSystemProcessingService }, { token: GooglePayCheckoutPaymentService }, { token: GooglePayInstantPaymentService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
10520
10597
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, providedIn: 'root' }); }
10521
10598
  }
10522
10599
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, decorators: [{
@@ -10527,7 +10604,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10527
10604
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10528
10605
  type: Inject,
10529
10606
  args: [windowToken]
10530
- }] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }, { type: UserBehaviourAnalyticsService }] });
10607
+ }] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }] });
10531
10608
 
10532
10609
  var ApplePayIntegrationType;
10533
10610
  (function (ApplePayIntegrationType) {
@@ -10774,11 +10851,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10774
10851
  }], ctorParameters: () => [{ type: SecureApiClient }] });
10775
10852
 
10776
10853
  class ApplePayExternalWindowCommunicationService {
10777
- constructor(window, webSocketFactory, socketBridgeService, userBehaviourAnalyticsService) {
10854
+ constructor(window, webSocketFactory, socketBridgeService) {
10778
10855
  this.window = window;
10779
10856
  this.webSocketFactory = webSocketFactory;
10780
10857
  this.socketBridgeService = socketBridgeService;
10781
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10858
+ this.analyticsEvent = new Subject();
10859
+ }
10860
+ get analyticsEvent$() {
10861
+ return this.analyticsEvent.asObservable();
10782
10862
  }
10783
10863
  getWindowClose$() {
10784
10864
  const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
@@ -10803,7 +10883,10 @@ class ApplePayExternalWindowCommunicationService {
10803
10883
  return this.getEventSource(isRecalculateCartMessage);
10804
10884
  }
10805
10885
  async openWebSocketConnection(token) {
10806
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayOpenWebSocketConnection, 'manual');
10886
+ this.analyticsEvent.next({
10887
+ eventName: UserBehaviourEventName.applePayOpenWebSocketConnection,
10888
+ eventType: userBehaviourEventTypes.manual,
10889
+ });
10807
10890
  const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
10808
10891
  if (this.websocketClient) {
10809
10892
  this.websocketClient.close();
@@ -10812,7 +10895,11 @@ class ApplePayExternalWindowCommunicationService {
10812
10895
  await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
10813
10896
  }
10814
10897
  async sendMessageToAnotherWindow(command, payload) {
10815
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePaySendMessageToAnotherWindow, 'manual', { value: command });
10898
+ this.analyticsEvent.next({
10899
+ eventName: UserBehaviourEventName.applePaySendMessageToAnotherWindow,
10900
+ eventType: userBehaviourEventTypes.manual,
10901
+ value: command,
10902
+ });
10816
10903
  await this.socketBridgeService.publishMessage(command, payload);
10817
10904
  }
10818
10905
  getEventSource(eventHandler) {
@@ -10821,7 +10908,7 @@ class ApplePayExternalWindowCommunicationService {
10821
10908
  return JSON.parse(message);
10822
10909
  }), filter(eventHandler));
10823
10910
  }
10824
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10911
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10825
10912
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
10826
10913
  }
10827
10914
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
@@ -10832,7 +10919,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10832
10919
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10833
10920
  type: Inject,
10834
10921
  args: [windowToken]
10835
- }] }, { type: WebSocketFactory }, { type: SocketBridgeService }, { type: UserBehaviourAnalyticsService }] });
10922
+ }] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
10836
10923
 
10837
10924
  class ApplePayService {
10838
10925
  get paymentParameters() {
@@ -10848,6 +10935,9 @@ class ApplePayService {
10848
10935
  get applePayQrOpened$() {
10849
10936
  return this.applePayQrOpened.asObservable();
10850
10937
  }
10938
+ get analyticsEvent$() {
10939
+ return merge(this.analyticsEvent.asObservable(), this.braintreeHandler.analyticsEvent$, this.checkoutHandler.analyticsEvent$, this.externalWindowCommunicationService.analyticsEvent$);
10940
+ }
10851
10941
  /* istanbul ignore next */
10852
10942
  get windowClosing$() {
10853
10943
  return this.applePaySdkService.windowClosing$;
@@ -10875,7 +10965,7 @@ class ApplePayService {
10875
10965
  .getWindowReturnMessage$()
10876
10966
  .pipe(takeUntil(this.destroy$));
10877
10967
  }
10878
- constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, userBehaviourAnalyticsService, settingsService) {
10968
+ constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
10879
10969
  this.window = window;
10880
10970
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
10881
10971
  this.braintreeHandler = braintreeHandler;
@@ -10884,12 +10974,12 @@ class ApplePayService {
10884
10974
  this.loggerService = loggerService;
10885
10975
  this.applePaySdkService = applePaySdkService;
10886
10976
  this.externalWindowCommunicationService = externalWindowCommunicationService;
10887
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10888
10977
  this.settingsService = settingsService;
10889
10978
  this.payment = new Subject();
10890
10979
  this.error = new Subject();
10891
10980
  this.integrationType = new Subject();
10892
10981
  this.applePayQrOpened = new Subject();
10982
+ this.analyticsEvent = new Subject();
10893
10983
  this.destroy$ = new Subject();
10894
10984
  this.paymentClient = null;
10895
10985
  this.applePayParams = null;
@@ -11012,9 +11102,17 @@ class ApplePayService {
11012
11102
  this.applePayParams = this.appleParamsBuilder.updateParams(this.applePayParams, summary);
11013
11103
  }
11014
11104
  proceedCheckout(parameters, additionalParams) {
11015
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayAcquirer, 'manual', { value: parameters.acquirer });
11105
+ this.analyticsEvent.next({
11106
+ eventName: UserBehaviourEventName.applePayAcquirer,
11107
+ eventType: userBehaviourEventTypes.manual,
11108
+ value: parameters.acquirer,
11109
+ });
11016
11110
  if (additionalParams.isApplePayInstantFlowEnabled) {
11017
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.sysInstantFlowOpen, userBehaviourEventTypes.open, { instanceId: applePayId });
11111
+ this.analyticsEvent.next({
11112
+ eventName: UserBehaviourEventName.sysInstantFlowOpen,
11113
+ eventType: userBehaviourEventTypes.open,
11114
+ instanceId: applePayId,
11115
+ });
11018
11116
  }
11019
11117
  const sessionHandler = this.getSessionHandler(parameters.acquirer);
11020
11118
  if (!sessionHandler) {
@@ -11073,7 +11171,7 @@ class ApplePayService {
11073
11171
  this.applePayQrOpened.next();
11074
11172
  }
11075
11173
  }
11076
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: SummaryFinanceDetailsAdapterService }, { token: BraintreeHandler }, { token: CheckoutHandler }, { token: ApplePayParamsBuilderService }, { token: LoggerService }, { token: ApplePaySdkService }, { token: ApplePayExternalWindowCommunicationService }, { token: UserBehaviourAnalyticsService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11174
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: SummaryFinanceDetailsAdapterService }, { token: BraintreeHandler }, { token: CheckoutHandler }, { token: ApplePayParamsBuilderService }, { token: LoggerService }, { token: ApplePaySdkService }, { token: ApplePayExternalWindowCommunicationService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11077
11175
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
11078
11176
  }
11079
11177
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, decorators: [{
@@ -11084,7 +11182,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
11084
11182
  }], ctorParameters: () => [{ type: undefined, decorators: [{
11085
11183
  type: Inject,
11086
11184
  args: [windowToken]
11087
- }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: UserBehaviourAnalyticsService }, { type: SettingsService }] });
11185
+ }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: SettingsService }] });
11088
11186
 
11089
11187
  /*
11090
11188
  * Public API Surface of core-library