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

Demo: Restart Rollbar with new access token without requiring submission #272

Merged
merged 1 commit into from
Mar 21, 2023
Merged
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
4 changes: 2 additions & 2 deletions Demos/iosAppSwift/iosAppSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 50;
DEVELOPMENT_ASSET_PATHS = "\"iosAppSwift/Preview Content\"";
DEVELOPMENT_TEAM = 9P5JVC2F34;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -320,7 +320,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 50;
DEVELOPMENT_ASSET_PATHS = "\"iosAppSwift/Preview Content\"";
DEVELOPMENT_TEAM = 9P5JVC2F34;
ENABLE_PREVIEWS = YES;
Expand Down
15 changes: 12 additions & 3 deletions Demos/iosAppSwift/iosAppSwift/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ struct ContentView: View {
.tint(.blue)
}

func restart() {
func restartIfValid(_ accessToken: String) {
guard accessToken.isValid else { return }

let config = Rollbar.configuration().mutableCopy()
config.destination.accessToken = accessToken
Rollbar.update(withConfiguration: config)

Rollbar.infoMessage("Rollbar Apple SDK access token changed.")

print("Rollbar Apple SDK access token changed to \(accessToken)")
}

var body: some View {
Expand All @@ -40,7 +45,7 @@ struct ContentView: View {
.multilineTextAlignment(.center)
.textCase(.lowercase)
.lineLimit(1)
.onSubmit(accessToken.isValid ? restart : {})
.onChange(of: accessToken, perform: restartIfValid)
.padding(.bottom)

ScrollView {
Expand Down Expand Up @@ -88,10 +93,14 @@ struct Example {

/// Some different ways to explicitly log an error to Rollbar.
func manualLogging() {
let extraInfo = ["item_1": "value_1", "item_2": "value_2"]
Rollbar.infoMessage(
"Rollbar is up and running! Enjoy your remote error and log monitoring...",
data: ["key_x": "value_x", "key_y": "value_y"])

Rollbar.log(.error, message: "My log message")

let extraInfo = ["item_1": "value_1", "item_2": "value_2"]

Rollbar.log(
.error,
error: ExampleError.invalidInput,
Expand Down
5 changes: 0 additions & 5 deletions Demos/iosAppSwift/iosAppSwift/iosAppSwiftApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ class AppDelegate: NSObject, UIApplicationDelegate {
// Initialize a Rollbar shared instance with a crash collector
Rollbar.initWithConfiguration(config)

// Note the ability to add aditional key/value pairs to the occurrence data for extra context
Rollbar.infoMessage(
"Rollbar is up and running! Enjoy your remote error and log monitoring...",
data: ["key_x": "value_x", "key_y": "value_y"])

return true
}
}
Expand Down