-
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.
# Conflicts: # Package.swift # Sources/EmbraceCore/Public/Metadata/MetadataHandler.swift # Sources/EmbraceCore/Public/Metadata/MetadataRecordTmp.swift # Sources/EmbraceCoreDataInternal/CoreDataWrapper.swift # Sources/EmbraceStorageInternal/Records/EmbraceStorage+Metadata.swift # Sources/EmbraceUploadInternal/Cache/EmbraceUploadCache.swift # Sources/EmbraceUploadInternal/Cache/UploadDataRecord.swift # Tests/EmbraceCoreDataInternalTests/CoreDataWrapperTests.swift # Tests/EmbraceCoreTests/Public/Metadata/MetadataHandlerTests.swift # Tests/EmbraceStorageInternalTests/MetadataRecordTests.swift # Tests/EmbraceUploadInternalTests/EmbraceUploadCacheTests+ClearDataDate.swift # Tests/EmbraceUploadInternalTests/EmbraceUploadCacheTests.swift
- Loading branch information
Showing
144 changed files
with
2,863 additions
and
5,812 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
Sources/EmbraceCommonInternal/Storage/Model/EmbraceLog.swift
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 @@ | ||
// | ||
// Copyright © 2025 Embrace Mobile, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OpenTelemetryApi | ||
|
||
public protocol EmbraceLog { | ||
var idRaw: String { get set } | ||
var processIdRaw: String { get set } | ||
var severityRaw: Int { get set } | ||
var body: String { get set } | ||
var timestamp: Date { get set } | ||
|
||
func allAttributes() -> [EmbraceLogAttribute] | ||
func attribute(forKey key: String) -> EmbraceLogAttribute? | ||
func setAttributeValue(value: AttributeValue, forKey key: String) | ||
} | ||
|
||
public extension EmbraceLog { | ||
var processId: ProcessIdentifier? { | ||
return ProcessIdentifier(hex: processIdRaw) | ||
} | ||
|
||
var severity: LogSeverity { | ||
return LogSeverity(rawValue: severityRaw) ?? .info | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Sources/EmbraceCommonInternal/Storage/Model/EmbraceLogAttribute.swift
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,46 @@ | ||
// | ||
// Copyright © 2025 Embrace Mobile, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OpenTelemetryApi | ||
|
||
public enum EmbraceLogAttributeType: Int { | ||
case string, int, double, bool | ||
} | ||
|
||
public protocol EmbraceLogAttribute { | ||
var key: String { get set } | ||
var valueRaw: String { get set } | ||
var typeRaw: Int { get set } | ||
} | ||
|
||
public extension EmbraceLogAttribute { | ||
|
||
var value: AttributeValue { | ||
get { | ||
let type = EmbraceLogAttributeType(rawValue: typeRaw) ?? .string | ||
|
||
switch type { | ||
case .int: return AttributeValue(Int(valueRaw) ?? 0) | ||
case .double: return AttributeValue(Double(valueRaw) ?? 0) | ||
case .bool: return AttributeValue(Bool(valueRaw) ?? false) | ||
default: return AttributeValue(valueRaw) | ||
} | ||
} | ||
|
||
set { | ||
valueRaw = newValue.description | ||
typeRaw = typeForValue(newValue).rawValue | ||
} | ||
} | ||
|
||
func typeForValue(_ value: AttributeValue) -> EmbraceLogAttributeType { | ||
switch value { | ||
case .int: return .int | ||
case .double: return .double | ||
case .bool: return .bool | ||
default: return .string | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Sources/EmbraceCommonInternal/Storage/Model/EmbraceMetadata.swift
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,49 @@ | ||
// | ||
// Copyright © 2025 Embrace Mobile, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum MetadataRecordType: String, Codable { | ||
/// Resource that is attached to session and logs data | ||
case resource | ||
|
||
/// Embrace-generated resource that is deemed required and cannot be removed by the user of the SDK | ||
case requiredResource | ||
|
||
/// Custom property attached to session and logs data and that can be manipulated by the user of the SDK | ||
case customProperty | ||
|
||
/// Persona tag attached to session and logs data and that can be manipulated by the user of the SDK | ||
case personaTag | ||
} | ||
|
||
public enum MetadataRecordLifespan: String, Codable { | ||
/// Value tied to a specific session | ||
case session | ||
|
||
/// Value tied to multiple sessions within a single process | ||
case process | ||
|
||
/// Value tied to all sessions until explicitly removed | ||
case permanent | ||
} | ||
|
||
public protocol EmbraceMetadata { | ||
var key: String { get set } | ||
var value: String { get set } | ||
var typeRaw: String { get set } | ||
var lifespanRaw: String { get set } | ||
var lifespanId: String { get set } | ||
var collectedAt: Date { get set } | ||
} | ||
|
||
public extension EmbraceMetadata { | ||
var type: MetadataRecordType? { | ||
return MetadataRecordType(rawValue: typeRaw) | ||
} | ||
|
||
var lifespan: MetadataRecordLifespan? { | ||
return MetadataRecordLifespan(rawValue: lifespanRaw) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Sources/EmbraceCommonInternal/Storage/Model/EmbraceSession.swift
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,30 @@ | ||
// | ||
// Copyright © 2025 Embrace Mobile, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol EmbraceSession { | ||
var idRaw: String { get set } | ||
var processIdRaw: String { get set } | ||
var state: String { get set } | ||
var traceId: String { get set } | ||
var spanId: String { get set } | ||
var startTime: Date { get set } | ||
var endTime: Date? { get set } | ||
var lastHeartbeatTime: Date { get set } | ||
var crashReportId: String? { get set } | ||
var coldStart: Bool { get set } | ||
var cleanExit: Bool { get set } | ||
var appTerminated: Bool { get set } | ||
} | ||
|
||
public extension EmbraceSession { | ||
var id: SessionIdentifier? { | ||
return SessionIdentifier(string: idRaw) | ||
} | ||
|
||
var processId: ProcessIdentifier? { | ||
return ProcessIdentifier(hex: processIdRaw) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Sources/EmbraceCommonInternal/Storage/Model/EmbraceSpan.swift
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,26 @@ | ||
// | ||
// Copyright © 2025 Embrace Mobile, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol EmbraceSpan { | ||
var id: String { get set } | ||
var name: String { get set } | ||
var traceId: String { get set } | ||
var typeRaw: String { get set } | ||
var data: Data { get set } | ||
var startTime: Date { get set } | ||
var endTime: Date? { get set } | ||
var processIdRaw: String { get set } | ||
} | ||
|
||
public extension EmbraceSpan { | ||
var type: SpanType? { | ||
return SpanType(rawValue: typeRaw) | ||
} | ||
|
||
var processId: ProcessIdentifier? { | ||
return ProcessIdentifier(hex: processIdRaw) | ||
} | ||
} |
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
Oops, something went wrong.