UNPKG

@dynatrace/react-native-plugin

Version:

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

73 lines (72 loc) 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigurationBuilder = void 0; const Configuration_1 = require("./Configuration"); const ConfigurationDefaults_1 = require("./ConfigurationDefaults"); const ConfigurationPreset_1 = require("./ConfigurationPreset"); class ConfigurationBuilder { constructor(beaconUrl, applicationId) { this.beaconUrl = ''; this.applicationId = ''; this.beaconUrl = beaconUrl; this.applicationId = applicationId; const preset = new ConfigurationPreset_1.ConfigurationPreset(); this.reportCrash = ConfigurationDefaults_1.DEFAULT_REPORT_CRASH; this.errorHandler = preset.isErrorHandlerEnabled(); this.reportFatalErrorAsCrash = preset.isReportFatalErrorAsCrash(); this.logLevel = preset.getLogLevel(); this.lifecycleUpdate = preset.getLifecycleUpdate(); this.userOptIn = ConfigurationDefaults_1.DEFAULT_USER_OPT_IN; this.actionNamePrivacy = preset.getActionNamePrivacy(); this.bundleName = preset.getBundleName(); this.bundleVersion = preset.getBundleVersion(); this.autoStartup = preset.isAutoStartupEnabled(); } withCrashReporting(reportCrash) { this.reportCrash = reportCrash; return this; } withErrorHandler(errorHandler) { this.errorHandler = errorHandler; return this; } withReportFatalErrorAsCrash(reportFatalErrorAsCrash) { this.reportFatalErrorAsCrash = reportFatalErrorAsCrash; return this; } withLogLevel(logLevel) { this.logLevel = logLevel; return this; } withLifecycleUpdate(lifecycleUpdate) { this.lifecycleUpdate = lifecycleUpdate; return this; } withUserOptIn(userOptIn) { this.userOptIn = userOptIn; return this; } withActionNamePrivacy(actionNamePrivacy) { this.actionNamePrivacy = actionNamePrivacy; return this; } withBundleName(bundleName) { this.bundleName = bundleName; return this; } withBundleVersion(bundleVersion) { this.bundleVersion = bundleVersion; return this; } buildConfiguration() { if (!this.autoStartup && this.beaconUrl.length === 0) { throw new Error('beaconUrl configuration property is empty. This configuration is not possible! Please use a proper beacon URL.'); } if (!this.autoStartup && this.applicationId.length === 0) { throw new Error('applicationId configuration property is empty. ' + 'This configuration is not possible! Please use a proper application ID.'); } return new Configuration_1.Configuration(this.beaconUrl, this.applicationId, this.reportCrash, this.errorHandler, this.reportFatalErrorAsCrash, this.logLevel, this.lifecycleUpdate, this.userOptIn, this.actionNamePrivacy, this.bundleName, this.bundleVersion); } } exports.ConfigurationBuilder = ConfigurationBuilder;