Skip to content

tapemetric/analytics-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Tapemetric Analytics — Android SDK

video analytics SDK for Android phones, tablets, and Android TV.

Requirements

  • Android API 21+ (Lollipop, 5.0+) — covers 99%+ of devices
  • Kotlin 1.9+ recommended; Java 17 also supported
  • AndroidX

Installation

Gradle (Maven Central)

In your app-level build.gradle:

dependencies {
    implementation 'com.tapemetric:analytics:1.0.0'
}

Or in build.gradle.kts:

dependencies {
    implementation("com.tapemetric:analytics:1.0.0")
}

Version catalog (libs.versions.toml)

[versions]
tapemetric = "1.0.0"

[libraries]
tapemetric-analytics = { module = "com.tapemetric:analytics", version.ref = "tapemetric" }

Permissions

Already declared in the SDK's manifest — you don't need to add anything to your app:

  • INTERNET — required to send events
  • ACCESS_NETWORK_STATE — used to delay flushes when offline

The SDK never requests location, contacts, or device identifiers.

Quick start

import com.tapemetric.analytics.Tapemetric
import com.tapemetric.analytics.TapemetricConfig
import com.tapemetric.analytics.TrackContent
import com.tapemetric.analytics.PlaybackState
import com.tapemetric.analytics.PlanType

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        // 1. Configure once at app start
        Tapemetric.configure(
            this,
            TapemetricConfig(apiKey = "tm_live_yourkey")
        )
    }
}

class PlayerActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 2. Identify after login
        Tapemetric.identify("user_123", plan = PlanType.SVOD)

        // 3. Track playback
        val content = TrackContent(
            contentId = "aashiqana_s04e12",
            contentType = "series",
            contentTitle = "Aashiqana"
        )
        Tapemetric.trackPlayStart(content, PlaybackState(positionSec = 0.0))
    }
}

ExoPlayer integration

val exoPlayer = ExoPlayer.Builder(this).build()

exoPlayer.addListener(object : Player.Listener {
    override fun onPlaybackStateChanged(state: Int) {
        val pos = exoPlayer.currentPosition / 1000.0
        val playback = PlaybackState(positionSec = pos)
        when (state) {
            Player.STATE_BUFFERING -> {
                // Buffer measured; report when it ends
            }
            Player.STATE_ENDED -> Tapemetric.trackComplete(playback)
        }
    }

    override fun onIsPlayingChanged(isPlaying: Boolean) {
        val pos = exoPlayer.currentPosition / 1000.0
        if (isPlaying) Tapemetric.trackResume(PlaybackState(positionSec = pos))
        else Tapemetric.trackPause(PlaybackState(positionSec = pos))
    }

    override fun onPlayerError(error: PlaybackException) {
        Tapemetric.trackError(
            code = error.errorCodeName,
            message = error.message ?: "unknown",
            fatal = true
        )
    }
})

Logout / reset

// On logout
Tapemetric.reset()

Java interop

All methods are annotated @JvmStatic, so from Java:

import com.tapemetric.analytics.Tapemetric;
import com.tapemetric.analytics.TapemetricConfig;
import com.tapemetric.analytics.TrackContent;
import com.tapemetric.analytics.PlaybackState;

Tapemetric.configure(this, new TapemetricConfig("tm_live_yourkey"));
Tapemetric.trackPlayStart(
    new TrackContent("aashiqana_s04e12", "series", "Aashiqana", null, null),
    new PlaybackState(0.0, null, null)
);

ProGuard / R8

The SDK ships its own consumer-rules.pro. No app-side rules required.

Documentation

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages