# These rules are added to the customer app obfuscation
# If you do something with reflection, chance your rule should be here

# keep protobuf generated message lite
-keepnames class com.google.protobuf.GeneratedMessageLite { *;}
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
    <fields>;
}

# Keep classes implementing StartableModule interface, see ModuleStarter.kt
-keep class * implements com.contentsquare.android.core.communication.StartableModule {
    public <init>(...);
}

# Keep class names for all Views
-keepnames class * extends android.view.View

# Keep Jetpack Compose classes used in the tree view path
-keepnames class androidx.compose.foundation.lazy.layout.LazyLayoutSemanticState { *; }

# Keep classes, methods and fields resolved by reflection
-keepnames class com.google.android.material.appbar.AppBarLayout {
    void setExpanded(boolean, boolean);
}

# Keep API classes used by cross-platform
-keep class com.contentsquare.android.api.bridge.logmonitor.LogMonitorInterface { *; }
-keep class com.contentsquare.android.api.bridge.telemetry.TelemetryInterface { *; }
-keep class com.contentsquare.android.api.bridge.flutter.FlutterInterface { *; }
-keep class com.contentsquare.android.api.bridge.xpf.XpfInterface { *; }
-keep interface com.contentsquare.android.api.bridge.xpf.ExternalBridgeInterface { *; }
-keep class com.contentsquare.android.api.bridge.xpf.ExternalBridgeType { *; }

-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt
-keepclassmembers @kotlinx.serialization.Serializable class ** {
    *** Companion;
}
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1>$Companion {
    kotlinx.serialization.KSerializer serializer(...);
}
-keepclasseswithmembers class **$$serializer {
    *** INSTANCE;
}

# prevent deleting SessionReplayStartStopController ref as it's not used but needed
-keep class **.ContentsquareModule {
    private static <fields>;
}
# Avoid VerifyError crash on customer App if they enable test coverage
# Not sure we need also this keep rule on the consumer-proguard side, normaly jacoco is not used in prod/minified environnement.
# But the customer already complaint a lot, so we apply the "ceinture et bretelle" rule
# See https://contentsquare.atlassian.net/browse/SUP-15941 & https://github.com/jacoco/jacoco/issues/1381
-keep class com.contentsquare.android.internal.features.sessionreplay.processing.SessionReplayProcessor { *; }

#This rule is added to prevent deleting Heap method ref in case comsumer app don't call them directly
-keep class io.heap.core.Heap {
    public static java.lang.String getSessionId();
    public static java.lang.String getUserId();
    public static java.lang.String getEnvironmentId();
}
