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

Sentry Integration for SDK #278

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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
3 changes: 3 additions & 0 deletions .arkana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global_secrets:
- SENTRY_DSN
package_manager: cocoapods
40 changes: 40 additions & 0 deletions ErrorReporting.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import ArkanaKeys
import Sentry

protocol ErrorReportingService {
func captureError(_ error: any Error, userInfo: [String: Any]?)
}

class SentryErrorReporter {
static let shared: SentryErrorReporter = SentryErrorReporter()

private let sentryHub: SentryHub

private init() {
// setup sentry options
let options = Sentry.Options()
options.dsn = ArkanaKeys.Global.sENTRY_DSN

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobitech should this be SENTRY_DSN?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is autogenerated by the tool used to encrypt the Sentry DSN.

options.releaseName = SmileID.version
options.enableCrashHandler = true
options.debug = true
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0

// setup sentry scope
let scope = Sentry.Scope()
scope.setTag(value: SmileID.config.partnerId, key: "partner_id")
let user = Sentry.User()
user.userId = SmileID.config.partnerId
scope.setUser(user)

// setup sentry hub
let sentryClient = SentryClient(options: options)
self.sentryHub = SentryHub(client: sentryClient, andScope: scope)
}
}

extension SentryErrorReporter: ErrorReportingService {
func captureError(_ error: any Error, userInfo: [String: Any]? = nil) {
sentryHub.capture(error: error)
}
}
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ platform :ios, '13.0'
target 'SmileID_Example' do
pod 'SmileID', :path => '../'
pod 'netfox'
pod 'Sentry'
pod 'Sentry', '~> 8.43.0'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to fix this to a specific Sentry version?

pod 'SwiftLint'
pod 'ArkanaKeys', :path => './ArkanaKeys/ArkanaKeys/'
pod 'ArkanaKeysInterfaces', :path => './ArkanaKeys/ArkanaKeysInterfaces/'
Expand Down
17 changes: 10 additions & 7 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ PODS:
- FingerprintJS/SystemControl (1.5.0)
- lottie-ios (4.4.3)
- netfox (1.21.0)
- Sentry (8.36.0):
- Sentry/Core (= 8.36.0)
- Sentry/Core (8.36.0)
- Sentry (8.43.0):
- Sentry/Core (= 8.43.0)
- Sentry/Core (8.43.0)
- SmileID (10.3.4):
- ArkanaKeys
- ArkanaKeysInterfaces
- FingerprintJS
- lottie-ios (~> 4.4.2)
- Sentry (~> 8.43.0)
- ZIPFoundation (~> 0.9)
- SwiftLint (0.55.1)
- ZIPFoundation (0.9.19)
Expand All @@ -23,7 +26,7 @@ DEPENDENCIES:
- ArkanaKeys (from `./ArkanaKeys/ArkanaKeys/`)
- ArkanaKeysInterfaces (from `./ArkanaKeys/ArkanaKeysInterfaces/`)
- netfox
- Sentry
- Sentry (~> 8.43.0)
- SmileID (from `../`)
- SwiftLint

Expand All @@ -50,11 +53,11 @@ SPEC CHECKSUMS:
FingerprintJS: 96410117a394cca04d0f1e2374944c8697f2cceb
lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418
netfox: 9d5cc727fe7576c4c7688a2504618a156b7d44b7
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
SmileID: 5a7c0437b9861b76d37a18e2f3d2f5a7b3056310
Sentry: 532b281a53b1b45a523fd592f608956fb36e577c
SmileID: e1c8829d2d6d0789f36f588bffff204118a3148e
SwiftLint: 3fe909719babe5537c552ee8181c0031392be933
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c

PODFILE CHECKSUM: ebb96bfc1b5a0c7f6061ff1e91ac138e67c1d9f4
PODFILE CHECKSUM: 3d594b06532c72adf95b06a33b17603190f6e8bb

COCOAPODS: 1.16.2
138 changes: 69 additions & 69 deletions Example/SmileID.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"version" : "4.5.0"
}
},
{
"identity" : "sentry-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/getsentry/sentry-cocoa",
"state" : {
"revision" : "f45e9c62d7a4d9258ac3cf35a3acf9dbab4481d1",
"version" : "8.43.0"
}
},
{
"identity" : "zipfoundation",
"kind" : "remoteSourceControl",
Expand Down
8 changes: 6 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/weichsel/ZIPFoundation.git", .upToNextMajor(from: "0.9.0")),
.package(url: "https://github.com/airbnb/lottie-spm", from: "4.4.2"),
.package(url: "https://github.com/fingerprintjs/fingerprintjs-ios", from: "1.5.0")
.package(url: "https://github.com/fingerprintjs/fingerprintjs-ios", from: "1.5.0"),
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.43.0"),
.package(name: "ArkanaKeys", path: "./ArkanaKeys")
],
targets: [
.target(
name: "SmileID",
dependencies: [
.product(name: "ZIPFoundation", package: "ZIPFoundation"),
.product(name: "FingerprintJS", package: "fingerprintjs-ios"),
.product(name: "Lottie", package: "lottie-spm")
.product(name: "Lottie", package: "lottie-spm"),
.product(name: "Sentry", package: "sentry-cocoa"),
.product(name: "ArkanaKeys", package: "ArkanaKeys")
],
path: "Sources/SmileID",
resources: [.process("Resources")]
Expand Down
3 changes: 3 additions & 0 deletions SmileID.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Pod::Spec.new do |s|
s.dependency 'ZIPFoundation', '~> 0.9'
s.dependency 'FingerprintJS'
s.dependency 'lottie-ios', '~> 4.4.2'
s.dependency 'Sentry', '~> 8.43.0'
s.dependency 'ArkanaKeys'
s.dependency 'ArkanaKeysInterfaces'
s.swift_version = '5.5'
s.source_files = 'Sources/SmileID/Classes/**/*'
s.resource_bundles = {
Expand Down
5 changes: 3 additions & 2 deletions Sources/SmileID/Classes/SmileID.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import FingerprintJS
import Foundation
import Sentry
import SwiftUI
import UIKit

Expand Down Expand Up @@ -95,8 +96,8 @@ public class SmileID {
SmileIDResourcesHelper.registerFonts()
let fingerprinter = FingerprinterFactory.getInstance()
Task {
/// The fingerprint isn't currently as stable as the Device Identifier, because the v
/// alues might change between OS updates or when the user changes settings
/// The fingerprint isn't currently as stable as the Device Identifier, because the
/// values might change between OS updates or when the user changes settings
/// used to compute the previous value.
/// https://github.com/fingerprintjs/fingerprintjs-ios
if let fingerprint = await fingerprinter.getDeviceId() {
Expand Down
Loading