@xsolla/payment-client-core 0.4.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 (30) hide show
  1. package/esm2022/lib/core/payment/status/check-status/check-status.service.mjs +19 -13
  2. package/esm2022/lib/core/payment/status/listen-status/listen-status.service.mjs +31 -1
  3. package/esm2022/lib/core/payment/status/status.service.mjs +48 -5
  4. package/esm2022/lib/core/payment/status/websocket-status/websocket-status.service.mjs +6 -2
  5. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +17 -9
  6. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +20 -10
  7. package/esm2022/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.mjs +19 -8
  8. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +40 -15
  9. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +32 -13
  10. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.mjs +8 -1
  11. package/esm2022/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +14 -8
  12. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.mjs +21 -9
  13. package/esm2022/lib/core/user-behaviour-analytics/user-behaviour-analytics.interface.mjs +1 -1
  14. package/esm2022/lib/version.mjs +2 -2
  15. package/fesm2022/xsolla-payment-client-core.mjs +251 -71
  16. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  17. package/lib/core/payment/status/check-status/check-status.service.d.ts +7 -0
  18. package/lib/core/payment/status/listen-status/listen-status.service.d.ts +1 -0
  19. package/lib/core/payment/status/status.service.d.ts +13 -1
  20. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +4 -3
  21. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +4 -3
  22. package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +4 -3
  23. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +1 -3
  24. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +1 -3
  25. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.d.ts +4 -0
  26. package/lib/core/sdk-payment-systems/google-pay/google-pay.service.d.ts +4 -3
  27. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +5 -3
  28. package/lib/core/user-behaviour-analytics/user-behaviour-analytics.interface.d.ts +12 -0
  29. package/lib/version.d.ts +1 -1
  30. 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.4.0';
16
+ const PAYMENT_CLIENT_CORE_VERSION = '0.5.1';
17
17
 
18
18
  class TranslateHelper {
19
19
  static init(service) {
@@ -6215,22 +6215,28 @@ class CheckStatusService extends XpsApiPart {
6215
6215
  this.invoice = invoice;
6216
6216
  }
6217
6217
  request() {
6218
- const requestParams = this.requestFactory(this.settingsService.token, this.invoice);
6219
- this.xpsApiService
6220
- .directPaymentRequest(requestParams)
6221
- .then((xpsResponse) => {
6222
- const response = this.xpsResponseErrorsMappingService.mapErrors(xpsResponse);
6223
- const checkStatusResponse = this.responseFactory({
6224
- status: response.status,
6225
- final: response.final,
6226
- isPaymentAccountAttached: response.is_payment_account_attached,
6227
- });
6228
- this.emitResponse(checkStatusResponse);
6229
- })
6218
+ this.requestStatus(this.invoice)
6219
+ .then((checkStatusResponse) => this.emitResponse(checkStatusResponse))
6230
6220
  .catch((error) => {
6231
6221
  throw new ResponseError(error.message);
6232
6222
  });
6233
6223
  }
6224
+ /**
6225
+ * Performs a one-shot getstatus poll and returns the mapped response without
6226
+ * emitting it to the shared `response$` stream. Used by StatusService to
6227
+ * consult the authoritative terminal signal without interfering with the
6228
+ * listen-status polling loop. See PAYMENTS-29021.
6229
+ */
6230
+ async requestStatus(invoice) {
6231
+ const requestParams = this.requestFactory(this.settingsService.token, invoice);
6232
+ const xpsResponse = await this.xpsApiService.directPaymentRequest(requestParams);
6233
+ const response = this.xpsResponseErrorsMappingService.mapErrors(xpsResponse);
6234
+ return this.responseFactory({
6235
+ status: response.status,
6236
+ final: response.final,
6237
+ isPaymentAccountAttached: response.is_payment_account_attached,
6238
+ });
6239
+ }
6234
6240
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckStatusService, deps: [{ token: XpsApiService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable }); }
6235
6241
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckStatusService, providedIn: 'root' }); }
6236
6242
  }
@@ -6703,8 +6709,12 @@ class WebsocketStatusService {
6703
6709
  this.clearReinsuranceCheckTimeout();
6704
6710
  }
6705
6711
  if (message === WebSocketStatus.troubledStatus) {
6712
+ // A troubled status can be the terminal AFS-declined/refunded outcome.
6713
+ // Trigger a getstatus poll so listen-status can read the authoritative
6714
+ // verdict and finalize, instead of silently closing and leaving the UI
6715
+ // stuck on "Processing"
6706
6716
  this.clearReinsuranceCheckTimeout();
6707
- this.closeWebSocket();
6717
+ this.needCheckStatusSubject.next();
6708
6718
  }
6709
6719
  }
6710
6720
  removeSubscription() {
@@ -6740,6 +6750,7 @@ class ListenStatusService {
6740
6750
  this.destroy$ = new Subject();
6741
6751
  this.listenInvoice = null;
6742
6752
  this.websocketInvoice = null;
6753
+ this.pendingTerminalStatus = null;
6743
6754
  }
6744
6755
  listen(invoice) {
6745
6756
  if (this.isListening) {
@@ -6758,6 +6769,7 @@ class ListenStatusService {
6758
6769
  this.isListening = false;
6759
6770
  this.listenInvoice = null;
6760
6771
  this.websocketInvoice = null;
6772
+ this.pendingTerminalStatus = null;
6761
6773
  this.websocketStatusService.closeWebSocket();
6762
6774
  this.destroy$.next();
6763
6775
  this.destroy$.complete();
@@ -6774,6 +6786,13 @@ class ListenStatusService {
6774
6786
  if (!statusResponse?.status) {
6775
6787
  return;
6776
6788
  }
6789
+ const terminalStatus = this.pendingTerminalStatus;
6790
+ if (terminalStatus) {
6791
+ statusResponse.status.statusState = terminalStatus;
6792
+ if (terminalStatus === StatusEnum.canceled) {
6793
+ statusResponse.status.isCanceled = true;
6794
+ }
6795
+ }
6777
6796
  const statusSettings = {
6778
6797
  statusState: statusResponse.status.statusState,
6779
6798
  isCancelUser: statusResponse.status.isCancelUser,
@@ -6800,6 +6819,14 @@ class ListenStatusService {
6800
6819
  instanceId: statusResponse.status.pid,
6801
6820
  });
6802
6821
  }
6822
+ // A terminal verdict from the getstatus poll (e.g. AFS-declined and
6823
+ // refunded) is authoritative: finalize even when the full status still
6824
+ // reports needToCheck.
6825
+ if (terminalStatus) {
6826
+ this.stopListening();
6827
+ this.statusDoneSubject.next(statusSettings);
6828
+ return;
6829
+ }
6803
6830
  if (statusSettings.needWebSocket) {
6804
6831
  if (!this.websocketStatusService.isOpened ||
6805
6832
  this.websocketInvoice !== invoice) {
@@ -6826,6 +6853,19 @@ class ListenStatusService {
6826
6853
  this.websocketStatusService.closeWebSocket();
6827
6854
  return;
6828
6855
  }
6856
+ // AFS-declined / refunded transactions report a terminal failure here
6857
+ // (canceled/error + final) while the full status may still say
6858
+ // processing. Re-fetch the rich status, then flag it so the update
6859
+ // handler overrides the state to the terminal verdict and finalizes.
6860
+ const isTerminalFailure = checkStatusResponse.final === true &&
6861
+ (checkStatusResponse.status === StatusEnum.canceled ||
6862
+ checkStatusResponse.status === StatusEnum.error);
6863
+ if (isTerminalFailure) {
6864
+ this.pendingTerminalStatus = checkStatusResponse.status;
6865
+ this.statusService.request();
6866
+ this.websocketStatusService.closeWebSocket();
6867
+ return;
6868
+ }
6829
6869
  if (checkStatusResponse.final === false) {
6830
6870
  this.websocketStatusService.startReinsuranceCheckTimeout();
6831
6871
  return;
@@ -7019,13 +7059,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
7019
7059
  }], ctorParameters: () => [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }, { type: StatusUpdatedActionCreator }] });
7020
7060
 
7021
7061
  class StatusService {
7022
- constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService, statusUpdatedActionCreator) {
7062
+ constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService, checkStatusService, statusUpdatedActionCreator) {
7023
7063
  this.urlService = urlService;
7024
7064
  this.statusRequestService = statusRequestService;
7025
7065
  this.financeDetailsService = financeDetailsService;
7026
7066
  this.listenStatusService = listenStatusService;
7027
7067
  this.nextActionService = nextActionService;
7028
7068
  this.savePaymentMethodStatusService = savePaymentMethodStatusService;
7069
+ this.checkStatusService = checkStatusService;
7029
7070
  this.statusUpdatedActionCreator = statusUpdatedActionCreator;
7030
7071
  this.listenStatusSubscription = null;
7031
7072
  }
@@ -7038,6 +7079,7 @@ class StatusService {
7038
7079
  this.startWaitingStatusUpdates(params.invoice);
7039
7080
  this.statusRequestService.request();
7040
7081
  const statusResponse = await firstValueFrom(this.statusRequestService.response$);
7082
+ await this.applyPollTerminalStatus(statusResponse.status, params.invoice);
7041
7083
  this.financeDetailsService.emitWithStatus(statusResponse.status);
7042
7084
  return statusResponse.status;
7043
7085
  }
@@ -7056,6 +7098,46 @@ class StatusService {
7056
7098
  this.listenStatusSubscription = null;
7057
7099
  this.listenStatusService.stopListening();
7058
7100
  }
7101
+ /**
7102
+ * The full-status endpoint can report a non-terminal state (e.g.
7103
+ * `processing` with group `delivering`) for a transaction that has actually
7104
+ * been terminated — most notably a card payment declined by AFS and then
7105
+ * auto-refunded. In that scenario the lightweight getstatus poll is the only
7106
+ * authoritative terminal signal (`status: canceled`, `final: true`), so we
7107
+ * consult it and surface the terminal verdict to the partner instead of
7108
+ * leaving `statusState` stuck on `processing`.
7109
+ */
7110
+ async applyPollTerminalStatus(status, invoice) {
7111
+ const nonTerminalStates = [
7112
+ StatusEnum.created,
7113
+ StatusEnum.awaiting,
7114
+ StatusEnum.processing,
7115
+ StatusEnum.held,
7116
+ ];
7117
+ if (!status.needToCheck ||
7118
+ !nonTerminalStates.includes(status.statusState)) {
7119
+ return;
7120
+ }
7121
+ let pollStatus;
7122
+ try {
7123
+ pollStatus = await this.checkStatusService.requestStatus(invoice);
7124
+ }
7125
+ catch {
7126
+ return;
7127
+ }
7128
+ const terminalStatus = pollStatus.final === true &&
7129
+ (pollStatus.status === StatusEnum.canceled ||
7130
+ pollStatus.status === StatusEnum.error)
7131
+ ? pollStatus.status
7132
+ : null;
7133
+ if (!terminalStatus) {
7134
+ return;
7135
+ }
7136
+ status.statusState = terminalStatus;
7137
+ if (terminalStatus === StatusEnum.canceled) {
7138
+ status.isCanceled = true;
7139
+ }
7140
+ }
7059
7141
  getRequestParamsFromUrl(url) {
7060
7142
  const searchParams = this.urlService.getSearchParams(url ?? '');
7061
7143
  const keys = new Set(Object.keys(searchParams));
@@ -7091,7 +7173,7 @@ class StatusService {
7091
7173
  this.nextActionService.emitFlowUpdates(this.statusUpdatedActionCreator.getActionData({ statusResponse }));
7092
7174
  });
7093
7175
  }
7094
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }, { token: SavePaymentMethodStatusService }, { token: StatusUpdatedActionCreator }], target: i0.ɵɵFactoryTarget.Injectable }); }
7176
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }, { token: SavePaymentMethodStatusService }, { token: CheckStatusService }, { token: StatusUpdatedActionCreator }], target: i0.ɵɵFactoryTarget.Injectable }); }
7095
7177
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StatusService, providedIn: 'root' }); }
7096
7178
  }
7097
7179
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StatusService, decorators: [{
@@ -7099,7 +7181,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
7099
7181
  args: [{
7100
7182
  providedIn: 'root',
7101
7183
  }]
7102
- }], ctorParameters: () => [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }, { type: StatusUpdatedActionCreator }] });
7184
+ }], ctorParameters: () => [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }, { type: CheckStatusService }, { type: StatusUpdatedActionCreator }] });
7103
7185
 
7104
7186
  class CreditCardStateService extends EmitDataService {
7105
7187
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CreditCardStateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -9394,6 +9476,7 @@ class ApplePaySessionHandlerAbstract {
9394
9476
  constructor() {
9395
9477
  this.payment = new Subject();
9396
9478
  this._errorSubject = new Subject();
9479
+ this._analyticsEventSubject = new Subject();
9397
9480
  }
9398
9481
  get error$() {
9399
9482
  return this._errorSubject.asObservable();
@@ -9401,9 +9484,15 @@ class ApplePaySessionHandlerAbstract {
9401
9484
  get payment$() {
9402
9485
  return this.payment.asObservable();
9403
9486
  }
9487
+ get analyticsEvent$() {
9488
+ return this._analyticsEventSubject.asObservable();
9489
+ }
9404
9490
  emitError(error) {
9405
9491
  this._errorSubject.next(error);
9406
9492
  }
9493
+ emitAnalyticsEvent(event) {
9494
+ this._analyticsEventSubject.next(event);
9495
+ }
9407
9496
  buildPaymentRequest(params) {
9408
9497
  return {
9409
9498
  total: {
@@ -9430,12 +9519,15 @@ class ApplePayCartService {
9430
9519
  get cartRecalculationRequest$() {
9431
9520
  return this.cartRecalculationRequest.asObservable();
9432
9521
  }
9433
- constructor(userBehaviourAnalyticsService, summaryFinanceDetailsAdapterService) {
9434
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9522
+ get analyticsEvent$() {
9523
+ return this.analyticsEvent.asObservable();
9524
+ }
9525
+ constructor(summaryFinanceDetailsAdapterService) {
9435
9526
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
9436
9527
  this.cartSuccessfulRecalculated = new Subject();
9437
9528
  this.cartErrorRecalculated = new Subject();
9438
9529
  this.cartRecalculationRequest = new Subject();
9530
+ this.analyticsEvent = new Subject();
9439
9531
  }
9440
9532
  recalculateCartTaxes(shippingContact) {
9441
9533
  const zip = shippingContact.postalCode;
@@ -9449,7 +9541,9 @@ class ApplePayCartService {
9449
9541
  zip: parsedZip,
9450
9542
  country,
9451
9543
  });
9452
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartTaxes, 'manual', {
9544
+ this.analyticsEvent.next({
9545
+ eventName: UserBehaviourEventName.applePayRecalculateCartTaxes,
9546
+ eventType: userBehaviourEventTypes.manual,
9453
9547
  dimension1: country,
9454
9548
  dimension2: parsedZip || '',
9455
9549
  });
@@ -9476,7 +9570,10 @@ class ApplePayCartService {
9476
9570
  this.cartSuccessfulRecalculated.next(updatedPrice);
9477
9571
  }
9478
9572
  sendErrorRecalculatedCart(error) {
9479
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartError, 'manual');
9573
+ this.analyticsEvent.next({
9574
+ eventName: UserBehaviourEventName.applePayRecalculateCartError,
9575
+ eventType: userBehaviourEventTypes.manual,
9576
+ });
9480
9577
  this.cartErrorRecalculated.next(error);
9481
9578
  }
9482
9579
  isZipCountry(country) {
@@ -9511,7 +9608,7 @@ class ApplePayCartService {
9511
9608
  getTotalAmount(finance) {
9512
9609
  return finance?.grand_total?.amount ?? finance?.total?.amount;
9513
9610
  }
9514
- 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 }); }
9515
9612
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
9516
9613
  }
9517
9614
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, decorators: [{
@@ -9519,15 +9616,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9519
9616
  args: [{
9520
9617
  providedIn: 'root',
9521
9618
  }]
9522
- }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }, { type: SummaryFinanceDetailsAdapterService }] });
9619
+ }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
9523
9620
 
9524
9621
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9525
- constructor(window, loggerService, applePayCartService, userBehaviourAnalyticsService) {
9622
+ constructor(window, loggerService, applePayCartService) {
9526
9623
  super();
9527
9624
  this.window = window;
9528
9625
  this.loggerService = loggerService;
9529
9626
  this.applePayCartService = applePayCartService;
9530
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9531
9627
  this.paymentClient = null;
9532
9628
  }
9533
9629
  setClient(client) {
@@ -9557,18 +9653,30 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9557
9653
  if (!session)
9558
9654
  return;
9559
9655
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
9560
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
9656
+ this.emitAnalyticsEvent({
9657
+ eventName: UserBehaviourEventName.applePayBraintreeStartSession,
9658
+ eventType: userBehaviourEventTypes.manual,
9659
+ });
9561
9660
  session.onshippingcontactselected = (event) => {
9562
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeSelectShipping, 'manual');
9661
+ this.emitAnalyticsEvent({
9662
+ eventName: UserBehaviourEventName.applePayBraintreeSelectShipping,
9663
+ eventType: userBehaviourEventTypes.manual,
9664
+ });
9563
9665
  this.applePayCartService.cartSuccessfulRecalculated$
9564
9666
  .pipe(take(1))
9565
9667
  .subscribe((updatedPrice) => {
9566
9668
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9567
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated, 'manual');
9669
+ this.emitAnalyticsEvent({
9670
+ eventName: UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated,
9671
+ eventType: userBehaviourEventTypes.manual,
9672
+ });
9568
9673
  session.completeShippingContactSelection(contactUpdate);
9569
9674
  });
9570
9675
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9571
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartErrorRecalculated, 'manual');
9676
+ this.emitAnalyticsEvent({
9677
+ eventName: UserBehaviourEventName.applePayBraintreeCartErrorRecalculated,
9678
+ eventType: userBehaviourEventTypes.manual,
9679
+ });
9572
9680
  session.completeShippingContactSelection({
9573
9681
  errors: [error],
9574
9682
  newTotal: {
@@ -9581,7 +9689,9 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9581
9689
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9582
9690
  };
9583
9691
  session.onvalidatemerchant = (event) => {
9584
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchant, 'manual', {
9692
+ this.emitAnalyticsEvent({
9693
+ eventName: UserBehaviourEventName.applePayBraintreeValidateMerchant,
9694
+ eventType: userBehaviourEventTypes.manual,
9585
9695
  value: event.validationURL,
9586
9696
  extraValue: params.totalLabel,
9587
9697
  });
@@ -9599,14 +9709,20 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9599
9709
  session.completeMerchantValidation(merchantSession);
9600
9710
  })
9601
9711
  .catch((error) => {
9602
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchantError, 'manual');
9712
+ this.emitAnalyticsEvent({
9713
+ eventName: UserBehaviourEventName.applePayBraintreeValidateMerchantError,
9714
+ eventType: userBehaviourEventTypes.manual,
9715
+ });
9603
9716
  console.error(ApplePayErrors.merchantValidationError, error);
9604
9717
  session.abort();
9605
9718
  applePayFinallyCallback();
9606
9719
  });
9607
9720
  };
9608
9721
  session.onpaymentauthorized = (event) => {
9609
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentAuthorized, 'manual');
9722
+ this.emitAnalyticsEvent({
9723
+ eventName: UserBehaviourEventName.applePayBraintreePaymentAuthorized,
9724
+ eventType: userBehaviourEventTypes.manual,
9725
+ });
9610
9726
  this.paymentClient
9611
9727
  ?.tokenize({ token: event.payment.token })
9612
9728
  .then((response) => {
@@ -9619,21 +9735,27 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9619
9735
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9620
9736
  })
9621
9737
  .catch((error) => {
9622
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentTokenizationError, 'manual');
9738
+ this.emitAnalyticsEvent({
9739
+ eventName: UserBehaviourEventName.applePayBraintreePaymentTokenizationError,
9740
+ eventType: userBehaviourEventTypes.manual,
9741
+ });
9623
9742
  console.error('Apple Pay: Tokenization error', error);
9624
9743
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
9625
9744
  applePayFinallyCallback();
9626
9745
  });
9627
9746
  };
9628
9747
  session.oncancel = (event) => {
9629
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentCancel, 'manual');
9748
+ this.emitAnalyticsEvent({
9749
+ eventName: UserBehaviourEventName.applePayBraintreePaymentCancel,
9750
+ eventType: userBehaviourEventTypes.manual,
9751
+ });
9630
9752
  console.error(ApplePayErrors.cancelled, event);
9631
9753
  this.emitError(ApplePayErrors.cancelled);
9632
9754
  applePayFinallyCallback();
9633
9755
  };
9634
9756
  session.begin();
9635
9757
  }
9636
- 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 }); }
9637
9759
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler }); }
9638
9760
  }
9639
9761
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -9641,16 +9763,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9641
9763
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9642
9764
  type: Inject,
9643
9765
  args: [windowToken]
9644
- }] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9766
+ }] }, { type: LoggerService }, { type: ApplePayCartService }] });
9645
9767
 
9646
9768
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9647
- constructor(window, http, loggerService, applePayCartService, userBehaviourAnalyticsService) {
9769
+ constructor(window, http, loggerService, applePayCartService) {
9648
9770
  super();
9649
9771
  this.window = window;
9650
9772
  this.http = http;
9651
9773
  this.loggerService = loggerService;
9652
9774
  this.applePayCartService = applePayCartService;
9653
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9654
9775
  }
9655
9776
  startSession(params, additionalParams, applePayFinallyCallback) {
9656
9777
  const request = this.buildPaymentRequest(params);
@@ -9668,16 +9789,25 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9668
9789
  if (!session)
9669
9790
  return;
9670
9791
  session.onshippingcontactselected = (event) => {
9671
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
9792
+ this.emitAnalyticsEvent({
9793
+ eventName: UserBehaviourEventName.applePayCheckoutSelectShipping,
9794
+ eventType: userBehaviourEventTypes.manual,
9795
+ });
9672
9796
  this.applePayCartService.cartSuccessfulRecalculated$
9673
9797
  .pipe(take(1))
9674
9798
  .subscribe((updatedPrice) => {
9675
9799
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9676
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated, 'manual');
9800
+ this.emitAnalyticsEvent({
9801
+ eventName: UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated,
9802
+ eventType: userBehaviourEventTypes.manual,
9803
+ });
9677
9804
  session.completeShippingContactSelection(contactUpdate);
9678
9805
  });
9679
9806
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9680
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartErrorRecalculated, 'manual');
9807
+ this.emitAnalyticsEvent({
9808
+ eventName: UserBehaviourEventName.applePayCheckoutCartErrorRecalculated,
9809
+ eventType: userBehaviourEventTypes.manual,
9810
+ });
9681
9811
  session.completeShippingContactSelection({
9682
9812
  errors: [error],
9683
9813
  newTotal: {
@@ -9690,7 +9820,9 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9690
9820
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9691
9821
  };
9692
9822
  session.onvalidatemerchant = (event) => {
9693
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchant, 'manual', {
9823
+ this.emitAnalyticsEvent({
9824
+ eventName: UserBehaviourEventName.applePayCheckoutValidateMerchant,
9825
+ eventType: userBehaviourEventTypes.manual,
9694
9826
  value: event.validationURL,
9695
9827
  extraValue: params.totalLabel,
9696
9828
  });
@@ -9713,7 +9845,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9713
9845
  session.completeMerchantValidation(response.merchantSession);
9714
9846
  },
9715
9847
  error: (error) => {
9716
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchantError, 'manual');
9848
+ this.emitAnalyticsEvent({
9849
+ eventName: UserBehaviourEventName.applePayCheckoutValidateMerchantError,
9850
+ eventType: userBehaviourEventTypes.manual,
9851
+ });
9717
9852
  console.error(ApplePayErrors.merchantValidationError, error);
9718
9853
  session.abort();
9719
9854
  applePayFinallyCallback();
@@ -9721,7 +9856,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9721
9856
  });
9722
9857
  };
9723
9858
  session.onpaymentauthorized = (event) => {
9724
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentAuthorized, 'manual');
9859
+ this.emitAnalyticsEvent({
9860
+ eventName: UserBehaviourEventName.applePayCheckoutPaymentAuthorized,
9861
+ eventType: userBehaviourEventTypes.manual,
9862
+ });
9725
9863
  this.payment.next(JSON.stringify({
9726
9864
  token: event.payment.token ?? '',
9727
9865
  email: event.payment.billingContact?.emailAddress ?? null,
@@ -9731,14 +9869,17 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9731
9869
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9732
9870
  };
9733
9871
  session.oncancel = (event) => {
9734
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentCancel, 'manual');
9872
+ this.emitAnalyticsEvent({
9873
+ eventName: UserBehaviourEventName.applePayCheckoutPaymentCancel,
9874
+ eventType: userBehaviourEventTypes.manual,
9875
+ });
9735
9876
  console.error(ApplePayErrors.cancelled, event);
9736
9877
  this.emitError(ApplePayErrors.cancelled);
9737
9878
  applePayFinallyCallback();
9738
9879
  };
9739
9880
  session.begin();
9740
9881
  }
9741
- 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 }); }
9742
9883
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler }); }
9743
9884
  }
9744
9885
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -9746,7 +9887,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9746
9887
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9747
9888
  type: Inject,
9748
9889
  args: [windowToken]
9749
- }] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9890
+ }] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }] });
9750
9891
 
9751
9892
  class PaymentBehaviourModule {
9752
9893
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
@@ -9972,11 +10113,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9972
10113
  }] }] });
9973
10114
 
9974
10115
  class GooglePayCheckoutPaymentService {
9975
- constructor(paymentSystemProcessingService, userBehaviourAnalyticsService, loggerService) {
10116
+ constructor(paymentSystemProcessingService, loggerService) {
9976
10117
  this.paymentSystemProcessingService = paymentSystemProcessingService;
9977
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9978
10118
  this.loggerService = loggerService;
9979
10119
  this.checkout = null;
10120
+ this.analyticsEvent = new Subject();
10121
+ }
10122
+ get analyticsEvent$() {
10123
+ return this.analyticsEvent.asObservable();
9980
10124
  }
9981
10125
  preparePayment({ initParams, checkDeviceData, }) {
9982
10126
  if (!initParams || !checkDeviceData.base64checkoutData) {
@@ -10021,7 +10165,11 @@ class GooglePayCheckoutPaymentService {
10021
10165
  return paymentDataRequest.allowedPaymentMethods;
10022
10166
  }
10023
10167
  handleSuccessfulPayment(response) {
10024
- 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
+ });
10025
10173
  if (!this.checkout)
10026
10174
  return;
10027
10175
  let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
@@ -10030,7 +10178,11 @@ class GooglePayCheckoutPaymentService {
10030
10178
  this.paymentSystemProcessingService.emitStatusUrl(returnUrl);
10031
10179
  }
10032
10180
  handleFailedPayment(error) {
10033
- 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
+ });
10034
10186
  if (!this.checkout)
10035
10187
  return;
10036
10188
  const statusCode = error?.statusCode;
@@ -10043,7 +10195,7 @@ class GooglePayCheckoutPaymentService {
10043
10195
  isCancelledStatus(statusCode) {
10044
10196
  return statusCode.toLowerCase() === 'canceled';
10045
10197
  }
10046
- 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 }); }
10047
10199
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
10048
10200
  }
10049
10201
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -10051,7 +10203,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10051
10203
  args: [{
10052
10204
  providedIn: 'root',
10053
10205
  }]
10054
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }, { type: LoggerService }] });
10206
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: LoggerService }] });
10055
10207
 
10056
10208
  class GooglePayInstantPaymentService {
10057
10209
  constructor(summaryFinanceDetailsAdapterService, loggerService) {
@@ -10185,19 +10337,19 @@ class GooglePayService {
10185
10337
  get googlePaymentClientWasInitialized() {
10186
10338
  return !!this.googlePaymentClient;
10187
10339
  }
10188
- constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector, userBehaviourAnalyticsService) {
10340
+ constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector) {
10189
10341
  this.window = window;
10190
10342
  this.loggerService = loggerService;
10191
10343
  this.paymentSystemProcessingService = paymentSystemProcessingService;
10192
10344
  this.googlePayCheckoutPaymentService = googlePayCheckoutPaymentService;
10193
10345
  this.googlePayInstantPaymentService = googlePayInstantPaymentService;
10194
10346
  this.injector = injector;
10195
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10196
10347
  this.googlePayScriptUrl = 'https://pay.google.com/gp/p/js/pay.js';
10197
10348
  this.readyToPay = new BehaviorSubject(null);
10198
10349
  this.paymentWindowIsReady = new Subject();
10199
10350
  this.paymentWindowIsClose = new Subject();
10200
10351
  this.error = new Subject();
10352
+ this.analyticsEvent = new Subject();
10201
10353
  this.paymentInProgress = false;
10202
10354
  this.googlePaymentClient = null;
10203
10355
  this.paymentService = null;
@@ -10214,6 +10366,9 @@ class GooglePayService {
10214
10366
  get error$() {
10215
10367
  return this.error.asObservable();
10216
10368
  }
10369
+ get analyticsEvent$() {
10370
+ return merge(this.analyticsEvent.asObservable(), this.googlePayCheckoutPaymentService.analyticsEvent$);
10371
+ }
10217
10372
  isReadyToPay() {
10218
10373
  return this.readyToPay.getValue();
10219
10374
  }
@@ -10286,7 +10441,11 @@ class GooglePayService {
10286
10441
  return Promise.resolve(null);
10287
10442
  }
10288
10443
  if (this.initParams.isInstantPayFlow) {
10289
- 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
+ });
10290
10449
  }
10291
10450
  const paymentDataRequest = this.paymentService.getPaymentRequest();
10292
10451
  if (!paymentDataRequest) {
@@ -10434,7 +10593,7 @@ class GooglePayService {
10434
10593
  }
10435
10594
  return allowedLocales.find((locale) => locale === userLocale) ?? 'en';
10436
10595
  }
10437
- 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 }); }
10438
10597
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, providedIn: 'root' }); }
10439
10598
  }
10440
10599
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, decorators: [{
@@ -10445,7 +10604,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10445
10604
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10446
10605
  type: Inject,
10447
10606
  args: [windowToken]
10448
- }] }, { 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 }] });
10449
10608
 
10450
10609
  var ApplePayIntegrationType;
10451
10610
  (function (ApplePayIntegrationType) {
@@ -10692,11 +10851,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10692
10851
  }], ctorParameters: () => [{ type: SecureApiClient }] });
10693
10852
 
10694
10853
  class ApplePayExternalWindowCommunicationService {
10695
- constructor(window, webSocketFactory, socketBridgeService, userBehaviourAnalyticsService) {
10854
+ constructor(window, webSocketFactory, socketBridgeService) {
10696
10855
  this.window = window;
10697
10856
  this.webSocketFactory = webSocketFactory;
10698
10857
  this.socketBridgeService = socketBridgeService;
10699
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10858
+ this.analyticsEvent = new Subject();
10859
+ }
10860
+ get analyticsEvent$() {
10861
+ return this.analyticsEvent.asObservable();
10700
10862
  }
10701
10863
  getWindowClose$() {
10702
10864
  const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
@@ -10721,7 +10883,10 @@ class ApplePayExternalWindowCommunicationService {
10721
10883
  return this.getEventSource(isRecalculateCartMessage);
10722
10884
  }
10723
10885
  async openWebSocketConnection(token) {
10724
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayOpenWebSocketConnection, 'manual');
10886
+ this.analyticsEvent.next({
10887
+ eventName: UserBehaviourEventName.applePayOpenWebSocketConnection,
10888
+ eventType: userBehaviourEventTypes.manual,
10889
+ });
10725
10890
  const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
10726
10891
  if (this.websocketClient) {
10727
10892
  this.websocketClient.close();
@@ -10730,7 +10895,11 @@ class ApplePayExternalWindowCommunicationService {
10730
10895
  await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
10731
10896
  }
10732
10897
  async sendMessageToAnotherWindow(command, payload) {
10733
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePaySendMessageToAnotherWindow, 'manual', { value: command });
10898
+ this.analyticsEvent.next({
10899
+ eventName: UserBehaviourEventName.applePaySendMessageToAnotherWindow,
10900
+ eventType: userBehaviourEventTypes.manual,
10901
+ value: command,
10902
+ });
10734
10903
  await this.socketBridgeService.publishMessage(command, payload);
10735
10904
  }
10736
10905
  getEventSource(eventHandler) {
@@ -10739,7 +10908,7 @@ class ApplePayExternalWindowCommunicationService {
10739
10908
  return JSON.parse(message);
10740
10909
  }), filter(eventHandler));
10741
10910
  }
10742
- 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 }); }
10743
10912
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
10744
10913
  }
10745
10914
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
@@ -10750,7 +10919,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10750
10919
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10751
10920
  type: Inject,
10752
10921
  args: [windowToken]
10753
- }] }, { type: WebSocketFactory }, { type: SocketBridgeService }, { type: UserBehaviourAnalyticsService }] });
10922
+ }] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
10754
10923
 
10755
10924
  class ApplePayService {
10756
10925
  get paymentParameters() {
@@ -10766,6 +10935,9 @@ class ApplePayService {
10766
10935
  get applePayQrOpened$() {
10767
10936
  return this.applePayQrOpened.asObservable();
10768
10937
  }
10938
+ get analyticsEvent$() {
10939
+ return merge(this.analyticsEvent.asObservable(), this.braintreeHandler.analyticsEvent$, this.checkoutHandler.analyticsEvent$, this.externalWindowCommunicationService.analyticsEvent$);
10940
+ }
10769
10941
  /* istanbul ignore next */
10770
10942
  get windowClosing$() {
10771
10943
  return this.applePaySdkService.windowClosing$;
@@ -10793,7 +10965,7 @@ class ApplePayService {
10793
10965
  .getWindowReturnMessage$()
10794
10966
  .pipe(takeUntil(this.destroy$));
10795
10967
  }
10796
- constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, userBehaviourAnalyticsService, settingsService) {
10968
+ constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
10797
10969
  this.window = window;
10798
10970
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
10799
10971
  this.braintreeHandler = braintreeHandler;
@@ -10802,12 +10974,12 @@ class ApplePayService {
10802
10974
  this.loggerService = loggerService;
10803
10975
  this.applePaySdkService = applePaySdkService;
10804
10976
  this.externalWindowCommunicationService = externalWindowCommunicationService;
10805
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10806
10977
  this.settingsService = settingsService;
10807
10978
  this.payment = new Subject();
10808
10979
  this.error = new Subject();
10809
10980
  this.integrationType = new Subject();
10810
10981
  this.applePayQrOpened = new Subject();
10982
+ this.analyticsEvent = new Subject();
10811
10983
  this.destroy$ = new Subject();
10812
10984
  this.paymentClient = null;
10813
10985
  this.applePayParams = null;
@@ -10930,9 +11102,17 @@ class ApplePayService {
10930
11102
  this.applePayParams = this.appleParamsBuilder.updateParams(this.applePayParams, summary);
10931
11103
  }
10932
11104
  proceedCheckout(parameters, additionalParams) {
10933
- 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
+ });
10934
11110
  if (additionalParams.isApplePayInstantFlowEnabled) {
10935
- 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
+ });
10936
11116
  }
10937
11117
  const sessionHandler = this.getSessionHandler(parameters.acquirer);
10938
11118
  if (!sessionHandler) {
@@ -10991,7 +11171,7 @@ class ApplePayService {
10991
11171
  this.applePayQrOpened.next();
10992
11172
  }
10993
11173
  }
10994
- 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 }); }
10995
11175
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
10996
11176
  }
10997
11177
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, decorators: [{
@@ -11002,7 +11182,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
11002
11182
  }], ctorParameters: () => [{ type: undefined, decorators: [{
11003
11183
  type: Inject,
11004
11184
  args: [windowToken]
11005
- }] }, { 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 }] });
11006
11186
 
11007
11187
  /*
11008
11188
  * Public API Surface of core-library