UNPKG

@dynatrace/react-native-plugin

Version:

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

40 lines (39 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RefreshControlHelper = void 0; const IDynatraceProperties_1 = require("../IDynatraceProperties"); const RefreshControlHelper = (Dynatrace) => ({ attachOnRefresh: (refreshControlProps) => { if ((0, IDynatraceProperties_1.isDynatraceIgnored)(refreshControlProps)) { return; } const origOnRefresh = refreshControlProps.onRefresh; const nameOfAction = _findActionName(refreshControlProps); if (origOnRefresh != null) { refreshControlProps.onRefresh = () => { const finalNameOfAction = nameOfAction == null ? 'Swipe to Refesh' : `Swipe to Refesh ${nameOfAction}`; const action = Dynatrace.enterAutoAction(finalNameOfAction); try { if (origOnRefresh != null) { origOnRefresh(); } } finally { action.leaveAction(); } }; } }, }); exports.RefreshControlHelper = RefreshControlHelper; const _findActionName = (refreshControlProps) => { if ((0, IDynatraceProperties_1.isDynatraceNaming)(refreshControlProps)) { return refreshControlProps.dtActionName; } else if (refreshControlProps.accessibilityLabel != null) { return refreshControlProps.accessibilityLabel; } return null; };