-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from team-telnyx/feat/WEBRTC-2347-stats
[WEBRTC-2347] [feat] Stats
- Loading branch information
Showing
33 changed files
with
915 additions
and
383 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// MARK: - Dictionary | ||
extension Dictionary { | ||
|
||
var telnyx_webrtc_json: String { | ||
let invalidJson = "Not a valid JSON" | ||
do { | ||
let jsonData = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) | ||
return String(bytes: jsonData, encoding: String.Encoding.utf8) ?? invalidJson | ||
} catch { | ||
return invalidJson | ||
} | ||
} | ||
|
||
func printJson() { | ||
Logger.log.i(message: "\(telnyx_webrtc_json)") | ||
} | ||
} |
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
class DebugReportDataMessage: StatsMessage { | ||
init(reportID: String, reportData: [String: Any]) { | ||
|
||
var data = reportData | ||
data["timeTaken"] = 1 | ||
let dateFormatter = ISO8601DateFormatter() | ||
dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] | ||
let timestamp = dateFormatter.string(from: Date()) | ||
data["timestamp"] = timestamp | ||
super.init(type: .DEBUG_REPORT_DATA, | ||
reportID: reportID, | ||
reportData: data) | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
class DebugReportStartMessage: StatsMessage { | ||
init(reportID: String) { | ||
super.init(type: .DEBUG_REPORT_START, | ||
reportID: reportID, | ||
reportData: nil) | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
class DebugReportStopMessage: StatsMessage { | ||
init(reportID: String) { | ||
super.init(type: .DEBUG_REPORT_STOP, | ||
reportID: reportID, | ||
reportData: nil) | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// StatsMessage.swift | ||
// TelnyxRTC | ||
// | ||
// Created by Isaac Akakpo on 8/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
private let DEBUG_REPORT_VERSION: Int = 1 | ||
|
||
enum StatsMessageType : String { | ||
case DEBUG_REPORT_STOP = "debug_report_stop" | ||
case DEBUG_REPORT_START = "debug_report_start" | ||
case DEBUG_REPORT_DATA = "debug_report_data" | ||
} | ||
|
||
class StatsMessage: Message { | ||
init(type: StatsMessageType, | ||
reportID: String, | ||
reportData: [String:Any]?) { | ||
super.init() | ||
self.jsonMessage["debug_report_version"] = DEBUG_REPORT_VERSION | ||
self.jsonMessage["debug_report_data"] = reportData | ||
self.jsonMessage["type"] = type.rawValue | ||
self.jsonMessage["debug_report_id"] = reportID | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.