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

Int and Decimal event properties missing from events #496

Closed
initishbhatt opened this issue May 8, 2024 · 6 comments
Closed

Int and Decimal event properties missing from events #496

initishbhatt opened this issue May 8, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@initishbhatt
Copy link

Expected Behavior

The expected behavior is that all event properties, including integers and decimals such as amount and id, should be visible and available in the Amplitude dashboard for analysis. All properties should be correctly captured and displayed alongside other string properties like name and email.

Current Behavior

When observing events in the Amplitude dashboard, properties that are of type integer and decimal (e.g., amount, id) are missing. Other properties like name and email are visible and recorded as expected.

Possible Solution

Steps to Reproduce

  1. Open the application and navigate to the feature where the events are triggered.
  2. Perform an action that triggers the event, such as tapping a button which sends event properties including amount, id, name, and email.
  3. Review the event in the Amplitude dashboard.
  4. Observe that while string properties such as name and email are recorded and visible, integer and decimal properties like amount and id are missing from the event details in the dashboard.

Environment

  • SDK Version: 1.3.3
  • Device: iPhone 15Pro
  • OS Version: iOS 17.4
@initishbhatt initishbhatt added the bug Something isn't working label May 8, 2024
@crleona crleona self-assigned this May 8, 2024
@crleona
Copy link
Collaborator

crleona commented May 8, 2024

Hi @initishbhatt, I'm assuming you're using the Amplitude-Swift SDK based on the version number (Please let me know if this is not the case!), and I'm unable to reproduce the issue with standard ints/floats or ints/floats wrapped in an NSNumber. Is it possible that these properties are not enabled in your tracking plan? (In Amplitude, Data-> Tracking Plan, more details)

@initishbhatt
Copy link
Author

initishbhatt commented May 9, 2024

Hi @crleona yes we are using the Amplitude-Swift SDK and have recently migrated from the Objc SDK. The properties are enabled in the tracking plan as we use the same plan for both Android and iOS but the issue is reported only for iOS.
During debug i can see the event properties available but they are not seen on the dashboard.

print event.eventProperties
([String : Any?]?) 4 key/value pairs {
  [0] = {
    key = "screen_name"
    value = "test_screen"
  }
  [1] = {
    key = "id"
    value = some {
      _mantissa = (0 = 21992, 1 = 7, 2 = 0, 3 = 0, 4 = 0, 5 = 0, 6 = 0, 7 = 0)
    }
  }
  [2] = {
    key = "is_active"
    value = false
  }
  [3] = {
    key = "amount"
    value = some {
      _mantissa = (0 = 36, 1 = 0, 2 = 0, 3 = 0, 4 = 0, 5 = 0, 6 = 0, 7 = 0)
    }
  }
}

this is the debug print from the Amplitude SDK function where i can see the event properties id and amount but on the dashboard i can only see is_active and screen_name

  @discardableResult
    public func track(eventType: String, eventProperties: [String: Any]? = nil, options: EventOptions? = nil)
        -> Amplitude
    {
        let event = BaseEvent(eventType: eventType)
        event.eventProperties = eventProperties
        if let eventOptions = options {
            event.mergeEventOptions(eventOptions: eventOptions)
        }
        process(event: event)
        return self
    }

@initishbhatt
Copy link
Author

[Update]
i am able to see the values now by creating an extension on Decimal

extension Decimal {
    var doubleValue: Double {
        return NSDecimalNumber(decimal: self).doubleValue
    }
}

and using double value instead of decimal

let decimalValue = Decimal(1.487)
let doubleValue = decimalValue.doubleValue

seems like Decimal values are ignored in event properties, let us know if this is a bug or an expected behaviour

@crleona
Copy link
Collaborator

crleona commented May 9, 2024

The Decimal type is not supported. Please convert it to a standard numeric value type like Float or Double, as you've described in your update.

Can I ask for your use case for the additional precision of Decimal over the standard types? It's unlikely that we'd be able to represent this internally at full precision even if we were to add support.

@initishbhatt
Copy link
Author

Thanks, To be honest like so many aspects of programming, the short answer is: it depends

i would say it was a design decision from the previous devs as the app has multiple currencies and values to deal with and Decimal makes precision easier. it only came into notice when values were missing from Amplitude.

none the less it makes a good case for us to discuss if we can adopt a Double instead of Decimal.

@crleona
Copy link
Collaborator

crleona commented May 10, 2024

Ah ok, I can see where that makes sense for currency. Still, I'd prefer to make the loss in precision a bit more explicit and handle the downcast before calling into Amplitude. But, please reopen this issue if casting to double doesn't work for you. Thanks!

@crleona crleona closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants