UNPKG

@dynatrace/react-native-plugin

Version:

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

28 lines (27 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createViewInfo = void 0; const VIEW_ID_LENGTH = 16; const MAX_HEXADECIMAL_VALUE = 16; const ASCII_CODE_NUMERIC_0 = 48; const ASCII_CODE_A = 65; const NUMERICAL_CHARACTER_COUNT = 10; const OFFSET_A = ASCII_CODE_A - NUMERICAL_CHARACTER_COUNT; const createViewInfo = (name) => ({ ["view.id"]: createRandomHexString(VIEW_ID_LENGTH), ["view.name"]: name, }); exports.createViewInfo = createViewInfo; const createRandomHexString = (length) => createRandomString(length, MAX_HEXADECIMAL_VALUE); const createRandomString = (length, maxRange) => { const resultArray = Array(length); for (let i = 0; i < length; i++) { const randomInRange = Math.floor(Math.random() * maxRange); const character = String.fromCharCode(randomInRange + (randomInRange < NUMERICAL_CHARACTER_COUNT ? ASCII_CODE_NUMERIC_0 : OFFSET_A)); resultArray.push(character); } return resultArray.join(''); };