Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provided locale object has invalid currency code. #19

Open
lukasz-szyszkowski opened this issue Nov 21, 2024 · 6 comments
Open

Provided locale object has invalid currency code. #19

lukasz-szyszkowski opened this issue Nov 21, 2024 · 6 comments

Comments

@lukasz-szyszkowski
Copy link

There is an issue with SDK. Since it's compile without any errors I have an exception in runtime that crashes an app.
It shouldn't happen.

I'm using ProductAddedToCartEvent and event.setDiscountedPrice(.init(amount: NSDecimalNumber(decimal: product.secondPriceDecimal ?? .zero).floatValue))

The question is how it is possible that locale currency code is invalid?

2024-11-21 09:47:01.295754+0100 Development AppName iOS App[22214:12169693] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Provided Locale object has invalid currency code. Please ensure that provided locale is valid Locale object'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018040c304 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018005131c objc_exception_throw + 56
	2   CoreFoundation                      0x000000018040c214 -[NSException initWithCoder:] + 0
	3   SyneriseSDK                         0x00000001049bfe0c SNR_StringToTokenOrigin + 8608
	4   SyneriseSDK                         0x00000001049bfd44 SNR_StringToTokenOrigin + 8408
	5   Development AppName iOS App.debug.dyl 0x00000001079be52c $sSo12SNRUnitPriceC6amountABSf_tcfcTO + 24
	6   Development AppName iOS App.debug.dyl 0x00000001079b7060 $sSo12SNRUnitPriceC6amountABSf_tcfC + 44
	7   Development AppName iOS App.debug.dyl 0x00000001079b71ec $s25Development_AppName_iOS_App14SyneriseHelperC14trackAddToCart7product8quantityyAA12WishlistItemV_SitF + 380
	8   Development AppName iOS App.debug.dyl 0x0000000107dc43c4 $s25Development_AppName_iOS_App17WishlistViewModelC17moveProductToCart4itemyAA0E4ItemV_tYaFTY0_ + 336
	9   Development AppName iOS App.debug.dyl 0x0000000107dc91b9 $s25Development_AppName_iOS_App17WishlistViewModelC10setBinding33_1C03DBE1CF7097757A420D3EFF62442DLLyyFyAA0E4ItemVSgcfU_ytSgyYacfU0_TQ1_ + 1
	10  Development AppName iOS App.debug.dyl 0x0000000107dcaa35 $s25Development_AppName_iOS_App17WishlistViewModelC10setBinding33_1C03DBE1CF7097757A420D3EFF62442DLLyyFyAA0E4ItemVSgcfU_ytSgyYacfU0_TATQ0_ + 1
	11  Development AppName iOS App.debug.dyl 0x000000010761765d $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ0_ + 1
	12  Development AppName iOS App.debug.dyl 0x00000001076177b9 $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_ + 1
	13  libswift_Concurrency.dylib          0x00000001ae384d0d _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1
)
libc++abi: terminating with uncaught exception of type NSException
@lukasz-szyszkowski
Copy link
Author

lukasz-szyszkowski commented Nov 21, 2024

It still happening even if I set locale manually to .init(identifier: "pl_PL")

What reason stands behind sending locale to Synerise? We have polish mCommerce app but it could be used on devices with any locale. So if I need to force specific locale this is not a good solution IMO.

@lukasz-szyszkowski
Copy link
Author

Unfortunately it happens on production now. We have a lot of app crashes :/

@awoczek
Copy link
Collaborator

awoczek commented Nov 25, 2024

Could you paste yor crashing code and stacktrace?

@lukasz-szyszkowski
Copy link
Author

CleanShot 2024-11-25 at 12 58 58
Cod in app:

func trackRemovedFromCart(product: CartModel.Product, quantity: Int) {
        guard isTrackingEventsEnabled else { return }
        
        let event = ProductRemovedFromCartEvent(
            label: "Customer removed product from cart",
            sku: product.sku,
            finalPrice: .init(amount: NSDecimalNumber(decimal: product.actualPrice).floatValue),
            quantity: quantity,
            params: params([:], excludedParams: [.source])
        )
        
        event.setOffline(false)
        event.setDiscountedPrice(.init(amount: NSDecimalNumber(decimal: product.actualPrice).floatValue))
        
        Tracker.send(event)
    }

@lukasz-szyszkowski
Copy link
Author

100% of cases from iOS 17.1.1

@awoczek
Copy link
Collaborator

awoczek commented Nov 25, 2024

Thank you, we take it with high priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants