Skip to content

Support Map<String, Any> for properties and traits. #168

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

Merged
merged 19 commits into from
Jun 15, 2023

Conversation

didiergarcia
Copy link
Contributor

No description provided.

@didiergarcia didiergarcia requested a review from wenxi-zeng June 1, 2023 17:45
@codecov-commenter
Copy link

codecov-commenter commented Jun 1, 2023

Codecov Report

Patch coverage has no change and project coverage change: -33.37 ⚠️

Comparison is base (f7fa676) 79.06% compared to head (4754b78) 45.69%.

Additional details and impacted files
@@              Coverage Diff              @@
##               main     #168       +/-   ##
=============================================
- Coverage     79.06%   45.69%   -33.37%     
+ Complexity      482       14      -468     
=============================================
  Files            75        8       -67     
  Lines          6061      860     -5201     
  Branches        741       81      -660     
=============================================
- Hits           4792      393     -4399     
+ Misses          684      437      -247     
+ Partials        585       30      -555     

see 67 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@didiergarcia didiergarcia marked this pull request as ready for review June 6, 2023 15:19
didiergarcia and others added 3 commits June 7, 2023 12:12
…ted inline <reified T: Any> functions that now known to send Map<*,*> to our new AnySerializer object.
@@ -24,13 +24,13 @@ test {
dependencies {
// MAIN DEPS
api 'com.segment:sovran-kotlin:1.2.2'
api "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
api "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the kotlin libs version. need to do the same for android gradle

@@ -170,15 +171,14 @@ open class Analytics protected constructor(
* @param properties to describe the action. Needs to be [serializable](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md)
* @see <a href="https://segment.com/docs/spec/track/">Track Documentation</a>
*/
inline fun <reified T : Any> track(
inline fun <reified T> track(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed Any. this was what causes Any serializer not found

} else {
track(name, properties, Json.serializersModule.serializer())
}
val format = Json { serializersModule = SerializersModule {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to move format to utilities. we gonna need it for the other calls

@OptIn(InternalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("My Any Serializer", SerialKind.CONTEXTUAL)
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = ContextualSerializer(Any::class, null, emptyArray()).descriptor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change doesn't matter. just nice to have, instead of init it arbitrary

/**
* A pre-configured Json Implementation with an Any type serializer.
*/
val JsonSerializer = Json { serializersModule = SerializersModule {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsonSerializer feels a bit too more generic. I was confused it with Json when I read the code. feel AnySerializer is a better name, even we kind randomly named it. Can we change it to something else that reflects its actual use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... name conflicts with the AnySerializer that does the actually work. I changed it to JsonAnySerializer.

@didiergarcia didiergarcia merged commit 07feb1d into main Jun 15, 2023
@didiergarcia didiergarcia deleted the support-maps-for-properties branch June 15, 2023 15:30
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

Successfully merging this pull request may close these issues.

3 participants