|
| 1 | +import 'expo-router/entry'; |
| 2 | +import { Platform } from 'react-native'; |
| 3 | + |
| 4 | +// Initialize New Relic agent |
| 5 | +try { |
| 6 | + const NewRelic = require('newrelic-react-native-agent'); |
| 7 | + const { version } = require('./package.json'); |
| 8 | + |
| 9 | + // New Relic tokens for iOS and Android |
| 10 | + let appToken; |
| 11 | + |
| 12 | + if (Platform.OS === 'ios') { |
| 13 | + appToken = 'AA4947ff8556e29649729eb4a51ec43c236e936603-NRMA'; |
| 14 | + } else { |
| 15 | + appToken = 'AAd9a8f7117b043a06ea91e7f4afb65cf34344223f-NRMA'; |
| 16 | + } |
| 17 | + |
| 18 | + const agentConfiguration = { |
| 19 | + // Android Specific |
| 20 | + // Optional: Enable or disable collection of event data. |
| 21 | + analyticsEventEnabled: true, |
| 22 | + |
| 23 | + // Optional: Enable or disable crash reporting. |
| 24 | + crashReportingEnabled: true, |
| 25 | + |
| 26 | + // Optional: Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested. |
| 27 | + // This will disable default and custom interactions. |
| 28 | + interactionTracingEnabled: true, |
| 29 | + |
| 30 | + // Optional: Enable or disable reporting successful HTTP requests to the MobileRequest event type. |
| 31 | + networkRequestEnabled: true, |
| 32 | + |
| 33 | + // Optional: Enable or disable reporting network and HTTP request errors to the MobileRequestError event type. |
| 34 | + networkErrorRequestEnabled: true, |
| 35 | + |
| 36 | + // Optional: Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events. |
| 37 | + httpResponseBodyCaptureEnabled: true, |
| 38 | + |
| 39 | + // Optional: Enable or disable agent logging. |
| 40 | + loggingEnabled: true, |
| 41 | + |
| 42 | + // Optional: Specifies the log level. Omit this field for the default log level. |
| 43 | + // Options include: ERROR (least verbose), WARNING, INFO, VERBOSE, AUDIT (most verbose). |
| 44 | + logLevel: NewRelic.LogLevel.INFO, |
| 45 | + |
| 46 | + // iOS Specific |
| 47 | + // Optional: Enable/Disable automatic instrumentation of WebViews |
| 48 | + webViewInstrumentation: true, |
| 49 | + |
| 50 | + // Optional: Set a specific collector address for sending data. Omit this field for default address. |
| 51 | + // collectorAddress: "", |
| 52 | + |
| 53 | + // Optional: Set a specific crash collector address for sending crashes. Omit this field for default address. |
| 54 | + // crashCollectorAddress: "" |
| 55 | + }; |
| 56 | + |
| 57 | + // Initialize New Relic agent |
| 58 | + if (NewRelic && NewRelic.startAgent) { |
| 59 | + NewRelic.startAgent(appToken, agentConfiguration); |
| 60 | + NewRelic.setJSAppVersion(version); |
| 61 | + } |
| 62 | +} catch (error) { |
| 63 | + // Silently fail if New Relic initialization fails |
| 64 | +} |
0 commit comments