From 7a36a739866a94cad6772552adc625d4f7c51e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Wilczek?= Date: Thu, 29 Jun 2023 23:11:04 +0200 Subject: [PATCH] build(deps): bump Sentry for iOS (sentry-cocoa) to 8.8.0 (#397) * build(deps): bump Sentry for iOS to 8.8.0 Fixed formatting issues in plist files * update changelog * Updated capacitor plugin * Ensure compatibility with all example apps * Fix type mismatch --------- Co-authored-by: LucasZF --- CHANGELOG.md | 6 + SentryCapacitor.podspec | 5 +- .../ionic-angular-v2/ios/App/App/Info.plist | 2 +- example/ionic-angular-v2/ios/App/Podfile | 2 +- .../ios/App/App.xcodeproj/project.pbxproj | 4 +- .../ionic-angular-v5/ios/App/App/Info.plist | 2 +- example/ionic-angular/ios/App/App/Info.plist | 2 +- example/ionic-angular/yarn.lock | 144 +++++++++--------- ios/Plugin.xcodeproj/project.pbxproj | 6 +- ios/Plugin/Plugin.swift | 99 ++++++------ ios/Podfile | 4 +- ios/Podfile.lock | 24 +-- 12 files changed, 154 insertions(+), 146 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d5a678..78fc6189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +### Dependencies + +- Bump sentry-cocoa SDK to `8.8.0` ([#397](https://github.com/getsentry/sentry-capacitor/pull/397)) + - [changelog](https://github.com/getsentry/sentry-cocoa/releases/tag/8.8.0) + - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.1...8.8.0) + - Improved capacitor plugin file (added weak self, updated workaround from sentry-react-native) - Bump Sentry JavaScript SDK to `7.56.0` ([#398](https://github.com/getsentry/sentry-capacitor/pull/398)) - [changelog](https://github.com/getsentry/sentry-javascript/releases/tag/7.56.0) - [diff](https://github.com/getsentry/sentry-javascript/compare/7.54.0...7.56.0) diff --git a/SentryCapacitor.podspec b/SentryCapacitor.podspec index ca1a2fa4..40fd576c 100644 --- a/SentryCapacitor.podspec +++ b/SentryCapacitor.podspec @@ -12,6 +12,9 @@ Pod::Spec.new do |s| s.source = { :git => package['repository']['url'], :tag => s.version.to_s } s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}' + s.dependency 'Sentry/HybridSDK', '8.8.0' + s.dependency 'Capacitor' + if File.exist?('../../@capacitor/core/package.json') == false # If Capacitor was not found (could happen when using Yarn PNP), fallback to the # required minimum version of Capacitor 4. @@ -26,7 +29,5 @@ Pod::Spec.new do |s| end end s.ios.deployment_target = miniOSVersion - s.dependency 'Sentry', '~> 7.27.1' - s.dependency 'Capacitor' s.swift_version = '5.1' end diff --git a/example/ionic-angular-v2/ios/App/App/Info.plist b/example/ionic-angular-v2/ios/App/App/Info.plist index 7b9064bd..f575db6a 100644 --- a/example/ionic-angular-v2/ios/App/App/Info.plist +++ b/example/ionic-angular-v2/ios/App/App/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion en CFBundleDisplayName - ionic-angular + ionic-angular CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/example/ionic-angular-v2/ios/App/Podfile b/example/ionic-angular-v2/ios/App/Podfile index 913c0031..b51e0dee 100644 --- a/example/ionic-angular-v2/ios/App/Podfile +++ b/example/ionic-angular-v2/ios/App/Podfile @@ -10,7 +10,7 @@ def capacitor_pods # Automatic Capacitor Pod dependencies, do not delete pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' - pod 'SentryCapacitor', :path => '../../.yalc/@sentry/capacitor' + pod 'SentryCapacitor', :path => '../../node_modules/@sentry/capacitor' # Do not delete end diff --git a/example/ionic-angular-v5/ios/App/App.xcodeproj/project.pbxproj b/example/ionic-angular-v5/ios/App/App.xcodeproj/project.pbxproj index 99cf0aea..aabbb18b 100644 --- a/example/ionic-angular-v5/ios/App/App.xcodeproj/project.pbxproj +++ b/example/ionic-angular-v5/ios/App/App.xcodeproj/project.pbxproj @@ -281,7 +281,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -332,7 +332,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; diff --git a/example/ionic-angular-v5/ios/App/App/Info.plist b/example/ionic-angular-v5/ios/App/App/Info.plist index be421cbf..c02c4bec 100644 --- a/example/ionic-angular-v5/ios/App/App/Info.plist +++ b/example/ionic-angular-v5/ios/App/App/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion en CFBundleDisplayName - ionic-angular + ionic-angular CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/example/ionic-angular/ios/App/App/Info.plist b/example/ionic-angular/ios/App/App/Info.plist index be421cbf..c02c4bec 100644 --- a/example/ionic-angular/ios/App/App/Info.plist +++ b/example/ionic-angular/ios/App/App/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion en CFBundleDisplayName - ionic-angular + ionic-angular CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/example/ionic-angular/yarn.lock b/example/ionic-angular/yarn.lock index b0920caa..cd852f72 100644 --- a/example/ionic-angular/yarn.lock +++ b/example/ionic-angular/yarn.lock @@ -1634,48 +1634,48 @@ "@angular-devkit/schematics" "13.3.0" jsonc-parser "3.0.0" -"@sentry-internal/tracing@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.54.0.tgz#eeb10ee72426d08669a7706faa4264f1ec02c71d" - integrity sha512-JsyhZ0wWZ+VqbHJg+azqRGdYJDkcI5R9+pnkO6SzbzxrRewqMAIwzkpPee3oI7vG99uhMEkOkMjHu0nQGwkOQw== - dependencies: - "@sentry/core" "7.54.0" - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" +"@sentry-internal/tracing@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.56.0.tgz#ba709258f2f0f3d8a36f9740403088b39212b843" + integrity sha512-OKI4Pz/O13gng8hT9rNc+gRV3+P7nnk1HnHlV8fgaQydS6DsRxoDL1sHa42tZGbh7K9jqNAP3TC6VjBOsr2tXA== + dependencies: + "@sentry/core" "7.56.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" tslib "^1.9.3" -"@sentry/angular@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/angular/-/angular-7.54.0.tgz#1e8468bab819be3107b94fa15dc0b95967806f27" - integrity sha512-/c3mys0dE64GKk0jjmWG9a+rGQbEwX1pflayD1cjwCStb0D/RVp4mUOMmbj5n40TlqQQehxfbFSSAA53fD+jQQ== +"@sentry/angular@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/angular/-/angular-7.56.0.tgz#f76f228cecf68d0042bde9436c84a1ffc4abf8bc" + integrity sha512-KECZOiwt7ZKPMNGlV4d6Unl2B2bZN7M8EOXGXP35BVSs5aIq6S1cIYlXxzWC67YUJ0zfxPDtNbRrYRQ3rpmgxw== dependencies: - "@sentry/browser" "7.54.0" - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry/browser" "7.56.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" tslib "^2.0.0" -"@sentry/browser@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.54.0.tgz#7fe331c776d02b5c902733aa41dcbfac7bef1ae6" - integrity sha512-EvLAw03N9WE2m1CMl2/1YMeIs1icw9IEOVJhWmf3uJEysNJOFWXu6ZzdtHEz1E6DiJYhc1HzDya0ExZeJxNARA== +"@sentry/browser@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.56.0.tgz#6bf3ff21bc2e9b66a72ea0c7dcc3572fdeb3bd8f" + integrity sha512-qpyyw+NM/psbNAYMlTCCdWwxHHcogppEQ+Q40jGE4sKP2VRIjjyteJkUcaEMoGpbJXx9puzTWbpzqlQ8r15Now== dependencies: - "@sentry-internal/tracing" "7.54.0" - "@sentry/core" "7.54.0" - "@sentry/replay" "7.54.0" - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry-internal/tracing" "7.56.0" + "@sentry/core" "7.56.0" + "@sentry/replay" "7.56.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" tslib "^1.9.3" "@sentry/capacitor@file:.yalc/@sentry/capacitor": - version "0.12.0" + version "0.12.1" dependencies: - "@sentry/browser" "7.54.0" - "@sentry/core" "7.54.0" - "@sentry/hub" "7.54.0" - "@sentry/integrations" "7.54.0" - "@sentry/tracing" "7.54.0" - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry/browser" "7.56.0" + "@sentry/core" "7.56.0" + "@sentry/hub" "7.56.0" + "@sentry/integrations" "7.56.0" + "@sentry/tracing" "7.56.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" "@sentry/wizard" "^1.1.4" promise "^8.1.0" @@ -1692,62 +1692,62 @@ proxy-from-env "^1.1.0" which "^2.0.2" -"@sentry/core@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.54.0.tgz#8c4cb8800f8df708b3f3f6483026bb9a02820014" - integrity sha512-MAn0E2EwgNn1pFQn4qxhU+1kz6edullWg6VE5wCmtpXWOVw6sILBUsQpeIG5djBKMcneJCdOlz5jeqcKPrLvZQ== +"@sentry/core@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.56.0.tgz#f4253e0d61f55444180a63e5278b62e57303f7cf" + integrity sha512-Nuyyfh09Yz27kPo74fXHlrdmZeK6zrlJVtxQ6LkwuoaTBcNcesNXVaOtr6gjvUGUmsfriVPP3Jero5LXufV7GQ== dependencies: - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" tslib "^1.9.3" -"@sentry/hub@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.54.0.tgz#fca3db1c302a030ed07f59c33603de32c207cc70" - integrity sha512-GePswxz0rzSaCGB0QR2FgH7Hht9SfxsVyX271FtPH3V5hUIZOHlftXggqmNy5XyyiGf27zsWM+DYgQUFJwMcjQ== +"@sentry/hub@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.56.0.tgz#840f4df37945ac2230570366f8913c0406cfa827" + integrity sha512-d5AnPHk7PNhPFHyIuyMEnG+dtC8SHbCBffm05jMqL0+ocU1rSAJb4K6r5D1wrfQtHxPHNV+R3uwkvOWDekF+VA== dependencies: - "@sentry/core" "7.54.0" - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry/core" "7.56.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" tslib "^1.9.3" -"@sentry/integrations@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.54.0.tgz#62c73013ca6040d0c9b045809fc5d6ecefda3339" - integrity sha512-RolGsQzJChJzjHTJcCKSZ1HanmY33floc5o13WgU9NoDqJbLGLNcOIrAu+WynqPe8P5VTVrVb8NiwhLqWrKp4g== +"@sentry/integrations@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.56.0.tgz#6fe812454fbccf00810f65667eb393b3bf298b92" + integrity sha512-0d/E/R3MW+5bQ9wcHPD0h/B2KFOpUt+wQgN1kNk7atY12auDzHKuGCjPP87D/xVyRoma3ErFqZCRqwtvCj1cfQ== dependencies: - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" localforage "^1.8.1" tslib "^1.9.3" -"@sentry/replay@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.54.0.tgz#f0f44f9413ceefd1809bf1665e82315927ae08db" - integrity sha512-C0F0568ybphzGmKGe23duB6n5wJcgM7WLYhoeqW3o2bHeqpj1dGPSka/K3s9KzGaAgzn1zeOUYXJsOs+T/XdsA== +"@sentry/replay@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.56.0.tgz#8a49dcb45e9ea83bf905cec0d9b42fed4b8085bd" + integrity sha512-bvjiJK1+SM/paLapuL+nEJ8CIF1bJqi0nnFyxUIi2L5L6yb2uMwfyT3IQ+kz0cXJsLdb3HN4WMphVjyiU9pFdg== dependencies: - "@sentry/core" "7.54.0" - "@sentry/types" "7.54.0" - "@sentry/utils" "7.54.0" + "@sentry/core" "7.56.0" + "@sentry/types" "7.56.0" + "@sentry/utils" "7.56.0" -"@sentry/tracing@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.54.0.tgz#8364cec20aadc16d8ffcfd4ed9e437e1d317fa87" - integrity sha512-IyflAAqOiKuNvhWXrJsXN8yfl8DbHRpfgtCEPo5TBvdkpcyxUyfE8W2a2MQ8MXDzgfJT1IixXEwleO+qPIi3Gg== +"@sentry/tracing@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.56.0.tgz#f119c2b04c06718fa3a0d00b2781c56005e9dd80" + integrity sha512-Qy7lJdC2YBk9T8JFt4da7xHB3pTZH6yUiIwo5edmSBv2cY6MQ0QZgLzsjJurjf47+/WecVYYKdye9q4twsBlDA== dependencies: - "@sentry-internal/tracing" "7.54.0" + "@sentry-internal/tracing" "7.56.0" -"@sentry/types@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.54.0.tgz#bfee18107a78e290e6c8ad41646e2b9d9dd95234" - integrity sha512-D+i9xogBeawvQi2r0NOrM7zYcUaPuijeME4O9eOTrDF20tj71hWtJLilK+KTGLYFtpGg1h+9bPaz7OHEIyVopg== +"@sentry/types@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.56.0.tgz#9042a099cf9e8816d081886d24b88082a5d9f87a" + integrity sha512-5WjhVOQm75ItOytOx2jTx+5yw8/qJ316+g1Di8dS9+kgIi1zniqdMcX00C2yYe3FMUgFB49PegCUYulm9Evapw== -"@sentry/utils@7.54.0": - version "7.54.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.54.0.tgz#a3acb5e25a1409cbca7b46d6356d7417a253ea9a" - integrity sha512-3Yf5KlKjIcYLddOexSt2ovu2TWlR4Fi7M+aCK8yUTzwNzf/xwFSWOstHlD/WiDy9HvfhWAOB/ukNTuAeJmtasw== +"@sentry/utils@7.56.0": + version "7.56.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.56.0.tgz#e60e4935d17b2197584abf6ce61b522ad055352c" + integrity sha512-wgeX7bufxc//TjjSIE+gCMm8hVId7Jzvc+f441bYrWnNZBuzPIDW2BummCcPrKzSYe5GeYZDTZGV8YZGMLGBjw== dependencies: - "@sentry/types" "7.54.0" + "@sentry/types" "7.56.0" tslib "^1.9.3" "@sentry/wizard@^1.1.4": diff --git a/ios/Plugin.xcodeproj/project.pbxproj b/ios/Plugin.xcodeproj/project.pbxproj index f89699a4..597dbf55 100644 --- a/ios/Plugin.xcodeproj/project.pbxproj +++ b/ios/Plugin.xcodeproj/project.pbxproj @@ -285,12 +285,14 @@ "${BUILT_PRODUCTS_DIR}/Capacitor/Capacitor.framework", "${BUILT_PRODUCTS_DIR}/CapacitorCordova/Cordova.framework", "${BUILT_PRODUCTS_DIR}/Sentry/Sentry.framework", + "${BUILT_PRODUCTS_DIR}/SentryPrivate/SentryPrivate.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Capacitor.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cordova.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sentry.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SentryPrivate.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -454,7 +456,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Plugin/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)"; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin; @@ -479,7 +481,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Plugin/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin; diff --git a/ios/Plugin/Plugin.swift b/ios/Plugin/Plugin.swift index 7fb8a25d..351cf69a 100644 --- a/ios/Plugin/Plugin.swift +++ b/ios/Plugin/Plugin.swift @@ -16,7 +16,7 @@ public class SentryCapacitor: CAPPlugin { private var didReceiveDidBecomeActiveNotification = false public override func load() { - self.registerObserver() + registerObserver() } private func registerObserver() { @@ -46,15 +46,14 @@ public class SentryCapacitor: CAPPlugin { let options = try Options.init(dict: optionsDict) // Note: For now, in sentry-cocoa, beforeSend is not called before captureEnvelope - options.beforeSend = { event in - self.setEventOriginTag(event: event) - + options.beforeSend = { [weak self] event in + self?.setEventOriginTag(event: event) return event } SentrySDK.start(options: options) - self.sentryOptions = options + sentryOptions = options // checking enableAutoSessionTracking is actually not necessary, but we'd spare the sent bits. if didReceiveDidBecomeActiveNotification && sentryOptions?.enableAutoSessionTracking == true { @@ -72,20 +71,19 @@ public class SentryCapacitor: CAPPlugin { } @objc func captureEnvelope(_ call: CAPPluginCall) { - guard let bytes = call.getArray("envelope") as? [NSNumber] else { + guard let bytes = call.getArray("envelope", NSNumber.self) else { print("Cannot parse the envelope data") call.reject("Envelope is null or empty") return } let pointer = UnsafeMutablePointer.allocate(capacity: bytes.count) - for (index, number) in bytes.enumerated() - { + for (index, number) in bytes.enumerated() { // The numbers are stored as int32/64 but only the initial bits contains the number so this conversion is safe pointer[index] = UInt8(number.intValue) } - var data = Data(buffer: UnsafeMutableBufferPointer(start: pointer, count: bytes.count)) + let data = Data(buffer: UnsafeMutableBufferPointer(start: pointer, count: bytes.count)) guard let envelope = PrivateSentrySDKOnly.envelope(with: data) else { call.reject("SentryCapacitor", "Failed to parse envelope from byte array.", nil) @@ -99,11 +97,9 @@ public class SentryCapacitor: CAPPlugin { } @objc func getStringBytesLength(_ call: CAPPluginCall) { - let payloadSize = call.getString("string")?.utf8.count - if (payloadSize != nil) { - call.resolve(["value": payloadSize!]) - } - else { + if let payloadSize = call.getString("string")?.utf8.count { + call.resolve(["value": payloadSize]) + } else { call.reject("Coud not calculate string length.") } } @@ -127,40 +123,49 @@ public class SentryCapacitor: CAPPlugin { @objc func fetchNativeDeviceContexts(_ call: CAPPluginCall) { // Based on: https://github.com/getsentry/sentry-react-native/blob/a8d5ac86e3c53c90ef8e190cc082bdac440bd2a7/ios/RNSentry.m#L156-L188 + // Updated with: https://github.com/getsentry/sentry-react-native/blob/241b7c2831f1bb5691c735058d8dc3de61c40fac/ios/RNSentry.mm#L190-L228 // Temp work around until sorted out this API in sentry-cocoa. // TODO: If the callback isnt' executed the promise wouldn't be resolved. - SentrySDK.configureScope { [self] scope in + SentrySDK.configureScope { [weak self] scope in var contexts: [String : Any?] = [:] - let serializedScope = scope.serialize() + for (key, value) in serializedScope { + contexts[key] = value + } + if contexts["user"] == nil { + contexts["user"] = ["id" : PrivateSentrySDKOnly.installationID] + } - // Scope serializes as 'context' instead of 'contexts' as it does for the event. - let tempContexts = serializedScope["context"] - - var user: [String : Any?] = [:] - let tempUser = serializedScope["user"] as? [String : Any?] - if (tempUser != nil) { - for (key, value) in tempUser! { - user[key] = value; + if self?.sentryOptions?.debug == true { + let data: Data? = try? JSONSerialization.data(withJSONObject: contexts, options: []) + if let data = data { + let debugContext = String(data: data, encoding: .utf8) + print("Contexts: \(debugContext ?? "")") } - } else { - user["id"] = PrivateSentrySDKOnly.installationID } - contexts["user"] = user - if (tempContexts != nil) { - contexts["context"] = tempContexts + let extraContext = PrivateSentrySDKOnly.getExtraContext() + var context = contexts["context"] as? [String: Any] ?? [:] + + if let deviceExtraContext = extraContext["device"] as? [String: Any] { + var deviceContext = context["device"] as? [String: Any] ?? [:] + for (key, value) in deviceExtraContext { + deviceContext[key] = value + } + context["device"] = deviceContext } - if (self.sentryOptions?.debug == true) - { - let data: Data? = try? JSONSerialization.data(withJSONObject: contexts, options: []) - var debugContext: String? - if let data = data { - debugContext = String(data: data, encoding: .utf8) + + if let appExtraContext = extraContext["app"] as? [String: Any] { + var appContext = context["app"] as? [String: Any] ?? [:] + for (key, value) in appExtraContext { + appContext[key] = value } - print("Contexts: \(debugContext ?? "")") + context["app"] = appContext } - call.resolve(contexts as PluginCallResultData) + + contexts["context"] = context + + call.resolve(contexts as PluginResultData) } } @@ -175,7 +180,6 @@ public class SentryCapacitor: CAPPlugin { } else { let user = User() - if let userId = defaultUserKeys?["id"] as? String { user.userId = userId } @@ -231,15 +235,15 @@ public class SentryCapacitor: CAPPlugin { } @objc func addBreadcrumb(_ call: CAPPluginCall) { - SentrySDK.configureScope { scope in + SentrySDK.configureScope { [weak self] scope in let breadcrumb = Breadcrumb() if let timestamp = call.getDouble("timestamp") { breadcrumb.timestamp = Date(timeIntervalSince1970: timestamp) } - if let level = call.getString("level") { - breadcrumb.level = self.processLevel(level) + if let level = call.getString("level"), let processedLevel = self?.processLevel(level) { + breadcrumb.level = processedLevel } if let category = call.getString("category") { @@ -250,7 +254,7 @@ public class SentryCapacitor: CAPPlugin { breadcrumb.message = call.getString("message") breadcrumb.data = call.getObject("data") - scope.add(breadcrumb) + scope.addBreadcrumb(breadcrumb) } call.resolve() @@ -286,17 +290,10 @@ public class SentryCapacitor: CAPPlugin { } private func setEventOriginTag(event: Event) { - guard let sdk = event.sdk else { + guard let sdk = event.sdk, isValidSdk(sdk: sdk), let name = sdk["name"] as? String, name == "sentry.cocoa" else { return } - if isValidSdk(sdk: sdk) { - switch sdk["name"] as? String { - case "sentry.cocoa": - setEventEnvironmentTag(event: event, origin: "ios", environment: "native") - default: - return - } - } + setEventEnvironmentTag(event: event, origin: "ios", environment: "native") } private func setEventEnvironmentTag(event: Event, origin: String, environment: String) { diff --git a/ios/Podfile b/ios/Podfile index 1c598e63..da926be8 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,6 +1,6 @@ require_relative '../node_modules/@capacitor/ios/scripts/pods_helpers' -platform :ios, '13.0' +platform :ios, '11.0' def capacitor_pods # Comment the next line if you're not using Swift and don't want to use dynamic frameworks @@ -12,7 +12,7 @@ end target 'Plugin' do capacitor_pods - pod 'Sentry/HybridSDK', '7.30.2' + pod 'Sentry/HybridSDK', '8.8.0' end target 'PluginTests' do diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a1ecac63..48bd732a 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,19 +1,20 @@ PODS: - - Capacitor (4.0.1): + - Capacitor (5.0.4): - CapacitorCordova - - CapacitorCordova (4.0.1) - - Sentry (7.27.1): - - Sentry/Core (= 7.27.1) - - Sentry/Core (7.27.1) + - CapacitorCordova (5.0.4) + - Sentry/HybridSDK (8.8.0): + - SentryPrivate (= 8.8.0) + - SentryPrivate (8.8.0) DEPENDENCIES: - "Capacitor (from `../node_modules/@capacitor/ios`)" - "CapacitorCordova (from `../node_modules/@capacitor/ios`)" - - Sentry (= 7.27.1) + - Sentry/HybridSDK (= 8.8.0) SPEC REPOS: trunk: - Sentry + - SentryPrivate EXTERNAL SOURCES: Capacitor: @@ -22,10 +23,11 @@ EXTERNAL SOURCES: :path: "../node_modules/@capacitor/ios" SPEC CHECKSUMS: - Capacitor: 706b36563433f4a866cbe6d2eade7c04725d9e08 - CapacitorCordova: 728728aeeee853028558fefb4ccf7310e9d85a7a - Sentry: bc644307e2eb6a4c9c55cf117a80b895bb2a25a7 + Capacitor: d3d4463573438b9fa65326d1f3549da6f4c21634 + CapacitorCordova: b1fe6bf1f36974a8e4a9044b342d22d49c0996d6 + Sentry: 927dfb29d18a14d924229a59cc2ad149f43349f2 + SentryPrivate: 4350d865f898224ab9fa02b37d6ee7fbb623f47e -PODFILE CHECKSUM: 45aa9f5ace9de5db6ba43d0d21d381f3222a0bbe +PODFILE CHECKSUM: 9a2567a23dab418c80582123cf792dc7a97fb7c6 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3