Skip to content

Commit 09feacf

Browse files
authored
Add more properties for Android event callback
* fix: Add more properties to event for success callback Add additional tests for Android Update sentry-cocoa and KSCrash Fixes #220
1 parent bd79efe commit 09feacf

File tree

7 files changed

+49
-11
lines changed

7 files changed

+49
-11
lines changed

android/src/main/java/io/sentry/MapUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ public static WritableMap toWritableMap(Map<String, Object> map) {
127127
} else if (value.getClass() != null && value.getClass().isArray()) {
128128
writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
129129
}
130-
131-
iterator.remove();
132130
}
133131

134132
return writableMap;

android/src/main/java/io/sentry/RNSentryModule.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
import com.facebook.react.bridge.WritableNativeMap;
2020

2121
import java.util.ArrayDeque;
22-
import java.util.ArrayList;
22+
import java.util.Collections;
2323
import java.util.Deque;
2424
import java.util.HashMap;
2525
import java.util.HashSet;
2626
import java.util.Iterator;
27-
import java.util.List;
2827
import java.util.Map;
2928
import java.util.Set;
3029
import java.util.logging.Level;
@@ -108,6 +107,11 @@ public void onSuccess(Event event) {
108107
WritableMap params = Arguments.createMap();
109108
params.putString("event_id", event.getId().toString());
110109
params.putString("level", event.getLevel().toString().toLowerCase());
110+
params.putString("message", event.getMessage());
111+
params.putString("release", event.getRelease());
112+
params.putString("dist", event.getDist());
113+
params.putMap("extra", MapUtil.toWritableMap(event.getExtra()));
114+
params.putMap("tags", MapUtil.toWritableMap(Collections.<String, Object>unmodifiableMap(event.getTags())));
111115
RNSentryEventEmitter.sendEvent(reactContext, RNSentryEventEmitter.SENTRY_EVENT_SENT_SUCCESSFULLY, params);
112116
}
113117
});

appium/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test-android: create-android-test-bundle new-demo-project copy-local-files-to-ex
3333
fastlane aws_android_upload_and_run
3434
ANDROID=1 ruby check_run_failues.rb
3535

36-
local-android-test:
36+
local-android-test: create-android-test-bundle new-demo-project copy-local-files-to-example
3737
fastlane build_android_for_device_farm
3838
ANDROID=1 pytest -vv tests/test_android.py
3939

appium/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def default_capabilities():
8383
desired_caps['showIOSLog'] = True
8484
if not runs_on_aws():
8585
if os.environ.get('ANDROID') == '1':
86-
desired_caps['app'] = os.path.abspath('example/android/app/build/outputs/apk/app-release-unsigned.apk')
86+
desired_caps['app'] = os.path.abspath('example/android/app/build/outputs/apk/app-full-release-unsigned.apk')
8787
desired_caps['platformName'] = 'Android'
8888
desired_caps['deviceName'] = 'Android'
8989
else:

appium/tests/test_android.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,30 @@
33

44
from time import sleep
55

6+
7+
def extractText(driver):
8+
return driver.find_elements_by_xpath('//android.widget.EditText')[0].text
9+
610
def test_send_message(driver):
711
driver.find_element_by_accessibility_id('send message').click()
812

913
sleep(3)
1014

11-
value = driver.find_elements_by_xpath('//android.widget.EditText')[0].text
15+
value = extractText(driver)
1216

1317
assert value != None
1418
event = json.loads(value)
1519

1620
assert event['event_id'] != None
1721
assert event['level'] == 'warning'
22+
assert event['message'] == 'TEST message'
23+
assert event['extra']['react']
24+
assert event['tags']['react']
1825

1926
def test_throw_error(driver):
2027
driver.find_element_by_accessibility_id('throw error').click()
2128
driver.relaunch_app()
22-
value = driver.find_elements_by_xpath('//android.widget.EditText')[0].text
29+
value = extractText(driver)
2330
# the crash should have been already sent
2431
assert value is None
2532

@@ -28,10 +35,39 @@ def test_native_crash(driver):
2835
driver.find_element_by_accessibility_id('native crash').click()
2936
driver.relaunch_app()
3037
sleep(3)
31-
value = driver.find_elements_by_xpath('//android.widget.EditText')[0].text
38+
value = extractText(driver)
3239

3340
assert value != None
3441
event = json.loads(value)
3542

3643
assert event['event_id'] != None
3744
assert event['level'] == 'fatal'
45+
46+
def test_version(driver):
47+
driver.find_element_by_accessibility_id('set version').click()
48+
driver.find_element_by_accessibility_id('send message').click()
49+
sleep(3)
50+
value = extractText(driver)
51+
assert value != None
52+
event = json.loads(value)
53+
assert event['release'] == 'com.awesomeproject.full-1337'
54+
55+
56+
def test_release(driver):
57+
driver.find_element_by_accessibility_id('set release').click()
58+
driver.find_element_by_accessibility_id('send message').click()
59+
sleep(3)
60+
value = extractText(driver)
61+
assert value != None
62+
event = json.loads(value)
63+
assert event['release'] == 'myversion'
64+
65+
66+
def test_dist(driver):
67+
driver.find_element_by_accessibility_id('set dist').click()
68+
driver.find_element_by_accessibility_id('send message').click()
69+
sleep(3)
70+
value = extractText(driver)
71+
assert value != None
72+
event = json.loads(value)
73+
assert event['dist'] == '500'

0 commit comments

Comments
 (0)