You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-73Lines changed: 29 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@
6
6
7
7
This plugin allows you to instrument .NET MAUI mobile apps with help of native New Relic Android and iOS Bindings. The New Relic SDKs collect crashes, network traffic, and other information for hybrid apps using native components.
The .NET MAUI mobile plugin allows you to track navigation events within the [.NET MAUI Shell](https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/navigation). In order to do so, you only need to call:
91
+
The .NET MAUI mobile plugin allows you to track navigation events within the [.NET MAUI Shell](https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/navigation). There are two ways to initialize this depending on your app's startup timing.
98
92
93
+
**Option 1: In the App Constructor**
94
+
You can call the tracking method directly in the constructor immediately after setting the `MainPage`.
**Option 2: In the OnStart Method (Recommended for timing/NullReferenceException issues)**
105
+
If your application shell is not fully initialized during the constructor execution, calling the navigation tracker may result in a `System.NullReferenceException`. To avoid this, move the call into the MAUI `OnStart()` lifecycle method:
It is recommended to call this method along when starting the agent. These events will only be recorded after navigation is complete. You can find this data through the data explorer in `MobileBreadcrumb` under the name `ShellNavigated` or by query:
120
+
These events will only be recorded after navigation is complete. You can find this data through the data explorer in `MobileBreadcrumb` under the name `ShellNavigated` or by query:
111
121
112
122
```sql
113
123
SELECT*FROM MobileBreadcrumb WHERE name ='ShellNavigated' SINCE 24 HOURS AGO
@@ -122,41 +132,31 @@ The breadcrumb will contain three attributes:
122
132
123
133
See the examples below, and for more detail,
124
134
see [New Relic iOS SDK doc](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/ios-sdk-api)
125
-
or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api)
126
-
.
135
+
or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api).
### [NoticeHttpTransaction](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api/notice-http-transaction/)(string url, string httpMethod, int statusCode, long startTime,long endTime, long bytesSent, long bytesReceived, string responseBody): void;
174
-
175
172
> Tracks network requests manually. You can use this method to record HTTP transactions, with an option to also send a response body.
176
-
177
173
```C#
178
174
CrossNewRelic.Current.NoticeHttpTransaction(
179
175
"https://newrelic.com",
@@ -188,9 +184,7 @@ or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobi
188
184
```
189
185
190
186
### [NoticeNetworkFailure](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api/notice-network-failure/)(string url, string httpMethod, int statusCode, long startTime,long endTime, long bytesSent, long bytesReceived, string responseBody): void;
191
-
192
187
> Records network failures. If a network request fails, use this method to record details about the failure.
193
-
194
188
```C#
195
189
CrossNewRelic.Current.NoticeNetworkFailure(
196
190
"https://fakewebsite.com",
@@ -202,9 +196,7 @@ or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobi
> Sets the maximum size of total data that can be stored for offline storage.By default, mobile monitoring can collect a maximum of 100 megaBytes of offline storage.
362
325
> When a data payload fails to send because the device doesn't have an internet connection, it can be stored in the file system until an internet connection has been made.
363
326
> After a typical harvest payload has been successfully sent, all offline data is sent to New Relic and cleared from storage.
@@ -366,7 +329,6 @@ or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobi
366
329
```
367
330
368
331
### LogInfo(String message) : void
369
-
370
332
> Logs an informational message to the New Relic log.
371
333
```C#
372
334
CrossNewRelic.Current.LogInfo("This is an informational message");
@@ -377,6 +339,7 @@ or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobi
377
339
```C#
378
340
CrossNewRelic.Current.LogError("This is an error message");
379
341
```
342
+
380
343
### LogVerbose(String message) : void
381
344
> Logs a verbose message to the New Relic log.
382
345
```C#
@@ -414,12 +377,12 @@ or [Android SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobi
414
377
}
415
378
);
416
379
```
380
+
417
381
## Error reporting
418
382
419
383
This plugin provides a handler to record unhandled exceptions to New Relic. It is recommended to initialize the handler prior to starting the agent.
@@ -442,42 +405,35 @@ This plugin also provides a method to manually record any handled exceptions as
442
405
}
443
406
```
444
407
445
-
446
408
## Troubleshooting
447
409
448
410
-### No Http data appears:
449
411
- To instrument http data, make sure to use the HttpMessageHandler in HttpClient.
450
412
451
-
452
413
-### Crash reports may not be sent when ProGuard rules are not properly configured for New Relic in hybrid Android applications
453
414
- Ensure proper ProGuard rules are added to your ProGuard configuration file. See ["Configuring ProGuard Rules"](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/configure-proguard-or-dexguard-android-apps/) in setup documentation.
454
415
455
-
-### App Crashes When Adding `TrackNavigation` Method in `MauiProgram` or `AppShell` File
456
-
- If you experience a crash in this scenario, ensure that the `TrackShellNavigatedEvents` method is called after setting the `MainPage` in the `App` constructor.
416
+
-### App Crashes or Throws NullReferenceException with `TrackShellNavigatedEvents`
417
+
- If you experience a `System.NullReferenceException` when calling `CrossNewRelic.Current.TrackShellNavigatedEvents()`in the `App()` constructor, it is likely because the application shell is not fully bootstrapped yet. To resolve this, move the call out of the constructor and into the MAUI `OnStart()` lifecycle method within your `App.xaml.cs` file (see the **Screen Tracking Events** section for code examples).
457
418
458
419
## Support
459
420
460
421
New Relic hosts and moderates an online forum where customers, users, maintainers, contributors, and New Relic employees can discuss and collaborate:
We encourage your contributions to improve [project name]! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
467
-
468
427
If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.
469
428
470
429
**A note about vulnerabilities**
471
-
472
430
As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
473
-
474
431
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
475
-
476
432
If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
477
-
478
433
To all contributors, we thank you! Without your contribution, this project would not be what it is today.
479
434
480
435
## License
436
+
481
437
Except as described below, the `newrelic-maui-plugin` is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
482
438
483
439
The [New Relic XCFramework agent] (/docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/get-started/introduction-new-relic-mobile-ios/) is licensed under the [New Relic Agent Software Notice] (/docs.newrelic.com/docs/licenses/license-information/distributed-licenses/new-relic-agent-software-notice/).
0 commit comments