From 473246e9d8e7ae664246372525f5126574a9eb99 Mon Sep 17 00:00:00 2001 From: Jamie Lynch Date: Tue, 9 Jul 2024 12:43:28 +0100 Subject: [PATCH] refactor: alter internal api visibility --- .../api/embrace-android-sdk.api | 129 ++++++++++++++++++ .../embracesdk/internal/api/BreadcrumbApi.kt | 7 +- .../internal/api/EmbraceAndroidApi.kt | 16 ++- .../internal/api/InternalInterfaceApi.kt | 1 + .../internal/api/InternalWebViewApi.kt | 2 + .../embracesdk/internal/api/LogsApi.kt | 32 +++-- .../embracesdk/internal/api/MomentsApi.kt | 23 ++-- .../internal/api/NetworkRequestApi.kt | 2 + .../embracesdk/internal/api/OTelApi.kt | 10 +- .../android/embracesdk/internal/api/SdkApi.kt | 4 +- .../embracesdk/internal/api/SdkStateApi.kt | 14 +- .../embracesdk/internal/api/SessionApi.kt | 15 +- .../embracesdk/internal/api/UserApi.kt | 27 ++-- .../android/embracesdk/spans/TracingApi.kt | 36 ++--- 14 files changed, 237 insertions(+), 81 deletions(-) diff --git a/embrace-android-sdk/api/embrace-android-sdk.api b/embrace-android-sdk/api/embrace-android-sdk.api index 228d915d87..005b096f43 100644 --- a/embrace-android-sdk/api/embrace-android-sdk.api +++ b/embrace-android-sdk/api/embrace-android-sdk.api @@ -239,6 +239,19 @@ public final class io/embrace/android/embracesdk/internal/InternalTracingApi$Def public static synthetic fun stopSpan$default (Lio/embrace/android/embracesdk/internal/InternalTracingApi;Ljava/lang/String;Lio/embrace/android/embracesdk/spans/ErrorCode;Ljava/lang/Long;ILjava/lang/Object;)Z } +public abstract interface class io/embrace/android/embracesdk/internal/api/BreadcrumbApi { + public abstract fun addBreadcrumb (Ljava/lang/String;)V +} + +public abstract interface class io/embrace/android/embracesdk/internal/api/EmbraceAndroidApi { + public abstract fun endView (Ljava/lang/String;)Z + public abstract fun start (Landroid/content/Context;)V + public abstract fun start (Landroid/content/Context;Lio/embrace/android/embracesdk/Embrace$AppFramework;)V + public abstract fun start (Landroid/content/Context;Z)V + public abstract fun start (Landroid/content/Context;ZLio/embrace/android/embracesdk/Embrace$AppFramework;)V + public abstract fun startView (Ljava/lang/String;)Z +} + public abstract interface class io/embrace/android/embracesdk/internal/api/InternalInterfaceApi { public abstract fun getFlutterInternalInterface ()Lio/embrace/android/embracesdk/FlutterInternalInterface; public abstract fun getInternalInterface ()Lio/embrace/android/embracesdk/internal/EmbraceInternalInterface; @@ -252,12 +265,94 @@ public abstract interface class io/embrace/android/embracesdk/internal/api/Inter public abstract fun trackWebViewPerformance (Ljava/lang/String;Ljava/lang/String;)V } +public abstract interface class io/embrace/android/embracesdk/internal/api/LogsApi { + public abstract fun logCustomStacktrace ([Ljava/lang/StackTraceElement;)V + public abstract fun logCustomStacktrace ([Ljava/lang/StackTraceElement;Lio/embrace/android/embracesdk/Severity;)V + public abstract fun logCustomStacktrace ([Ljava/lang/StackTraceElement;Lio/embrace/android/embracesdk/Severity;Ljava/util/Map;)V + public abstract fun logCustomStacktrace ([Ljava/lang/StackTraceElement;Lio/embrace/android/embracesdk/Severity;Ljava/util/Map;Ljava/lang/String;)V + public abstract fun logError (Ljava/lang/String;)V + public abstract fun logException (Ljava/lang/Throwable;)V + public abstract fun logException (Ljava/lang/Throwable;Lio/embrace/android/embracesdk/Severity;)V + public abstract fun logException (Ljava/lang/Throwable;Lio/embrace/android/embracesdk/Severity;Ljava/util/Map;)V + public abstract fun logException (Ljava/lang/Throwable;Lio/embrace/android/embracesdk/Severity;Ljava/util/Map;Ljava/lang/String;)V + public abstract fun logInfo (Ljava/lang/String;)V + public abstract fun logMessage (Ljava/lang/String;Lio/embrace/android/embracesdk/Severity;)V + public abstract fun logMessage (Ljava/lang/String;Lio/embrace/android/embracesdk/Severity;Ljava/util/Map;)V + public abstract fun logPushNotification (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Boolean;)V + public abstract fun logWarning (Ljava/lang/String;)V +} + +public abstract interface class io/embrace/android/embracesdk/internal/api/MomentsApi { + public abstract fun endAppStartup ()V + public abstract fun endAppStartup (Ljava/util/Map;)V + public abstract fun endMoment (Ljava/lang/String;)V + public abstract fun endMoment (Ljava/lang/String;Ljava/lang/String;)V + public abstract fun endMoment (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V + public abstract fun endMoment (Ljava/lang/String;Ljava/util/Map;)V + public abstract fun startMoment (Ljava/lang/String;)V + public abstract fun startMoment (Ljava/lang/String;Ljava/lang/String;)V + public abstract fun startMoment (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V +} + public abstract interface class io/embrace/android/embracesdk/internal/api/NetworkRequestApi { public abstract fun generateW3cTraceparent ()Ljava/lang/String; public abstract fun getTraceIdHeader ()Ljava/lang/String; public abstract fun recordNetworkRequest (Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;)V } +public abstract interface class io/embrace/android/embracesdk/internal/api/OTelApi { + public abstract fun addLogRecordExporter (Lio/opentelemetry/sdk/logs/export/LogRecordExporter;)V + public abstract fun addSpanExporter (Lio/opentelemetry/sdk/trace/export/SpanExporter;)V + public abstract fun getOpenTelemetry ()Lio/opentelemetry/api/OpenTelemetry; +} + +public abstract interface class io/embrace/android/embracesdk/internal/api/SdkApi : io/embrace/android/embracesdk/internal/api/BreadcrumbApi, io/embrace/android/embracesdk/internal/api/EmbraceAndroidApi, io/embrace/android/embracesdk/internal/api/InternalInterfaceApi, io/embrace/android/embracesdk/internal/api/InternalWebViewApi, io/embrace/android/embracesdk/internal/api/LogsApi, io/embrace/android/embracesdk/internal/api/MomentsApi, io/embrace/android/embracesdk/internal/api/NetworkRequestApi, io/embrace/android/embracesdk/internal/api/OTelApi, io/embrace/android/embracesdk/internal/api/SdkStateApi, io/embrace/android/embracesdk/internal/api/SessionApi, io/embrace/android/embracesdk/internal/api/UserApi, io/embrace/android/embracesdk/spans/TracingApi { +} + +public final class io/embrace/android/embracesdk/internal/api/SdkApi$DefaultImpls { + public static fun createSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;JJ)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/EmbraceSpan;)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;JJLjava/util/Map;Ljava/util/List;)Z + public static fun recordSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public static fun recordSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public static fun recordSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public static fun startSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public static fun startSpan (Lio/embrace/android/embracesdk/internal/api/SdkApi;Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; +} + +public abstract interface class io/embrace/android/embracesdk/internal/api/SdkStateApi { + public abstract fun getCurrentSessionId ()Ljava/lang/String; + public abstract fun getDeviceId ()Ljava/lang/String; + public abstract fun getLastRunEndState ()Lio/embrace/android/embracesdk/Embrace$LastRunEndState; + public abstract fun isStarted ()Z + public abstract fun setAppId (Ljava/lang/String;)Z +} + +public abstract interface class io/embrace/android/embracesdk/internal/api/SessionApi { + public abstract fun addSessionProperty (Ljava/lang/String;Ljava/lang/String;Z)Z + public abstract fun endSession ()V + public abstract fun endSession (Z)V + public abstract fun getSessionProperties ()Ljava/util/Map; + public abstract fun removeSessionProperty (Ljava/lang/String;)Z +} + +public abstract interface class io/embrace/android/embracesdk/internal/api/UserApi { + public abstract fun addUserPersona (Ljava/lang/String;)V + public abstract fun clearAllUserPersonas ()V + public abstract fun clearUserAsPayer ()V + public abstract fun clearUserEmail ()V + public abstract fun clearUserIdentifier ()V + public abstract fun clearUserPersona (Ljava/lang/String;)V + public abstract fun clearUsername ()V + public abstract fun setUserAsPayer ()V + public abstract fun setUserEmail (Ljava/lang/String;)V + public abstract fun setUserIdentifier (Ljava/lang/String;)V + public abstract fun setUsername (Ljava/lang/String;)V +} + public abstract interface class io/embrace/android/embracesdk/internal/clock/Clock { public abstract fun now ()J public abstract fun nowInNanos ()J @@ -413,3 +508,37 @@ public final class io/embrace/android/embracesdk/spans/ErrorCode : java/lang/Enu public static fun values ()[Lio/embrace/android/embracesdk/spans/ErrorCode; } +public abstract interface class io/embrace/android/embracesdk/spans/TracingApi { + public abstract fun createSpan (Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public abstract fun createSpan (Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public abstract fun getSpan (Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public abstract fun isTracingAvailable ()Z + public abstract fun recordCompletedSpan (Ljava/lang/String;JJ)Z + public abstract fun recordCompletedSpan (Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/EmbraceSpan;)Z + public abstract fun recordCompletedSpan (Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;)Z + public abstract fun recordCompletedSpan (Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Z + public abstract fun recordCompletedSpan (Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;Lio/embrace/android/embracesdk/spans/EmbraceSpan;Ljava/util/Map;Ljava/util/List;)Z + public abstract fun recordCompletedSpan (Ljava/lang/String;JJLjava/util/Map;Ljava/util/List;)Z + public abstract fun recordSpan (Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;Ljava/util/Map;Ljava/util/List;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public abstract fun recordSpan (Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public abstract fun recordSpan (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public abstract fun recordSpan (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public abstract fun startSpan (Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public abstract fun startSpan (Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public abstract fun startSpan (Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;Ljava/lang/Long;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; +} + +public final class io/embrace/android/embracesdk/spans/TracingApi$DefaultImpls { + public static fun createSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;JJ)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/EmbraceSpan;)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;JJLio/embrace/android/embracesdk/spans/ErrorCode;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Z + public static fun recordCompletedSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;JJLjava/util/Map;Ljava/util/List;)Z + public static fun recordSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public static fun recordSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public static fun recordSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + public static fun startSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; + public static fun startSpan (Lio/embrace/android/embracesdk/spans/TracingApi;Ljava/lang/String;Lio/embrace/android/embracesdk/spans/EmbraceSpan;)Lio/embrace/android/embracesdk/spans/EmbraceSpan; +} + diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/BreadcrumbApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/BreadcrumbApi.kt index 82f4dbb62b..7c834bcdff 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/BreadcrumbApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/BreadcrumbApi.kt @@ -1,6 +1,9 @@ package io.embrace.android.embracesdk.internal.api -internal interface BreadcrumbApi { +import io.embrace.android.embracesdk.annotation.InternalApi + +@InternalApi +public interface BreadcrumbApi { /** * Adds a breadcrumb. @@ -9,5 +12,5 @@ internal interface BreadcrumbApi { * * @param message the name of the breadcrumb to add */ - fun addBreadcrumb(message: String) + public fun addBreadcrumb(message: String) } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/EmbraceAndroidApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/EmbraceAndroidApi.kt index b098b525fa..4762487139 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/EmbraceAndroidApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/EmbraceAndroidApi.kt @@ -2,6 +2,7 @@ package io.embrace.android.embracesdk.internal.api import android.content.Context import io.embrace.android.embracesdk.Embrace +import io.embrace.android.embracesdk.annotation.InternalApi /** * Declares the functions that consist of Embrace's public API - specifically @@ -9,7 +10,8 @@ import io.embrace.android.embracesdk.Embrace * [EmbraceAndroidApi] directly or implement it in your own custom classes, * as new functions may be added in future. Use the [Embrace] class instead. */ -internal interface EmbraceAndroidApi { +@InternalApi +public interface EmbraceAndroidApi { /** * Starts instrumentation of the Android application using the Embrace SDK. This should be @@ -21,7 +23,7 @@ internal interface EmbraceAndroidApi { * * @param context an instance of the application context */ - fun start(context: Context) + public fun start(context: Context) /** * Starts instrumentation of the Android application using the Embrace SDK. This should be @@ -36,7 +38,7 @@ internal interface EmbraceAndroidApi { */ @Suppress("DEPRECATION") @Deprecated("Use {@link #start(Context)} instead.") - fun start( + public fun start( context: Context, appFramework: Embrace.AppFramework ) @@ -54,7 +56,7 @@ internal interface EmbraceAndroidApi { * sets the environment for all sessions to 'Development'. */ @Deprecated("Use {@link #start(Context)} instead. The isDevMode parameter has no effect.") - fun start( + public fun start( context: Context, isDevMode: Boolean ) @@ -75,7 +77,7 @@ internal interface EmbraceAndroidApi { */ @Suppress("DEPRECATION") @Deprecated("Use {@link #start(Context, Embrace.AppFramework)} instead. The isDevMode parameter has no effect.") - fun start( + public fun start( context: Context, isDevMode: Boolean, appFramework: Embrace.AppFramework @@ -94,7 +96,7 @@ internal interface EmbraceAndroidApi { * * @param name the name of the view to log */ - fun startView(name: String): Boolean + public fun startView(name: String): Boolean /** * Records that a view 'ended'. You should call this when your app stops displaying an @@ -109,5 +111,5 @@ internal interface EmbraceAndroidApi { * * @param name the name of the view to log */ - fun endView(name: String): Boolean + public fun endView(name: String): Boolean } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalInterfaceApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalInterfaceApi.kt index 780bdea757..f97cb1070a 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalInterfaceApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalInterfaceApi.kt @@ -6,6 +6,7 @@ import io.embrace.android.embracesdk.UnityInternalInterface import io.embrace.android.embracesdk.annotation.InternalApi import io.embrace.android.embracesdk.internal.EmbraceInternalInterface +@InternalApi public interface InternalInterfaceApi { /** diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalWebViewApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalWebViewApi.kt index 650954637c..fc5cc073f8 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalWebViewApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/InternalWebViewApi.kt @@ -1,7 +1,9 @@ package io.embrace.android.embracesdk.internal.api import android.webkit.ConsoleMessage +import io.embrace.android.embracesdk.annotation.InternalApi +@InternalApi public interface InternalWebViewApi { public fun logWebView(url: String?) public fun trackWebViewPerformance(tag: String, consoleMessage: ConsoleMessage) diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/LogsApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/LogsApi.kt index aa5a97b3d1..8a0c2894c2 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/LogsApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/LogsApi.kt @@ -1,11 +1,13 @@ package io.embrace.android.embracesdk.internal.api import io.embrace.android.embracesdk.Severity +import io.embrace.android.embracesdk.annotation.InternalApi /** * The public API that is used to send log messages. */ -internal interface LogsApi { +@InternalApi +public interface LogsApi { /** * Remotely logs a message at the given severity level. These log messages will appear as part of the session * timeline, and can be used to describe what was happening at a particular time within the app. @@ -13,7 +15,7 @@ internal interface LogsApi { * @param message the message to remotely log * @param severity the severity level of the log message */ - fun logMessage( + public fun logMessage( message: String, severity: Severity, ) @@ -26,7 +28,7 @@ internal interface LogsApi { * @param severity the severity level of the log message * @param properties the properties to attach to the log message */ - fun logMessage( + public fun logMessage( message: String, severity: Severity, properties: Map?, @@ -38,7 +40,7 @@ internal interface LogsApi { * * @param message the message to remotely log */ - fun logInfo(message: String) + public fun logInfo(message: String) /** * Remotely logs a message at WARN level. These log messages will appear as part of the session @@ -46,7 +48,7 @@ internal interface LogsApi { * * @param message the message to remotely log */ - fun logWarning(message: String) + public fun logWarning(message: String) /** * Remotely logs a message at ERROR level. These log messages will appear as part of the session @@ -54,7 +56,7 @@ internal interface LogsApi { * * @param message the message to remotely log */ - fun logError(message: String) + public fun logError(message: String) /** * Remotely logs a Throwable/Exception at ERROR level. These log messages and stacktraces @@ -63,7 +65,7 @@ internal interface LogsApi { * * @param throwable the throwable to remotely log */ - fun logException(throwable: Throwable) + public fun logException(throwable: Throwable) /** * Remotely logs a Throwable/Exception at given severity level. These log messages and stacktraces @@ -73,7 +75,7 @@ internal interface LogsApi { * @param throwable the throwable to remotely log * @param severity the severity level of the log message */ - fun logException( + public fun logException( throwable: Throwable, severity: Severity, ) @@ -87,7 +89,7 @@ internal interface LogsApi { * @param severity the severity level of the log message * @param properties custom key-value pairs to include with the log message */ - fun logException( + public fun logException( throwable: Throwable, severity: Severity, properties: Map?, @@ -103,7 +105,7 @@ internal interface LogsApi { * @param properties custom key-value pairs to include with the log message * @param message the message to remotely log instead of the throwable message */ - fun logException( + public fun logException( throwable: Throwable, severity: Severity, properties: Map?, @@ -117,7 +119,7 @@ internal interface LogsApi { * * @param stacktraceElements the stacktrace to remotely log */ - fun logCustomStacktrace(stacktraceElements: Array) + public fun logCustomStacktrace(stacktraceElements: Array) /** * Remotely logs a custom stacktrace at given severity level. These log messages and stacktraces @@ -127,7 +129,7 @@ internal interface LogsApi { * @param stacktraceElements the stacktrace to remotely log * @param severity the severity level of the log message */ - fun logCustomStacktrace( + public fun logCustomStacktrace( stacktraceElements: Array, severity: Severity, ) @@ -141,7 +143,7 @@ internal interface LogsApi { * @param severity the severity level of the log message * @param properties custom key-value pairs to include with the log message */ - fun logCustomStacktrace( + public fun logCustomStacktrace( stacktraceElements: Array, severity: Severity, properties: Map?, @@ -157,7 +159,7 @@ internal interface LogsApi { * @param properties custom key-value pairs to include with the log message * @param message the message to remotely log instead of the throwable message */ - fun logCustomStacktrace( + public fun logCustomStacktrace( stacktraceElements: Array, severity: Severity, properties: Map?, @@ -176,7 +178,7 @@ internal interface LogsApi { * @param isNotification if it is a notification message. * @param hasData if the message contains payload data. */ - fun logPushNotification( + public fun logPushNotification( title: String?, body: String?, topic: String?, diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/MomentsApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/MomentsApi.kt index 582e6888e7..a6682b9ce4 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/MomentsApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/MomentsApi.kt @@ -1,9 +1,12 @@ package io.embrace.android.embracesdk.internal.api +import io.embrace.android.embracesdk.annotation.InternalApi + /** * The public API that is used to start & end moments. */ -internal interface MomentsApi { +@InternalApi +public interface MomentsApi { /** * Starts a 'moment'. Moments are used for encapsulating particular activities within @@ -13,7 +16,7 @@ internal interface MomentsApi { * * @param name a name identifying the moment */ - fun startMoment(name: String) + public fun startMoment(name: String) /** * Starts a 'moment'. Moments are used for encapsulating particular activities within @@ -24,7 +27,7 @@ internal interface MomentsApi { * @param name a name identifying the moment * @param identifier an identifier distinguishing between multiple moments with the same name */ - fun startMoment(name: String, identifier: String?) + public fun startMoment(name: String, identifier: String?) /** * Starts a 'moment'. Moments are used for encapsulating particular activities within @@ -36,7 +39,7 @@ internal interface MomentsApi { * @param identifier an identifier distinguishing between multiple moments with the same name * @param properties custom key-value pairs to provide with the moment */ - fun startMoment( + public fun startMoment( name: String, identifier: String?, properties: Map? @@ -49,7 +52,7 @@ internal interface MomentsApi { * * @param name the name of the moment to end */ - fun endMoment(name: String) + public fun endMoment(name: String) /** * Signals the end of a moment with the specified name. @@ -59,7 +62,7 @@ internal interface MomentsApi { * @param name the name of the moment to end * @param identifier the identifier of the moment to end, distinguishing between moments with the same name */ - fun endMoment(name: String, identifier: String?) + public fun endMoment(name: String, identifier: String?) /** * Signals the end of a moment with the specified name. @@ -70,7 +73,7 @@ internal interface MomentsApi { * @param name the name of the moment to end * @param properties custom key-value pairs to provide with the moment */ - fun endMoment( + public fun endMoment( name: String, properties: Map? ) @@ -84,7 +87,7 @@ internal interface MomentsApi { * @param identifier the identifier of the moment to end, distinguishing between moments with the same name * @param properties custom key-value pairs to provide with the moment */ - fun endMoment( + public fun endMoment( name: String, identifier: String?, properties: Map? @@ -93,12 +96,12 @@ internal interface MomentsApi { /** * Signals that the app has completed startup. */ - fun endAppStartup() + public fun endAppStartup() /** * Signals that the app has completed startup. * * @param properties properties to include as part of the startup moment */ - fun endAppStartup(properties: Map) + public fun endAppStartup(properties: Map) } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/NetworkRequestApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/NetworkRequestApi.kt index 39e168116b..e0720bdfeb 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/NetworkRequestApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/NetworkRequestApi.kt @@ -1,10 +1,12 @@ package io.embrace.android.embracesdk.internal.api +import io.embrace.android.embracesdk.annotation.InternalApi import io.embrace.android.embracesdk.network.EmbraceNetworkRequest /** * The public API that is used for capturing network requests manually */ +@InternalApi public interface NetworkRequestApi { /** diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/OTelApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/OTelApi.kt index c89f38be74..5393feb79b 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/OTelApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/OTelApi.kt @@ -1,5 +1,6 @@ package io.embrace.android.embracesdk.internal.api +import io.embrace.android.embracesdk.annotation.InternalApi import io.opentelemetry.api.OpenTelemetry import io.opentelemetry.api.trace.Tracer import io.opentelemetry.sdk.logs.export.LogRecordExporter @@ -8,21 +9,22 @@ import io.opentelemetry.sdk.trace.export.SpanExporter /** * Methods that enable integration with the the large OTel ecosystem through standard OTel APIs and concepts. */ -internal interface OTelApi { +@InternalApi +public interface OTelApi { /** * Add a [LogRecordExporter] that OTel Logs will be exported to after logging */ - fun addLogRecordExporter(logRecordExporter: LogRecordExporter) + public fun addLogRecordExporter(logRecordExporter: LogRecordExporter) /** * Adds a [SpanExporter] that OTel Spans will be exported to after completion */ - fun addSpanExporter(spanExporter: SpanExporter) + public fun addSpanExporter(spanExporter: SpanExporter) /** * Returns an [OpenTelemetry] that provides working [Tracer] implementations that will record spans that fit into the Embrace data * model. */ - fun getOpenTelemetry(): OpenTelemetry + public fun getOpenTelemetry(): OpenTelemetry } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkApi.kt index 53a6298f59..91f4b59434 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkApi.kt @@ -1,8 +1,10 @@ package io.embrace.android.embracesdk.internal.api +import io.embrace.android.embracesdk.annotation.InternalApi import io.embrace.android.embracesdk.spans.TracingApi -internal interface SdkApi : +@InternalApi +public interface SdkApi : LogsApi, MomentsApi, NetworkRequestApi, diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkStateApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkStateApi.kt index edf03714e0..20b194aad2 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkStateApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SdkStateApi.kt @@ -1,15 +1,17 @@ package io.embrace.android.embracesdk.internal.api import io.embrace.android.embracesdk.Embrace +import io.embrace.android.embracesdk.annotation.InternalApi -internal interface SdkStateApi { +@InternalApi +public interface SdkStateApi { /** * Whether or not the SDK has been started. * * @return true if the SDK is started, false otherwise */ - val isStarted: Boolean + public val isStarted: Boolean /** * Sets a custom app ID that overrides the one specified at build time. Must be called before @@ -18,11 +20,11 @@ internal interface SdkStateApi { * @param appId custom app ID * @return true if the app ID could be set, false otherwise. */ - fun setAppId(appId: String): Boolean + public fun setAppId(appId: String): Boolean - fun getDeviceId(): String + public fun getDeviceId(): String - val currentSessionId: String? + public val currentSessionId: String? - fun getLastRunEndState(): Embrace.LastRunEndState + public fun getLastRunEndState(): Embrace.LastRunEndState } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SessionApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SessionApi.kt index e8f23f847f..22c19831ca 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SessionApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/SessionApi.kt @@ -1,9 +1,12 @@ package io.embrace.android.embracesdk.internal.api +import io.embrace.android.embracesdk.annotation.InternalApi + /** * The public API that is used to interact with sessions. */ -internal interface SessionApi { +@InternalApi +public interface SessionApi { /** * Adds a property to the current session, overwriting any previous property set with the given key. If a permanent property @@ -18,7 +21,7 @@ internal interface SessionApi { * @return True if the property was successfully added. Reasons this may fail include an invalid key or value, or if the * session has exceeded its total properties limit. */ - fun addSessionProperty( + public fun addSessionProperty( key: String, value: String, permanent: Boolean @@ -29,24 +32,24 @@ internal interface SessionApi { * * @return true if a property with that name had previously existed. */ - fun removeSessionProperty(key: String): Boolean + public fun removeSessionProperty(key: String): Boolean /** * Retrieves a map of the current session properties. * * @return a new immutable map containing the current session properties, or null if the SDK has not been started or has been stopped. */ - fun getSessionProperties(): Map? + public fun getSessionProperties(): Map? /** * Ends the current session and starts a new one. */ - fun endSession() + public fun endSession() /** * Ends the current session and starts a new one. * * @param clearUserInfo Pass in true to clear all user info set on this device. */ - fun endSession(clearUserInfo: Boolean) + public fun endSession(clearUserInfo: Boolean) } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/UserApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/UserApi.kt index c44e4e363e..305ac2f1e8 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/UserApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/api/UserApi.kt @@ -1,9 +1,12 @@ package io.embrace.android.embracesdk.internal.api +import io.embrace.android.embracesdk.annotation.InternalApi + /** * The public API that is used to set user information. */ -internal interface UserApi { +@InternalApi +public interface UserApi { /** * Sets the user ID. This would typically be some form of unique identifier such as a UUID or database key for the user. @@ -12,35 +15,35 @@ internal interface UserApi { * * @param userId the unique identifier for the user */ - fun setUserIdentifier(userId: String?) + public fun setUserIdentifier(userId: String?) /** * Clears the currently set user ID. For example, if the user logs out. */ - fun clearUserIdentifier() + public fun clearUserIdentifier() /** * Sets the current user's email address. * * @param email the email address of the current user */ - fun setUserEmail(email: String?) + public fun setUserEmail(email: String?) /** * Clears the currently set user's email address. */ - fun clearUserEmail() + public fun clearUserEmail() /** * Sets this user as a paying user. This adds a persona to the user's identity. */ - fun setUserAsPayer() + public fun setUserAsPayer() /** * Clears this user as a paying user. This would typically be called if a user is no longer * paying for the service and has reverted back to a basic user. */ - fun clearUserAsPayer() + public fun clearUserAsPayer() /** * Adds a custom user persona. A persona is a trait associated with a given user. A maximum @@ -48,29 +51,29 @@ internal interface UserApi { * * @param persona the persona to set */ - fun addUserPersona(persona: String) + public fun addUserPersona(persona: String) /** * Clears the custom user persona, if it is set. * * @param persona the persona to clear */ - fun clearUserPersona(persona: String) + public fun clearUserPersona(persona: String) /** * Clears all custom user personas from the user. */ - fun clearAllUserPersonas() + public fun clearAllUserPersonas() /** * Sets the username of the currently logged in user. * * @param username the username to set */ - fun setUsername(username: String?) + public fun setUsername(username: String?) /** * Clears the username of the currently logged in user, for example if the user has logged out. */ - fun clearUsername() + public fun clearUsername() } diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/spans/TracingApi.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/spans/TracingApi.kt index d1e057a532..2aa906d0ef 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/spans/TracingApi.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/spans/TracingApi.kt @@ -7,7 +7,7 @@ import io.embrace.android.embracesdk.annotation.BetaApi * The actual trace won't be recorded until the SDK is started, but it's safe to use this prior to SDK initialization. */ @BetaApi -internal interface TracingApi { +public interface TracingApi { /** * Create an [EmbraceSpan] with the given name that will be the root span of a new trace. Returns null if the [EmbraceSpan] cannot * be created given the current conditions of the SDK or an invalid name. @@ -15,7 +15,7 @@ internal interface TracingApi { * Note: the [EmbraceSpan] created will not be started. For a method that creates and starts the span, use [startSpan] */ @BetaApi - fun createSpan( + public fun createSpan( name: String ): EmbraceSpan? = createSpan(name = name, parent = null) @@ -27,7 +27,7 @@ internal interface TracingApi { * * Note: the [EmbraceSpan] created will not be started. For a method that creates and starts the span, use [startSpan] */ @BetaApi - fun createSpan( + public fun createSpan( name: String, parent: EmbraceSpan? ): EmbraceSpan? @@ -37,7 +37,7 @@ internal interface TracingApi { * [EmbraceSpan] cannot be created or started. */ @BetaApi - fun startSpan( + public fun startSpan( name: String ): EmbraceSpan? = startSpan(name = name, parent = null) @@ -46,7 +46,7 @@ internal interface TracingApi { * or started, like if the parent has been started. */ @BetaApi - fun startSpan( + public fun startSpan( name: String, parent: EmbraceSpan? ): EmbraceSpan? = startSpan( @@ -60,7 +60,7 @@ internal interface TracingApi { * Returns null if the [EmbraceSpan] cannot be created or started, like if the parent has been started. */ @BetaApi - fun startSpan( + public fun startSpan( name: String, parent: EmbraceSpan?, startTimeMs: Long? @@ -72,7 +72,7 @@ internal interface TracingApi { * [Throwable] will be rethrown. */ @BetaApi - fun recordSpan( + public fun recordSpan( name: String, code: () -> T ): T = recordSpan(name = name, parent = null, attributes = null, events = null, code = code) @@ -84,7 +84,7 @@ internal interface TracingApi { * [Throwable] will be rethrown. */ @BetaApi - fun recordSpan( + public fun recordSpan( name: String, parent: EmbraceSpan?, code: () -> T @@ -96,7 +96,7 @@ internal interface TracingApi { * the span will end at the point of the throw and the [Throwable] will be rethrown. */ @BetaApi - fun recordSpan( + public fun recordSpan( name: String, attributes: Map?, events: List?, @@ -111,7 +111,7 @@ internal interface TracingApi { * [Throwable] will be rethrown. */ @BetaApi - fun recordSpan( + public fun recordSpan( name: String, parent: EmbraceSpan?, attributes: Map?, @@ -124,7 +124,7 @@ internal interface TracingApi { * a new trace. */ @BetaApi - fun recordCompletedSpan( + public fun recordCompletedSpan( name: String, startTimeMs: Long, endTimeMs: Long @@ -145,7 +145,7 @@ internal interface TracingApi { * unsuccessfully under the stated circumstances. */ @BetaApi - fun recordCompletedSpan( + public fun recordCompletedSpan( name: String, startTimeMs: Long, endTimeMs: Long, @@ -166,7 +166,7 @@ internal interface TracingApi { * will result in a new trace with the new span as its root. */ @BetaApi - fun recordCompletedSpan( + public fun recordCompletedSpan( name: String, startTimeMs: Long, endTimeMs: Long, @@ -188,7 +188,7 @@ internal interface TracingApi { * operation the span represents was ended unsuccessfully under the stated circumstances. */ @BetaApi - fun recordCompletedSpan( + public fun recordCompletedSpan( name: String, startTimeMs: Long, endTimeMs: Long, @@ -210,7 +210,7 @@ internal interface TracingApi { * a [List] of [EmbraceSpanEvent] to be used as the events of the recorded span. */ @BetaApi - fun recordCompletedSpan( + public fun recordCompletedSpan( name: String, startTimeMs: Long, endTimeMs: Long, @@ -234,7 +234,7 @@ internal interface TracingApi { * as the events of the recorded span. */ @BetaApi - fun recordCompletedSpan( + public fun recordCompletedSpan( name: String, startTimeMs: Long, endTimeMs: Long, @@ -250,11 +250,11 @@ internal interface TracingApi { * if was completed in a prior session. */ @BetaApi - fun getSpan(spanId: String): EmbraceSpan? + public fun getSpan(spanId: String): EmbraceSpan? /** * @see [Embrace.isStarted] */ @Deprecated("Not required. Use Embrace.isStarted() to know when the full tracing API is available") - fun isTracingAvailable(): Boolean + public fun isTracingAvailable(): Boolean }