Skip to content

Commit

Permalink
fix: fix the ip address not catch issue (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhao900914 authored Sep 27, 2022
1 parent 384a82d commit bf8e2a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class AndroidContextPlugin : Plugin {
event.partnerId = it
}
}
event.ip ?: let {
// get the ip in server side if there is no event level ip
event.ip = "\$remote"
}
event.plan ?: let {
amplitude.configuration.plan ?. let {
event.plan = it.clone()
Expand Down
3 changes: 3 additions & 0 deletions core/src/test/kotlin/com/amplitude/core/AmplitudeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ internal class AmplitudeTest {
assertEquals(mapOf(Pair("foo", "bar")), it.eventProperties)
assertEquals("CA", it.region)
assertEquals("test", it.plan?.source)
assertEquals("\$remote", it.ip)
assertEquals("ampli", it.ingestionMetadata?.sourceName)
}
}
Expand All @@ -80,6 +81,7 @@ internal class AmplitudeTest {
val event = BaseEvent()
event.eventType = "test event"
event.region = "CA"
event.ip = "127.0.0.1"
amplitude.track(event, eventOptions)
val track = slot<BaseEvent>()
verify { mockPlugin.track(capture(track)) }
Expand All @@ -91,6 +93,7 @@ internal class AmplitudeTest {
assertEquals("SF", it.city)
assertEquals("test", it.plan?.source)
assertEquals("ampli", it.ingestionMetadata?.sourceName)
assertEquals("127.0.0.1", it.ip)
}
}
}
Expand Down

0 comments on commit bf8e2a1

Please sign in to comment.