crash_event_react_native.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. from typing import Dict, Mapping, MutableMapping, Sequence
  2. def get_frames(filename: str) -> Sequence[MutableMapping[str, str]]:
  3. frames = [
  4. {
  5. "function": "dispatchEvent",
  6. "filename": "/Users/sentry.user/git-repos/sentry-react-native/samples/react-native/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js",
  7. "abs_path": "/Users/sentry.user/git-repos/sentry-react-native/samples/react-native/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js",
  8. },
  9. {
  10. "function": "Button.props.onPress",
  11. "filename": "/Users/sentry.user/git-repos/sentry-react-native/samples/react-native/src/Screens/HomeScreen.tsx",
  12. "abs_path": "/Users/sentry.user/git-repos/sentry-react-native/samples/react-native/src/Screens/HomeScreen.tsx",
  13. },
  14. {
  15. "function": "community.lib.dosomething",
  16. "filename": "/Users/sentry.user/git-repos/sentry-react-native/samples/react-native/node_modules/react-native-community/Renderer/implementations/ReactFabric-dev.js",
  17. "abs_path": "/Users/sentry.user/git-repos/sentry-react-native/samples/react-native/node_modules/react-native-community/Renderer/implementations/ReactFabric-dev.js",
  18. },
  19. {
  20. "function": "nativeCrash",
  21. "filename": "/Users/sentry.user/git-repos/sentry-react-native/dist/js/sdk.js",
  22. "abs_path": "/Users/sentry.user/git-repos/sentry-react-native/dist/js/sdk.js",
  23. },
  24. {
  25. "function": "ReactNativeClient#nativeCrash",
  26. "filename": filename,
  27. "abs_path": "/Users/sentry.user/git-repos/sentry-react-native/dist/js/client.js",
  28. },
  29. ]
  30. return frames
  31. def get_crash_event(
  32. filename="/Users/sentry.user/git-repos/sentry-react-native/dist/js/client.js", **kwargs
  33. ) -> Dict[str, object]:
  34. return get_crash_event_with_frames(get_frames(filename=filename), **kwargs)
  35. def get_crash_event_with_frames(frames: Sequence[Mapping[str, str]], **kwargs) -> Dict[str, object]:
  36. result = {
  37. "event_id": "150d5b0b4f3a4797a3cd1345374ac484",
  38. "release": "com.samplenewarchitecture@1.0+1",
  39. "dist": "1",
  40. "platform": "javascript",
  41. "message": "",
  42. "environment": "dev",
  43. "exception": {
  44. "values": [
  45. {
  46. "type": "Error",
  47. "value": "Uncaught Thrown Error",
  48. "stacktrace": {"frames": frames},
  49. "mechanism": {"type": "onerror", "handled": False},
  50. }
  51. ]
  52. },
  53. "key_id": "3554525",
  54. "level": "fatal",
  55. "contexts": {
  56. "app": {
  57. "app_start_time": "2024-01-11T10:30:29.281Z",
  58. "app_identifier": "com.samplenewarchitecture",
  59. "app_name": "sampleNewArchitecture",
  60. "app_version": "1.0",
  61. "app_build": "1",
  62. "in_foreground": True,
  63. "view_names": ["Home"],
  64. "permissions": {
  65. "ACCESS_NETWORK_STATE": "granted",
  66. "ACCESS_WIFI_STATE": "granted",
  67. "DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION": "granted",
  68. "INTERNET": "granted",
  69. "SYSTEM_ALERT_WINDOW": "not_granted",
  70. },
  71. "type": "app",
  72. },
  73. "device": {
  74. "family": "sdk_gphone64_arm64",
  75. "model": "sdk_gphone64_arm64",
  76. "model_id": "UPB2.230407.019",
  77. "battery_level": 100.0,
  78. "orientation": "portrait",
  79. "manufacturer": "Google",
  80. "brand": "google",
  81. "screen_width_pixels": 1080,
  82. "screen_height_pixels": 2209,
  83. "screen_density": 2.625,
  84. "screen_dpi": 420,
  85. "online": True,
  86. "charging": False,
  87. "low_memory": False,
  88. "simulator": True,
  89. "memory_size": 2074669056,
  90. "free_memory": 607039488,
  91. "storage_size": 6228115456,
  92. "free_storage": 4940427264,
  93. "boot_time": "2024-01-11T09:56:37.070Z",
  94. "timezone": "Europe/Vienna",
  95. "locale": "en_US",
  96. "processor_count": 4,
  97. "processor_frequency": 0,
  98. "archs": ["arm64-v8a"],
  99. "battery_temperature": 25,
  100. "connection_type": "wifi",
  101. "id": "64b13018-2922-4938-92b1-3135861a69c8",
  102. "language": "en",
  103. "type": "device",
  104. },
  105. "os": {
  106. "name": "Android",
  107. "version": "13",
  108. "build": "sdk_gphone64_arm64-userdebug UpsideDownCake UPB2.230407.019 10170211 dev-keys",
  109. "kernel_version": "6.1.21-android14-3-01811-g9e35a21ec03f-ab9850788",
  110. "rooted": False,
  111. "type": "os",
  112. },
  113. },
  114. "logger": "",
  115. "sdk": {
  116. "name": "sentry.javascript.react-native",
  117. "version": "5.15.2",
  118. "integrations": [
  119. "ModulesLoader",
  120. "ReactNativeErrorHandlers",
  121. "Release",
  122. "InboundFilters",
  123. "FunctionToString",
  124. "Breadcrumbs",
  125. "HttpContext",
  126. "NativeLinkedErrors",
  127. "EventOrigin",
  128. "SdkInfo",
  129. "ReactNativeInfo",
  130. "DebugSymbolicator",
  131. "RewriteFrames",
  132. "DeviceContext",
  133. "HermesProfiling",
  134. "ReactNativeTracing",
  135. "Screenshot",
  136. "ViewHierarchy",
  137. "HttpClient",
  138. "react-navigation-v5",
  139. "ReactNativeUserInteractionTracing",
  140. "ReactNativeProfiler",
  141. "TouchEventBoundary",
  142. ],
  143. "packages": [
  144. {"name": "sentry.java.android.react-native", "version": "6.34.0"},
  145. {"name": "npm:@sentry/react-native", "version": "5.15.2"},
  146. ],
  147. },
  148. "timestamp": 1704969036.875,
  149. "type": "error",
  150. "user": {
  151. "email": "philipp@example.com",
  152. "ip_address": "85.193.160.231",
  153. "geo": {
  154. "country_code": "AT",
  155. "city": "Diersbach",
  156. "subdivision": "Upper Austria",
  157. "region": "Austria",
  158. },
  159. },
  160. "version": "7",
  161. }
  162. result.update(kwargs)
  163. return result