|  | 
| 28 | 28 | NSString *const kSentryLaunchProfileConfigKeyTracesSampleRand = @"traces.sample_rand"; | 
| 29 | 29 | NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRate = @"profiles"; | 
| 30 | 30 | NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRand = @"profiles.sample_rand"; | 
| 31 |  | -#    if !SDK_V9 | 
| 32 |  | -NSString *const kSentryLaunchProfileConfigKeyContinuousProfiling = @"continuous-profiling"; | 
| 33 |  | -#    endif // !SDK_V9 | 
| 34 | 31 | NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2 | 
| 35 | 32 |     = @"continuous-profiling-v2-enabled"; | 
| 36 | 33 | NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle | 
|  | 
| 83 | 80 |                                         profileOptions:profileOptions]; | 
| 84 | 81 | } | 
| 85 | 82 | 
 | 
| 86 |  | -void | 
| 87 |  | -_sentry_continuousProfilingV1_startLaunchProfile(BOOL shouldWaitForFullDisplay) | 
| 88 |  | -{ | 
| 89 |  | -    sentry_profileConfiguration = | 
| 90 |  | -        [[SentryProfileConfiguration alloc] initWaitingForFullDisplay:shouldWaitForFullDisplay | 
| 91 |  | -                                                         continuousV1:YES]; | 
| 92 |  | -    [SentryContinuousProfiler start]; | 
| 93 |  | -} | 
| 94 |  | - | 
| 95 | 83 | /** | 
| 96 | 84 |  * Hydrate any relevant launch profiling options persisted from the previous launch and start a | 
| 97 | 85 |  * trace that will automatically start a manual lifecycle continuous profile (v2) | 
|  | 
| 162 | 150 | } | 
| 163 | 151 | 
 | 
| 164 | 152 | SentryLaunchProfileDecision | 
| 165 |  | -sentry_launchShouldHaveContinuousProfilingV2(SentryOptions *options) | 
|  | 153 | +sentry_launchShouldHaveContinuousProfiling(SentryOptions *options) | 
| 166 | 154 | { | 
| 167 | 155 |     if (!options.profiling.profileAppStarts) { | 
| 168 | 156 |         SENTRY_LOG_DEBUG(@"Continuous profiling v2 enabled but disabled app start profiling, " | 
|  | 
| 219 | 207 | SentryLaunchProfileDecision | 
| 220 | 208 | sentry_shouldProfileNextLaunch(SentryOptions *options) | 
| 221 | 209 | { | 
| 222 |  | -    if ([options isContinuousProfilingV2Enabled]) { | 
| 223 |  | -        return sentry_launchShouldHaveContinuousProfilingV2(options); | 
|  | 210 | +    if ([options isContinuousProfilingEnabled]) { | 
|  | 211 | +        return sentry_launchShouldHaveContinuousProfiling(options); | 
| 224 | 212 |     } | 
| 225 | 213 |     return (SentryLaunchProfileDecision) { NO, nil, nil }; | 
| 226 | 214 | } | 
|  | 
| 269 | 257 |     BOOL isContinuousV2 = | 
| 270 | 258 |         [persistedLaunchConfigOptionsDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] | 
| 271 | 259 |             boolValue]; | 
| 272 |  | -#    if !SDK_V9 | 
| 273 |  | -    BOOL isContinuousV1 = | 
| 274 |  | -        [persistedLaunchConfigOptionsDict[kSentryLaunchProfileConfigKeyContinuousProfiling] | 
| 275 |  | -            boolValue]; | 
| 276 |  | -    if (isContinuousV1 && isContinuousV2) { | 
| 277 |  | -        SENTRY_LOG_WARN(@"Launch profile misconfiguration detected."); | 
| 278 |  | -        _sentry_cleanUpConfigFile(); | 
| 279 |  | -        return; | 
| 280 |  | -    } | 
| 281 |  | -#    else | 
| 282 |  | -    BOOL isContinuousV1 = false; | 
| 283 |  | -#    endif // !SDK_V9 | 
| 284 | 260 | 
 | 
| 285 | 261 |     SentrySamplerDecision *decision | 
| 286 | 262 |         = _sentry_profileSampleDecision(persistedLaunchConfigOptionsDict); | 
| 287 |  | -    if (!isContinuousV1 && nil == decision) { | 
|  | 263 | +    if (nil == decision) { | 
| 288 | 264 |         SENTRY_LOG_DEBUG(@"Couldn't hydrate the persisted sample decision."); | 
| 289 | 265 |         _sentry_cleanUpConfigFile(); | 
| 290 | 266 |         return; | 
|  | 
| 302 | 278 | 
 | 
| 303 | 279 |     BOOL shouldWaitForFullDisplay = shouldWaitForFullDisplayValue.boolValue; | 
| 304 | 280 | 
 | 
| 305 |  | -    if (isContinuousV1) { | 
| 306 |  | -        SENTRY_LOG_DEBUG(@"Starting continuous launch profile v1."); | 
| 307 |  | -        _sentry_continuousProfilingV1_startLaunchProfile(shouldWaitForFullDisplay); | 
| 308 |  | -        _sentry_cleanUpConfigFile(); | 
| 309 |  | -        return; | 
| 310 |  | -    } | 
| 311 |  | - | 
| 312 | 281 |     SentryProfileOptions *profileOptions = nil; | 
| 313 | 282 |     if (isContinuousV2) { | 
| 314 | 283 |         SENTRY_LOG_DEBUG(@"Starting continuous launch profile v2."); | 
|  | 
| 336 | 305 |             SentryProfileLifecycleTrace, shouldWaitForFullDisplay); | 
| 337 | 306 |     } else { | 
| 338 | 307 |         sentry_profileConfiguration = | 
| 339 |  | -            [[SentryProfileConfiguration alloc] initWaitingForFullDisplay:shouldWaitForFullDisplay | 
| 340 |  | -                                                             continuousV1:NO]; | 
|  | 308 | +            [[SentryProfileConfiguration alloc] initWaitingForFullDisplay:shouldWaitForFullDisplay]; | 
| 341 | 309 |     } | 
| 342 | 310 | 
 | 
| 343 | 311 |     // trace lifecycle UI profiling (continuous profiling v2) and trace-based profiling both join | 
|  | 
| 365 | 333 |             [NSMutableDictionary<NSString *, NSNumber *> dictionary]; | 
| 366 | 334 |         configDict[kSentryLaunchProfileConfigKeyWaitForFullDisplay] = | 
| 367 | 335 |             @(options.enableTimeToFullDisplayTracing); | 
| 368 |  | -#    if !SDK_V9 | 
| 369 | 336 |         if ([options isContinuousProfilingEnabled]) { | 
| 370 |  | -#    endif // !SDK_V9 | 
| 371 |  | -            if ([options isContinuousProfilingV2Enabled]) { | 
| 372 |  | -                SENTRY_LOG_DEBUG(@"Configuring continuous launch profile v2."); | 
| 373 |  | -                configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] = @YES; | 
| 374 |  | -                configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle] = | 
| 375 |  | -                    @(options.profiling.lifecycle); | 
| 376 |  | -                if (options.profiling.lifecycle == SentryProfileLifecycleTrace) { | 
| 377 |  | -                    configDict[kSentryLaunchProfileConfigKeyTracesSampleRate] | 
| 378 |  | -                        = config.tracesDecision.sampleRate; | 
| 379 |  | -                    configDict[kSentryLaunchProfileConfigKeyTracesSampleRand] | 
| 380 |  | -                        = config.tracesDecision.sampleRand; | 
| 381 |  | -                } | 
| 382 |  | -                configDict[kSentryLaunchProfileConfigKeyProfilesSampleRate] | 
| 383 |  | -                    = config.profilesDecision.sampleRate; | 
| 384 |  | -                configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand] | 
| 385 |  | -                    = config.profilesDecision.sampleRand; | 
| 386 |  | -            } else { | 
| 387 |  | -#    if !SDK_V9 | 
| 388 |  | -                SENTRY_LOG_DEBUG(@"Configuring continuous launch profile."); | 
| 389 |  | -                configDict[kSentryLaunchProfileConfigKeyContinuousProfiling] = @YES; | 
| 390 |  | -#    endif // !SDK_V9 | 
|  | 337 | +            SENTRY_LOG_DEBUG(@"Configuring continuous launch profile v2."); | 
|  | 338 | +            configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] = @YES; | 
|  | 339 | +            configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle] = | 
|  | 340 | +                @(options.profiling.lifecycle); | 
|  | 341 | +            if (options.profiling.lifecycle == SentryProfileLifecycleTrace) { | 
|  | 342 | +                configDict[kSentryLaunchProfileConfigKeyTracesSampleRate] | 
|  | 343 | +                    = config.tracesDecision.sampleRate; | 
|  | 344 | +                configDict[kSentryLaunchProfileConfigKeyTracesSampleRand] | 
|  | 345 | +                    = config.tracesDecision.sampleRand; | 
| 391 | 346 |             } | 
| 392 |  | -#    if !SDK_V9 | 
| 393 |  | -        } else { | 
| 394 |  | -            SENTRY_LOG_DEBUG(@"Configuring trace launch profile."); | 
| 395 |  | -            configDict[kSentryLaunchProfileConfigKeyTracesSampleRate] | 
| 396 |  | -                = config.tracesDecision.sampleRate; | 
| 397 |  | -            configDict[kSentryLaunchProfileConfigKeyTracesSampleRand] | 
| 398 |  | -                = config.tracesDecision.sampleRand; | 
| 399 | 347 |             configDict[kSentryLaunchProfileConfigKeyProfilesSampleRate] | 
| 400 | 348 |                 = config.profilesDecision.sampleRate; | 
| 401 | 349 |             configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand] | 
| 402 | 350 |                 = config.profilesDecision.sampleRand; | 
| 403 | 351 |         } | 
| 404 |  | -#    endif // !SDK_V9 | 
| 405 | 352 |         writeAppLaunchProfilingConfigFile(configDict); | 
| 406 | 353 |     }]; | 
| 407 | 354 | } | 
|  | 
0 commit comments