|
5 | 5 | #import <OCMock/OCMock.h> |
6 | 6 | #import <RNSentry/RNSentry.h> |
7 | 7 | #import <Sentry/PrivateSentrySDKOnly.h> |
| 8 | +#import <Sentry/SentryProfilingConditionals.h> |
8 | 9 | #import <UIKit/UIKit.h> |
9 | 10 | #import <XCTest/XCTest.h> |
10 | 11 | @import Sentry; |
@@ -1372,6 +1373,91 @@ - (void)testStartBeforeBreadcrumbsCallbackDoesNotFiltersOutNonDevServerOrDsnRequ |
1372 | 1373 | XCTAssertEqual(breadcrumb, result); |
1373 | 1374 | } |
1374 | 1375 |
|
| 1376 | +#if SENTRY_TARGET_PROFILING_SUPPORTED |
| 1377 | +// Regression test for the v8.0.0 bug where the init path (RNSentryStart) did not |
| 1378 | +// handle `_experiments.profilingOptions`, silently dropping iOS UI profiling config. |
| 1379 | +// This pins the full entry point used by `initNativeSdk` in RNSentry.mm. |
| 1380 | +- (void)testStartWithDictionaryInstallsConfigureProfilingFromExperimentsProfilingOptions |
| 1381 | +{ |
| 1382 | + NSError *error = nil; |
| 1383 | + |
| 1384 | + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ |
| 1385 | + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", |
| 1386 | + @"_experiments" : @ { |
| 1387 | + @"profilingOptions" : @ { |
| 1388 | + @"profileSessionSampleRate" : @1.0, |
| 1389 | + @"lifecycle" : @"trace", |
| 1390 | + @"startOnAppStart" : @YES, |
| 1391 | + }, |
| 1392 | + }, |
| 1393 | + }; |
| 1394 | + [RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error]; |
| 1395 | + SentryOptions *actualOptions = PrivateSentrySDKOnly.options; |
| 1396 | + |
| 1397 | + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); |
| 1398 | + XCTAssertNil(error, @"Should not pass no error"); |
| 1399 | + XCTAssertNotNil(actualOptions.configureProfiling, |
| 1400 | + @"configureProfiling must be installed after startWithOptions when profilingOptions is " |
| 1401 | + @"present"); |
| 1402 | +} |
| 1403 | + |
| 1404 | +- (void)testStartCreateOptionsWithDictionaryProfilingOptionsInstallsConfigureProfiling |
| 1405 | +{ |
| 1406 | + NSError *error = nil; |
| 1407 | + |
| 1408 | + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ |
| 1409 | + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", |
| 1410 | + @"_experiments" : @ { |
| 1411 | + @"profilingOptions" : @ { |
| 1412 | + @"profileSessionSampleRate" : @1.0, |
| 1413 | + @"lifecycle" : @"trace", |
| 1414 | + @"startOnAppStart" : @YES, |
| 1415 | + }, |
| 1416 | + }, |
| 1417 | + }; |
| 1418 | + SentryOptions *actualOptions = |
| 1419 | + [RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; |
| 1420 | + |
| 1421 | + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); |
| 1422 | + XCTAssertNil(error, @"Should not pass no error"); |
| 1423 | + XCTAssertNotNil(actualOptions.configureProfiling, |
| 1424 | + @"configureProfiling callback should be installed when profilingOptions is present"); |
| 1425 | +} |
| 1426 | + |
| 1427 | +- (void)testStartCreateOptionsWithDictionaryProfilingOptionsMissingDoesNotInstallConfigureProfiling |
| 1428 | +{ |
| 1429 | + NSError *error = nil; |
| 1430 | + |
| 1431 | + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ |
| 1432 | + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", |
| 1433 | + }; |
| 1434 | + SentryOptions *actualOptions = |
| 1435 | + [RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; |
| 1436 | + |
| 1437 | + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); |
| 1438 | + XCTAssertNil(error, @"Should not pass no error"); |
| 1439 | + XCTAssertNil(actualOptions.configureProfiling, |
| 1440 | + @"configureProfiling callback should not be installed without profilingOptions"); |
| 1441 | +} |
| 1442 | + |
| 1443 | +- (void)testStartCreateOptionsWithDictionaryEmptyExperimentsDoesNotInstallConfigureProfiling |
| 1444 | +{ |
| 1445 | + NSError *error = nil; |
| 1446 | + |
| 1447 | + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ |
| 1448 | + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", |
| 1449 | + @"_experiments" : @ { }, |
| 1450 | + }; |
| 1451 | + SentryOptions *actualOptions = |
| 1452 | + [RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; |
| 1453 | + |
| 1454 | + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); |
| 1455 | + XCTAssertNil(error, @"Should not pass no error"); |
| 1456 | + XCTAssertNil(actualOptions.configureProfiling, |
| 1457 | + @"configureProfiling callback should not be installed when profilingOptions is absent"); |
| 1458 | +} |
| 1459 | +#endif |
| 1460 | + |
1375 | 1461 | - (void)testStartEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags |
1376 | 1462 | { |
1377 | 1463 | SentryEvent *testEvent = [[SentryEvent alloc] init]; |
|
0 commit comments