diff --git a/cmd/root.go b/cmd/root.go index b1b55ae..51ea361 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -40,7 +40,7 @@ func Execute() { // resolveConfig or exit with error func resolveConfig() *config.Config { - cfg, err := config.New(Version, Commit, configPath, skipConfig, EmbedFrontend) + cfg, err := config.New(Commit, Version, configPath, skipConfig, EmbedFrontend) if err != nil { fmt.Printf("unable to initialize config: %s\n", err.Error()) os.Exit(1) diff --git a/go.mod b/go.mod index db1e66c..3ff1f1a 100644 --- a/go.mod +++ b/go.mod @@ -26,14 +26,14 @@ require ( github.com/oxygenpay/tatum-sdk v0.0.0-20230529210116-d986b7743613 github.com/pkg/errors v0.9.1 github.com/robfig/cron/v3 v3.0.1 - github.com/rs/zerolog v1.26.1 + github.com/rs/zerolog v1.29.0 github.com/rubenv/sql-migrate v1.2.0 github.com/samber/lo v1.37.0 github.com/spf13/cobra v1.6.1 github.com/stretchr/testify v1.8.1 github.com/tidwall/gjson v1.14.4 github.com/wemeetagain/go-hdwallet v0.1.0 - github.com/ziflex/lecho/v3 v3.1.0 + github.com/ziflex/lecho/v3 v3.5.0 go.etcd.io/bbolt v1.3.6 go.uber.org/atomic v1.10.0 golang.org/x/crypto v0.11.0 diff --git a/go.sum b/go.sum index 764f8c4..6d7479e 100644 --- a/go.sum +++ b/go.sum @@ -104,6 +104,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -458,6 +459,7 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -541,11 +543,14 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/rs/zerolog v1.26.0/go.mod h1:yBiM87lvSqX8h0Ww4sdzNSkVYZ8dL2xjZJG1lAuGZEo= github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= +github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= +github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/rubenv/sql-migrate v1.2.0 h1:fOXMPLMd41sK7Tg75SXDec15k3zg5WNV6SjuDRiNfcU= github.com/rubenv/sql-migrate v1.2.0/go.mod h1:Z5uVnq7vrIrPmHbVFfR4YLHRZquxeHpckCnRq0P/K9Y= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -636,6 +641,8 @@ github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/ziflex/lecho/v3 v3.1.0 h1:65bSzSc0yw7EEhi44lMnkOI877ZzbE7tGDWfYCQXZwI= github.com/ziflex/lecho/v3 v3.1.0/go.mod h1:dwQ6xCAKmSBHhwZ6XmiAiDptD7iklVkW7xQYGUncX0Q= +github.com/ziflex/lecho/v3 v3.5.0 h1:Z4TBr8SbUUnfaVc8tGJf1Jhu0G9Jxjl77lPW0riXKak= +github.com/ziflex/lecho/v3 v3.5.0/go.mod h1:+eInrytYHxVPI6NQbua9xXGerB1x0ujj9jAV33yBIko= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= diff --git a/internal/server/http/server.go b/internal/server/http/server.go index bd04b22..9b77e69 100644 --- a/internal/server/http/server.go +++ b/internal/server/http/server.go @@ -91,6 +91,7 @@ func WithLogger(logger *zerolog.Logger) Opt { s.echo.Use(lecho.Middleware(lecho.Config{ Logger: lecho.From(l, lecho.WithLevel(log.INFO)), RequestIDKey: middleware.RequestIDKey, + Enricher: loggerEnricher, Skipper: func(c echo.Context) bool { path := c.Request().URL.Path @@ -106,6 +107,20 @@ func WithLogger(logger *zerolog.Logger) Opt { } } +func loggerEnricher(c echo.Context, logger zerolog.Context) zerolog.Context { + merchantID := c.Param("merchantId") + if merchantID != "" { + logger = logger.Str("merchant_id", merchantID) + } + + paymentID := c.Param("paymentId") + if paymentID != "" { + logger = logger.Str("payment_id", paymentID) + } + + return logger.Str("path", c.Path()) +} + const healthcheckPath = "/health" func withHealthcheck(e *echo.Echo) { diff --git a/internal/service/payment/service.go b/internal/service/payment/service.go index 187ec7d..7c84eaa 100644 --- a/internal/service/payment/service.go +++ b/internal/service/payment/service.go @@ -580,6 +580,11 @@ func (s *Service) Update(ctx context.Context, merchantID, id int64, props Update return s.entryToPayment(pt) } +func (s *Service) Fail(ctx context.Context, pt *Payment) error { + _, err := s.Update(ctx, pt.MerchantID, pt.ID, UpdateProps{Status: StatusFailed}) + return err +} + func (s *Service) SetWebhookTimestamp(ctx context.Context, merchantID, id int64, sentAt time.Time) error { err := s.repo.UpdatePaymentWebhookInfo(ctx, repository.UpdatePaymentWebhookInfoParams{ ID: id, diff --git a/internal/service/payment/service_withdrawal.go b/internal/service/payment/service_withdrawal.go index 51f7163..2293193 100644 --- a/internal/service/payment/service_withdrawal.go +++ b/internal/service/payment/service_withdrawal.go @@ -2,6 +2,7 @@ package payment import ( "context" + "fmt" "strconv" "time" @@ -33,7 +34,7 @@ func (s *Service) ListWithdrawals(ctx context.Context, status Status, filterByID } if len(filterByIDs) > 0 && len(results) != len(filterByIDs) { - return nil, errors.New("results len mismatch") + return nil, fmt.Errorf("withdrawals filter mismatch for status %q", status) } payments := make([]*Payment, len(results)) diff --git a/internal/service/processing/service_withdrawal.go b/internal/service/processing/service_withdrawal.go index fc9aab2..260f0b1 100644 --- a/internal/service/processing/service_withdrawal.go +++ b/internal/service/processing/service_withdrawal.go @@ -23,12 +23,7 @@ func (s *Service) BatchCreateWithdrawals(ctx context.Context, withdrawalIDs []in return nil, err } - // 1.Validate payments - if errValidate := s.validateWithdrawals(withdrawals); errValidate != nil { - return nil, errValidate - } - - // 2. Get OUTBOUND wallets and balances + // 1. Get OUTBOUND wallets and balances outboundWallets, outboundBalances, err := s.getOutboundWalletsWithBalancesAsMap(ctx) if err != nil { return nil, errors.Wrap(err, "unable to get outbound wallets with balances") @@ -36,7 +31,8 @@ func (s *Service) BatchCreateWithdrawals(ctx context.Context, withdrawalIDs []in result := &TransferResult{} - // 3. For each withdrawal: + // 2. For each withdrawal: + // - Validate // - Resolve currency // - Resolve outbound system wallet & balance // - Resolve merchant balance & withdrawal address @@ -47,6 +43,18 @@ func (s *Service) BatchCreateWithdrawals(ctx context.Context, withdrawalIDs []in for i := range withdrawals { withdrawal := withdrawals[i] group.Go(func() error { + // Let's validate each withdrawal individually. + // By doing so, we can reject it without blocking other withdrawals. + if errValidate := validateWithdrawal(withdrawal); errValidate != nil { + if errUpdate := s.payments.Fail(ctx, withdrawal); errUpdate != nil { + result.registerErr(errors.Wrap(errUpdate, "unable to mark invalid withdrawal as failed")) + } else { + result.registerErr(errors.Wrap(errValidate, "withdrawal is invalid, marked as failed")) + } + + return nil + } + currency, err := s.blockchain.GetCurrencyByTicker(withdrawal.Price.Ticker()) if err != nil { result.registerErr(errors.Wrap(err, "unable to get withdrawal currency")) @@ -540,27 +548,26 @@ func (s *Service) cancelWithdrawal( return nil } -func (s *Service) validateWithdrawals(withdrawals []*payment.Payment) error { - for _, pt := range withdrawals { - if pt.Type != payment.TypeWithdrawal { - return errors.Wrap(ErrInvalidInput, "payment is not withdrawal") - } +func validateWithdrawal(pt *payment.Payment) error { + if pt.Type != payment.TypeWithdrawal { + return errors.Wrap(ErrInvalidInput, "payment is not withdrawal") + } - if pt.Status != payment.StatusPending { - return errors.Wrap(ErrInvalidInput, "withdrawal is not pending") - } + if pt.Status != payment.StatusPending { + return errors.Wrap(ErrInvalidInput, "withdrawal is not pending") + } - if pt.MerchantID == 0 { - return errors.Wrap(ErrInvalidInput, "invalid merchant id") - } + if pt.MerchantID == 0 { + return errors.Wrap(ErrInvalidInput, "invalid merchant id") + } - if pt.WithdrawalBalanceID() < 1 { - return errors.Wrap(ErrInvalidInput, "invalid balance id") - } + if pt.WithdrawalBalanceID() < 1 { + return errors.Wrap(ErrInvalidInput, "invalid balance id") + } - if pt.WithdrawalAddressID() < 1 { - return errors.Wrap(ErrInvalidInput, "invalid address id") - } + // edge-case: a customer can delete the address while withdrawal is pending + if pt.WithdrawalAddressID() < 1 { + return errors.Wrap(ErrInvalidInput, "invalid address id") } return nil diff --git a/internal/service/processing/service_withdrawal_test.go b/internal/service/processing/service_withdrawal_test.go index 83e6b1e..e51b984 100644 --- a/internal/service/processing/service_withdrawal_test.go +++ b/internal/service/processing/service_withdrawal_test.go @@ -12,6 +12,7 @@ import ( "github.com/oxygenpay/oxygen/internal/service/blockchain" "github.com/oxygenpay/oxygen/internal/service/merchant" "github.com/oxygenpay/oxygen/internal/service/payment" + "github.com/oxygenpay/oxygen/internal/service/processing" "github.com/oxygenpay/oxygen/internal/service/transaction" "github.com/oxygenpay/oxygen/internal/service/wallet" "github.com/oxygenpay/oxygen/internal/test" @@ -504,7 +505,7 @@ func TestService_BatchCreateWithdrawals(t *testing.T) { }) }) - t.Run("Creates 2 ETH transactions, one failed", func(t *testing.T) { + t.Run("Creates 2 ETH transactions, one fails due to insufficient balance", func(t *testing.T) { tc.Clear.Wallets(t) isTest := false @@ -607,112 +608,129 @@ func TestService_BatchCreateWithdrawals(t *testing.T) { assert.Equal(t, expectedWalletBalance, outboundBalance.Amount.StringRaw()) }) - t.Run("Fails", func(t *testing.T) { + t.Run("Validation error", func(t *testing.T) { tc.Clear.Wallets(t) - t.Run("Validation error", func(t *testing.T) { - mt, _ := tc.Must.CreateMerchant(t, 1) + mt, _ := tc.Must.CreateMerchant(t, 1) - merchantBalance := tc.Must.CreateBalance(t, wallet.EntityTypeMerchant, mt.ID, withBalance(eth, "123_000_000_000_000_000", false)) - merchantAddress, err := tc.Services.Merchants.CreateMerchantAddress(ctx, mt.ID, merchant.CreateMerchantAddressParams{ - Name: "A1", - Blockchain: kmswallet.Blockchain(eth.Blockchain), - Address: "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5", + merchantBalance := tc.Must.CreateBalance(t, wallet.EntityTypeMerchant, mt.ID, withBalance(eth, "123_000_000_000_000_000", false)) + merchantAddress, err := tc.Services.Merchants.CreateMerchantAddress(ctx, mt.ID, merchant.CreateMerchantAddressParams{ + Name: "A1", + Blockchain: kmswallet.Blockchain(eth.Blockchain), + Address: "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5", + }) + require.NoError(t, err) + + makeWithdrawal := func(amount money.Money, meta payment.Metadata) *payment.Payment { + entry, err := tc.Repository.CreatePayment(ctx, repository.CreatePaymentParams{ + PublicID: uuid.New(), + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + Type: string(payment.TypeWithdrawal), + Status: string(payment.StatusPending), + MerchantID: mt.ID, + MerchantOrderUuid: uuid.New(), + Price: repository.MoneyToNumeric(amount), + Decimals: int32(amount.Decimals()), + Currency: amount.Ticker(), + Metadata: meta.ToJSONB(), + IsTest: false, }) require.NoError(t, err) - makeWithdrawal := func(amount money.Money, meta payment.Metadata) *payment.Payment { - entry, err := tc.Repository.CreatePayment(ctx, repository.CreatePaymentParams{ - PublicID: uuid.New(), - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - Type: string(payment.TypeWithdrawal), - Status: string(payment.StatusPending), - MerchantID: mt.ID, - MerchantOrderUuid: uuid.New(), - Price: repository.MoneyToNumeric(amount), - Decimals: int32(amount.Decimals()), - Currency: amount.Ticker(), - Metadata: meta.ToJSONB(), - IsTest: false, - }) - require.NoError(t, err) - - pt, err := tc.Services.Payment.GetByID(ctx, mt.ID, entry.ID) - require.NoError(t, err) - - return pt - } - - for testCaseIndex, testCase := range []struct { - errContains string - withdrawals func() []*payment.Payment - }{ - { - // actually "payment is not withdrawal" - errContains: "results len mismatch", - withdrawals: func() []*payment.Payment { - return []*payment.Payment{tc.CreateSamplePayment(t, mt.ID)} - }, + pt, err := tc.Services.Payment.GetByID(ctx, mt.ID, entry.ID) + require.NoError(t, err) + + return pt + } + + for _, tt := range []struct { + name string + assert func(t *testing.T, in []*payment.Payment, result *processing.TransferResult, err error) + withdrawals func() []*payment.Payment + }{ + { + name: "payment is not withdrawal", + withdrawals: func() []*payment.Payment { + return []*payment.Payment{tc.CreateSamplePayment(t, mt.ID)} }, - { - // actually "status is not pending" - errContains: "results len mismatch", - withdrawals: func() []*payment.Payment { - withdrawal, err := tc.Services.Payment.CreateWithdrawal(ctx, mt.ID, payment.CreateWithdrawalProps{ - BalanceID: merchantBalance.UUID, - AddressID: merchantAddress.UUID, - AmountRaw: "0.1", - }) - require.NoError(t, err) - - _, err = tc.Services.Payment.Update(ctx, mt.ID, withdrawal.ID, payment.UpdateProps{Status: payment.StatusInProgress}) - require.NoError(t, err) - - return []*payment.Payment{withdrawal} - }, + assert: func(t *testing.T, _ []*payment.Payment, _ *processing.TransferResult, err error) { + assert.ErrorContains(t, err, `withdrawals filter mismatch for status "pending"`) }, - { - errContains: "invalid address id", - withdrawals: func() []*payment.Payment { - return []*payment.Payment{ - makeWithdrawal( - lo.Must(eth.MakeAmount("123_456")), - payment.Metadata{payment.MetaBalanceID: strconv.Itoa(int(merchantBalance.ID))}, - ), - } - }, + }, + { + name: "status is not pending", + withdrawals: func() []*payment.Payment { + withdrawal, err := tc.Services.Payment.CreateWithdrawal(ctx, mt.ID, payment.CreateWithdrawalProps{ + BalanceID: merchantBalance.UUID, + AddressID: merchantAddress.UUID, + AmountRaw: "0.1", + }) + require.NoError(t, err) + + _, err = tc.Services.Payment.Update(ctx, mt.ID, withdrawal.ID, payment.UpdateProps{Status: payment.StatusInProgress}) + require.NoError(t, err) + + return []*payment.Payment{withdrawal} }, - { - errContains: "invalid balance id", - withdrawals: func() []*payment.Payment { - return []*payment.Payment{ - makeWithdrawal( - lo.Must(eth.MakeAmount("123_456")), - payment.Metadata{payment.MetaAddressID: strconv.Itoa(int(merchantAddress.ID))}, - ), - } - }, + assert: func(t *testing.T, _ []*payment.Payment, _ *processing.TransferResult, err error) { + assert.ErrorContains(t, err, `withdrawals filter mismatch for status "pending"`) }, - } { - t.Run(strconv.Itoa(testCaseIndex+1), func(t *testing.T) { - // ARRANGE - // Given balances - input := testCase.withdrawals() - - // ACT - // Transfer money - ids := util.MapSlice(input, func(p *payment.Payment) int64 { return p.ID }) - result, err := tc.Services.Processing.BatchCreateWithdrawals(ctx, ids) - assert.Nil(t, result) - - // ASSERT - // Check that error contain string - if testCase.errContains != "" { - assert.ErrorContains(t, err, testCase.errContains) + }, + { + name: "invalid address id", + withdrawals: func() []*payment.Payment { + return []*payment.Payment{ + makeWithdrawal( + lo.Must(eth.MakeAmount("123_456")), + payment.Metadata{payment.MetaBalanceID: strconv.Itoa(int(merchantBalance.ID))}, + ), } - }) - } - }) + }, + assert: func(t *testing.T, in []*payment.Payment, result *processing.TransferResult, err error) { + assert.NoError(t, err) + assert.Equal(t, int64(1), result.TotalErrors) + assert.ErrorContains(t, result.UnhandledErrors[0], "withdrawal is invalid, marked as failed") + + pt, _ := tc.Services.Payment.GetByID(ctx, in[0].MerchantID, in[0].ID) + require.NoError(t, err) + assert.Equal(t, payment.StatusFailed, pt.Status) + }, + }, + { + name: "invalid balance id", + withdrawals: func() []*payment.Payment { + return []*payment.Payment{ + makeWithdrawal( + lo.Must(eth.MakeAmount("123_456")), + payment.Metadata{payment.MetaAddressID: strconv.Itoa(int(merchantAddress.ID))}, + ), + } + }, + assert: func(t *testing.T, in []*payment.Payment, result *processing.TransferResult, err error) { + assert.NoError(t, err) + assert.Equal(t, int64(1), result.TotalErrors) + assert.ErrorContains(t, result.UnhandledErrors[0], "withdrawal is invalid, marked as failed") + + pt, _ := tc.Services.Payment.GetByID(ctx, in[0].MerchantID, in[0].ID) + require.NoError(t, err) + assert.Equal(t, payment.StatusFailed, pt.Status) + }, + }, + } { + t.Run(tt.name, func(t *testing.T) { + // ARRANGE + // Given balances + input := tt.withdrawals() + + // ACT + // Create withdrawals + ids := util.MapSlice(input, func(p *payment.Payment) int64 { return p.ID }) + result, err := tc.Services.Processing.BatchCreateWithdrawals(ctx, ids) + + // ASSERT + tt.assert(t, input, result, err) + }) + } }) t.Run("Logic error", func(t *testing.T) { diff --git a/ui-dashboard/index.html b/ui-dashboard/index.html index c3d8054..f6a38f6 100644 --- a/ui-dashboard/index.html +++ b/ui-dashboard/index.html @@ -6,10 +6,10 @@ - + - O2Pay + OxygenPay
diff --git a/ui-dashboard/package-lock.json b/ui-dashboard/package-lock.json index c5a45b4..8f48d3b 100644 --- a/ui-dashboard/package-lock.json +++ b/ui-dashboard/package-lock.json @@ -18,7 +18,7 @@ "date-fns-tz": "^2.0.0", "json5": "^2.2.3", "lodash-es": "4.17.21", - "posthog-js": "1.57.2", + "posthog-js": "1.81.1", "react": "18.2.0", "react-dom": "18.2.0", "react-router-dom": "6.4.4", @@ -5024,11 +5024,11 @@ "license": "MIT" }, "node_modules/posthog-js": { - "version": "1.57.2", - "license": "MIT", + "version": "1.81.1", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.81.1.tgz", + "integrity": "sha512-pQfG9ZGVn3R7Uh1cC/S02trZ6u4TOLs1NhZG3WiNrqMKDA8MJQjZ/PqdkLO0/BeozRBfIbON6pw3xfOIneIclg==", "dependencies": { - "fflate": "^0.4.1", - "rrweb-snapshot": "^1.1.14" + "fflate": "^0.4.1" } }, "node_modules/prelude-ls": { @@ -5926,10 +5926,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/rrweb-snapshot": { - "version": "1.1.14", - "license": "MIT" - }, "node_modules/rtl-css-js": { "version": "1.16.0", "license": "MIT", @@ -9826,10 +9822,11 @@ "dev": true }, "posthog-js": { - "version": "1.57.2", + "version": "1.81.1", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.81.1.tgz", + "integrity": "sha512-pQfG9ZGVn3R7Uh1cC/S02trZ6u4TOLs1NhZG3WiNrqMKDA8MJQjZ/PqdkLO0/BeozRBfIbON6pw3xfOIneIclg==", "requires": { - "fflate": "^0.4.1", - "rrweb-snapshot": "^1.1.14" + "fflate": "^0.4.1" } }, "prelude-ls": { @@ -10354,9 +10351,6 @@ "fsevents": "~2.3.2" } }, - "rrweb-snapshot": { - "version": "1.1.14" - }, "rtl-css-js": { "version": "1.16.0", "requires": { diff --git a/ui-dashboard/package.json b/ui-dashboard/package.json index 2abc889..b903704 100644 --- a/ui-dashboard/package.json +++ b/ui-dashboard/package.json @@ -37,7 +37,7 @@ "date-fns-tz": "^2.0.0", "json5": "^2.2.3", "lodash-es": "4.17.21", - "posthog-js": "1.57.2", + "posthog-js": "1.81.1", "react": "18.2.0", "react-dom": "18.2.0", "react-router-dom": "6.4.4", diff --git a/ui-dashboard/public/fav/browserconfig.xml b/ui-dashboard/public/fav/browserconfig.xml deleted file mode 100644 index 99f4ca5..0000000 --- a/ui-dashboard/public/fav/browserconfig.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - #333333 - - - diff --git a/ui-dashboard/public/fav/mstile-150x150.png b/ui-dashboard/public/fav/mstile-150x150.png deleted file mode 100644 index 1dabe03..0000000 Binary files a/ui-dashboard/public/fav/mstile-150x150.png and /dev/null differ diff --git a/ui-dashboard/public/fav/site.webmanifest b/ui-dashboard/public/fav/site.webmanifest deleted file mode 100644 index 5619645..0000000 --- a/ui-dashboard/public/fav/site.webmanifest +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "", - "short_name": "", - "icons": [ - { - "src": "/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "/android-chrome-512x512.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "theme_color": "#333333", - "background_color": "#333333", - "display": "standalone" -} diff --git a/ui-dashboard/public/site.webmanifest b/ui-dashboard/public/site.webmanifest new file mode 100644 index 0000000..246e073 --- /dev/null +++ b/ui-dashboard/public/site.webmanifest @@ -0,0 +1,19 @@ +{ + "name": "OxygenPay", + "short_name": "OxygenPay", + "icons": [ + { + "src": "/fav/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/fav/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#50AF95", + "background_color": "#50AF95", + "display": "standalone" +} diff --git a/ui-dashboard/src/app.tsx b/ui-dashboard/src/app.tsx index 6bb4079..e443c95 100644 --- a/ui-dashboard/src/app.tsx +++ b/ui-dashboard/src/app.tsx @@ -109,10 +109,6 @@ const App: React.FC = () => { await authProvider.getCookie(); } catch (e) { if (e instanceof AxiosError && e.response?.status === 401) { - if (isPosthogActive) { - posthog?.reset(true); - } - navigate("/login", { state: { isNeedLogout: true @@ -128,10 +124,6 @@ const App: React.FC = () => { setUser(user); } catch (e) { if (e instanceof AxiosError && e.response?.status === 401) { - if (isPosthogActive) { - posthog?.reset(true); - } - navigate("/login", { state: { isNeedLogout: true @@ -180,7 +172,6 @@ const App: React.FC = () => { React.useEffect(() => { if (user && isPosthogActive) { - posthog?.reset(true); posthog?.identify(user.email, { email: user.email, uuid: user.uuid diff --git a/ui-payment/index.html b/ui-payment/index.html index 49da74a..d0f54bf 100644 --- a/ui-payment/index.html +++ b/ui-payment/index.html @@ -6,7 +6,7 @@ - + OxygenPay diff --git a/ui-payment/package-lock.json b/ui-payment/package-lock.json index 81ef743..7701ebc 100644 --- a/ui-payment/package-lock.json +++ b/ui-payment/package-lock.json @@ -11,7 +11,7 @@ "@vitejs/plugin-basic-ssl": "^1.0.1", "axios": "^1.1.3", "formik": "^2.2.9", - "posthog-js": "^1.57.2", + "posthog-js": "1.81.1", "qrcode.react": "^3.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -4872,12 +4872,11 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, "node_modules/posthog-js": { - "version": "1.57.2", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.57.2.tgz", - "integrity": "sha512-ER4gkYZasrd2Zwmt/yLeZ5G/nZJ6tpaYBCpx3CvocDx+3F16WdawJlYMT0IyLKHXDniC5+AsjzFd6fi8uyYlJA==", + "version": "1.81.1", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.81.1.tgz", + "integrity": "sha512-pQfG9ZGVn3R7Uh1cC/S02trZ6u4TOLs1NhZG3WiNrqMKDA8MJQjZ/PqdkLO0/BeozRBfIbON6pw3xfOIneIclg==", "dependencies": { - "fflate": "^0.4.1", - "rrweb-snapshot": "^1.1.14" + "fflate": "^0.4.1" } }, "node_modules/prelude-ls": { @@ -5268,11 +5267,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/rrweb-snapshot": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-1.1.14.tgz", - "integrity": "sha512-eP5pirNjP5+GewQfcOQY4uBiDnpqxNRc65yKPW0eSoU1XamDfc4M8oqpXGMyUyvLyxFDB0q0+DChuxxiU2FXBQ==" - }, "node_modules/rtl-css-js": { "version": "1.16.0", "resolved": "https://registry.npmjs.org/rtl-css-js/-/rtl-css-js-1.16.0.tgz", @@ -9438,12 +9432,11 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, "posthog-js": { - "version": "1.57.2", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.57.2.tgz", - "integrity": "sha512-ER4gkYZasrd2Zwmt/yLeZ5G/nZJ6tpaYBCpx3CvocDx+3F16WdawJlYMT0IyLKHXDniC5+AsjzFd6fi8uyYlJA==", + "version": "1.81.1", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.81.1.tgz", + "integrity": "sha512-pQfG9ZGVn3R7Uh1cC/S02trZ6u4TOLs1NhZG3WiNrqMKDA8MJQjZ/PqdkLO0/BeozRBfIbON6pw3xfOIneIclg==", "requires": { - "fflate": "^0.4.1", - "rrweb-snapshot": "^1.1.14" + "fflate": "^0.4.1" } }, "prelude-ls": { @@ -9711,11 +9704,6 @@ "fsevents": "~2.3.2" } }, - "rrweb-snapshot": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-1.1.14.tgz", - "integrity": "sha512-eP5pirNjP5+GewQfcOQY4uBiDnpqxNRc65yKPW0eSoU1XamDfc4M8oqpXGMyUyvLyxFDB0q0+DChuxxiU2FXBQ==" - }, "rtl-css-js": { "version": "1.16.0", "resolved": "https://registry.npmjs.org/rtl-css-js/-/rtl-css-js-1.16.0.tgz", diff --git a/ui-payment/package.json b/ui-payment/package.json index f349d48..717c9e2 100644 --- a/ui-payment/package.json +++ b/ui-payment/package.json @@ -27,7 +27,7 @@ "@vitejs/plugin-basic-ssl": "^1.0.1", "axios": "^1.1.3", "formik": "^2.2.9", - "posthog-js": "^1.57.2", + "posthog-js": "1.81.1", "qrcode.react": "^3.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/ui-payment/public/fav/browserconfig.xml b/ui-payment/public/fav/browserconfig.xml deleted file mode 100644 index 99f4ca5..0000000 --- a/ui-payment/public/fav/browserconfig.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - #333333 - - - diff --git a/ui-payment/public/fav/mstile-150x150.png b/ui-payment/public/fav/mstile-150x150.png deleted file mode 100644 index 1dabe03..0000000 Binary files a/ui-payment/public/fav/mstile-150x150.png and /dev/null differ diff --git a/ui-payment/public/fav/site.webmanifest b/ui-payment/public/fav/site.webmanifest deleted file mode 100644 index 5619645..0000000 --- a/ui-payment/public/fav/site.webmanifest +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "", - "short_name": "", - "icons": [ - { - "src": "/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "/android-chrome-512x512.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "theme_color": "#333333", - "background_color": "#333333", - "display": "standalone" -} diff --git a/ui-payment/public/site.webmanifest b/ui-payment/public/site.webmanifest new file mode 100644 index 0000000..246e073 --- /dev/null +++ b/ui-payment/public/site.webmanifest @@ -0,0 +1,19 @@ +{ + "name": "OxygenPay", + "short_name": "OxygenPay", + "icons": [ + { + "src": "/fav/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/fav/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#50AF95", + "background_color": "#50AF95", + "display": "standalone" +}