Interface JustTrackSdk
An instance of this class represents your handle to the backend services to attribute a user and track events about the user. You should create exactly one instance during app startup and hold onto it the whole time your application runs.
public interface JustTrackSdk
Methods
anonymize
io.justtrack.AsyncFuture<Boolean> anonymize()
Instruct the justtrack backend to delete identifying information about the user.
Returns
A future which resolves as soon as the backend was notified.
createAffiliateLink
@Deprecated
@NonNull io.justtrack.AsyncFuture<String> createAffiliateLink(@Nullable String channel)
Deprecated.
Build an affiliate link and invoke your callback with a link a user can use to recruit new users.
You can provide a channel to include in the link. Should a user then get recruited via that link, you can see from where the link came from (if your app provides more than one opportunity to invite new users into your app).
The channel name must be shorter than 256 characters if provided and consist only of printable ASCII characters (U+0020 to U+007E).
Parameters
Name | Description |
---|---|
channel | If provided, the name of the channel for this link. |
Returns
A future which resolves to the affiliate link.
forwardAdImpression
boolean forwardAdImpression(@NonNull AdImpression adImpression)
Forward an ad impression to the justtrack backend. Depending on the ad SDK we will use this data to display the correct amount of ad revenue your app generated.
Parameters
Name | Description |
---|---|
adImpression | adImpression The ad impression data to be forwarded to the justtrack backend. |
Returns
true if the ad impression was forwarded to the justtrack backend. false if the ad impression contained invalid data.
Throws
getAdvertiserIdInfo
@NonNull
io.justtrack.AsyncFuture<AdvertiserIdInfo> getAdvertiserIdInfo()
Retrieve information about the advertiser id of the user. The returned future always resolves
to a non-null AdvertiserIdInfo
, but AdvertiserIdInfo.getAdvertiserId()
might
return null if we failed to retrieve the advertiser id of the user for some reason.
Returns
Information about the advertiser id of the user.
getAppVersionAtInstall
@NonNull
io.justtrack.AsyncFuture<io.justtrack.ApplicationVersion> getAppVersionAtInstall()
Retrieve the version of your app during install (during the first initialization of the SDK to be precise).
Returns
A future which resolves to the version of your app during app install.
getAttribution
@NonNull
io.justtrack.AsyncFuture<Attribution> getAttribution()
Send attribution information about the current user of your app to the backend and provide data about the origin of the user to your callback. You should call this method on startup to get your justtrack UUID for the user (internal identifier used by justtrack to uniquely identify a user of an app).
If you call this method on the second app launch again (and the user did not delete application data), the last response from the backend will be provided to you again. Thus, calling this method is idempotent.
If no attribution can be obtained (because the network is down), the call is automatically retried
as soon as network connectivity is restored. This will not carry over to the future returned from
the first call to this method (but subsequent calls will return a future for the current try).
You should use registerAttributionListener(AttributionListener)
to get notified as soon
as a valid attribution was obtained.
If the future fails, it throws an AttributionException
(wrapped in an ExecutionException
).
Returns
A future which resolves to the attribution of your user or throws an exception in case of an error.
getInstallInstanceId
@NonNull
io.justtrack.AsyncFuture<String> getInstallInstanceId()
Get the unique id of the current install of that user.
Returns
The install instance id for the current user.
getJusttrackUserId
@Deprecated
@NonNull io.justtrack.AsyncFuture<String> getJusttrackUserId()
Deprecated.
Retrieves the justtrack user id. It allows you to uniquely identify a user at least until the app is uninstalled.
Returns
A future which resolves to the justtrack user id.
getPreliminaryRetargetingParameters
@Nullable
PreliminaryRetargetingParameters getPreliminaryRetargetingParameters()
Retrieve the preliminary retargeting parameters extracted from the intent your app was started with.
Returns
The preliminary retargeting parameters (if any) or null.
getRetargetingParameters
@NonNull
io.justtrack.AsyncFuture<RetargetingParameters> getRetargetingParameters()
Retrieve the retargeting parameters your app was started with. These parameters are only available on the first start of the app after a retargeting click was performed.
Returns
A future which resolves to the retargeting parameters (if any) or null.
getSdkVersion
@NonNull
Version getSdkVersion()
Retrieve the current version of the SDK.
Returns
The current version of the SDK.
getTestGroupId
@NonNull
io.justtrack.AsyncFuture<Integer> getTestGroupId()
Retrieve the test group of the user. The test group is retrieved from the justtrack backend and resolves to null should the request fail. It doesn't change once some value (even null) has been returned for it.
In some cases, the backend can't compute a test group id. In that case, the returned value is also null.
Returns
The test group of the user or null.
installUncaughtExceptionHandler
void installUncaughtExceptionHandler()
Install the uncaught exception handler of the justtrack SDK as the default uncaught exception handler. If you already had a default uncaught exception handler set, this will wrap your handler and eventually call it was well.
integrateWithAdColony
void integrateWithAdColony()
Inject a listener into the AdColony framework and forward ad impressions automatically to the justtrack backend.
Throws
integrateWithAppLovin
io.justtrack.AsyncFuture<Void> integrateWithAppLovin(@NonNull AppLovinIntegrationType integrationType, @NonNull UserIdSource userIdSource)
Inject a listener into the AppLovin framework and forward ad impressions automatically to the justtrack backend.
You can only ever integrate with AppLovin OR AppLovin MAX, never both at the same time!
Parameters
Name | Description |
---|---|
integrationType | Determines how we integrate with the AppLovin SDK. |
userIdSource | The source of the user id we should forward. Only forwarded when using AppLovinIntegrationType.MaxIntegration . |
Returns
A future which resolves as soon as the integration with AppLovin is set up.
integrateWithAppLovin
void integrateWithAppLovin(@NonNull AppLovinIntegrationType integrationType, @NonNull String customUserId)
Inject a listener into the AppLovin framework and forward ad impressions automatically to the justtrack backend.
Parameters
Name | Description |
---|---|
integrationType | Determines how we integrate with the AppLovin SDK. |
customUserId | The user id to forward to AppLovin. |
Throws
integrateWithChartboost
void integrateWithChartboost()
Inject a listener into the Chartboost framework and forward ad impressions automatically to the justtrack backend.
Throws
integrateWithFirebase
@NonNull
io.justtrack.AsyncFuture<Void> integrateWithFirebase()
Retrieve the Firebase app instance id from the Firebase SDk and forward it to the justtrack backend
using setFirebaseAppInstanceId(String)
.
Returns
A future which resolves as soon as the backend was notified about the app instance id.
integrateWithIronSource
io.justtrack.AsyncFuture<Void> integrateWithIronSource(@NonNull UserIdSource userIdSource)
Optionally forward the justtrack userId to the IronSource SDK and add a listener to ad impressions
which publishes them as AppEvent
s.
Depending on the given UserIdSource
, we either forward the justtrack user id
or no id at all.
You don't need to call this method if you used JustTrackSdkConfig.Builder.withIronSourceIntegration(UserIdSource)
already. It is instead provided if you need to control the exact moment when the integration is
set up and need to know when it is ready.
Parameters
Name | Description |
---|---|
userIdSource | The source of the user id we should forward. |
Returns
A future which resolves as soon as the integration with IronSource is set up.
integrateWithIronSource
void integrateWithIronSource(@NonNull String customUserId)
Forward the given userId to the IronSource SDK and add a listener to ad impressions which
publishes them as AppEvent
s.
You don't need to call this method if you used JustTrackSdkConfig.Builder.withIronSourceIntegration(String)
already. It is instead provided if you need to control the exact moment when the integration is
set up and need to know when it is ready.
Parameters
Name | Description |
---|---|
customUserId | The user id to forward to IronSource. |
Throws
integrateWithUnityAds
void integrateWithUnityAds()
Inject a listener into the UnityAds framework and forward ad impressions automatically to the justtrack backend.
Throws
isRunning
boolean isRunning()
Check if the SDK was already started and hasn't been stopped yet.
Returns
A boolean whether the SDK is tracking or not.
onNewIntent
void onNewIntent(@Nullable android.content.Intent newIntent)
Notify the SDK about a new Intent
arriving at your Activity
.
This switches the SDK to await new Intents to always arrive via this method. If you implement
Activity.onNewIntent(Intent)
and call Activity.setIntent(Intent)
from there, you don't need to call this method.
Parameters
Name | Description |
---|---|
newIntent | The new Intent which brought your app to the foreground. |
publishEvent
@NonNull
io.justtrack.AsyncFuture<Void> publishEvent(@NonNull AppEvent event)
Publish an event the user caused to the backend. Events are send in batches to the backend and persisted to disk until they have successfully been sent.
Parameters
Name | Description |
---|---|
event | The event you want to publish. |
Returns
A future which resolves to an implementation defined value if your event was published or throws an exception if the event could not be published. If you don't care whether the event has already reached the backend you can just ignore the returned future.
registerAttributionListener
@NonNull
Subscription registerAttributionListener(@NonNull AttributionListener attributionListener)
Register a new attribution listener instance.
Parameters
Name | Description |
---|---|
attributionListener | An attribution listener. |
Returns
A subscription object to unregister the listener again.
registerDeepLinkListener
@NonNull
Subscription registerDeepLinkListener(@NonNull DeepLinkListener deepLinkListener)
Register a new deeplink listener instance.
Parameters
Name | Description |
---|---|
deepLinkListener | A deeplink listener. |
Returns
A subscription object to unregister the listener again.
registerPreliminaryRetargetingParametersListener
@NonNull
Subscription registerPreliminaryRetargetingParametersListener(@NonNull PreliminaryRetargetingParametersListener preliminaryRetargetingParametersListener)
Register a new preliminary retargeting parameters listener instance.
Parameters
Name | Description |
---|---|
preliminaryRetargetingParametersListener | A preliminary retargeting parameters listener. |
Returns
A subscription object to unregister the listener again.
registerRetargetingParametersListener
@NonNull
Subscription registerRetargetingParametersListener(@NonNull RetargetingParametersListener retargetingParametersListener)
Register a new retargeting parameters listener instance.
Parameters
Name | Description |
---|---|
retargetingParametersListener | A retargeting parameters listener. |
Returns
A subscription object to unregister the listener again.
setAutomaticInAppPurchaseTracking
void setAutomaticInAppPurchaseTracking(boolean enabled)
The justtrack SDK can automatically track in-app product and subscription purchases and forward them to the justtrack backend. It is enabled by default, but this method allows you to configure the automation for your needs.
Parameters
Name | Description |
---|---|
enabled | Set this to true to automatically forward in-app product and subscription purchases. |
setFirebaseAppInstanceId
@NonNull
io.justtrack.AsyncFuture<Boolean> setFirebaseAppInstanceId(@NonNull String firebaseAppInstanceId)
Forward the Firebase app instance id (see FirebaseAnalytics.getAppInstanceId() to how to obtain one) to the justtrack backend.
The Firebase app instance id must be between 8 and 256 characters and consist only of printable ASCII characters (U+0020 to U+007E).
Parameters
Name | Description |
---|---|
firebaseAppInstanceId | The id to forward. |
Returns
A future which resolves as soon as the backend was notified about the app instance id.
setUserId
@NonNull
io.justtrack.AsyncFuture<Boolean> setUserId(@NonNull String userId)
Forward a user id to the justtrack backend.
It is safe to call this method multiple times with the same user id. If the user id of the current user changes for some reason, you have to call this method as soon as possible (otherwise we will not be able to recognize the new custom user id until this method is called). You can call this method multiple times while the app is running.
The user id must be shorter than 4096 characters and consist only of printable ASCII characters (U+0020 to U+007E).
Parameters
Name | Description |
---|---|
userId | The user id to forward. |
Returns
A future which resolves as soon as the backend was notified about the user id.
shutdown
void shutdown()
Notify the SDK about your app being destroyed. Will unregister all observers setup during SDK initialization. Afterwards you need to initialize the SDK again. Thus, you always have to create a new instance of the SDK in your onCreate callback.
start
void start()
The SDK starts tracking the user only after the start method is called. User's unique IDs, install and app events will only be tracked after the method is used. Any event preceding the start call will not be reported by the SDK.
stop
void stop()
The SDK stops tracking the user entirely. No ID's or app events will be tracked or reported. Any app events collected before the stop method is called will still be reported.