@logbrew/react-native 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ constexpr size_t kProjectChars = 36;
26
26
  constexpr size_t kReleaseChars = 256;
27
27
  constexpr size_t kEnvironmentChars = 128;
28
28
  constexpr size_t kServiceChars = 128;
29
- constexpr size_t kMaxModules = 192;
29
+ constexpr size_t kMaxModules = 4096;
30
30
  constexpr std::array<int, 6> kSignals = {SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP};
31
31
 
32
32
  #pragma pack(push, 1)
@@ -57,6 +57,7 @@ struct Module {
57
57
 
58
58
  std::array<Module, kMaxModules> g_modules{};
59
59
  size_t g_module_count = 0;
60
+ bool g_module_overflow = false;
60
61
  std::array<struct sigaction, kSignals.size()> g_previous_actions{};
61
62
  std::array<char, 1024> g_record_path{};
62
63
  SignalRecord g_record_template{};
@@ -111,6 +112,7 @@ bool read_build_id(const dl_phdr_info* info, std::array<uint8_t, 16>* output) {
111
112
 
112
113
  int collect_module(dl_phdr_info* info, size_t, void*) {
113
114
  if (g_module_count == g_modules.size()) {
115
+ g_module_overflow = true;
114
116
  return 1;
115
117
  }
116
118
  uintptr_t start = UINTPTR_MAX;
@@ -329,7 +331,12 @@ Java_co_logbrew_reactnative_AndroidDiagnosticsRuntime_nativeInstall(
329
331
  g_record_template.magic = kMagic;
330
332
  g_record_template.version = kVersion;
331
333
  g_module_count = 0;
334
+ g_module_overflow = false;
332
335
  dl_iterate_phdr(collect_module, nullptr);
336
+ if (g_module_overflow) {
337
+ g_installed.store(false);
338
+ return JNI_FALSE;
339
+ }
333
340
  struct sigaction action {};
334
341
  sigemptyset(&action.sa_mask);
335
342
  action.sa_sigaction = signal_handler;
@@ -185,7 +185,7 @@ final class AndroidNativeDiagnostics {
185
185
  nextId("java"),
186
186
  System.currentTimeMillis(),
187
187
  "Native application crash",
188
- "fatal",
188
+ "critical",
189
189
  safeSymbol(error == null ? null : error.getClass().getName(), 256, "AndroidJavaCrash"),
190
190
  "uncaught_exception",
191
191
  0,
@@ -221,7 +221,7 @@ final class AndroidNativeDiagnostics {
221
221
  record.id,
222
222
  record.timestampMs,
223
223
  "Native application crash",
224
- "fatal",
224
+ "critical",
225
225
  "AndroidNativeCrash",
226
226
  "signal",
227
227
  0,
@@ -244,8 +244,15 @@ final class AndroidNativeDiagnostics {
244
244
  output.append("{\"type\":\"issue\",\"id\":\"").append(id)
245
245
  .append("\",\"timestamp\":\"").append(timestamp(timestampMs))
246
246
  .append("\",\"attributes\":{\"title\":\"").append(title)
247
- .append("\",\"level\":\"").append(level)
248
- .append("\",\"exception\":{\"type\":\"").append(exceptionType)
247
+ .append("\",\"level\":\"").append(level).append('"');
248
+ appendJavaFrames(output, frames);
249
+ if (nativeFrame != null) {
250
+ output.append(",\"nativeStackFrames\":[{\"imageUuid\":\"")
251
+ .append(nativeFrame.imageUuid).append("\",\"architecture\":\"")
252
+ .append(nativeFrame.architecture).append("\",\"instructionOffset\":\"")
253
+ .append(nativeFrame.instructionOffset).append("\"}]");
254
+ }
255
+ output.append(",\"exception\":{\"type\":\"").append(exceptionType)
249
256
  .append("\",\"mechanism\":{\"type\":\"").append(mechanism)
250
257
  .append("\",\"handled\":false}},\"metadata\":{")
251
258
  .append("\"crash.mechanism\":\"").append(mechanism)
@@ -262,17 +269,11 @@ final class AndroidNativeDiagnostics {
262
269
  }
263
270
  output.append('}');
264
271
  appendContext(output, eventConfiguration);
265
- appendJavaFrames(output, frames);
266
- if (nativeFrame != null) {
267
- output.append(",\"nativeStackFrames\":[{\"imageUuid\":\"")
268
- .append(nativeFrame.imageUuid).append("\",\"architecture\":\"")
269
- .append(nativeFrame.architecture).append("\",\"instructionOffset\":\"")
270
- .append(nativeFrame.instructionOffset).append("\"}]");
271
- }
272
272
  return output.append("}}").toString();
273
273
  }
274
274
 
275
275
  private static void appendJavaFrames(StringBuilder output, StackTraceElement[] frames) {
276
+ int start = output.length();
276
277
  output.append(",\"stackFrames\":[");
277
278
  int count = 0;
278
279
  for (StackTraceElement frame : frames) {
@@ -294,11 +295,15 @@ final class AndroidNativeDiagnostics {
294
295
  .append(json(safeSymbol(frame.getClassName(), 512, "unknown"))).append("\"}");
295
296
  count += 1;
296
297
  }
297
- output.append(']');
298
+ if (count == 0) {
299
+ output.setLength(start);
300
+ } else {
301
+ output.append(']');
302
+ }
298
303
  }
299
304
 
300
305
  private static void appendContext(StringBuilder output, Configuration value) {
301
- output.append(",\"context\":{\"resource\":{\"service\":{\"name\":\"")
306
+ output.append(",\"context\":{\"schemaVersion\":1,\"resource\":{\"service\":{\"name\":\"")
302
307
  .append(json(value.service)).append("\"},\"deployment\":{\"environment\":\"")
303
308
  .append(json(value.environment)).append("\",\"release\":\"")
304
309
  .append(json(value.release)).append("\"},\"operatingSystem\":{\"name\":\"Android\",\"version\":\"")
@@ -321,16 +326,16 @@ final class AndroidNativeDiagnostics {
321
326
 
322
327
  private static String safeFilename(String value) {
323
328
  String safe = safeSymbol(value, 256, null);
324
- return safe == null || safe.contains("/") || safe.contains("\\") ? null : safe;
329
+ return safe == null || safe.contains("/") || safe.contains("\\") || safe.contains("?") || safe.contains("#") ? null : safe;
325
330
  }
326
331
 
327
332
  private static String safeSymbol(String value, int maximum, String fallback) {
328
333
  return value == null
329
- || value.isEmpty()
334
+ || value.trim().isEmpty()
330
335
  || value.length() > maximum
331
336
  || value.chars().anyMatch(character -> character <= 31 || character == 127)
332
337
  ? fallback
333
- : value;
338
+ : value.trim();
334
339
  }
335
340
 
336
341
  private static String json(String value) {
package/index.cjs CHANGED
@@ -16,7 +16,7 @@ const {
16
16
  } = require("./metadata.cjs");
17
17
 
18
18
  const DEFAULT_SDK_NAME = "logbrew-react-native";
19
- const DEFAULT_SDK_VERSION = "0.1.24";
19
+ const DEFAULT_SDK_VERSION = "0.1.26";
20
20
  const DEFAULT_ENDPOINT = "https://api.logbrew.co/v1/events";
21
21
  const NATIVE_RANDOM_HEX = Symbol.for("co.logbrew.react-native.secure-random-hex");
22
22
  const MAX_ACTION_NAME_LENGTH = 64;
@@ -3,7 +3,7 @@ import Foundation
3
3
  @objc(LBRNAppleNativeDiagnostics)
4
4
  public final class LBRNAppleNativeDiagnostics: NSObject, @unchecked Sendable {
5
5
  private static let shared = LBRNAppleNativeDiagnostics()
6
- private static let sdkVersion = "0.1.24"
6
+ private static let sdkVersion = "0.1.26"
7
7
 
8
8
  private let lock = NSLock()
9
9
  private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logbrew/react-native",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "React Native offline delivery, native diagnostics, screen, error, trace, action, and network timeline helpers for LogBrew.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
@@ -252,7 +252,7 @@
252
252
  "url": "git+https://github.com/LogBrewCo/sdk.git"
253
253
  },
254
254
  "peerDependencies": {
255
- "@logbrew/sdk": "^0.1.15",
255
+ "@logbrew/sdk": "^0.1.20",
256
256
  "expo": ">=49",
257
257
  "react": ">=18",
258
258
  "react-native": ">=0.72"