Skip to content

Commit

Permalink
feat: enable explicitMode and add visibility modifiers to all exposed…
Browse files Browse the repository at this point in the history
… methods/fields
  • Loading branch information
wzieba committed Dec 13, 2023
1 parent cad7ca2 commit 568b3ee
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
5 changes: 5 additions & 0 deletions parsely/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
Expand Down Expand Up @@ -57,6 +58,10 @@ android {
}
}
}

kotlin {
explicitApi(ExplicitApiMode.Warning)
}
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions parsely/src/main/java/com/parsely/parselyandroid/Clock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util.TimeZone
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

open class Clock {
open val now: Duration
internal open class Clock {
internal open val now: Duration
get() = Calendar.getInstance(TimeZone.getTimeZone("UTC")).timeInMillis.milliseconds
}
51 changes: 25 additions & 26 deletions parsely/src/main/java/com/parsely/parselyandroid/ParselyTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.util.UUID
* Accessed as a singleton. Maintains a queue of pageview events in memory and periodically
* flushes the queue to the Parse.ly pixel proxy server.
*/
open class ParselyTracker protected constructor(siteId: String, flushInterval: Int, c: Context) {
public open class ParselyTracker protected constructor(siteId: String, flushInterval: Int, c: Context) {
private var isDebug: Boolean
private val flushManager: FlushManager
private var engagementManager: EngagementManager? = null
Expand All @@ -57,7 +57,6 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
flushManager = ParselyFlushManager(
{
flushEvents()
Unit
}, flushInterval * 1000L,
sdkScope
)
Expand Down Expand Up @@ -93,18 +92,18 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
*
* @return The base engagement tracking interval.
*/
val engagementInterval: Double?
public val engagementInterval: Double?
get() = engagementManager?.intervalMillis

val videoEngagementInterval: Double?
public val videoEngagementInterval: Double?
get() = videoEngagementManager?.intervalMillis

/**
* Returns whether the engagement tracker is running.
*
* @return Whether the engagement tracker is running.
*/
fun engagementIsActive(): Boolean {
public fun engagementIsActive(): Boolean {
return engagementManager != null && engagementManager!!.isRunning
}

Expand All @@ -113,7 +112,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
*
* @return Whether video tracking is active.
*/
fun videoIsActive(): Boolean {
public fun videoIsActive(): Boolean {
return videoEngagementManager != null && videoEngagementManager!!.isRunning
}

Expand All @@ -122,7 +121,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
*
* @return The interval at which the event queue is flushed to Parse.ly.
*/
val flushInterval: Long
public val flushInterval: Long
get() = flushManager.intervalMillis / 1000

/**
Expand All @@ -134,7 +133,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
*
* @param debug Value to use for debug flag.
*/
fun setDebug(debug: Boolean) {
public fun setDebug(debug: Boolean) {
isDebug = debug
log("Debugging is now set to $isDebug")
}
Expand All @@ -151,15 +150,15 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* would normally crawl.
* @param extraData A Map of additional information to send with the event.
*/
fun trackPageview(
public fun trackPageview(
url: String,
urlRef: String? = null,
urlMetadata: ParselyMetadata? = null,
extraData: Map<String?, Any?>? = null,
) {
if (url.isBlank()) {
log("url cannot be empty");
return;
log("url cannot be empty")
return
}

lastPageviewUuid = generatePixelId()
Expand Down Expand Up @@ -187,14 +186,14 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* @param urlRef Referrer URL associated with this video view.
*/
@JvmOverloads
fun startEngagement(
public fun startEngagement(
url: String,
urlRef: String? = null,
extraData: Map<String?, Any?>? = null
) {
if (url.isBlank()) {
log("url cannot be empty");
return;
log("url cannot be empty")
return
}

// Cancel anything running
Expand Down Expand Up @@ -223,7 +222,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* like `onPause` or `onStop`. Otherwise, engaged time tracking may keep running in the background
* and Parse.ly values may be inaccurate.
*/
fun stopEngagement() {
public fun stopEngagement() {
if (engagementManager == null) {
return
}
Expand Down Expand Up @@ -254,15 +253,15 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* @param extraData A Map of additional information to send with the event.
</CUSTOMERDOMAIN></CUSTOMERDOMAIN> */
@JvmOverloads
fun trackPlay(
public fun trackPlay(
url: String,
urlRef: String? = null,
videoMetadata: ParselyVideoMetadata,
extraData: Map<String?, Any?>? = null,
) {
if (url.isBlank()) {
log("url cannot be empty");
return;
log("url cannot be empty")
return
}

// If there is already an engagement manager for this video make sure it is started.
Expand Down Expand Up @@ -314,7 +313,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* like `onPause` or `onStop`. Otherwise, engaged time tracking may keep running in the background
* and Parse.ly values may be inaccurate.
*/
fun trackPause() {
public fun trackPause() {
if (videoEngagementManager == null) {
return
}
Expand All @@ -334,7 +333,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* like `onPause` or `onStop`. Otherwise, engaged time tracking may keep running in the background
* and Parse.ly values may be inaccurate.
*/
fun resetVideo() {
public fun resetVideo() {
if (videoEngagementManager == null) {
return
}
Expand Down Expand Up @@ -362,7 +361,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
* Any usage of this method is safe to remove and will have no effect. Keeping for backwards compatibility.
*/
@Deprecated("The SDK now automatically flushes the queue on app lifecycle events. Any usage of this method is safe to remove and will have no effect")
fun flushEventQueue() {
public fun flushEventQueue() {
// no-op
}

Expand All @@ -383,7 +382,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
*
* @return Whether the event queue flush timer is running.
*/
fun flushTimerIsActive(): Boolean {
public fun flushTimerIsActive(): Boolean {
return flushManager.isRunning
}

Expand All @@ -395,19 +394,19 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
flushQueue.invoke(isDebug)
}

companion object {
public companion object {
private var instance: ParselyTracker? = null
private const val DEFAULT_FLUSH_INTERVAL_SECS = 60
private const val DEFAULT_ENGAGEMENT_INTERVAL_MILLIS = 10500
@JvmField val ROOT_URL = "https://p1.parsely.com/".intern()
@JvmField public val ROOT_URL: String = "https://p1.parsely.com/".intern()

/**
* Singleton instance accessor. Note: This must be called after [.sharedInstance]
*
* @return The singleton instance
*/
@JvmStatic
fun sharedInstance(): ParselyTracker? {
public fun sharedInstance(): ParselyTracker? {
return instance
}

Expand All @@ -421,7 +420,7 @@ open class ParselyTracker protected constructor(siteId: String, flushInterval: I
*/
@JvmStatic
@JvmOverloads
fun sharedInstance(
public fun sharedInstance(
siteId: String,
flushInterval: Int = DEFAULT_FLUSH_INTERVAL_SECS,
context: Context
Expand Down

0 comments on commit 568b3ee

Please sign in to comment.