typewriter
typewriter copied to clipboard
Bug (?) and/or feature request: Violations are thrown for event properties not matching the case defined in the tracking plan
Hello Segment team!
We have a tracking plan where we define event properties using snake_case. When using the nice-property-names: true
option in typewriter.yml
, a property such as account_id
gets transformed to accountID
. This is fine, aside from the fact that when an event is called with that property name, it will always throw a violation because it doesn't match the snake case property. Not sure if this is a bug or not.
If it's not a bug, I'd like to suggest this feature:
Add a new option to the typewriter.yml
that allows for conversion of property names back to JSON. If you specify the option just-types: false
, then a nice Convert
class is generated in the output code. However, they can't be used in combination with the generated track functions because the types won't match up. If there was an option to convert back to JSON before the event is sent to Segment, then there wouldn't be violations in this case.
Hi @cjhensen
I confirmed this is happening and it is a bug. This one might be a tricky bug to fix as we the nice-property-names
options comes directly from the Quicktype library we use for generating the types in each language (same for the handy conversion functions).
I agree on your solution, the right way would be to convert the classes back to JSON and then then send those. The tricky part however will be to actually map these conversions to each type, we will have to delve for a while in Quicktype's internals to find the right way to do so.
Sorry for not having a better solution, but for now I think the best is to stick to the names as they are in defined in the the tracking plan to prevent issues. For now I'm going to have to turn off the nice-property-names
options while we work on a better solution.
Hi @oscb! Apologies for my delay in response here. I appreciate you confirming the bug. We are going to stick with the property names as defined in the tracking plan for the time being while this bug is open. Thanks!