-
Notifications
You must be signed in to change notification settings - Fork 25
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
chore: java sdk based on the android core sdk #129
base: main
Are you sure you want to change the base?
Changes from all commits
5d5b280
7b484cd
156576b
1c4b085
c01ba87
c10cc3c
8c055ee
87f9554
14c1ffc
b45884a
8f3ac36
001fec6
7d757b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ public class PostHogFake : PostHogInterface { | |
properties: Map<String, Any>?, | ||
userProperties: Map<String, Any>?, | ||
userPropertiesSetOnce: Map<String, Any>?, | ||
groupProperties: Map<String, Any>?, | ||
groups: Map<String, Any>?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should have been |
||
) { | ||
this.event = event | ||
this.properties = properties | ||
|
@@ -42,24 +42,44 @@ public class PostHogFake : PostHogInterface { | |
override fun isFeatureEnabled( | ||
key: String, | ||
defaultValue: Boolean, | ||
distinctId: String?, | ||
groups: Map<String, Any>?, | ||
): Boolean { | ||
return false | ||
} | ||
|
||
override fun getFeatureFlag( | ||
key: String, | ||
defaultValue: Any?, | ||
distinctId: String?, | ||
groups: Map<String, Any>?, | ||
): Any? { | ||
return null | ||
} | ||
|
||
override fun getFeatureFlagPayload( | ||
key: String, | ||
defaultValue: Any?, | ||
distinctId: String?, | ||
groups: Map<String, Any>?, | ||
): Any? { | ||
return null | ||
} | ||
|
||
override fun getAllFeatureFlags( | ||
distinctId: String?, | ||
groups: Map<String, Any>?, | ||
): Map<String, Any>? { | ||
return null | ||
} | ||
|
||
override fun getAllFeatureFlagsAndPayloads( | ||
distinctId: String?, | ||
groups: Map<String, Any>?, | ||
): Pair<Map<String, Any>?, Map<String, Any?>?> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big fan of |
||
return Pair(null, null) | ||
} | ||
|
||
override fun flush() { | ||
} | ||
|
||
|
@@ -76,17 +96,22 @@ public class PostHogFake : PostHogInterface { | |
type: String, | ||
key: String, | ||
groupProperties: Map<String, Any>?, | ||
distinctId: String?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "is it worth it"... 🤔 it's a dev experience question I guess.... what does it mean for what I have to type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you call
I agree, I also prefer better dev UX but since both libs (core and Android) share the same interface, this is the issue we get hence my comment above. |
||
) { | ||
} | ||
|
||
override fun screen( | ||
screenTitle: String, | ||
properties: Map<String, Any>?, | ||
distinctId: String?, | ||
) { | ||
this.screenTitle = screenTitle | ||
} | ||
|
||
override fun alias(alias: String) { | ||
override fun alias( | ||
alias: String, | ||
distinctId: String?, | ||
) { | ||
} | ||
|
||
override fun isOptOut(): Boolean { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
group = "com.posthog" | ||
version = "1.0.0" | ||
|
||
dependencies { | ||
implementation(project(mapOf("path" to ":posthog"))) | ||
testImplementation(kotlin("test")) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions.postHogConfig() | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(PosthogBuildConfig.Build.JAVA_VERSION.majorVersion.toInt()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.posthog | ||
|
||
import java.lang.Thread.sleep | ||
|
||
public fun main() { | ||
val config = | ||
PostHogConfig("phc_pQ70jJhZKHRvDIL5ruOErnPy6xiAiWCqlL4ayELj4X8").apply { | ||
debug = true | ||
flushAt = 1 | ||
} | ||
PostHog.setup(config) | ||
|
||
PostHog.capture( | ||
event = "Hello World!", | ||
distinctId = "123", | ||
properties = mapOf("test" to true), | ||
userProperties = mapOf("name" to "my name"), | ||
userPropertiesSetOnce = mapOf("age" to 33), | ||
groups = mapOf("company" to "posthog"), | ||
) | ||
PostHog.isFeatureEnabled( | ||
"myFlag", | ||
defaultValue = false, | ||
distinctId = "123", | ||
groups = mapOf("company" to "posthog"), | ||
) | ||
|
||
PostHog.flush() | ||
// | ||
PostHog.close() | ||
|
||
while (Thread.activeCount() > 1) { | ||
println("threads still active") | ||
sleep(10000) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are the defaults for Android