-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from MyUNiDAYS/initial
Initial
- Loading branch information
Showing
17 changed files
with
408 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = 'segmenkt' | ||
spec.version = '0.0.8' | ||
spec.homepage = 'Link to a Kotlin/Native module homepage' | ||
spec.source = { :http=> ''} | ||
spec.authors = '' | ||
spec.license = '' | ||
spec.summary = 'Some description for a Kotlin/Native module' | ||
spec.vendored_frameworks = 'build/cocoapods/framework/segmenkt.framework' | ||
spec.libraries = 'c++' | ||
spec.ios.deployment_target = '10.0' | ||
spec.dependency 'Analytics', '~> 4.1.6' | ||
|
||
spec.pod_target_xcconfig = { | ||
'KOTLIN_PROJECT_PATH' => ':', | ||
'PRODUCT_MODULE_NAME' => 'segmenkt', | ||
} | ||
|
||
spec.script_phases = [ | ||
{ | ||
:name => 'Build segmenkt', | ||
:execution_position => :before_compile, | ||
:shell_path => '/bin/sh', | ||
:script => <<-SCRIPT | ||
if [ "YES" = "$COCOAPODS_SKIP_KOTLIN_BUILD" ]; then | ||
echo "Skipping Gradle build task invocation due to COCOAPODS_SKIP_KOTLIN_BUILD environment variable set to \"YES\"" | ||
exit 0 | ||
fi | ||
set -ev | ||
REPO_ROOT="$PODS_TARGET_SRCROOT" | ||
"$REPO_ROOT/gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ | ||
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ | ||
-Pkotlin.native.cocoapods.archs="$ARCHS" \ | ||
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION" | ||
SCRIPT | ||
} | ||
] | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myunidays.library"/> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myunidays.segmenkt"> | ||
|
||
</manifest> |
107 changes: 107 additions & 0 deletions
107
library/src/androidMain/kotlin/com/myunidays/segmenkt/Analytics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.myunidays.segmenkt | ||
|
||
import android.content.Context | ||
import com.segment.analytics.Options | ||
import com.segment.analytics.Properties | ||
import com.segment.analytics.Traits | ||
import java.util.concurrent.TimeUnit | ||
|
||
actual class Analytics internal constructor(val android: com.segment.analytics.Analytics) { | ||
|
||
actual companion object { | ||
actual fun setupWithConfiguration(configuration: Configuration): Analytics { | ||
val analyticsConfig = com.segment.analytics.Analytics.Builder(configuration.application as Context, configuration.writeKey) | ||
.collectDeviceId(configuration.collectDeviceId) | ||
.experimentalUseNewLifecycleMethods(configuration.useLifecycleObserver) | ||
.flushInterval(configuration.flushInterval.toLong(), TimeUnit.SECONDS) | ||
.flushQueueSize(configuration.flushAt) | ||
.tag(if (configuration.tag.isNullOrBlank()) configuration.writeKey else configuration.tag + "-" + configuration.writeKey) | ||
if (configuration.trackDeepLinks) analyticsConfig.trackDeepLinks() | ||
if (configuration.trackApplicationLifecycleEvents) analyticsConfig.trackApplicationLifecycleEvents() | ||
configuration.apiHost?.let { analyticsConfig.defaultApiHost(it) } | ||
val analytics = analyticsConfig.build() | ||
com.segment.analytics.Analytics.setSingletonInstance(analytics) | ||
return Analytics(analytics) | ||
} | ||
actual fun shared(context: Any?): Analytics = | ||
Analytics(com.segment.analytics.Analytics.with(context as? Context)) | ||
} | ||
|
||
actual fun alias(userId: String, options: Map<Any?, *>?) = | ||
android.alias( | ||
userId, | ||
Options().apply { | ||
options?.forEach { property -> | ||
(property.key as? String)?.let { putContext(it, property.value) } | ||
} | ||
} | ||
) | ||
|
||
actual fun track(name: String, properties: Map<Any?, *>?, options: Map<Any?, *>?) = | ||
android.track( | ||
name, | ||
Properties().apply { | ||
properties?.forEach { property -> | ||
(property.key as? String)?.let { putValue(it, property.value) } | ||
} | ||
}, | ||
Options().apply { | ||
options?.forEach { property -> | ||
(property.key as? String)?.let { putContext(it, property.value) } | ||
} | ||
} | ||
) | ||
|
||
actual fun identify(userId: String, traits: Map<Any?, *>?, options: Map<Any?, *>?) = | ||
android.identify( | ||
userId, | ||
Traits().apply { | ||
traits?.forEach { trait -> | ||
(trait.key as? String)?.let { putValue(it, trait.value) } | ||
} | ||
}, | ||
Options().apply { | ||
options?.forEach { property -> | ||
(property.key as? String)?.let { putContext(it, property.value) } | ||
} | ||
} | ||
) | ||
|
||
actual fun screen( | ||
screenTitle: String, | ||
properties: Map<Any?, *>?, | ||
options: Map<Any?, *>? | ||
) = android.screen( | ||
null, | ||
screenTitle, | ||
Properties().apply { | ||
properties?.forEach { property -> | ||
(property.key as? String)?.let { putValue(it, property.value) } | ||
} | ||
}, | ||
Options().apply { | ||
options?.forEach { property -> | ||
(property.key as? String)?.let { putContext(it, property.value) } | ||
} | ||
} | ||
) | ||
|
||
actual fun group(groupId: String, traits: Map<Any?, *>?, options: Map<Any?, *>?) = | ||
android.group( | ||
groupId, | ||
Traits().apply { | ||
traits?.forEach { trait -> | ||
(trait.key as? String)?.let { putValue(it, trait.value) } | ||
} | ||
}, | ||
Options().apply { | ||
options?.forEach { property -> | ||
(property.key as? String)?.let { putContext(it, property.value) } | ||
} | ||
} | ||
) | ||
|
||
actual fun reset() { | ||
android.reset() | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
library/src/androidMain/kotlin/com/myunidays/segmenkt/Platform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.myunidays.segmenkt | ||
|
||
actual val platform = PlatformType.ANDROID |
17 changes: 17 additions & 0 deletions
17
library/src/commonMain/kotlin/com/myunidays/segmenkt/Analytics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.myunidays.segmenkt | ||
|
||
expect class Analytics { | ||
|
||
companion object { | ||
fun setupWithConfiguration(configuration: Configuration): Analytics | ||
fun shared(context: Any? = null): Analytics | ||
} | ||
|
||
fun track(name: String, properties: Map<Any?, *>? = null, options: Map<Any?, *>? = null) | ||
fun identify(userId: String, traits: Map<Any?, *>? = null, options: Map<Any?, *>? = null) | ||
fun alias(userId: String, options: Map<Any?, *>? = null) | ||
fun screen(screenTitle: String, properties: Map<Any?, *>? = null, options: Map<Any?, *>? = null) | ||
fun group(groupId: String, traits: Map<Any?, *>? = null, options: Map<Any?, *>? = null) | ||
|
||
fun reset() | ||
} |
Oops, something went wrong.