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(release): pulling release/1.2.0 into master #27

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/draft-new-beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0

- name: Set Node 16
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 0

- name: Set Node 16
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fetch-depth: 0

- name: Set Node 16
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.2.0](https://github.com/rudderlabs/metrics-reporter-ios/compare/v1.1.1...v1.2.0) (2023-12-07)


### Features

* added os_version and os_name as part of the request payload to the metrics service. ([#23](https://github.com/rudderlabs/metrics-reporter-ios/issues/23)) ([d06aba4](https://github.com/rudderlabs/metrics-reporter-ios/commit/d06aba4ef2491f4f0d5615be3be7335fe067dff7))


### Bug Fixes

* fixed sqlite db path on the tvos platforms ([#25](https://github.com/rudderlabs/metrics-reporter-ios/issues/25)) ([eb997f7](https://github.com/rudderlabs/metrics-reporter-ios/commit/eb997f7b31d1530938c8d2f60c48344cfa42699d))

### [1.1.1](https://github.com/rudderlabs/metrics-reporter-ios/compare/v1.1.0...v1.1.1) (2023-09-28)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
342 changes: 189 additions & 153 deletions MetricsReporter.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion MetricsReporterTests/ErrorOperatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ final class ErrorOperatorTests: XCTestCase {
"notifier": [
"name": "Bugsnag iOS",
"version": "some.version",
"url": "https://github.com/rudderlabs/rudder-sdk-ios"
"url": "https://github.com/rudderlabs/rudder-sdk-ios",
"os_version": "\(Vendor.current.osVersion)",
"os_name": "\(Vendor.current.osName)",
],
"events": [
[
Expand Down
10 changes: 8 additions & 2 deletions MetricsReporterTests/MetricsUploaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ final class MetricsUploaderTests: XCTestCase {
"version": "1",
"source": {
"name": "ios",
"sdk_version": "some.version"
"sdk_version": "some.version",
"os_version": "\(Vendor.current.osVersion)",
"os_name": "\(Vendor.current.osName)"
},
"metrics": [
{
Expand All @@ -85,7 +87,9 @@ final class MetricsUploaderTests: XCTestCase {
"notifier": {
"name": "Bugsnag iOS",
"version": "some.version",
"url": "https://github.com/rudderlabs/rudder-sdk-ios"
"url": "https://github.com/rudderlabs/rudder-sdk-ios",
"os_version": "\(Vendor.current.osVersion)",
"os_name": "\(Vendor.current.osName)"
},
"events": \(createErrorEvent(index: 0))
}
Expand Down Expand Up @@ -164,6 +168,8 @@ struct Payload: Codable, Equatable {
struct Source: Codable, Equatable {
let name: String
let sdk_version: String
let os_version: String?
let os_name: String?
}

struct Metric: Codable, Equatable {
Expand Down
30 changes: 30 additions & 0 deletions MetricsReporterTests/VendorTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// VendorTests.swift
// MetricsReporter
//
// Created by Desu Sai Venkat on 30/10/23.
//

import XCTest
@testable import MetricsReporter

final class VendorTests: XCTestCase {

func test_OSName() {
#if os(iOS)
XCTAssertEqual("iOS", Vendor.current.osName)
#elseif os(tvOS)
XCTAssertEqual("tvOS", Vendor.current.osName)
#elseif os(watchOS)
XCTAssertEqual("watchOS", Vendor.current.osName)
#elseif os(macOS)
XCTAssertEqual("macOS", Vendor.current.osName)
#endif
}

func test_OSVersion() {
let osVersion = Vendor.current.osVersion
XCTAssertNotNil(osVersion)
print("\(Vendor.current.osName) and version \(osVersion)")
}
}
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- MetricsReporter (1.1.0):
- MetricsReporter (1.1.1):
- RSCrashReporter (= 1.0.0)
- RudderKit (= 1.4.0)
- RSCrashReporter (1.0.0)
Expand All @@ -20,10 +20,10 @@ EXTERNAL SOURCES:
:path: "."

SPEC CHECKSUMS:
MetricsReporter: 82f644e301a9b32d5bff9c5b11526144faeb448d
MetricsReporter: 759631361ffd2b8f0d375b1225c8a631311f6da2
RSCrashReporter: 7e26b51ac816e967acb58fa458040946a93a9e65
RudderKit: d9d6997696e1642b753d8bdf94e57af643a68f03

PODFILE CHECKSUM: dad18b36d04fcf5738932c8cb26d81ee3aaba37c

COCOAPODS: 1.13.0
COCOAPODS: 1.14.2
44 changes: 24 additions & 20 deletions Sources/Classes/Database/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ class Database: DatabaseOperations {
}
var value: Float = 0.0
switch metric {
case let m as Count:
value = Float(m.value)
case let m as Gauge:
value = m.value
default:
break
case let m as Count:
value = Float(m.value)
case let m as Gauge:
value = m.value
default:
break
}
return metricOperator.saveMetric(name: metric.name, value: value, type: metric.type.rawValue, labels: labels)
}
Expand All @@ -134,14 +134,14 @@ class Database: DatabaseOperations {
}
}
switch metricEntity.type {
case MetricType.count.rawValue:
let count = Count(name: metricEntity.name, labels: labels, value: Int(metricEntity.value))
countList?.append(count)
case MetricType.gauge.rawValue:
let gauge = Gauge(name: metricEntity.name, labels: labels, value: metricEntity.value)
gaugeList?.append(gauge)
default:
break
case MetricType.count.rawValue:
let count = Count(name: metricEntity.name, labels: labels, value: Int(metricEntity.value))
countList?.append(count)
case MetricType.gauge.rawValue:
let gauge = Gauge(name: metricEntity.name, labels: labels, value: metricEntity.value)
gaugeList?.append(gauge)
default:
break
}
}
}
Expand All @@ -168,12 +168,12 @@ class Database: DatabaseOperations {
}
var newValue: Float = 0.0
switch metric {
case let m as Count:
newValue = Float(m.value)
case let m as Gauge:
newValue = m.value
default:
break
case let m as Count:
newValue = Float(m.value)
case let m as Gauge:
newValue = m.value
default:
break
}
let updatedValue: Float = (newValue > metricEntity.value) ? (newValue - metricEntity.value) : (metricEntity.value - newValue)
return metricOperator.updateMetric(metricEntity, updatedValue: updatedValue)
Expand Down Expand Up @@ -215,7 +215,11 @@ class Database: DatabaseOperations {

extension Database {
private static func getDBPath() -> String {
#if os(tvOS)
let urlDirectory = FileManager.default.urls(for: FileManager.SearchPathDirectory.cachesDirectory, in: FileManager.SearchPathDomainMask.userDomainMask)[0]
#else
let urlDirectory = FileManager.default.urls(for: FileManager.SearchPathDirectory.libraryDirectory, in: FileManager.SearchPathDomainMask.userDomainMask)[0]
#endif
let fileUrl = urlDirectory.appendingPathComponent("metrics.sqlite")
return fileUrl.path
}
Expand Down
59 changes: 59 additions & 0 deletions Sources/Classes/Helpers/Vendors/Vendor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Vendor.swift
// MetricsReporter
//
// Created by Desu Sai Venkat on 23/11/23.
//

import Foundation
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(watchOS)
import WatchKit
#endif


#if os(iOS) || os(tvOS)
internal class PhoneVendor: Vendor {
override var osName: String {
return UIDevice.current.systemName
}
}
#endif

#if os(macOS)
internal class MacVendor: Vendor {
override var osName: String {
return "macOS"
}
}
#endif

#if os(watchOS)
internal class WatchVendor: Vendor {
override var osName: String {
return WKInterfaceDevice.current().systemName
}
}
#endif

internal class Vendor {
var osName: String {
return "unknown"
}
var osVersion: String {
return "\(ProcessInfo.processInfo.operatingSystemVersion.majorVersion).\(ProcessInfo.processInfo.operatingSystemVersion.minorVersion).\(ProcessInfo.processInfo.operatingSystemVersion.patchVersion)"
}

static var current: Vendor = {
#if os(iOS) || os(tvOS)
return PhoneVendor()
#elseif os(macOS)
return MacVendor()
#elseif os(watchOS)
return WatchVendor()
#else
return Vendor()
#endif
}()
}
8 changes: 6 additions & 2 deletions Sources/Classes/Plugins/MetricsUploader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ class MetricsUploader: Plugin {
"source": [
"name": "ios",
"sdk_version": configuration.sdkVersion,
"write_key": configuration.writeKey
"write_key": configuration.writeKey,
"os_name": Vendor.current.osName,
"os_version": Vendor.current.osVersion
]
]
if let metrics = metrics {
Expand All @@ -158,7 +160,9 @@ extension [ErrorEntity] {
let notifier = [
"name": "Bugsnag iOS",
"version": configuration.sdkVersion,
"url": "https://github.com/rudderlabs/rudder-sdk-ios"
"url": "https://github.com/rudderlabs/rudder-sdk-ios",
"os_name": Vendor.current.osName,
"os_version": Vendor.current.osVersion
]

var eventList = [[String: Any]]()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.1.1",
"version": "1.2.0",
"description": "Rudder is a platform for collecting, storing and routing customer event data to dozens of tools"
}
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sonar.qualitygate.wait=false
sonar.projectKey=rudderlabs_metrics-reporter-ios
sonar.organization=rudderlabs
sonar.projectName=Metrics Reporter iOS
sonar.projectVersion=1.1.1
sonar.projectVersion=1.2.0

# Meta-data for the project
sonar.links.scm=https://github.com/rudderlabs/metrics-reporter-ios
Expand Down
Loading