-
- All Implemented Interfaces:
-
io.embrace.android.embracesdk.EmbraceAndroidApi,io.embrace.android.embracesdk.EmbraceApi,io.embrace.android.embracesdk.LogsApi,io.embrace.android.embracesdk.MomentsApi,io.embrace.android.embracesdk.NetworkRequestApi,io.embrace.android.embracesdk.SessionApi,io.embrace.android.embracesdk.UserApi,io.embrace.android.embracesdk.spans.TracingApi
public final class Embrace implements EmbraceAndroidApiEntry point for the SDK. This class is part of the Embrace Public API.
Contains a singleton instance of itself, and is used for initializing the SDK.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumEmbrace.AppFrameworkThe AppFramework that is in use.
public enumEmbrace.LastRunEndStateEnum representing the end state of the last run of the application.
-
Method Summary
Modifier and Type Method Description static EmbracegetInstance()Gets the singleton instance of the Embrace SDK. voidstart(@NonNull() Context context)Starts instrumentation of the Android application using the Embrace SDK. voidstart(@NonNull() Context context, boolean enableIntegrationTesting)Starts instrumentation of the Android application using the Embrace SDK. voidstart(@NonNull() Context context, boolean enableIntegrationTesting, @NonNull() Embrace.AppFramework appFramework)Starts instrumentation of the Android application using the Embrace SDK. booleanisStarted()Whether or not the SDK has been started. booleansetAppId(@NonNull() String appId)Sets a custom app ID that overrides the one specified at build time. voidsetUserIdentifier(@Nullable() String userId)voidclearUserIdentifier()voidsetUserEmail(@Nullable() String email)voidclearUserEmail()voidsetUserAsPayer()voidclearUserAsPayer()voidaddUserPersona(@NonNull() String persona)voidclearUserPersona(@NonNull() String persona)voidclearAllUserPersonas()booleanaddSessionProperty(@NonNull() String key, @NonNull() String value, boolean permanent)booleanremoveSessionProperty(@NonNull() String key)Map<String, String>getSessionProperties()voidsetUsername(@Nullable() String username)voidclearUsername()voidstartMoment(@NonNull() String name)Starts a 'moment'. voidstartMoment(@NonNull() String name, @Nullable() String identifier)Starts a 'moment'. voidstartMoment(@NonNull() String name, @Nullable() String identifier, @Nullable() Map<String, Object> properties)Starts a 'moment'. voidendMoment(@NonNull() String name)Signals the end of a moment with the specified name. voidendMoment(@NonNull() String name, @Nullable() String identifier)Signals the end of a moment with the specified name. voidendMoment(@NonNull() String name, @Nullable() Map<String, Object> properties)Signals the end of a moment with the specified name. voidendMoment(@NonNull() String name, @Nullable() String identifier, @Nullable() Map<String, Object> properties)Signals the end of a moment with the specified name. voidendAppStartup()Signals that the app has completed startup. voidendAppStartup(@NonNull() Map<String, Object> properties)Signals that the app has completed startup. StringgetTraceIdHeader()Retrieve the HTTP request header to extract trace ID from. StringgenerateW3cTraceparent()Randomly generate a W3C-compliant traceparent voidrecordNetworkRequest(@NonNull() EmbraceNetworkRequest networkRequest)voidlogInfo(@NonNull() String message)voidlogWarning(@NonNull() String message)voidlogError(@NonNull() String message)voidaddBreadcrumb(@NonNull() String message)Adds a breadcrumb. voidlogMessage(@NonNull() String message, @NonNull() Severity severity)voidlogMessage(@NonNull() String message, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties)voidlogException(@NonNull() Throwable throwable)voidlogException(@NonNull() Throwable throwable, @NonNull() Severity severity)voidlogException(@NonNull() Throwable throwable, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties)voidlogException(@NonNull() Throwable throwable, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties, @Nullable() String message)voidlogCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements)voidlogCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity)voidlogCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties)voidlogCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties, @Nullable() String message)synchronized voidendSession()synchronized voidendSession(boolean clearUserInfo)StringgetDeviceId()Get the user identifier assigned to the device by Embrace booleanstartView(@NonNull() String name)Records that a view 'started'. booleanendView(@NonNull() String name)Records that a view 'ended'. booleanisTracingAvailable()EmbraceSpancreateSpan(@NonNull() String name)EmbraceSpancreateSpan(@NonNull() String name, @Nullable() EmbraceSpan parent)EmbraceSpanstartSpan(@NonNull() String name)EmbraceSpanstartSpan(@NonNull() String name, @Nullable() EmbraceSpan parent)EmbraceSpanstartSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @Nullable() Long startTimeMs)<T> TrecordSpan(@NonNull() String name, @NonNull() Function0<out T> code)<T> TrecordSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @NonNull() Function0<out T> code)<T> TrecordSpan(@NonNull() String name, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events, @NonNull() Function0<out T> code)<T> TrecordSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events, @NonNull() Function0<out T> code)booleanrecordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode, @Nullable() EmbraceSpan parent, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events)booleanrecordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs)booleanrecordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode)booleanrecordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() EmbraceSpan parent)booleanrecordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode, @Nullable() EmbraceSpan parent)booleanrecordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events)EmbraceSpangetSpan(@NonNull() String spanId)voidaddSpanExporter(@NonNull() SpanExporter spanExporter)Adds a [SpanExporter] to the tracer. voidlogPushNotification(@Nullable() String title, @Nullable() String body, @Nullable() String topic, @Nullable() String id, @Nullable() Integer notificationPriority, @NonNull() Integer messageDeliveredPriority, @NonNull() Boolean isNotification, @NonNull() Boolean hasData)voidtrackWebViewPerformance(@NonNull() String tag, @NonNull() ConsoleMessage consoleMessage)Listen to performance-tracking JavaScript previously embedded in the website's code.The WebView being tracked must have JavaScript enabled. voidtrackWebViewPerformance(@NonNull() String tag, @NonNull() String message)Listen to performance-tracking JavaScript previously embedded in the website's code.The WebView being tracked must have JavaScript enabled. StringgetCurrentSessionId()Get the ID for the current session.Returns null if a session has not been started yet or the SDK hasn't been initialized. Embrace.LastRunEndStategetLastRunEndState()Get the end state of the last run of the application. EmbraceInternalInterfacegetInternalInterface()Get internal interface for the intra-Embrace, not-publicly-supported API ReactNativeInternalInterfacegetReactNativeInternalInterface()Gets the ReactNativeInternalInterface that should be used as the sole source ofcommunication with the Android SDK for React Native. UnityInternalInterfacegetUnityInternalInterface()FlutterInternalInterfacegetFlutterInternalInterface()Gets the FlutterInternalInterface that should be used as the sole source ofcommunication with the Android SDK for Flutter. -
Methods inherited from class io.embrace.android.embracesdk.EmbraceAndroidApi
start, start -
Methods inherited from class io.embrace.android.embracesdk.LogsApi
logCustomStacktrace, logError, logException, logInfo, logMessage, logPushNotification, logWarning -
Methods inherited from class io.embrace.android.embracesdk.MomentsApi
endMoment, endMoment, startMoment -
Methods inherited from class io.embrace.android.embracesdk.NetworkRequestApi
recordNetworkRequest -
Methods inherited from class io.embrace.android.embracesdk.SessionApi
addSessionProperty, endSession, getSessionProperties, removeSessionProperty -
Methods inherited from class io.embrace.android.embracesdk.UserApi
addUserPersona, clearAllUserPersonas, clearUserAsPayer, clearUserEmail, clearUserIdentifier, clearUserPersona, clearUsername, setUserAsPayer, setUserEmail, setUserIdentifier, setUsername -
Methods inherited from class io.embrace.android.embracesdk.spans.TracingApi
createSpan, getSpan, isTracingAvailable, recordCompletedSpan, recordSpan, startSpan -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getInstance
@NonNull() static Embrace getInstance()
Gets the singleton instance of the Embrace SDK.
-
start
void start(@NonNull() Context context)
Starts instrumentation of the Android application using the Embrace SDK. This should becalled during creation of the application, as early as possible.
See Embrace Docs forintegration instructions. For compatibility with other networking SDKs such as Akamai,the Embrace SDK must be initialized after any other SDK.
- Parameters:
context- an instance of the application context
-
start
void start(@NonNull() Context context, boolean enableIntegrationTesting)
Starts instrumentation of the Android application using the Embrace SDK. This should becalled during creation of the application, as early as possible.
See Embrace Docs forintegration instructions. For compatibility with other networking SDKs such as Akamai,the Embrace SDK must be initialized after any other SDK.
- Parameters:
context- an instance of contextenableIntegrationTesting- if true, debug sessions (those which are not part of arelease APK) will go to the live integration testing tabof the dashboard.
-
start
void start(@NonNull() Context context, boolean enableIntegrationTesting, @NonNull() Embrace.AppFramework appFramework)
Starts instrumentation of the Android application using the Embrace SDK. This should becalled during creation of the application, as early as possible.
See Embrace Docs forintegration instructions. For compatibility with other networking SDKs such as Akamai,the Embrace SDK must be initialized after any other SDK.
- Parameters:
context- an instance of contextenableIntegrationTesting- if true, debug sessions (those which are not part of arelease APK) will go to the live integration testing tabof the dashboard.
-
isStarted
boolean isStarted()
Whether or not the SDK has been started.
-
setAppId
boolean setAppId(@NonNull() String appId)
Sets a custom app ID that overrides the one specified at build time. Must be called beforethe SDK is started.
- Parameters:
appId- custom app ID
-
setUserIdentifier
void setUserIdentifier(@Nullable() String userId)
-
clearUserIdentifier
void clearUserIdentifier()
-
setUserEmail
void setUserEmail(@Nullable() String email)
-
clearUserEmail
void clearUserEmail()
-
setUserAsPayer
void setUserAsPayer()
-
clearUserAsPayer
void clearUserAsPayer()
-
addUserPersona
void addUserPersona(@NonNull() String persona)
-
clearUserPersona
void clearUserPersona(@NonNull() String persona)
-
clearAllUserPersonas
void clearAllUserPersonas()
-
addSessionProperty
boolean addSessionProperty(@NonNull() String key, @NonNull() String value, boolean permanent)
-
removeSessionProperty
boolean removeSessionProperty(@NonNull() String key)
-
getSessionProperties
@Nullable() Map<String, String> getSessionProperties()
-
setUsername
void setUsername(@Nullable() String username)
-
clearUsername
void clearUsername()
-
startMoment
void startMoment(@NonNull() String name)
Starts a 'moment'. Moments are used for encapsulating particular activities withinthe app, such as a user adding an item to their shopping cart.
The length of time a moment takes to execute is recorded.
- Parameters:
name- a name identifying the moment
-
startMoment
void startMoment(@NonNull() String name, @Nullable() String identifier)
Starts a 'moment'. Moments are used for encapsulating particular activities withinthe app, such as a user adding an item to their shopping cart.
The length of time a moment takes to execute is recorded.
- Parameters:
name- a name identifying the momentidentifier- an identifier distinguishing between multiple moments with the same name
-
startMoment
void startMoment(@NonNull() String name, @Nullable() String identifier, @Nullable() Map<String, Object> properties)
Starts a 'moment'. Moments are used for encapsulating particular activities withinthe app, such as a user adding an item to their shopping cart.
The length of time a moment takes to execute is recorded
- Parameters:
name- a name identifying the momentidentifier- an identifier distinguishing between multiple moments with the same nameproperties- custom key-value pairs to provide with the moment
-
endMoment
void endMoment(@NonNull() String name)
Signals the end of a moment with the specified name.
The duration of the moment is computed.
- Parameters:
name- the name of the moment to end
-
endMoment
void endMoment(@NonNull() String name, @Nullable() String identifier)
Signals the end of a moment with the specified name.
The duration of the moment is computed.
- Parameters:
name- the name of the moment to endidentifier- the identifier of the moment to end, distinguishing between moments with the same name
-
endMoment
void endMoment(@NonNull() String name, @Nullable() Map<String, Object> properties)
Signals the end of a moment with the specified name.
The duration of the moment is computed.
- Parameters:
name- the name of the moment to endproperties- custom key-value pairs to provide with the moment
-
endMoment
void endMoment(@NonNull() String name, @Nullable() String identifier, @Nullable() Map<String, Object> properties)
Signals the end of a moment with the specified name.
The duration of the moment is computed.
- Parameters:
name- the name of the moment to endidentifier- the identifier of the moment to end, distinguishing between moments with the same nameproperties- custom key-value pairs to provide with the moment
-
endAppStartup
void endAppStartup()
Signals that the app has completed startup.
-
endAppStartup
void endAppStartup(@NonNull() Map<String, Object> properties)
Signals that the app has completed startup.
- Parameters:
properties- properties to include as part of the startup moment
-
getTraceIdHeader
@NonNull() String getTraceIdHeader()
Retrieve the HTTP request header to extract trace ID from.
-
generateW3cTraceparent
@NonNull() String generateW3cTraceparent()
Randomly generate a W3C-compliant traceparent
-
recordNetworkRequest
void recordNetworkRequest(@NonNull() EmbraceNetworkRequest networkRequest)
-
logWarning
void logWarning(@NonNull() String message)
-
addBreadcrumb
void addBreadcrumb(@NonNull() String message)
Adds a breadcrumb.
Breadcrumbs track a user's journey through the application and will be shown on the timeline.
- Parameters:
message- the name of the breadcrumb to log
-
logMessage
void logMessage(@NonNull() String message, @NonNull() Severity severity)
-
logMessage
void logMessage(@NonNull() String message, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties)
-
logException
void logException(@NonNull() Throwable throwable)
-
logException
void logException(@NonNull() Throwable throwable, @NonNull() Severity severity)
-
logException
void logException(@NonNull() Throwable throwable, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties)
-
logException
void logException(@NonNull() Throwable throwable, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties, @Nullable() String message)
-
logCustomStacktrace
void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements)
-
logCustomStacktrace
void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity)
-
logCustomStacktrace
void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties)
-
logCustomStacktrace
void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity, @Nullable() Map<String, out Object> properties, @Nullable() String message)
-
endSession
synchronized void endSession()
-
endSession
synchronized void endSession(boolean clearUserInfo)
-
getDeviceId
@NonNull() String getDeviceId()
Get the user identifier assigned to the device by Embrace
-
startView
boolean startView(@NonNull() String name)
Records that a view 'started'. You should call this when your app starts displaying anactivity, a fragment, a screen, or any custom UI element, and you want to capture abreadcrumb that this happens.
A matching call to endView must be made when the view is no longerdisplayed.
A maximum of 100 breadcrumbs will be recorded per session, with a maximum length of 256characters per view name.
- Parameters:
name- the name of the view to log
-
endView
boolean endView(@NonNull() String name)
Records that a view 'ended'. You should call this when your app stops displaying anactivity, a fragment, a screen, or any custom UI element, and you want to capture abreadcrumb that this happens.
A matching call to startView must be made when the view is firstdisplayed, or no breadcrumb will be logged.
A maximum of 100 breadcrumbs will be recorded per session, with a maximum length of 256characters per view name.
- Parameters:
name- the name of the view to log
-
isTracingAvailable
boolean isTracingAvailable()
-
createSpan
@Nullable() EmbraceSpan createSpan(@NonNull() String name)
-
createSpan
@Nullable() EmbraceSpan createSpan(@NonNull() String name, @Nullable() EmbraceSpan parent)
-
startSpan
@Nullable() EmbraceSpan startSpan(@NonNull() String name)
-
startSpan
@Nullable() EmbraceSpan startSpan(@NonNull() String name, @Nullable() EmbraceSpan parent)
-
startSpan
@Nullable() EmbraceSpan startSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @Nullable() Long startTimeMs)
-
recordSpan
<T> T recordSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @NonNull() Function0<out T> code)
-
recordSpan
<T> T recordSpan(@NonNull() String name, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events, @NonNull() Function0<out T> code)
-
recordSpan
<T> T recordSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events, @NonNull() Function0<out T> code)
-
recordCompletedSpan
boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode, @Nullable() EmbraceSpan parent, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events)
-
recordCompletedSpan
boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs)
-
recordCompletedSpan
boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode)
-
recordCompletedSpan
boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() EmbraceSpan parent)
-
recordCompletedSpan
boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode, @Nullable() EmbraceSpan parent)
-
recordCompletedSpan
boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events)
-
getSpan
@Nullable() EmbraceSpan getSpan(@NonNull() String spanId)
-
addSpanExporter
void addSpanExporter(@NonNull() SpanExporter spanExporter)
Adds a [SpanExporter] to the tracer.
- Parameters:
spanExporter- the span exporter to add
-
logPushNotification
void logPushNotification(@Nullable() String title, @Nullable() String body, @Nullable() String topic, @Nullable() String id, @Nullable() Integer notificationPriority, @NonNull() Integer messageDeliveredPriority, @NonNull() Boolean isNotification, @NonNull() Boolean hasData)
-
trackWebViewPerformance
void trackWebViewPerformance(@NonNull() String tag, @NonNull() ConsoleMessage consoleMessage)
Listen to performance-tracking JavaScript previously embedded in the website's code.The WebView being tracked must have JavaScript enabled.
- Parameters:
tag- a name used to identify the WebView being trackedconsoleMessage- the console message collected from the WebView
-
trackWebViewPerformance
void trackWebViewPerformance(@NonNull() String tag, @NonNull() String message)
Listen to performance-tracking JavaScript previously embedded in the website's code.The WebView being tracked must have JavaScript enabled.
- Parameters:
tag- a name used to identify the WebView being trackedmessage- the console message collected from the WebView
-
getCurrentSessionId
@Nullable() String getCurrentSessionId()
Get the ID for the current session.Returns null if a session has not been started yet or the SDK hasn't been initialized.
-
getLastRunEndState
@NonNull() Embrace.LastRunEndState getLastRunEndState()
Get the end state of the last run of the application.
-
getInternalInterface
@NonNull() EmbraceInternalInterface getInternalInterface()
Get internal interface for the intra-Embrace, not-publicly-supported API
-
getReactNativeInternalInterface
@Nullable() ReactNativeInternalInterface getReactNativeInternalInterface()
Gets the ReactNativeInternalInterface that should be used as the sole source ofcommunication with the Android SDK for React Native. Not part of the supported public API.
-
getUnityInternalInterface
@Nullable() UnityInternalInterface getUnityInternalInterface()
-
getFlutterInternalInterface
@Nullable() FlutterInternalInterface getFlutterInternalInterface()
Gets the FlutterInternalInterface that should be used as the sole source ofcommunication with the Android SDK for Flutter. Not part of the supported public API.
-
-
-
-