Skip to content
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

feat: add Java android example #24

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.amplitude.core.LoggerProvider
import com.amplitude.core.ServerZone
import com.amplitude.core.StorageProvider

class Configuration(
class Configuration @JvmOverloads constructor(
apiKey: String,
val context: Context,
flushQueueSize: Int = FLUSH_QUEUE_SIZE,
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/com/amplitude/core/Amplitude.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ open class Amplitude internal constructor(
* @param callback the optional event callback
* @return the Amplitude instance
*/
@JvmOverloads
fun track(event: BaseEvent, callback: EventCallBack? = null): Amplitude {
callback ?. let {
event.callback = it
Expand All @@ -100,6 +101,7 @@ open class Amplitude internal constructor(
* @param options optional event options
* @return the Amplitude instance
*/
@JvmOverloads
fun track(eventType: String, eventProperties: JSONObject? = null, options: EventOptions? = null): Amplitude {
val event = BaseEvent()
event.eventType = eventType
Expand All @@ -119,6 +121,7 @@ open class Amplitude internal constructor(
* @param options optional event options
* @return the Amplitude instance
*/
@JvmOverloads
fun identify(identify: Identify, options: EventOptions? = null): Amplitude {
val event = IdentifyEvent()
event.userProperties = identify.properties
Expand Down Expand Up @@ -160,6 +163,7 @@ open class Amplitude internal constructor(
* @param options optional event options
* @return the Amplitude instance
*/
@JvmOverloads
fun groupIdentify(groupType: String, groupName: String, identify: Identify, options: EventOptions? = null): Amplitude {
val event = GroupIdentifyEvent()
var group: JSONObject? = null
Expand All @@ -185,6 +189,7 @@ open class Amplitude internal constructor(
* @param options optional event options
* @return the Amplitude instance
*/
@JvmOverloads
fun setGroup(groupType: String, groupName: String, options: EventOptions? = null): Amplitude {
val identify = Identify().set(groupType, groupName)
identify(identify, options)
Expand All @@ -199,6 +204,7 @@ open class Amplitude internal constructor(
* @param options optional event options
* @return the Amplitude instance
*/
@JvmOverloads
fun setGroup(groupType: String, groupName: Array<String>, options: EventOptions? = null): Amplitude {
val identify = Identify().set(groupType, groupName)
identify(identify, options)
Expand All @@ -219,6 +225,7 @@ open class Amplitude internal constructor(
* @param options optional event options
* @return the Amplitude instance
*/
@JvmOverloads
fun revenue(revenue: Revenue, options: EventOptions? = null): Amplitude {
if (!revenue.isValid()) {
logger.warn("Invalid revenue object, missing required fields")
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/amplitude/core/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.amplitude.core.utilities.InMemoryStorageProvider

typealias EventCallBack = (BaseEvent, status: Int, message: String) -> Unit

open class Configuration(
open class Configuration @JvmOverloads constructor(
val apiKey: String,
val flushQueueSize: Int = FLUSH_QUEUE_SIZE,
val flushIntervalMillis: Int = FLUSH_INTERVAL_MILLIS,
Expand Down
Loading