UNPKG

@dynatrace/react-native-plugin

Version:

This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.

78 lines (77 loc) 2.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAppStartEvent = exports.createErrorEvent = exports.createErrorCodeEvent = exports.createCrashEvent = void 0; const AppStartType_1 = require("../appstart/AppStartType"); const createCrashEvent = (type, message, stacktrace, isFatal) => { const event = { 'characteristics.has_crash': true, 'characteristics.has_error': true, 'error.is_fatal': isFatal, }; if (type != null) { event["exception.type"] = type; } if (message != null) { event["exception.message"] = message; } if (stacktrace != null) { event["exception.stack_trace"] = stacktrace; } return event; }; exports.createCrashEvent = createCrashEvent; const createErrorCodeEvent = (errorName, errorCode) => { const event = { 'characteristics.has_error': true, 'error.is_fatal': false, }; if (errorName != null) { event["name"] = errorName; } if (errorCode != null) { event["error.code"] = errorCode; } return event; }; exports.createErrorCodeEvent = createErrorCodeEvent; const createErrorEvent = (type, message, stacktrace) => { const event = { 'characteristics.has_error': true, 'characteristics.has_exception': true, 'error.is_fatal': false, }; if (type != null) { event["exception.type"] = type; } if (message != null) { event["exception.message"] = message; } if (stacktrace != null) { event["exception.stack_trace"] = stacktrace; } return event; }; exports.createErrorEvent = createErrorEvent; const createAppStartEvent = (appStartMeasurements) => { const event = { 'characteristics.is_app_start': true, }; let timings = []; for (const { type, key } of AppStartType_1.AppStartTypeKeyMapping) { if (appStartMeasurements[type] !== undefined) { event[key] = appStartMeasurements[type]; timings.push(appStartMeasurements[type]); } } timings = timings.sort((a, b) => a - b); if (timings.length > 0) { event["start_time"] = timings[0]; event["duration"] = timings[timings.length - 1] - timings[0]; } else { return null; } return event; }; exports.createAppStartEvent = createAppStartEvent;