-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7d6cc1
commit a83e4f0
Showing
17 changed files
with
186 additions
and
57 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
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
10 changes: 10 additions & 0 deletions
10
...posthog-android/src/main/java/com/posthog/android/internal/PostHogAndroidNetworkStatus.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,10 @@ | ||
package com.posthog.android.internal | ||
|
||
import android.content.Context | ||
import com.posthog.internal.PostHogNetworkStatus | ||
|
||
public class PostHogAndroidNetworkStatus(private val context: Context) : PostHogNetworkStatus { | ||
override fun isConnected(): Boolean { | ||
return context.isConnected() | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...osthog-android/src/main/java/com/posthog/android/internal/PostHogAppInstallIntegration.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,43 @@ | ||
package com.posthog.android.internal | ||
|
||
import android.content.Context | ||
import com.posthog.PostHog | ||
import com.posthog.PostHogConfig | ||
import com.posthog.PostHogIntegration | ||
|
||
internal class PostHogAppInstallIntegration(private val context: Context, private val config: PostHogConfig) : PostHogIntegration { | ||
override fun install() { | ||
getPackageInfo(context, config)?.let { packageInfo -> | ||
config.preferences?.let { preferences -> | ||
val versionName = packageInfo.versionName | ||
val versionCode = packageInfo.versionCodeCompat() | ||
|
||
val previousVersion = preferences.getValue("version") as? String | ||
var previousBuild = preferences.getValue("build") | ||
|
||
val event: String | ||
val props = mutableMapOf<String, Any>() | ||
if (previousBuild == null) { | ||
event = "Application Installed" | ||
} else { | ||
event = "Application Updated" | ||
previousVersion?.let { | ||
props["previous_version"] = it | ||
} | ||
// to keep compatibility | ||
if (previousBuild is Int) { | ||
previousBuild = previousBuild.toLong() | ||
} | ||
props["previous_build"] = previousBuild | ||
} | ||
props["version"] = versionName | ||
props["build"] = versionCode | ||
|
||
preferences.setValue("version", versionName) | ||
preferences.setValue("build", versionCode) | ||
|
||
PostHog.capture(event, properties = props) | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.