Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MyUNiDAYS/Segmenkt
Kotlin Multiplatform Wrapper for Segment
https://github.com/MyUNiDAYS/Segmenkt
Last synced: 6 days ago
JSON representation
Kotlin Multiplatform Wrapper for Segment
- Host: GitHub
- URL: https://github.com/MyUNiDAYS/Segmenkt
- Owner: MyUNiDAYS
- License: mit
- Created: 2022-11-25T08:56:19.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T16:34:33.000Z (about 2 months ago)
- Last Synced: 2024-09-10T20:05:23.219Z (about 2 months ago)
- Language: Kotlin
- Size: 181 KB
- Stars: 5
- Watchers: 13
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-kotlin-multiplatform - SegmenKT - A Segment wrapper for Kotlin Multiplatform. (Libraries / Utility)
README
SegmenKT Kotlin SDK
Segment + Kotlin = SegmenKT
The SegmenKT Kotlin SDK is a Kotlin-first SDK for Segment. Its API is similar to the Segment Android SDK but also supports multiplatform projects, enabling you to use Segment directly from your common source targeting iOS and Android.
## Installation
### KMM
```
implementation("com.myunidays:segmenkt:0.0.9")
```### Android
```
implementation("com.myunidays:segmenkt-android:0.0.9")
```### iOS
Run gradle task in this project
```
./gradlew assembleXCFramework
```Locate the framework in the following directory
```
build/XCFrameworks/
```
Add the xcframework file to your xcode project### JS
At the moment there is a JS target but it is currently filled with TODO's so it's not recommended to be used yet.
#### Important
In order for ios to work you will also need to include the segment framework to your ios project.
## How to use
Initialise segment with a config
### Kotlin
```
val segmentConfig = Configuration(
writeKey = WriteKey(
android = "123",
ios = "ABC",
js = "1"
),
context = context
)
Analytics.setupWithConfiguration(segmentConfig)
```No need to define a key for iOS if you are using just Android.
### Swift
```
let segmentConfig = Configuration(writeKey: WriteKey(android: nil, ios: "", js: nil), context: nil)
Analytics.Companion().setupWithConfiguration(configuration: segmentConfig)
```Then when you want to **Track**, **Identify**, **Group**, **Screen**
### Kotlin
```
Analytics.shared().track("Cool Event")
Analytics.shared().identify("1")
Analytics.shared().group("1")
Analytics.shared().screen("Cool Screen")
```### Swift
```
Analytics.Companion().shared(context: nil).track(name: "Cool Event", properties: nil)
Analytics.Companion().shared(context: nil).identify(userId: "1", traits: nil)
Analytics.Companion().shared(context: nil).group(groupId: "1", traits: nil)
Analytics.Companion().shared(context: nil).screen(screenTitle: "Cool Screen", properties: nil)
```## Contributing
This project is set up as an open source project. As such, if there are any suggestions that you have for features, for improving the code itself, or you have come across any problems; you can raise them and/or suggest changes in implementation.
If you are interested in contributing to this codebase, please follow the contributing guidelines. This contains guides on both contributing directly and raising feature requests or bug reports. Please adhere to our code of conduct when doing any of the above.