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

Configure Sentry for Mobile #21682

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ SHOW_NOT_IMPLEMENTED_FEATURES=0
ENABLE_ALERT_BANNER=0
FLAG_WALLET_CONNECT_ENABLED=1
API_LOGGING_ENABLED=1
SENTRY_ENVIRONMENT=ci-main
1 change: 1 addition & 0 deletions .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ ENABLE_ALERT_BANNER=0
FLAG_WALLET_CONNECT_ENABLED=1
MOBILE_DATA_SYNCING_TOGGLE_ENABLE=0
API_LOGGING_ENABLED=1
SENTRY_ENVIRONMENT=ci-main
1 change: 1 addition & 0 deletions .env.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ TEST_NETWORKS_ENABLED=1
ENABLE_ALERT_BANNER=1
FLAG_WALLET_CONNECT_ENABLED=1
API_LOGGING_ENABLED=1
SENTRY_ENVIRONMENT=ci-main
1 change: 1 addition & 0 deletions .env.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ TEST_NETWORKS_ENABLED=0
ENABLE_ALERT_BANNER=1
FLAG_WALLET_CONNECT_ENABLED=1
API_LOGGING_ENABLED=1
SENTRY_ENVIRONMENT=ci-nightly
1 change: 1 addition & 0 deletions .env.release
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ TEST_NETWORKS_ENABLED=0
STATUS_PROXY_STAGE_NAME=prod
FLAG_WALLET_CONNECT_ENABLED=1
API_LOGGING_ENABLED=0
SENTRY_ENVIRONMENT=production
3 changes: 2 additions & 1 deletion ci/Jenkinsfile.android
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library '[email protected].13'
library '[email protected].15'

/* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild()
Expand Down Expand Up @@ -41,6 +41,7 @@ pipeline {
BUILD_ENV = 'prod'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
FASTLANE_DISABLE_COLORS = 1
SENTRY_PRODUCTION = "${utils.isReleaseBuild() ? 'true' : 'false'}"
}

stages {
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.combined
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library '[email protected].13'
library '[email protected].15'

import groovy.json.JsonBuilder

Expand Down
3 changes: 2 additions & 1 deletion ci/Jenkinsfile.ios
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library '[email protected].13'
library '[email protected].15'

/* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild()
Expand Down Expand Up @@ -41,6 +41,7 @@ pipeline {
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
FASTLANE_DISABLE_COLORS = 1
BUNDLE_PATH = "${HOME}/.bundle"
SENTRY_PRODUCTION = "${utils.isReleaseBuild() ? 'true' : 'false'}"
}

stages {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class StatusModule(private val reactContext: ReactApplicationContext, private va
)
}

@ReactMethod
fun intendedPanic(message: String) {
StatusBackendClient.executeStatusGoRequest(
endpoint = "IntendedPanic",
requestBody = message,
statusgoFunction = { Statusgo.intendedPanic(message) },
)
}

@ReactMethod
fun addCentralizedMetric(request: String, callback: Callback) {
StatusBackendClient.executeStatusGoRequestWithCallback(
Expand Down
11 changes: 11 additions & 0 deletions modules/react-native-status/ios/RCTStatus/RCTStatus.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ - (void)handleSignal:(NSString *)signal
callback:callback];
}

RCT_EXPORT_METHOD(intendedPanic:(NSString *)message) {
ilmotta marked this conversation as resolved.
Show resolved Hide resolved
#if DEBUG
NSLog(@"IntendedPanic() method called");
#endif
[StatusBackendClient executeStatusGoRequest:@"IntendedPanic"
body:message
statusgoFunction:^NSString *{
return StatusgoIntendedPanic(message);
}];
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(fleets) {
return [StatusBackendClient executeStatusGoRequestWithResult:@"Fleets"
body:@""
Expand Down
37 changes: 28 additions & 9 deletions nix/status-go/mobile/build.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ callPackage, lib, buildGoPackage
, androidPkgs, openjdk, gomobile, xcodeWrapper, removeReferencesTo
, go-bindata, mockgen, protobuf3_20, protoc-gen-go
, go-bindata, mockgen, protobuf3_20, protoc-gen-go, git
, meta
, source
, platform ? "android"
Expand All @@ -11,7 +11,7 @@
, outputFileName ? "status-go-${source.shortRev}-${platform}.aar" }:

let
inherit (lib) concatStringsSep optionalString optional splitString;
inherit (lib) concatStringsSep optionalString optional splitString fileContents;
isIOS = platform == "ios";
isAndroid = platform == "android";
enforceXCodeAvailable = callPackage ./enforceXCodeAvailable.nix { };
Expand All @@ -29,7 +29,7 @@ in buildGoPackage rec {

extraSrcPaths = [ gomobile ];
nativeBuildInputs = [
gomobile removeReferencesTo go-bindata mockgen protoc-gen-go protobuf3_20
gomobile removeReferencesTo go-bindata mockgen protoc-gen-go protobuf3_20 git
] ++ optional isAndroid openjdk
++ optional isIOS xcodeWrapper;

Expand All @@ -46,12 +46,31 @@ in buildGoPackage rec {
# TODO: try removing when go is upgraded to 1.22
GODEBUG = "netdns=cgo+2";

preBuild = ''
echo 'Generate static files'
pushd go/src/$goPackagePath
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
popd
'';
# Sentry for status-go
SENTRY_CONTEXT_NAME = "status-mobile";
SENTRY_CONTEXT_VERSION = version;

preBuild = ''
# To fix fatal: not a git repository (or any of the parent directories): .git
git init --quiet --initial-branch=main .
git config user.email "nix@builder"
git config user.name "Nix Builder"
git commit --quiet --allow-empty -m "Initial commit"
git tag -a "v${source.cleanVersion}" -m "Version ${source.cleanVersion}"

# To fix sh: line 1: ../../_assets/scripts/version.sh: cannot execute: required file not found
mkdir -p go/src/github.com/status-im/status-go/_assets/scripts
cat > go/src/github.com/status-im/status-go/_assets/scripts/version.sh <<EOF
#!/usr/bin/env bash
echo "${source.version}"
EOF
chmod +x go/src/github.com/status-im/status-go/_assets/scripts/version.sh

echo 'Generate static files'
pushd go/src/$goPackagePath
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
popd
'';

buildPhase = ''
runHook preBuild
Expand Down
1 change: 1 addition & 0 deletions scripts/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SECRETS_ENV_VARS=(
'MIXPANEL_APP_ID'
'MIXPANEL_TOKEN'
'POKT_TOKEN'
'SENTRY_DSN_STATUS_GO'
)

# Secrets like this can't be passed via args or they end up in derivation.
Expand Down
8 changes: 7 additions & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
#shadow/env "STATUS_BACKEND_SERVER_IMAGE_SERVER_URI_PREFIX"
status-im.config/STATUS_BACKEND_SERVER_ROOT_DATA_DIR #shadow/env
"STATUS_BACKEND_SERVER_ROOT_DATA_DIR"

;; Uncomment this line during development if you want to test the integration with Sentry.
;;
;; status-im.config/SENTRY_DSN_STATUS_GO #shadow/env "SENTRY_DSN_STATUS_GO"

status-im.config/MIXPANEL_APP_ID #shadow/env "MIXPANEL_APP_ID"
status-im.config/MIXPANEL_TOKEN #shadow/env "MIXPANEL_TOKEN"
status-im.config/OPENSEA_API_KEY #shadow/env "OPENSEA_API_KEY"
Expand Down Expand Up @@ -123,7 +128,8 @@
status-im.config/ALCHEMY_ARBITRUM_MAINNET_TOKEN #shadow/env "ALCHEMY_ARBITRUM_MAINNET_TOKEN"
status-im.config/ALCHEMY_ARBITRUM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_ARBITRUM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_MAINNET_TOKEN #shadow/env "ALCHEMY_OPTIMISM_MAINNET_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"}
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"
status-im.config/SENTRY_DSN_STATUS_GO #shadow/env "SENTRY_DSN_STATUS_GO"}
:compiler-options {:output-feature-set :es6
;;disable for android build as there
;;is an intermittent warning with deftype
Expand Down
14 changes: 13 additions & 1 deletion src/legacy/status_im/ui/screens/advanced_settings/views.cljs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
(ns legacy.status-im.ui.screens.advanced-settings.views
(:require
[clojure.string :as string]
[legacy.status-im.ui.components.core :as components]
[legacy.status-im.ui.components.list.item :as list.item]
[legacy.status-im.ui.components.list.views :as list]
[quo.core :as quo]
[re-frame.core :as re-frame]
[status-im.config :as config]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf])
(:require-macros [legacy.status-im.utils.views :as views]))
Expand All @@ -22,7 +25,16 @@
peer-syncing-enabled?]}]
(keep
identity
[{:size :small
[(when (ff/enabled? ::ff/app-monitoring.intentional-crash)
{:size :small
:title (str "Force crash immediately"
(when (string/blank? config/sentry-dsn-status-go)
" (Sentry DSN is not set)"))
:accessibility-label :intended-panic
:on-press (fn []
(re-frame/dispatch [:app-monitoring/intended-panic
"status-mobile intentional panic"]))})
{:size :small
:title (i18n/label :t/log-level)
:accessibility-label :log-level-settings-button
:on-press
Expand Down
4 changes: 4 additions & 0 deletions src/native_module/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,7 @@
(.createAccountFromPrivateKey ^js (account-manager)
(types/clj->json {:privateKey private-key})
callback)))

(defn intended-panic
[message]
(.intendedPanic ^js (status) message))
8 changes: 8 additions & 0 deletions src/status_im/common/app_monitoring/effects.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns status-im.common.app-monitoring.effects
(:require
[native-module.core :as native-module]
[utils.re-frame :as rf]))

(rf/reg-fx :effects.app-monitoring/intended-panic
(fn [message]
(native-module/intended-panic message)))
8 changes: 8 additions & 0 deletions src/status_im/common/app_monitoring/events.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns status-im.common.app-monitoring.events
(:require
status-im.common.app-monitoring.effects
[utils.re-frame :as rf]))

(rf/reg-event-fx :app-monitoring/intended-panic
(fn [_ [message]]
{:fx [[:effects.app-monitoring/intended-panic message]]}))
5 changes: 5 additions & 0 deletions src/status_im/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,8 @@
(goog-define STATUS_BACKEND_SERVER_ROOT_DATA_DIR "")
;; if you're using android simulator, I suggest set the env variable to "http://10.0.2.2:"
(goog-define STATUS_BACKEND_SERVER_IMAGE_SERVER_URI_PREFIX "https://localhost:")

;;;; Sentry
;; Documentation: status-go/internal/sentry/README.md
(goog-define SENTRY_DSN_STATUS_GO "")
(def sentry-dsn-status-go SENTRY_DSN_STATUS_GO)
1 change: 1 addition & 0 deletions src/status_im/contexts/profile/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
{:dataDir (native-module/backup-disabled-data-dir)
:mixpanelAppId config/mixpanel-app-id
:mixpanelToken config/mixpanel-token
:sentryDSN config/sentry-dsn-status-go
:mediaServerEnableTLS (config/enabled? config/STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS)
:logEnabled (not (string/blank? config/log-level))
:logLevel config/log-level
Expand Down
1 change: 1 addition & 0 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
status-im.common.alert-banner.events
status-im.common.alert.effects
status-im.common.app-monitoring.events
status-im.common.async-storage.effects
status-im.common.emoji-picker.events
status-im.common.font.events
Expand Down
1 change: 1 addition & 0 deletions src/status_im/feature_flags.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(def ^:private initial-flags
{::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)
::community.view-token-requirements (enabled-in-env? :FLAG_VIEW_TOKEN_REQUIREMENTS)
::app-monitoring.intentional-crash (enabled-in-env? :FLAG_INTENTIONAL_CRASH_ENABLED)

;; Feature toggled (off by default) because the desktop app disabled this
;; feature and we want both clients in sync. We keep the code because it
Expand Down
15 changes: 6 additions & 9 deletions src/tests/test_utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@

(def status
(clj->js
{:getNodeConfig
(fn [] (types/clj->json {:WakuV2Config ""}))
:addCentralizedMetric
(fn [_ callback]
(callback))
:fleets
(fn [] (.fleets native-status))
:startLocalNotifications
identity}))
{:intendedPanic identity
:getNodeConfig (fn [] (types/clj->json {:WakuV2Config ""}))
:addCentralizedMetric (fn [_ callback]
(callback))
:fleets (fn [] (.fleets native-status))
:startLocalNotifications identity}))