Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixing in app thing
  • Loading branch information
Manoel Aranda Neto committed Oct 30, 2019
commit c0a3959ae286cdd8bcf3d78db4682222c0dfc73c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ List<SentryStackFrame> getStackFrames(@Nullable final StackTraceElement[] elemen
}

private boolean isInApp(String className) {
if (className == null || className.isEmpty()) {
return true;
}

if (inAppIncludes != null) {
for (String include : inAppIncludes) {
if (className.startsWith(include)) {
Expand All @@ -56,10 +60,10 @@ private boolean isInApp(String className) {
if (inAppExcludes != null) {
for (String exclude : inAppExcludes) {
if (className.startsWith(exclude)) {
return true;
return false;
}
}
}
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ class SentryStackTraceFactoryTest {

//region inAppExcludes
@Test
fun `when getStackFrames is called passing a valid inAppExcludes, inApp should be true if prefix matches it`() {
fun `when getStackFrames is called passing a valid inAppExcludes, inApp should be false if prefix matches it`() {
val element = generateStackTrace("io.sentry.MyActivity")
val elements = arrayOf(element)
val sentryStackTraceFactory = SentryStackTraceFactory(listOf("io.sentry"), null)
val sentryElements = sentryStackTraceFactory.getStackFrames(elements)

assertTrue(sentryElements.first().inApp)
assertFalse(sentryElements.first().inApp)
}

@Test
fun `when getStackFrames is called passing a valid inAppExcludes, inApp should be false if prefix doesnt matches it`() {
fun `when getStackFrames is called passing a valid inAppExcludes, inApp should be true if prefix doesnt matches it`() {
val element = generateStackTrace("io.myapp.MyActivity")
val elements = arrayOf(element)
val sentryStackTraceFactory = SentryStackTraceFactory(listOf("io.sentry"), null)
val sentryElements = sentryStackTraceFactory.getStackFrames(elements)

assertFalse(sentryElements.first().inApp)
assertTrue(sentryElements.first().inApp)
}

@Test
Expand All @@ -60,7 +60,7 @@ class SentryStackTraceFactoryTest {
val sentryStackTraceFactory = SentryStackTraceFactory(null, null)
val sentryElements = sentryStackTraceFactory.getStackFrames(elements)

assertFalse(sentryElements.first().inApp)
assertTrue(sentryElements.first().inApp)
}
//endregion

Expand All @@ -76,26 +76,36 @@ class SentryStackTraceFactoryTest {
}

@Test
fun `when getStackFrames is called passing a valid inAppIncludes, inApp should be false if prefix doesnt matches it`() {
fun `when getStackFrames is called passing a valid inAppIncludes, inApp should be true if prefix doesnt matches it`() {
val element = generateStackTrace("io.myapp.MyActivity")
val elements = arrayOf(element)
val sentryStackTraceFactory = SentryStackTraceFactory(null, listOf("io.sentry"))
val sentryElements = sentryStackTraceFactory.getStackFrames(elements)

assertFalse(sentryElements.first().inApp)
assertTrue(sentryElements.first().inApp)
}

@Test
fun `when getStackFrames is called passing an invalid inAppIncludes, inApp should be false`() {
fun `when getStackFrames is called passing an invalid inAppIncludes, inApp should be true`() {
val element = generateStackTrace("io.sentry.MyActivity")
val elements = arrayOf(element)
val sentryStackTraceFactory = SentryStackTraceFactory(null, null)
val sentryElements = sentryStackTraceFactory.getStackFrames(elements)

assertFalse(sentryElements.first().inApp)
assertTrue(sentryElements.first().inApp)
}
//endregion

private fun generateStackTrace(className: String) =
@Test
fun `when getStackFrames is called passing a valid inAppIncludes and inAppExcludes, inApp should take precedence`() {
val element = generateStackTrace("io.sentry.MyActivity")
val elements = arrayOf(element)
val sentryStackTraceFactory = SentryStackTraceFactory(listOf("io.sentry"), listOf("io.sentry"))
val sentryElements = sentryStackTraceFactory.getStackFrames(elements)

assertTrue(sentryElements.first().inApp)
}

private fun generateStackTrace(className: String?) =
StackTraceElement(className, "method", "fileName", -2)
}