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