-
-
Notifications
You must be signed in to change notification settings - Fork 514
feat: Update documentation for .NET 9 and MAUI #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YBTopaz8
wants to merge
17
commits into
parse-community:gh-pages
Choose a base branch
from
YBTopaz8:gh-pages
base: gh-pages
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2637b02
Fully Updated the Parse Docs to Follow The recent updates done.
YBTopaz8 00084bd
More changes
YBTopaz8 a4f24e3
Revisited some methods and updated them to use the latest syntax.
YBTopaz8 e9b98d5
Updated login/signup instructions
YBTopaz8 f0dcb96
More updates. Now on objects
YBTopaz8 8900fd0
Included Mentions of .NET MAUI as we do support the platform fully too
YBTopaz8 15b52b0
Delete assets/symbols.svg
YBTopaz8 4da3632
Update _includes/dotnet/analytics.md
YBTopaz8 c7b4a62
Update _includes/dotnet/analytics.md
YBTopaz8 aaaba1b
refactor
mtrezza 8f74c3f
Update files.md
mtrezza 2aac330
Merge branch 'gh-pages' into gh-pages
mtrezza 47ad8a1
Added back symbols file
YBTopaz8 bba81b8
Reverted to previous wordings and only updated code/examples
YBTopaz8 5cf86ac
Reverted Changes done to queries and updated syntax only (removed mkd…
YBTopaz8 69123cb
Likewise with roles
YBTopaz8 88c444d
Updated Users too
YBTopaz8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,108 @@ | ||
# Analytics | ||
|
||
Parse provides a number of hooks for you to get a glimpse into the ticking heart of your app. We understand that it's important to understand what your app is doing, how frequently, and when. | ||
Parse provides tools to gain insights into your app's activity. You can track app launches, custom events, and more. These analytics are available even if you primarily use Parse for data storage. Your app's dashboard provides real-time graphs and breakdowns (by device type, class name, or REST verb) of API requests, and you can save graph filters. | ||
|
||
While this section will cover different ways to instrument your app to best take advantage of Parse's analytics backend, developers using Parse to store and retrieve data can already take advantage of metrics on Parse. | ||
## App-Open Analytics | ||
|
||
Without having to implement any client-side logic, you can view real-time graphs and breakdowns (by device type, Parse class name, or REST verb) of your API Requests in your app's dashboard and save these graph filters to quickly access just the data you're interested in. | ||
Track application launches by calling `TrackAppOpenedAsync()` in your app's launch event handler. This provides data on when and how often your app is opened. Since MAUI does not have a single, clear "launching" event like some other platforms, the best place to put this call is in your `App.xaml.cs` constructor, *after* initializing the Parse client: | ||
|
||
## App-Open / Push Analytics | ||
```csharp | ||
// In App.xaml.cs | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
Our initial analytics hook allows you to track your application being launched. By adding the following line to your Launching event handler, you'll be able to collect data on when and how often your application is opened. | ||
MainPage = new AppShell(); | ||
|
||
```cs | ||
ParseAnalytics.TrackAppOpenedAsync(); | ||
// Initialize Parse Client (See initialization documentation) | ||
if (!InitializeParseClient()) | ||
{ | ||
// Handle initialization failure | ||
Console.WriteLine("Failed to initialize Parse."); | ||
} | ||
else | ||
{ | ||
// Track app open *after* successful Parse initialization. | ||
Task.Run(() => ParseClient.Instance.TrackLaunchAsync()); // Do not await in the constructor. | ||
} | ||
} | ||
``` | ||
|
||
**Important Considerations:** | ||
|
||
* **`Task.Run()`:** We use `Task.Run()` to call `TrackLaunchAsync()` *without* awaiting it in the `App` constructor. This is crucial because the constructor should complete quickly to avoid delaying app startup. `TrackLaunchAsync` will run in the background. If Parse initialization fails, we *don't* track the app open. | ||
* **MAUI Lifecycle:** MAUI's lifecycle events are different from older platforms. There isn't a single, universally appropriate "launching" event. The `App` constructor is generally a good place, *provided* you initialize Parse first and handle potential initialization failures. Other possible locations (depending on your specific needs) might include the `OnStart` method of your `App` class, or the first page's `OnAppearing` method. However, the constructor ensures it's tracked as early as possible. | ||
* **Push Notifications:** If you are using Push Notifications, you'll likely need to handle tracking opens from push notifications separately, in the code that handles the push notification reception and user interaction. This is *not* covered in this basic analytics section (see the Push Notifications documentation). | ||
|
||
## Custom Analytics | ||
|
||
`ParseAnalytics` also allows you to track free-form events, with a handful of `string` keys and values. These extra dimensions allow segmentation of your custom events via your app's Dashboard. | ||
|
||
Say your app offers search functionality for apartment listings, and you want to track how often the feature is used, with some additional metadata. | ||
|
||
```cs | ||
var dimensions = new Dictionary<string, string> { | ||
// Define ranges to bucket data points into meaningful segments | ||
{ "priceRange", "1000-1500" }, | ||
// Did the user filter the query? | ||
{ "source", "craigslist" }, | ||
// Do searches happen more often on weekdays or weekends? | ||
{ "dayType", "weekday" } | ||
}; | ||
// Send the dimensions to Parse along with the 'search' event | ||
ParseAnalytics.TrackEventAsync("search", dimensions); | ||
Track custom events with `TrackAnalyticsEventAsync()`. You can include a dictionary of `string` key-value pairs (dimensions) to segment your events. | ||
|
||
Example: Tracking apartment search usage: | ||
|
||
```csharp | ||
public async Task TrackSearchEventAsync(string priceRange, string source, string dayType) | ||
{ | ||
var dimensions = new Dictionary<string, string> | ||
{ | ||
{ "priceRange", priceRange }, | ||
{ "source", source }, | ||
{ "dayType", dayType } | ||
}; | ||
|
||
try | ||
{ | ||
await ParseClient.Instance.TrackAnalyticsEventAsync("search", dimensions); | ||
} | ||
catch (Exception ex) | ||
{ | ||
// Handle errors (e.g., network issues) | ||
Console.WriteLine($"Analytics tracking failed: {ex.Message}"); | ||
} | ||
} | ||
|
||
// Example usage: | ||
await TrackSearchEventAsync("1000-1500", "craigslist", "weekday"); | ||
|
||
``` | ||
|
||
`ParseAnalytics` can even be used as a lightweight error tracker — simply invoke the following and you'll have access to an overview of the rate and frequency of errors, broken down by error code, in your application: | ||
You can use `TrackAnalyticsEventAsync` for lightweight error tracking: | ||
|
||
```csharp | ||
// Example: Tracking errors | ||
public async Task TrackErrorEventAsync(int errorCode) | ||
{ | ||
var dimensions = new Dictionary<string, string> | ||
{ | ||
{ "code", errorCode.ToString() } | ||
}; | ||
|
||
try | ||
{ | ||
await ParseClient.Instance.TrackAnalyticsEventAsync("error", dimensions); | ||
} | ||
catch (Exception ex) | ||
{ | ||
//It failed.. not much to do, is there? | ||
YBTopaz8 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Console.WriteLine($"Analytics tracking failed: {ex.Message}"); | ||
} | ||
} | ||
|
||
```cs | ||
var errDimensions = new Dictionary<string, string> { | ||
{ "code", Convert.ToString(error.Code) } | ||
}; | ||
ParseAnalytics.TrackEventAsync("error", errDimensions ); | ||
// Example usage (within a catch block): | ||
catch (Exception ex) | ||
{ | ||
// ... other error handling ... | ||
await TrackErrorEventAsync(123); // Replace 123 with a meaningful error code. | ||
} | ||
``` | ||
|
||
Note that Parse currently only stores the first eight dimension pairs per call to `ParseAnalytics.TrackEventAsync()`. | ||
**Limitations:** | ||
|
||
* Parse stores only the first eight dimension pairs per `TrackAnalyticsEventAsync()` call. | ||
|
||
**API Changes and Usage (Key Points):** | ||
|
||
* **`ParseAnalytics.TrackAppOpenedAsync()` is now `ParseClient.Instance.TrackLaunchAsync()`:** The methods are now extension methods on the `IServiceHub` interface, and you access them via `ParseClient.Instance`. | ||
* **`ParseAnalytics.TrackEventAsync()` is now `ParseClient.Instance.TrackAnalyticsEventAsync()`:** Similar to the above, this is now an extension method. | ||
* **Asynchronous Operations:** All analytics methods are asynchronous (`async Task`). Use `await` when calling them (except in specific cases like the `App` constructor, where you should use `Task.Run()` to avoid blocking). | ||
* **Error Handling** Use `try-catch` and handle `Exception`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.