הוספת מעקב מותאם אישית לבקשות רשת ספציפיות (אפליקציות ל-Apple ול-Android)
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Performance Monitoring אוסף עקבות כדי לעזור לכם לעקוב אחרי הביצועים של האפליקציה. עקבה היא דוח של נתוני ביצועים שנאספו בין שתי נקודות זמן באפליקציה.
המעקב אחר בקשות לרשת שנאסף אוטומטית על ידי Performance Monitoring כולל את רוב הבקשות לרשת של האפליקציה. עם זאת, יכול להיות שבקשות מסוימות לא ידווחו, או שתשתמשו בספרייה אחרת כדי לשלוח בקשות לרשת. במקרים כאלה, אפשר להשתמש ב-Performance Monitoring API כדי להגדיר ידנית מעקב אחר בקשות רשת בהתאמה אישית. אפשר להשתמש בנתוני מעקב של בקשות רשת בהתאמה אישית רק באפליקציות ל-Apple ול-Android.
מדדי ברירת המחדל למעקב אחר בקשת רשת מותאמת אישית זהים למדדים של מעקב אחר בקשות רשת שנאספות באופן אוטומטי על ידי Performance Monitoring, כלומר זמן התגובה, גודל מטען הייעודי (payload) של התגובה והבקשה ושיעור ההצלחה. אי אפשר להוסיף מדדים מותאמים אישית למעקב אחרי בקשות רשת בהתאמה אישית.
בקוד, מגדירים את ההתחלה והסוף של מעקב אחר בקשת רשת בהתאמה אישית באמצעות ממשקי ה-API שזמינים ב-Performance Monitoring SDK.
עקבות של בקשות רשת בהתאמה אישית מופיעות במסוף Firebase לצד בקשות הרשת ש-Performance Monitoring מתעד באופן אוטומטי (בכרטיסיית המשנה בקשות רשת בטבלת העקבות).
הוספה של עקבות מותאמים אישית של בקשות רשת
משתמשים ב-Performance Monitoring HTTPMetric API
(Swift
|
Obj-C)
כדי להוסיף מעקב אחרי בקשות רשת בהתאמה אישית, כדי לעקוב אחרי בקשות רשת ספציפיות.
כדי להטמיע באופן ידני בקשות מותאמות אישית לרשת ב-Performance Monitoring, מוסיפים קוד שדומה לקוד הבא:
Swift
הערה: מוצר Firebase הזה לא זמין ב-macOS, ב-Mac Catalyst ובמטרות watchOS.
בנוסף, אפשר להוסיף מאפיינים מותאמים אישית למעקב אחרי בקשות רשת מותאמות אישית (Swift |
Obj-C), אבל אי אפשר להוסיף מדדים מותאמים אישית.
השלבים הבאים
הגדרת התראות לבקשות רשת שפוגעות בביצועים של האפליקציה. לדוגמה, אפשר להגדיר התראה באימייל לצוות אם זמן התגובה לתבנית ספציפית של כתובת URL חורג מסף שהגדרתם.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-09-05 (שעון UTC)."],[],[],null,["\u003cbr /\u003e\n\niOS+ Android Flutter \n\n\u003cbr /\u003e\n\nPerformance Monitoring collects *traces* to help you monitor the performance of your app. A\ntrace is a report of performance data captured between two points in time in\nyour app.\n\nThe\n[network request traces automatically collected by Performance Monitoring](/docs/perf-mon/network-traces)\ninclude most network requests for your app. However, some requests might not be\nreported or you might use a different library to make network requests. In these\ncases, you can use the Performance Monitoring API to manually instrument\n***custom network request traces***. Custom network request traces are only\nsupported for Apple and Android apps.\n\nThe default metrics for a custom network request trace are the same as those for\nthe network request traces automatically collected by Performance Monitoring, specifically\nresponse time, response and request payload size, and success rate. Custom\nnetwork request traces do not support adding custom metrics.\n\nIn your code, you define the beginning and the end of a custom network request\ntrace using the APIs provided by the Performance Monitoring SDK.\n\nCustom network request traces appear in the Firebase console alongside the\nnetwork requests that Performance Monitoring captures automatically\n(in the *Network requests* subtab of the traces table).\n\nAdd custom network request traces\n\nUse the Performance Monitoring HTTPMetric API\n([Swift](/docs/reference/swift/firebaseperformance/api/reference/Classes/HTTPMetric)\n\\|\n[Obj-C](/docs/reference/ios/firebaseperformance/api/reference/Classes/FIRHTTPMetric))\nto add custom network request traces to monitor specific network requests.\n\nTo manually instrument custom network requests in Performance Monitoring, add code similar\nto the following: \n\nSwift\n\n\n**Note:** This Firebase product is not available on macOS, Mac Catalyst, watchOS targets. \n\n guard let metric = HTTPMetric(url: \"https://www.google.com\", httpMethod: .get) else { return }\n\n metric.start()\n guard let url = URL(string: \"https://www.google.com\") else { return }\n let request: URLRequest = URLRequest(url:url)\n let session = URLSession(configuration: .default)\n let dataTask = session.dataTask(with: request) { (urlData, response, error) in\n if let httpResponse = response as? HTTPURLResponse {\n metric.responseCode = httpResponse.statusCode\n }\n metric.stop()\n }\n dataTask.resume()\n\nObjective-C\n\n\n**Note:** This Firebase product is not available on macOS, Mac Catalyst, watchOS targets. \n\n @property (nonatomic) FIRHTTPMetric *metric;\n\n - (void)beginManualNetworkInstrumentation {\n self.metric =\n [[FIRHttpMetric alloc] initWithURL:[NSURL URLWithString:@\"https://www.google.com\"]\n HTTPMethod:FIRHTTPMethodGET];\n\n [self.metric start];\n\n NSURLRequest *request =\n [NSURLRequest requestWithURL:[NSURL URLWithString:@\"https://www.google.com\"]];\n NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request\n delegate:self];\n [connection resume];\n }\n\n - (void)connection:(NSURLConnection *)connection\n didReceiveResponse:(NSURLResponse *) response {\n NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response\n self.metric.responseCode = httpResponse.statusCode;\n [self.metric stop];\n }\n\nCustom network request traces also support adding custom attributes\n([Swift](/docs/reference/swift/firebaseperformance/api/reference/Protocols/PerformanceAttributable#setvalue_:forattribute:) \\|\n[Obj-C](/docs/reference/ios/firebaseperformance/api/reference/Protocols/FIRPerformanceAttributable#-setvalue:forattribute:))\nbut not custom metrics.\n\nNext steps\n\n- [Set up alerts](/docs/perf-mon/alerts) for network requests that are degrading the performance of your app. For example, you can configure an email alert for your team if the *response time* for a specific URL pattern exceeds a threshold that you set."]]