Skip to main content
Version: SDK 5.0.x

Class JustTrackSdkBuilder

Use this class to build your instance of the SDK.

public final class JustTrackSdkBuilder
extends Object
implements SdkBuilder
Inheritance

java.lang.Object ← io.justtrack.JustTrackSdkBuilder

All Implemented Interfaces

SdkBuilder

Constructors

JustTrackSdkBuilder

public JustTrackSdkBuilder(@NonNull android.app.Application application, @Nullable android.content.Intent intent, @NonNull String apiToken)

Initialize a new builder with all required parameters.

Parameters

NameDescription
applicationA reference to your Application (or something extending it).
intentThe intent the app was launched on. Should be the result of Activity.getIntent().
apiTokenThe API token provided for your client.

JustTrackSdkBuilder

public JustTrackSdkBuilder(@NonNull android.app.Application application, @NonNull String apiToken)

Initialize a new builder from your application. If possible, use JustTrackSdkBuilder(Activity, String) instead.

Parameters

NameDescription
applicationA reference to your Application (or something extending it).
apiTokenThe API token provided for your client.

JustTrackSdkBuilder

public JustTrackSdkBuilder(@NonNull android.app.Activity currentActivity, @NonNull String apiToken)

Initialize a new builder from the current activity.

Parameters

NameDescription
currentActivityThe current active activity.
apiTokenThe API token provided for your client.

Methods

build

@NonNull
public JustTrackSdk build()

Description copied from interface: SdkBuilder

Build a new instance of the SDK. You should not use the builder after calling this method.

Returns

A fresh instance of the SDK.

Specified by

build in interface SdkBuilder

runCallbacksSerially

public SdkBuilder runCallbacksSerially()

Configures all callbacks performed by the SDK to be executed serially. We use this method from Unity to schedule the callbacks to happen in a serialized manner, ensuring they occur one after the other instead of concurrently from different threads.

This serialization is implemented to address a crash observed with Unity when calling many callbacks from Java to C# from different threads. By serializing all callbacks, they are guaranteed to occur one at a time. However, it's essential to keep these callbacks short on the C# side to prevent blocking the execution on the main thread (though we already introduce a short delay for callbacks to the game, making this approach acceptable).

setAttributionRetryDelaySeconds

@NonNull
public SdkBuilder setAttributionRetryDelaySeconds(long attributionRetryDelaySeconds)

Description copied from interface: SdkBuilder

Specify the number of seconds the SDK waits between tries to get an attribution after a network failure.

Parameters

NameDescription
attributionRetryDelaySecondsThe number of seconds until another try is made to fetch an attribution.

Returns

The builder so you can chain methods if you want.

Specified by

setAttributionRetryDelaySeconds in interface SdkBuilder

setAutomaticInAppPurchaseTracking

@NonNull
public SdkBuilder setAutomaticInAppPurchaseTracking(boolean enabled)

Description copied from interface: SdkBuilder

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

NameDescription
enabledSet this to true to automatically forward in-app product and subscription purchases.

Returns

The builder so you can chain methods if you want.

Specified by

setAutomaticInAppPurchaseTracking in interface SdkBuilder

setEnableBroadcastReceiver

@NonNull
public SdkBuilder setEnableBroadcastReceiver(boolean enabled)

Description copied from interface: SdkBuilder

Configure whether the SDK registers a BroadcastReceiver to integrate with other justtrack libraries. This is enabled by default, but you can disable it if you know that registering such a receiver is not allowed (e.g., because your app is currently in the background).

If a BroadcastReceiver can not be registered by the SDK, an error will be logged and the integration with other justtrack libraries is slightly degraded.

Parameters

NameDescription
enabledTrue if the SDK should try to register a BroadcastReceiver.

Returns

The builder so you can chain methods if you want.

Specified by

setEnableBroadcastReceiver in interface SdkBuilder

setEnableFirebaseIntegration

@NonNull
public SdkBuilder setEnableFirebaseIntegration(boolean enableFirebaseIntegration)

Description copied from interface: SdkBuilder

Specify whether we should automatically integrate with the Firebase SDK and send the Firebase app instance id of the user to the justtrack backend.

The integration is enabled by default if the Firebase SDK was detected in your app. You can however use this method to override the default behavior (although forcing the integration has a huge chance of not working, if we can't find the Firebase SDK, we will most likely not be able to talk to it, either).

You can disable the Firebase integration if you are already sending the Firebase app instance id to the justtrack SDK by hand (see SdkBuilder.setFirebaseAppInstanceId(String) or JustTrackSdk.setFirebaseAppInstanceId(String)).

Parameters

NameDescription
enableFirebaseIntegrationWhether we should send the Firebase app instance id

Returns

The builder so you can chain methods if you want.

Specified by

setEnableFirebaseIntegration in interface SdkBuilder

setEnableIronSourceIntegration

@NonNull
public SdkBuilder setEnableIronSourceIntegration(boolean enabled, @NonNull UserIdSource userIdSource)

Description copied from interface: SdkBuilder

Configure whether the SDK should integrate with IronSource and configure which user id it should forward to IronSource after you call SdkBuilder.build(). The SDK will also send an AppEvent for each ad to the backend.

This method overrides the setting from SdkBuilder.setEnableIronSourceIntegration(boolean, String).

By default the integration is disabled.

Parameters

NameDescription
enabledTrue if the SDK should integrate with IronSource.
userIdSourceConfigures whether we forward the justtrack user id or no user id at all.

Returns

The builder so you can chain methods if you want.

Specified by

setEnableIronSourceIntegration in interface SdkBuilder

setEnableIronSourceIntegration

@NonNull
public SdkBuilder setEnableIronSourceIntegration(boolean enabled, @NonNull String customUserId)

Description copied from interface: SdkBuilder

Configure whether the SDK should integrate with IronSource and provide the userId you specified after you call SdkBuilder.build(). The SDK will also send an AppEvent for each ad impression to the backend.

This method overrides the setting from SdkBuilder.setEnableIronSourceIntegration(boolean, UserIdSource).

By default the integration is disabled.

Parameters

NameDescription
enabledTrue if the SDK should integrate with IronSource.
customUserIdThe user id to forward to IronSource.

Returns

The builder so you can chain methods if you want.

Specified by

setEnableIronSourceIntegration in interface SdkBuilder

setFirebaseAppInstanceId

@NonNull
public SdkBuilder setFirebaseAppInstanceId(@NonNull String firebaseAppInstanceId) throws InvalidFieldException

Description copied from interface: SdkBuilder

Forward the Firebase app instance id (how to obtain one) to the justtrack backend upon SDK init.

You don't need to call this method if you rely on the automatic integration (see SdkBuilder.setEnableFirebaseIntegration(boolean)) or later publish the Firebase app instance id by hand (JustTrackSdk.setFirebaseAppInstanceId(String)).

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

NameDescription
firebaseAppInstanceIdThe id to forward.

Returns

The builder so you can chain methods if you want.

Specified by

setFirebaseAppInstanceId in interface SdkBuilder

Throws

NameDescription
InvalidFieldExceptionIf the Firebase app instance id was set to an invalid value.

setInactivityTimeFrame

@NonNull
public SdkBuilder setInactivityTimeFrame(long inactivityTimeFrameHours)

Description copied from interface: SdkBuilder

Specify the time frame after which a user is considered to be inactive. Default: 48h.

An inactive user did not open the app for this time frame and will check for a new attribution on the next app open. Thus, by default a user is inactive if they don't open the app at least every other day.

Parameters

NameDescription
inactivityTimeFrameHoursAfter how many hours will a user be inactive.

Returns

The builder so you can chain methods if you want.

Specified by

setInactivityTimeFrame in interface SdkBuilder

setInstallUncaughtExceptionHandler

@NonNull
public SdkBuilder setInstallUncaughtExceptionHandler(boolean installHandler)

Description copied from interface: SdkBuilder

Specify whether the justtrack SDK should install a handler for uncaught exceptions. The handler installed by the justtrack SDK will forward any uncaught exception to the previous default uncaught exception handler.

This is enabled by default. If you disable this, you can install the same handler manually by calling JustTrackSdk.installUncaughtExceptionHandler().

Parameters

NameDescription
installHandlerWhether we should install the justtrack uncaught exception handler.

Returns

The builder so you can chain methods if you want.

Specified by

setInstallUncaughtExceptionHandler in interface SdkBuilder

setLogger

@NonNull
public SdkBuilder setLogger(@NonNull Logger logger)

Description copied from interface: SdkBuilder

Set the logger the SDK will use. If you do not call this method, a default logger implementation will be used.

Parameters

NameDescription
loggerThe logger to use.

Returns

The builder so you can chain methods if you want.

Specified by

setLogger in interface SdkBuilder

setManualStart

public SdkBuilder setManualStart(boolean manualStart)

Description copied from interface: SdkBuilder

Dictates the nature of the start method call. If set to true then the start method will have to be called by app developers after justtrack SDK initialization. If set to false, which is the default value, then the start method will be automatically called by justtrack SDK after initialization.

Parameters

NameDescription
manualStartwhether the sdk should start manually or not

Returns

The builder so you can chain methods if you want.

Specified by

setManualStart in interface SdkBuilder

setPlatformType

@NonNull
public SdkBuilder setPlatformType(PlatformType platformType)

Description copied from interface: SdkBuilder

Specify which platform the SDK is running on. By default the platformType is set to Android.

Parameters

NameDescription
platformTypeANDROID, UNITY, REACT_NATIVE

Returns

The builder so you can chain methods if you want.

Specified by

setPlatformType in interface SdkBuilder

setReAttributionTimeFrame

@NonNull
public SdkBuilder setReAttributionTimeFrame(long reAttributionTimeFrameDays)

Description copied from interface: SdkBuilder

Specify the time frame after which a user is considered to be eligible for re-attribution. Default: 14 days.

A user eligible for re-attribution will fetch an attribution on the next app open. Thus, every active user will by default check every two weeks for a new attribution.

Parameters

NameDescription
reAttributionTimeFrameDaysAfter how many days will a user be eligible for re-attribution.

Returns

The builder so you can chain methods if you want.

Specified by

setReAttributionTimeFrame in interface SdkBuilder

setReFetchReAttributionDelaySeconds

@NonNull
public SdkBuilder setReFetchReAttributionDelaySeconds(long reFetchReAttributionDelaySeconds)

Description copied from interface: SdkBuilder

Specify the number of seconds until the SDK fetches the attribution again after a re-attribution opportunity was detected.

Set to a negative number to deactivate fetching the attribution again.

Parameters

NameDescription
reFetchReAttributionDelaySecondsThe number of seconds until the attribution is fetched a second time.

Returns

The builder so you can chain methods if you want.

Specified by

setReFetchReAttributionDelaySeconds in interface SdkBuilder

setTrackingId

@NonNull
public SdkBuilder setTrackingId(@Nullable String trackingId, @NonNull String trackingProvider) throws InvalidFieldException

Description copied from interface: SdkBuilder

Set the tracking id the SDK will send to the backend.

The tracking id and provider must be shorter than 4096 characters and consist only of printable ASCII characters (U+0020 to U+007E).

Parameters

NameDescription
trackingIdThe tracking id the SDK will send to the backend.
trackingProviderThe tracking provider which supplied the trackingId.

Returns

The builder so you can chain methods if you want.

Specified by

setTrackingId in interface SdkBuilder

Throws

NameDescription
InvalidFieldExceptionIf the tracking id or tracking provider were set to invalid values.

setUrlShortener

@NonNull
public SdkBuilder setUrlShortener(@NonNull UrlShortener urlShortener)

Description copied from interface: SdkBuilder

Set the URL shortener the SDK will use. If you do not call this method, a default implementation (which does not shorten URLs) will be used.

Parameters

NameDescription
urlShortenerThe UrlShortener to use.

Returns

The builder so you can chain methods if you want.

Specified by

setUrlShortener in interface SdkBuilder

setUserId

@NonNull
public SdkBuilder setUserId(@NonNull String userId) throws InvalidFieldException

Description copied from interface: SdkBuilder

Forward a user id to the justtrack backend upon SDK init.

The user id must be shorter than 4096 characters and consist only of printable ASCII characters (U+0020 to U+007E).

Parameters

NameDescription
userIdThe user id to forward.

Returns

The builder so you can chain methods if you want.

Specified by

setUserId in interface SdkBuilder

Throws

NameDescription
InvalidFieldExceptionIf the user id was set to an invalid value.