def extract_promoted_contexts( self, output: MutableMapping[str, Any], contexts: Mapping[str, Any], tags: Mapping[str, Any], ) -> None: app_ctx = contexts.get("app", None) or {} output["app_device"] = _unicodify(tags.get("app.device", None)) app_ctx.pop("device_app_hash", None) # tag=app.device os_ctx = contexts.get("os", None) or {} output["os"] = _unicodify(tags.get("os", None)) output["os_name"] = _unicodify(tags.get("os.name", None)) os_ctx.pop("name", None) # tag=os and/or os.name os_ctx.pop("version", None) # tag=os output["os_rooted"] = _boolify(tags.get("os.rooted", None)) os_ctx.pop("rooted", None) # tag=os.rooted output["os_build"] = _unicodify(os_ctx.pop("build", None)) output["os_kernel_version"] = _unicodify( os_ctx.pop("kernel_version", None)) runtime_ctx = contexts.get("runtime", None) or {} output["runtime"] = _unicodify(tags.get("runtime", None)) output["runtime_name"] = _unicodify(tags.get("runtime.name", None)) runtime_ctx.pop("name", None) # tag=runtime and/or runtime.name runtime_ctx.pop("version", None) # tag=runtime browser_ctx = contexts.get("browser", None) or {} output["browser"] = _unicodify(tags.get("browser", None)) output["browser_name"] = _unicodify(tags.get("browser.name", None)) browser_ctx.pop("name", None) # tag=browser and/or browser.name browser_ctx.pop("version", None) # tag=browser device_ctx = contexts.get("device", None) or {} output["device"] = _unicodify(tags.get("device", None)) device_ctx.pop("model", None) # tag=device output["device_family"] = _unicodify(tags.get("device.family", None)) device_ctx.pop("family", None) # tag=device.family output["device_name"] = _unicodify(device_ctx.pop("name", None)) output["device_brand"] = _unicodify(device_ctx.pop("brand", None)) output["device_locale"] = _unicodify(device_ctx.pop("locale", None)) output["device_uuid"] = _unicodify(device_ctx.pop("uuid", None)) output["device_model_id"] = _unicodify(device_ctx.pop( "model_id", None)) output["device_arch"] = _unicodify(device_ctx.pop("arch", None)) output["device_battery_level"] = _floatify( device_ctx.pop("battery_level", None)) output["device_orientation"] = _unicodify( device_ctx.pop("orientation", None)) output["device_simulator"] = _boolify(device_ctx.pop( "simulator", None)) output["device_online"] = _boolify(device_ctx.pop("online", None)) output["device_charging"] = _boolify(device_ctx.pop("charging", None))
def extract_promoted_contexts(self, output, contexts, tags): app_ctx = contexts.get('app', None) or {} output['app_device'] = _unicodify(tags.get('app.device', None)) app_ctx.pop('device_app_hash', None) # tag=app.device os_ctx = contexts.get('os', None) or {} output['os'] = _unicodify(tags.get('os', None)) output['os_name'] = _unicodify(tags.get('os.name', None)) os_ctx.pop('name', None) # tag=os and/or os.name os_ctx.pop('version', None) # tag=os output['os_rooted'] = _boolify(tags.get('os.rooted', None)) os_ctx.pop('rooted', None) # tag=os.rooted output['os_build'] = _unicodify(os_ctx.pop('build', None)) output['os_kernel_version'] = _unicodify( os_ctx.pop('kernel_version', None)) runtime_ctx = contexts.get('runtime', None) or {} output['runtime'] = _unicodify(tags.get('runtime', None)) output['runtime_name'] = _unicodify(tags.get('runtime.name', None)) runtime_ctx.pop('name', None) # tag=runtime and/or runtime.name runtime_ctx.pop('version', None) # tag=runtime browser_ctx = contexts.get('browser', None) or {} output['browser'] = _unicodify(tags.get('browser', None)) output['browser_name'] = _unicodify(tags.get('browser.name', None)) browser_ctx.pop('name', None) # tag=browser and/or browser.name browser_ctx.pop('version', None) # tag=browser device_ctx = contexts.get('device', None) or {} output['device'] = _unicodify(tags.get('device', None)) device_ctx.pop('model', None) # tag=device output['device_family'] = _unicodify(tags.get('device.family', None)) device_ctx.pop('family', None) # tag=device.family output['device_name'] = _unicodify(device_ctx.pop('name', None)) output['device_brand'] = _unicodify(device_ctx.pop('brand', None)) output['device_locale'] = _unicodify(device_ctx.pop('locale', None)) output['device_uuid'] = _unicodify(device_ctx.pop('uuid', None)) output['device_model_id'] = _unicodify(device_ctx.pop( 'model_id', None)) output['device_arch'] = _unicodify(device_ctx.pop('arch', None)) output['device_battery_level'] = _floatify( device_ctx.pop('battery_level', None)) output['device_orientation'] = _unicodify( device_ctx.pop('orientation', None)) output['device_simulator'] = _boolify(device_ctx.pop( 'simulator', None)) output['device_online'] = _boolify(device_ctx.pop('online', None)) output['device_charging'] = _boolify(device_ctx.pop('charging', None))
def extract_stacktraces(self, output, stacks): stack_types = [] stack_values = [] stack_mechanism_types = [] stack_mechanism_handled = [] frame_abs_paths = [] frame_filenames = [] frame_packages = [] frame_modules = [] frame_functions = [] frame_in_app = [] frame_colnos = [] frame_linenos = [] frame_stack_levels = [] stack_level = 0 for stack in stacks: if stack is None: continue stack_types.append(_unicodify(stack.get('type', None))) stack_values.append(_unicodify(stack.get('value', None))) mechanism = stack.get('mechanism', None) or {} stack_mechanism_types.append( _unicodify(mechanism.get('type', None))) stack_mechanism_handled.append( _boolify(mechanism.get('handled', None))) frames = (stack.get('stacktrace', None) or {}).get('frames', None) or [] for frame in frames: if frame is None: continue frame_abs_paths.append(_unicodify(frame.get('abs_path', None))) frame_filenames.append(_unicodify(frame.get('filename', None))) frame_packages.append(_unicodify(frame.get('package', None))) frame_modules.append(_unicodify(frame.get('module', None))) frame_functions.append(_unicodify(frame.get('function', None))) frame_in_app.append(frame.get('in_app', None)) frame_colnos.append(_collapse_uint32(frame.get('colno', None))) frame_linenos.append( _collapse_uint32(frame.get('lineno', None))) frame_stack_levels.append(stack_level) stack_level += 1 output['exception_stacks.type'] = stack_types output['exception_stacks.value'] = stack_values output['exception_stacks.mechanism_type'] = stack_mechanism_types output['exception_stacks.mechanism_handled'] = stack_mechanism_handled output['exception_frames.abs_path'] = frame_abs_paths output['exception_frames.filename'] = frame_filenames output['exception_frames.package'] = frame_packages output['exception_frames.module'] = frame_modules output['exception_frames.function'] = frame_functions output['exception_frames.in_app'] = frame_in_app output['exception_frames.colno'] = frame_colnos output['exception_frames.lineno'] = frame_linenos output['exception_frames.stack_level'] = frame_stack_levels
def extract_stacktraces(self, output: MutableMapping[str, Any], stacks: Sequence[Any]) -> None: stack_types = [] stack_values = [] stack_mechanism_types = [] stack_mechanism_handled = [] frame_abs_paths = [] frame_filenames = [] frame_packages = [] frame_modules = [] frame_functions = [] frame_in_app = [] frame_colnos = [] frame_linenos = [] frame_stack_levels = [] if output["project_id"] not in settings.PROJECT_STACKTRACE_BLACKLIST: stack_level = 0 for stack in stacks: if stack is None: continue stack_types.append(_unicodify(stack.get("type", None))) stack_values.append(_unicodify(stack.get("value", None))) mechanism = stack.get("mechanism", None) or {} stack_mechanism_types.append( _unicodify(mechanism.get("type", None))) stack_mechanism_handled.append( _boolify(mechanism.get("handled", None))) frames = (stack.get("stacktrace", None) or {}).get( "frames", None) or [] for frame in frames: if frame is None: continue frame_abs_paths.append( _unicodify(frame.get("abs_path", None))) frame_filenames.append( _unicodify(frame.get("filename", None))) frame_packages.append( _unicodify(frame.get("package", None))) frame_modules.append(_unicodify(frame.get("module", None))) frame_functions.append( _unicodify(frame.get("function", None))) frame_in_app.append(frame.get("in_app", None)) frame_colnos.append( _collapse_uint32(frame.get("colno", None))) frame_linenos.append( _collapse_uint32(frame.get("lineno", None))) frame_stack_levels.append(stack_level) stack_level += 1 output["exception_stacks.type"] = stack_types output["exception_stacks.value"] = stack_values output["exception_stacks.mechanism_type"] = stack_mechanism_types output["exception_stacks.mechanism_handled"] = stack_mechanism_handled output["exception_frames.abs_path"] = frame_abs_paths output["exception_frames.filename"] = frame_filenames output["exception_frames.package"] = frame_packages output["exception_frames.module"] = frame_modules output["exception_frames.function"] = frame_functions output["exception_frames.in_app"] = frame_in_app output["exception_frames.colno"] = frame_colnos output["exception_frames.lineno"] = frame_linenos output["exception_frames.stack_level"] = frame_stack_levels