segmentio / typewriter

Type safety + intellisense for your Segment analytics
https://segment.com/docs/protocols/typewriter/
MIT License
228 stars 53 forks source link

[Kotlin] Missing "import" in segment.kt #315

Closed zkovar closed 8 months ago

zkovar commented 8 months ago

In the segment.kt file generated, there are two issues:

  1. The package is not the first line in the file (this is Android norm)
  2. The referenced Segment SDK is missing an import statement

Run npx typewriter

typewriter.yml

#Segment Typewriter Configuration (https://segment.com/docs/protocols/typewriter)
#Just run `npx typewriter@next` to re-generate a client with the latest versions of these events.

client:
  #You can find more documentation on configuring this client in the Segment docs
  #See: https://segment.com/docs/protocols/typewriter
  language: kotlin
  sdk: kotlin
  languageOptions:
    package: com.my.package
trackingPlans:
  #Tracking Plan: App Rewrite - Tracking Plan
  #https://api.segmentapis.com/tracking-plans/tp_****
  - id: tp_****
    path: com.my.package

ACTUAL Output file:

com.segment.analytics.kotlin.core.Analytics
// This client was automatically generated by Segment Typewriter. ** Do Not Edit **
// To update this file, run:
//   npx typewriter

package com.my.package

import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

...

EXPECTED Output file:

package com.my.package

// This client was automatically generated by Segment Typewriter. ** Do Not Edit **
// To update this file, run:
//   npx typewriter

import com.segment.analytics.kotlin.core.Analytics

import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

...
zkovar commented 8 months ago

Resolved in typewriter/9.2.0, thank you!