getsentry / getsentry/sentry-cocoa

Be able to use app start and frames tracking when APM not enabled

Open
#2,262 2 comments 0 reactions 0 assignees View on GitHub
Cocoa Feature Spans
Dominant language
Swift
Stars
1.1k
Forks
418
Avg merge
2d 3h
Merged PRs (30d)
106

Description

### Problem Statement

When people decide to init the Hybrid SDKs manually, they follow [this step]().

`enableAutoPerformanceTracking` is already enabled by default and that's fine.

People already enable tracing in the Hybrid SDKs and may not want to enable it in the Native SDKs.

The problem is that `SentryAppStartTrackingIntegration` and `SentryFramesTrackingIntegration` are only installed if `isTracingEnabled` also returns true, which means a valid `tracesSampleRate` or `tracesSampler`.

So in order to get App start and Frames tracking on Hybrid SDKs when initing manually, people are forced to set one of them even if they don't want to.

The only workaround now is if people do (that's what the Hybrid SDKs do automatically):

```
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracking;
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracking;
#endif
```

But that's hacky and it should not be used by people anyway.

### Solution Brainstorm

Either remove the `isTracingEnabled` check from both integrations or `isTracingEnabled` returns `true` if tracesSampleRate is `0`, at least, we document that setting to 0 also works, better than exposing `PrivateSentrySDKOnly`.
Another option is to do a `or` condition, either `isTracingEnabled` or `enableAutoPerformanceTracking`, but since `enableAutoPerformanceTracking` is enabled by default, that's going to have the same effect.

The downside is that by enabling such integrations when tracing is disabled, you pay the runtime cost for something you are not using.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.