Skip to content
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

chore: merge EventLogger to master branch #85

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
149f78d
feat: Retrieve App and Device MetaData (SDKCF-6846)
SoumenRautray Nov 16, 2023
9f4835e
feat: declare event logger manager and public APIs (SDKCF-6845)
Esakkiraja-Pothikannan Nov 29, 2023
5c8900d
improve: Refactor event-logger code (SDKCF-6864)
anish-munirathinam Dec 22, 2023
97248eb
feat: Implement Network Manager Module (SDKCF-6849)
SoumenRautray Dec 26, 2023
58dd9a1
feat: Implement database manager (SDKCF-6848) (#67)
SoumenRautray Jan 4, 2024
d2c2674
chore: create public apis for Event Logger (SDKCF-6853)
SoumenRautray Jan 19, 2024
ab5cb69
feat: integrate Sample App for REvent Logger feature (SDKCF-6856)
Esakkiraja-Pothikannan Jan 22, 2024
8706df8
feat: add app lifecycle listener (SDKCF-6850)
Esakkiraja-Pothikannan Jan 22, 2024
0def630
feat: Implement Retry Mechanism (#71)
SoumenRautray Jan 22, 2024
d349784
improve: add real time error message in the default error (SDKCF-6856)
Esakkiraja-Pothikannan Jan 22, 2024
199304e
improve: refactor REvent parameters and log event Logic (SDKCF-6851) …
SoumenRautray Jan 24, 2024
077385b
improve: update sample app UI (SDKCF-6856)
Esakkiraja-Pothikannan Feb 7, 2024
4d49333
chore: change identifier to Real Time device Name (SDKCF-6880)
SoumenRautray Feb 23, 2024
5f80643
chore: fix crash on sample app on logging event (SDKCF-6882)
SoumenRautray Feb 23, 2024
6ac8380
improve: Update App name fetching logic for Eventlogger (SDKCF-6915)
SoumenRautray May 3, 2024
43d2b0a
chore: refactor retry mechanism (SDKCF-6920)
SoumenRautray May 9, 2024
c307082
Refactor code for ApplifeCycleListener
SoumenRautray May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# **Changelog**

## Unreleased
- Features:
- Retrieve Meta-data for Event Logger (SDKCF-6846)
- Event Logger Public API & Manager Class (SDKCF-6845)
- Implement database manager (SDKCF-6848)
- Implement Network Manager Module (SDKCF-6849)
- Add App Lifecycle Listener For Event Logger (SDKCF-6850)
- Implement Retry Mechanism (SDKCF-6851)
- Create public apis for Event Logger (SDKCF-6853)
- Integrate Sample App for REvent Logger feature (SDKCF-6856)
- Add app lifecycle listener (SDKCF-6850)
- Update fetching App name logic (SDKCF-6915)

- Improve:
- Refactor event-logger code (SDKCF-6864)
- Add real time error message in the default error (SDKCF-6856)
- Change identifier to Real Time device Name (SDKCF-6880)
- Refactor retry mechanism (SDKCF-6920)

- Fixes:
- Fix crash on sample app on logging event (SDKCF-6882)

#### 4.1.0 (2024-04-08)
- Improve:
- Add Privacy Manifest File (SDKCF-6906)
Expand Down
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ let package = Package(
targets: ["RSDKUtilsNimble"]),
.library(
name: "RLogger",
targets: ["RLogger"])
targets: ["RLogger"]),
.library(
name: "REventLogger",
targets: ["REventLogger"])
],
dependencies: [
.package(url: "https://github.com/Quick/Quick.git", "5.0.0"..<"7.2.0"),
Expand All @@ -37,9 +40,12 @@ let package = Package(
.target(
name: "RSDKUtilsNimble",
dependencies: ["RSDKUtilsMain", "Nimble"]),
.target(name: "REventLogger",
dependencies: ["RSDKUtilsMain"]),
.testTarget(
name: "Tests",
dependencies: ["RSDKUtilsMain", "RSDKUtilsNimble", "RSDKUtilsTestHelpers", "RLogger", "Quick", "Nimble"])
dependencies: ["RSDKUtilsMain", "RSDKUtilsNimble", "RSDKUtilsTestHelpers", "RLogger", "Quick", "Nimble",
"REventLogger"])
],
swiftLanguageVersions: [
.v5
Expand Down
6 changes: 6 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ platform :ios, '12.0'

use_frameworks!

target 'Sample' do
pod 'RSDKUtils', :path => './RSDKUtils.podspec'
pod 'RSDKUtils/REventLogger', :path => './RSDKUtils.podspec'
end

target 'Tests' do
pod 'Quick', '~> 5.0'
pod 'Nimble'
Expand All @@ -13,6 +18,7 @@ target 'Tests' do
pod 'RSDKUtils/TestHelpers', :path => './RSDKUtils.podspec'
pod 'RSDKUtils/Nimble', :path => './RSDKUtils.podspec'
pod 'RSDKUtils/RLogger', :path => './RSDKUtils.podspec'
pod 'RSDKUtils/REventLogger', :path => './RSDKUtils.podspec'
end

# vim:syntax=ruby:et:sts=2:sw=2:ts=2:ff=unix:
7 changes: 5 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PODS:
- RSDKUtils/Nimble (4.0.2):
- Nimble
- RSDKUtils/Main
- RSDKUtils/REventLogger (4.0.2):
- RSDKUtils/Main
- RSDKUtils/RLogger (4.0.2)
- RSDKUtils/TestHelpers (4.0.2):
- RSDKUtils/Main
Expand All @@ -18,6 +20,7 @@ DEPENDENCIES:
- Quick (~> 5.0)
- RSDKUtils (from `./RSDKUtils.podspec`)
- RSDKUtils/Nimble (from `./RSDKUtils.podspec`)
- RSDKUtils/REventLogger (from `./RSDKUtils.podspec`)
- RSDKUtils/RLogger (from `./RSDKUtils.podspec`)
- RSDKUtils/TestHelpers (from `./RSDKUtils.podspec`)
- SwiftLint (~> 0.50)
Expand All @@ -35,9 +38,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Nimble: 5316ef81a170ce87baf72dd961f22f89a602ff84
Quick: 749aa754fd1e7d984f2000fe051e18a3a9809179
RSDKUtils: 52f4e68f63a2e5c1e8589456aabcf631ffacdccb
RSDKUtils: 4fa748f1f5f73650ce0ba917fef82ded6b22edec
SwiftLint: 1b7561918a19e23bfed960e40759086e70f4dba5

PODFILE CHECKSUM: f6ba2f14867e1900fb90942ba329b080648b55b0
PODFILE CHECKSUM: 01e8a1825101c891baa7a09900085f8c27c08742

COCOAPODS: 1.15.2
5 changes: 5 additions & 0 deletions RSDKUtils.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,10 @@ Pod::Spec.new do |s|
s.subspec 'RLogger' do |ss|
ss.source_files = 'Sources/RLogger/**/*.swift', 'Sources/*.h'
end

s.subspec 'REventLogger' do |ss|
ss.source_files = 'Sources/REventLogger/**/*.swift', 'Sources/*.h'
ss.dependency 'RSDKUtils/Main'
end
end
# vim:syntax=ruby:et:sts=2:sw=2:ts=2:ff=unix:
239 changes: 238 additions & 1 deletion RSDKUtils.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions RSDKUtils.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45E4BB302B501360004C5303"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:RSDKUtils.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45E4BB302B501360004C5303"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:RSDKUtils.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45E4BB302B501360004C5303"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:RSDKUtils.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 2 additions & 2 deletions RSDKUtils.xcodeproj/xcshareddata/xcschemes/TestHost.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F6B5C43754FD40875B2E65BC9D884FE5"
BlueprintIdentifier = "C057818AF0725CF51E59105552E26522"
BuildableName = "RSDKUtils.framework"
BlueprintName = "RSDKUtils"
BlueprintName = "RSDKUtils.common-Nimble-TestHelpers"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
Expand Down
11 changes: 11 additions & 0 deletions Sample/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
13 changes: 13 additions & 0 deletions Sample/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Sample/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
26 changes: 26 additions & 0 deletions Sample/EventLogger/EventListView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import SwiftUI

struct EventListView: View {
private var interactor: EventLogging
@State private var eventList: [String] = []

init(interactor: EventLogging) {
self.interactor = interactor
}

var body: some View {
VStack(alignment: .leading) {
Text("Total number of Unique Count: \(eventList.count)")
}
List(eventList, id: \.self) { item in
Text(item)
}
.onAppear {
eventList = interactor.getStoredEvents()
}
}
}

#Preview {
EventListView(interactor: EventLoggerInteractor())
}
66 changes: 66 additions & 0 deletions Sample/EventLogger/EventLoggerInteractor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import Foundation
import RSDKUtils

enum Constant {
static let eventLoggerKey = "event_logger_cached_events"
Dismissed Show dismissed Hide dismissed
}

struct EventLoggerInteractor: EventLogging {
func logEvent(_ event: EventModel, completionHandler: @escaping ((Bool) -> Void)) {
let info = convertToJson(event.info)
for _ in 1...event.count {
DispatchQueue.main.async {
if event.isCritical {
REventLogger.shared.sendCriticalEvent(sourceName: event.sdkName,
sourceVersion: event.sdkVersion,
errorCode: event.errorCode,
errorMessage: event.errorMessage,
info: info)
}else{
REventLogger.shared.sendWarningEvent(sourceName: event.sdkName,
sourceVersion: event.sdkVersion,
errorCode: event.errorCode,
errorMessage: event.errorMessage,
info: info)
}
}
}
completionHandler(true)

func convertToJson(_ jsonString: String) -> [String: String]? {
guard let data = jsonString.data(using: .utf8),
let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: String] else {
return nil
}
return json
}
}

func getStoredEvents() -> [String] {
guard let data = UserDefaults.sharedDefaults?.value(forKey: Constant.eventLoggerKey) as? Data,
let json = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] else {
return []
}
let sortedValues = json.values.compactMap({$0 as? [String: Any]})
.sorted(by: { $0["firstOccurrenceOn"] as! Double > $1["firstOccurrenceOn"] as! Double })
return sortedValues.compactMap({ convertToString($0) })
}

func getConfiguration() -> (apiKey: String, apiEndpoint: String) {
let apiKey = Bundle.main.object(forInfoDictionaryKey: "EventLoggerAPIKey") as? String ?? ""
let apiEndpoint = Bundle.main.object(forInfoDictionaryKey: "EventLoggerAPIEndpoint") as? String ?? ""
return (apiKey, apiEndpoint)
}

private func convertToString(_ value: [String: Any]) -> String? {
guard let data = try? JSONSerialization.data(withJSONObject: value, options: [.sortedKeys, .prettyPrinted]),
let jsonString = String(data: data, encoding: .utf8) else {
return nil
}
return jsonString
}
}

extension UserDefaults {
static let sharedDefaults = UserDefaults(suiteName: "group." + Bundle.main.bundleIdentifier!)
}
Loading
Loading