Reports
1. Create report
Asleep.createReports()
var config: Asleep.Config?
var reports: Asleep.Reports?
if let config {
reports = Asleep.createReports(config: config)
}
Property Name | Type | Description |
---|---|---|
config | Asleep.Config | Enter Asleep.Config instance |
2. Get a single report
Asleep.Reports.report()
var reports: Asleep.Reports?
let sessionId: String
// Closure
reports?.report(sessionId: sessionId, completionBlock: { (report: Asleep.Report?, error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
if let report {
}
})
// Async
Task {
do {
let report = try await reports?.report(sessionId: sessionId)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
sessionId | String | sessionId that can be received when stopping tracking |
completionBlock | Asleep.Model.Report? | If nil, an error occurs. |
Asleep.AsleepError? | Error Codes |
3. Get multiple reports
Asleep.Reports.reports()
var reports: Asleep.Reports?
let fromDate: String = "2023-05-01"
let toDate: String = "2023-05-07"
// Closure
reports?.reports(fromDate: fromDate, toDate: toDate, completionBlock: { (reportSessions: [Asleep.Model.SleepSession]?, error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
if let reportSessions {
}
})
// Async
Task {
do {
let reportSessions = try await reports?.reports(fromDate: fromDate, toDate: toDate)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
fromDate | String (YYYY-MM-DD ) | View date start |
toDate | String (YYYY-MM-DD ) | View date end |
orderBy - default value: .descending | Asleep.Model.OrderBy [.ascending, .descending] | DESC : Descending prderASC : Ascending order |
offset - default value: 0 | Int | Number of reports to skip |
limit - default value: 20 | Int | Maximum number of report (0~100) |
completionBlock | Array<Asleep.Model.SleepSession>? | If nil, an error occurs. |
Asleep.AsleepError? | Error Codes |
4. Get average stats
Asleep.Reports.getAverageReport()
v2.3.0<=SDK
var reports: Asleep.Reports?
let fromDate: String = "2023-05-01"
let toDate: String = "2023-05-07"
// Closure
reports?.getAverageReport(fromDate: fromDate, toDate: toDate, completionBlock: { (averageReport: Asleep.Model.AverageReport?, error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
if let averageReport {
}
})
// Async
Task {
do {
let averageReport = try await reports?.getAverageReport(fromDate: fromDate, toDate: toDate)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
fromDate | String (YYYY-MM-DD ) | The starting time for the period you want to check the average |
toDate | String (YYYY-MM-DD ) | The ending time for the period you want to check the average |
completionBlock | Asleep.Model.AverageReport? | f nil, an error occurs. |
Asleep.AsleepError? | Error Codes |
5. Delete report
When session data is deleted from the Asleep server upon a request, it becomes difficult to provide specific evidence for the deleted sessions during subsequent billing usage analysis.
Asleep.Reports.deleteReport()
var reports: Asleep.Reports?
let sessionId: String
// Closure
reports?.deleteReport(sessionId: sessionId, completionBlock: { (error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
})
// Async
Task {
do {
try await deleteReport?.deleteReport(sessionId: sessionId)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
sessionId | String | sessionId to be deleted |
completionBlock | Asleep.AsleepError? | Error Codes |
6. Data Type
Asleep.Model.Report
struct Report {
let timezone: String
let peculiarities: [Peculiarity]
let missingDataRatio: Float
let session: Session
let stat: Stat?
}
enum Peculiarity {
case inProgress
case neverSlept
case tooShortForAnalysis
case tooLongForAnalysis
case tooManyDefectsInSleepStages
case noBreathingStability
case noRealtimePolling
}
Property name | Type | Description |
---|---|---|
timezone | String | The adjusted time zone of the analysis result e.g. UTC , Asia/Seoul (Timezone List) |
peculiarities | Asleep.Model.Peculiarity | A field for describing any specific details or peculiarities of the sleep session. This field can include multiple labels below.IN_PROGRESS : If the session is OPEN, CLOSEDNEVER_SLEPT : If it is determined that there was no sleep at all during the session measurement timeTOO_SHORT_FOR_ANALYSIS : When the measurement time is too short to conduct a valid analysis (currently less than 20 minutes)TOO_LONG_FOR_ANALYSIS : Analysis has been conducted successfully, but the session measurement time is excessively long, making it difficult to trust (currently exceeding 24 hours)TOO_MANY_DEFECTS_IN_SLEEP_STAGES : When the error rate is high due to factors like missing audio uploads, resulting in insufficient sleep analysis results.NO_BREATHING_STABILITY : When the customer's contract conditions do not support breathing stability analysis.NO_REALTIME_POLLING : When, according to the customer's contract, real-time access to sleep information is not available. |
missing_data_ratio | Floatt(0~1 range, decimal points ) | The error rate in sleep analysis results due to reasons such as missing audio uploads |
session | Asleep.Model.Session | Session Report information |
stat | Asleep.Model.Stat | Analysis Report information |
Asleep.Model.Session
struct Session {
let id: String
let state: State
let startTime: Date
let endTime: Date?
let unexpectedEndTime: Date?
let createdTimezone: String
let sleepStages: [Int]?
let breathStages: [Int]?
}
enum State {
case open
case closed
case complete
}
Property name | Type | Description | Version |
---|---|---|---|
id | String | Session Id | |
state | Asleep.Model.State | Sleep session state (OPEN , CLOSED , or COMPLETE ) | |
startTime | Date | Session start time | |
endTime | Date? | Session end time | |
unexpectedEndTime | Date? | If a session fails to proceed and terminate properly due to app crashes or similar issues, and the client later executes initConfig to terminate the session, the time at which this happens is recorded. In this case, the "end_time" is calculated based on the sequence number of the last uploaded audio file. Therefore, if "end_time" is not null, it indicates an abnormal session. | 2.2.0<=SDK |
createdTimezone | String | Timezone of session creation (Timezone List) | 2.2.0<=SDK |
sleepStages | Array<Int> | Sleep stages-1 : error0 : wake1 : light2 : deep3 : rem | |
breathStages | Array<Int> | Breathing Stability stages-1 : error0 : stable1 : unstable |
Asleep.Model.Stat
struct Stat {
let sleepEfficiency: Float?
let sleepLatency: Int?
let sleepTime: Date?
let wakeupLatency: Int?
let wakeTime: Date?
let lightLatency: Int?
let deepLatency: Int?
let remLatency: Int?
let timeInWake: Int?
let timeInSleepPeriod: Int?
let timeInSleep: Int?
let timeInBed: Int?
let timeInRem: Int?
let timeInLight: Int?
let timeInDeep: Int?
let timeInStableBreath: Int?
let timeInUnstableBreath: Int?
let timeInSnoring: Int?
let timeInNoSnoring: Int?
let wakeRatio: Float?
let sleepRatio: Float?
let remRatio: Float?
let lightRatio: Float?
let deepRatio: Float?
let stableBreathRatio: Float?
let unstableBreathRatio: Float?
let snoringRatio: Float?
let noSnoringRatio: Float?
let unstableBreathCount: Int?
let breathingPattern: BreathingPattern?
let breathingIndex: Float?
let sleepCycle: Int?
let sleepCycleCount: Int?
let sleepCycleTime: [Date]?
let wasoCount: Int?
let longestWaso: Int?
let sleepIndex: Int?
let snoringCount: Int?
}
enum BreathingPattern {
case stableBreath
case mildlyUnstableBreath
case moderatelyUnstableBreath
case severelyUnstableBreath
}
Property name | Type | Description | Version |
---|---|---|---|
sleepEfficiency | Float? | The percentage of time you actually slept during sleep measurement | |
sleepLatency | Int? | time it took to fall asleep | |
sleepTime | Date? | The time it takes to fall asleep after the start of sleep measurement | |
wakeupLatency | Int? | The time it takes to wake up and end your sleep measurement | |
wakeTime | Date? | wake up time | |
lightLatency | Int? | The time it takes to the first Light after the start of sleep. | 2.2.0<=SDK |
deepLatency | Int? | The time it takes to the first Deep after the start of sleep. | 2.2.0<=SDK |
remLatency | Int? | The time it takes to the first REM after the start of sleep. | 2.2.0<=SDK |
timeInWake | Int? | wake during sleep | |
timeInSleepPeriod | Int? | During sleep measurement time, excluding the time it took from the start of the sleep measurement to fall asleep and the time it took from the wake to the end of the sleep measurement | |
timeInSleep | Int? | During sleep measurement time, the time you were actually sleeping Classified into three stages: deep, light, rem | |
timeInBed | Int? | The time from the start of the sleep measurement to the end of the sleep measurement | |
timeInRem | Int? | Total time the sleep phase progressed to rem | |
timeInLight | Int? | Total time the sleep phase progressed to light | |
timeInDeep | Int? | Total time the sleep phase progressed to deep | |
timeInStableBreath | Int? | Total time in the breathing stable section | |
timeInUnstableBreath | Int? | Total time in the breathing unstable section | |
timeInSnoring | Int? | Total time of snoring | 2.4.0<=SDK |
timeInNoSnoring | Int? | Total time of no snoring | 2.4.0<=SDK |
wakeRatio | Float? | Rate of waking time in the middle during sleep stage | |
sleepRatio | Float? | The percentage of time you sleep without waking during the sleep phase | |
remRatio | Float? | Rate of REM sleep during sleep stage | |
lightRatio | Float? | Rate of light sleep during sleep stage | |
deepRatio | Float? | Rate of deep sleep during sleep stage | |
stableBreathRatio | Float? | The percentage of time that was a breathing stable section during the sleep stage | |
unstableBreathRatio | Float? | The percentage of time that was a breathing unstable section during the sleep stage | |
snoringRatio | Float? | The percentage of time during the sleep phase that there was a snoring section | 2.4.0<=SDK |
noSnoringRatio | Float? | The percentage of time during the sleep phase that there was no snoring. | 2.4.0<=SDK |
unstableBreathCount | Int? | The number of times unstable breathing occurred. | 2.2.0<=SDK |
breathingPattern | Asleep.Model.BreathingPattern? | Breathing stability stageSTABLE_BREATH : Stable breathingMILDLY_UNSTABLE_BREATH : Slightly unstable breathingMODERATELY_UNSTABLE_BREATH : Moderately unstable breathingSEVERELY_UNSTABLE_BREATH : Severely irregular, unstable breathing. | |
breathingIndex | Float? | Values for determining respiratory instability levels | |
sleepCycle | Int? | The average duration of one sleep cycle. | 2.2.0<=SDK |
sleepCycleCount | Int? | The number of sleep cycles. | 2.2.0<=SDK |
sleepCycleTime | [Date]? | Transition time for sleep cycles [First sleep cycle onset time, first sleep cycle end time, second sleep cycle end time, ..., last sleep cycle end time] | 2.2.0<=SDK |
wasoCount | Int? | The number of times 'wake' occurred during the sleep period | 2.2.0<=SDK |
longestWaso | Int? | The duration of the longest 'wake' during the sleep period | 2.2.0<=SDK |
sleepIndex | Int? | The metric that comprehensively represents sleep quality, defined by learning from the distribution of sleep data | 2.3.0<=SDK |
snoringCount | Int? | The number of times snoring occurred | 2.4.0<=SDK |
Asleep.Model.SleepSession
struct SleepSession {
let sessionId: String
let state: State
let sessionStartTime: Date
let sessionEndTime: Date?
let createdTimezone: String
let unexpectedEndTime: Date?
let lastReceivedSeqNum: Int
let timeInBed: Int
}
enum State {
case open
case closed
case complete
}
Property name | Type | Description | Version |
---|---|---|---|
sessionId | String | Sleep session ID | |
state | Asleep.Model.State | Status of Session 'OPEN': An in-progress session, with audio uploads available 'CLOSED': The session terminated by sending an end session request. Unable to upload audio files. Analysis of uploaded sleep audio is still in progress 'COMPLETE': All sleep analysis completed after the end of the session | |
sessionStartTime | Date | Session start time | |
sessionEndTime | Date? | Session end time | |
createdTimezone | String | Timezone of session creation (Timezone List) | 2.2.0<=SDK |
unexpectedEndTime | Date? | If a session fails to proceed and terminate properly due to app crashes or similar issues, and the client later executes initConfig to terminate the session, the time at which this happens is recorded. In this case, the "end_time" is calculated based on the sequence number of the last uploaded audio file. Therefore, if "end_time" is not null, it indicates an abnormal session. | 2.2.0<=SDK |
lastReceivedSeqNum | Int | The sequence number of the last uploaded audio file | |
timeInBed | Int | The time from the start of the sleep measurement to the end of the sleep measurement |
Asleep.Model.AverageReport
v2.3.0<=SDK
struct AverageReport {
let period: Period
let peculiarities: [Peculiarity]
let averageStats: AverageStats?
let neverSleptSessions: [NeverSleptSession]
let sleptSessions: [SleptSession]
}
Property name | Type | Description |
---|---|---|
period | Asleep.Model.Period | Timezone (Timezone List) |
peculiarities | [Asleep.Model.Peculiarity] | Special considerations when calculating the average of sleep sessions NO_BREATHING_STABILITY: When the customer's contract conditions do not support breathing stability analysis |
averageStats | Asleep.Model.AverageStats? | An object containing the averages of sleep metrics for "sleptSessions" |
neverSleptSessions | [Asleep.Model.NeverSleptSession] | A list of sessions during which it is determined that no sleep occurred at all during the measurement time. |
sleptSessions | [Asleep.Model.SleptSession] | A list of sessions during which it is determined that sleep occurred during the measurement time. |
Asleep.Model.Period
v2.3.0<=SDK
struct Period {
let timezone: String
let startDate: Date
let endDate: Date
}
Property name | Type | Description |
---|---|---|
timezone | String | requested timezone 예. UTC, Asia/Seoul |
startDate | Date | requested start date |
endDate | Date | requested end date |
Asleep.Model.AverageStats
v2.3.0<=SDK
struct AverageStats {
let startTime: String
let endTime: String
let sleepTime: String
let wakeTime: String
let sleepLatency: Int
let wakeupLatency: Int
let timeInBed: Int
let timeInSleepPeriod: Int
let timeInSleep: Int
let timeInWake: Int
let timeInLight: Int?
let timeInDeep: Int?
let timeInRem: Int?
let timeInStableBreath: Int?
let timeInUnstableBreath: Int?
let timeInSnoring: Int?
let timeInNoSnoring: Int?
let sleepEfficiency: Double
let wakeRatio: Double
let sleepRatio: Double
let lightRatio: Double?
let deepRatio: Double?
let remRatio: Double?
let stableBreathRatio: Double?
let unstableBreathRatio: Double?
let snoringRatio: Double?
let noSnoringRatio: Double?
let breathingIndex: Double?
let wasoCount: Int
let longestWaso: Int
let unstableBreathCount: Int
let sleepCycleCount: Int
let snoringCount: Int?
}
Property name | Type | Description |
---|---|---|
startTime | String(hh:mm:ss ) | Session start time |
endTime | String(hh:mm:ss ) | Session end time |
sleepTime | String(hh:mm:ss ) | The time it takes to fall asleep after the start of sleep staging |
wakeTime | String(hh:mm:ss ) | Wake time |
sleepLatency | Int | Time to fall asleep |
wakeupLatency | Int | The time it takes to wake up and end your sleep measurement |
timeInBed | Int | The time from the start of the sleep measurement to the end of the sleep measurement |
timeInSleepPeriod | Int | During sleep measurement time, excluding the time it took from the start of the sleep measurement to fall asleep and the time it took from the wake to the end of the sleep measurement (time_in_bed - sleep_latency - wakeup_latency) |
timeInSleep | Int | During sleep measurement time, the time you were actually sleeping This time is divided into three stages: deep,light,and rem |
timeInWake | Int | Wake time during sleep |
timeInLight | Int? | Total time the sleep phase progressed to light |
timeInDeep | Int? | Total time the sleep phase progressed to deep |
timeInRem | Int? | Total time the sleep phase progressed to rem |
timeInStableBreath | Int? | Total time in the breathing stable section |
timeInUnstableBreath | Int? | Total time of breath instability |
timeInSnoring | Int? | Total time of snoring |
timeInNoSnoring | Int? | Total time of no snoring |
sleepEfficiency | Double | The percentage of time you actually slept during sleep measurement |
wakeRatio | Double | Rate of waking time in the middle during sleep phase |
sleepRatio | Double | During sleep stage, sleep ratio, not wake |
lightRatio | Double? | Rate of light sleep during sleep phase |
deepRatio | Double? | Rate of deep sleep during sleep phase |
remRatio | Double? | rem sleep ratio |
stableBreathRatio | Double? | The percentage of time that was a breathing stable section during the sleep phase |
unstableBreathRatio | Double? | The percentage of time during the sleep phase that there was a breathing instability section |
snoringRatio | Double? | The percentage of time during the sleep phase that there was a snoring section |
noSnoringRatio | Double? | The percentage of time during the sleep phase that there was no snoring. |
breathingIndex | Double? | Values for determining respiratory instability levels |
wasoCount | Int | The number of times 'wake' occurred during the sleep period |
longestWaso | Int | The duration of the longest 'wake' during the sleep period |
unstableBreathCount | Int? | The number of times unstable breathing occurred. |
sleepCycleCount | Int? | The number of sleep cycles. |
snoringCount | Int? | The number of times snoring occurred. |
Asleep.Model.NeverSleptSession
v2.3.0<=SDK
struct NeverSleptSession {
let id: String
let startTime: Date
let endTime: Date
let completedTime: Date
}
Property name | Type | Description |
---|---|---|
id | String | session id |
startTime | Date | Session start time |
endTime | Date | Session end time |
completedTime | Date | Time of session analysis completion |
Asleep.Model.SleptSession
v2.3.0<=SDK
struct SleptSession {
let id: String
let createdTimezone: String
let startTime: Date
let endTime: Date
let completedTime: Date
let sleepEfficiency: Double
let sleepLatency: Int?
let wakeupLatency: Int?
let lightLatency: Int?
let deepLatency: Int?
let remLatency: Int?
let sleepTime: Date?
let wakeTime: Date?
let timeInWake: Int
let timeInSleepPeriod: Int
let timeInSleep: Int
let timeInBed: Int
let timeInRem: Int?
let timeInLight: Int?
let timeInDeep: Int?
let timeInStableBreath: Int?
let timeInUnstableBreath: Int?
let timeInSnoring: Int?
let timeInNoSnoring: Int?
let wakeRatio: Double
let sleepRatio: Double
let remRatio: Double?
let lightRatio: Double?
let deepRatio: Double?
let stableBreathRatio: Double?
let unstableBreathRatio: Double?
let snoringRatio: Double?
let noSnoringRatio: Double?
let unstableBreathCount: Int?
let breathingPattern: BreathingPattern?
let sleepCycle: Int?
let sleepCycleCount: Int?
let wasoCount: Int?
let longestWaso: Int?
let snoringCount: Int?
}
Property name | Type | Description |
---|---|---|
id | String | session id |
createdTimezone | String | Timezone of session creation (Timezone List) |
startTime | Date | Session start time |
endTime | Date | Session end time |
completedTime | Date | Time of session analysis completion |
sleepEfficiency | Double | The percentage of time you actually slept during sleep measurement |
sleepLatency | Int? | Time to fall asleep |
wakeupLatency | Int? | The time it takes to wake up and end your sleep measurement |
lightLatency | Int? | The time it takes to the first Light after the start of sleep |
deepLatency | Int? | The time it takes to the first Deep after the start of sleep |
remLatency | Int? | The time it takes to the first REM after the start of sleep |
sleepTime | Date? | The time it takes to fall asleep after the start of sleep staging |
wakeTime | Date? | Wake time |
timeInWake | Int | Wake time during sleep |
timeInSleepPeriod | Int | During sleep measurement time, excluding the time it took from the start of the sleep measurement to fall asleep and the time it took from the wake to the end of the sleep measurement (time_in_bed - sleep_latency - wakeup_latency) |
timeInSleep | Int | During sleep measurement time, the time you were actually sleeping This time is divided into three stages: deep,light,and rem |
timeInBed | Int | The time from the start of the sleep measurement to the end of the sleep measurement |
timeInRem | Int? | Total time the sleep phase progressed to rem |
timeInLight | Int? | Total time the sleep phase progressed to light |
timeInDeep | Int? | Total time the sleep phase progressed to deep |
timeInStableBreath | Int? | Total time in the breathing stable section |
timeInUnstableBreath | Int? | Total time of breath instability |
timeInSnoring | Int? | Total time of snoring |
timeInNoSnoring | Int? | Total time of no snoring |
wakeRatio | Double | Rate of waking time in the middle during sleep phase |
sleepRatio | Double | During sleep stage, sleep ratio, not wake |
remRatio | Double? | rem sleep ratio |
lightRatio | Double? | Rate of light sleep during sleep phase |
deepRatio | Double? | Rate of deep sleep during sleep phase |
stableBreathRatio | Double? | The percentage of time that was a breathing stable section during the sleep phase |
unstableBreathRatio | Double? | The percentage of time during the sleep phase that there was a breathing instability section |
unstableBreathCount | Int? | The number of times unstable breathing occurred. |
snoringRatio | Double? | The percentage of time during the sleep phase that there was a snoring section |
noSnoringRatio | Double? | The percentage of time during the sleep phase that there was no snoring. |
breathingPattern | BreathingPattern? | Breathing Instability Level STABLE_BREATH: stable MILDLY_UNSTABLE_BREATH: mildly unstable MODERTATELY_UNSTABLE_BREATH: moderately unstable SEVERELY_UNSTABLE_BREATH: severely unstable |
sleepCycle | Int? | The average duration of one sleep cycle |
sleepCycleCount | Int? | The number of sleep cycles |
wasoCount | Int? | The number of times 'wake' occurred during the sleep period |
longestWaso | Int? | The duration of the longest 'wake' during the sleep period |
snoringCount | Int? | The number of times snoring occurred. |
Updated 5 months ago