Code Monkey home page Code Monkey logo

Comments (6)

xgouchet avatar xgouchet commented on July 17, 2024

Hi @igorwojda and thanks for opening this question,

this is working as intended, as mentioned in the EventMapper's javadoc.

We have a check in place to ensure the event mapper returns the same instance of the event it receives. This is to ensure that all the internal fields marked as non mutable are indeed preserved by the event mapper implementation. You don't need to make a copy as all the fields that are allowed to be modified are mutable in the event object.

from dd-sdk-android.

igorwojda avatar igorwojda commented on July 17, 2024

This is an unintuitive behaviour. Also silent fail makes this quite concerning.

Ideal solution would be not to use mutable fields, but you should at least consider throwing an exception.

from dd-sdk-android.

xgouchet avatar xgouchet commented on July 17, 2024

Also silent fail makes this quite concerning.

This behavior is not silent if you enable the SDK internal logs :

Datadog.setVerbosity(Log.VERBOSE)

Would print a warning log in the logcat saying:
"RumEventMapper: the returned mapped object was not the same instance as the original object. This event will be dropped: { …}"

Ideal solution would be not to use mutable fields

Again, because we need to ensure that only some specific fields would change via the mapper, we can't allow any copy. Doing that would mean making complex nested comparison between the original and updated event, which would degrade the performance of the host application.
Making the relevant fields mutable, as stated in the docs, let customers map the fields effortlessly by replacing the mutable fields.

but you should at least consider throwing an exception.

Our policy is to never throw exceptions in our SDK, as we don't want to inadvertently crash the host application on the end user's device.

from dd-sdk-android.

igorwojda avatar igorwojda commented on July 17, 2024

I got the idea behind, not failing the app, although this behaviour could be more strict in debug build by default (or at least there should be a way to enable strict verification as warning in LogCat is not enough to prevent incorrect config).

from dd-sdk-android.

igorwojda avatar igorwojda commented on July 17, 2024

@xgouchet So what is the correct way of adding these custom properties?

from dd-sdk-android.

xgouchet avatar xgouchet commented on July 17, 2024

You can add custom properties to events in a variety of ways, depending on which event type we're talking about. Using the event mapper to add custom properties is not reccomended as custom properties often relate to the state of the application, and the event mapper is called asynchronously, when the state of the app might have changed.

Our documentation highlights several ways this can be achieved, and if you have a specific use case in mind we'd be happy to help suggest a solution for it.

from dd-sdk-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.