|
37 | 37 | public class SentryCordova extends CordovaPlugin { |
38 | 38 | private static final String TAG = "Sentry"; |
39 | 39 |
|
| 40 | + private static final String NATIVE_SDK_NAME = "sentry.native.android.cordova"; |
| 41 | + private static final String ANDROID_SDK_NAME = "sentry.java.android.cordova"; |
| 42 | + |
40 | 43 | final static Logger logger = Logger.getLogger("sentry-cordova"); |
41 | 44 |
|
42 | 45 | private SentryOptions sentryOptions; |
@@ -165,6 +168,13 @@ private void startWithOptions(final JSONObject jsonOptions, final CallbackContex |
165 | 168 | logger.info(String.format("Starting with DSN: '%s'", dsn)); |
166 | 169 | options.setDsn(dsn); |
167 | 170 |
|
| 171 | + SdkVersion sdkVersion = options.getSdkVersion(); |
| 172 | + if (sdkVersion == null) { |
| 173 | + sdkVersion = new SdkVersion(ANDROID_SDK_NAME, BuildConfig.VERSION_NAME); |
| 174 | + } else { |
| 175 | + sdkVersion.setName(ANDROID_SDK_NAME); |
| 176 | + } |
| 177 | + |
168 | 178 | boolean debug = jsonOptions.optBoolean("debug", false); |
169 | 179 | options.setDebug(debug); |
170 | 180 |
|
@@ -211,6 +221,8 @@ private void startWithOptions(final JSONObject jsonOptions, final CallbackContex |
211 | 221 | return event; |
212 | 222 | }); |
213 | 223 |
|
| 224 | + options.setNativeSdkName(NATIVE_SDK_NAME); |
| 225 | + |
214 | 226 | sentryOptions = options; |
215 | 227 | } catch (JSONException e) { |
216 | 228 | logger.severe("Error parsing options JSON sent over native bridge."); |
@@ -422,20 +434,20 @@ private void setEventOriginTag(SentryEvent event) { |
422 | 434 | if (sdk != null) { |
423 | 435 | switch (sdk.getName()) { |
424 | 436 | // If the event is from cordova js, it gets set there and we do not handle it here. |
425 | | - case "sentry.native": |
426 | | - setEventEnvironmentTag(event, "android", "native"); |
| 437 | + case NATIVE_SDK_NAME: |
| 438 | + setEventEnvironmentTag(event, "native"); |
427 | 439 | break; |
428 | | - case "sentry.java.android": |
429 | | - setEventEnvironmentTag(event, "android", "java"); |
| 440 | + case ANDROID_SDK_NAME: |
| 441 | + setEventEnvironmentTag(event, "java"); |
430 | 442 | break; |
431 | 443 | default: |
432 | 444 | break; |
433 | 445 | } |
434 | 446 | } |
435 | 447 | } |
436 | 448 |
|
437 | | - private void setEventEnvironmentTag(SentryEvent event, String origin, String environment) { |
438 | | - event.setTag("event.origin", origin); |
| 449 | + private void setEventEnvironmentTag(SentryEvent event, String environment) { |
| 450 | + event.setTag("event.origin", "android"); |
439 | 451 | event.setTag("event.environment", environment); |
440 | 452 | } |
441 | 453 |
|
|
0 commit comments