crash_event_react_native.py 6.6 KB

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