Skip to content

docs: Add Objective C examples to cocoa onboarding + non UI verification options #92506

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

Conversation

itaybre
Copy link
Contributor

@itaybre itaybre commented May 29, 2025

Apple onboarding only had Swift + UIKit verification steps.

Added:

  • Objective C code
  • Non UI options to verify the setup

Fixes getsentry/sentry-cocoa#4991

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@itaybre itaybre requested a review from a team as a code owner May 29, 2025 20:14
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 29, 2025
Copy link

codecov bot commented May 29, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
10418 3 10415 9
View the top 3 failed test(s) by shortest run time
apple-ios onboarding docs renders continuous profiling
Stack Traces | 0.093s run time
Error: expect(received).toHaveLength(expected)

Expected length: 2
Received length: 0
Received array:  []
    at Object.<anonymous> (.../gettingStartedDocs/apple/ios.spec.tsx:66:39)
    at Promise.then.completed (.../jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../jest-circus/build/run.js:316:40)
    at _runTest (.../jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../jest-circus/build/run.js:121:9)
    at run (.../jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../jest-runner/build/runTest.js:367:16)
    at runTest (.../jest-runner/build/runTest.js:444:34)
    at Object.worker (.../jest-runner/build/testWorker.js:106:12)
apple-ios onboarding docs renders transaction profiling
Stack Traces | 1.09s run time
Error: Unable to find an element with the text: function (_, element) { return findTextWithMarkup(element, textMatch); } (normalized from 'function (_, element) {
    return findTextWithMarkup(element, textMatch);
  }'). This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
...
    at waitForWrapper (.../sentry/sentry/node_modules/@.../dom/dist/wait-for.js:163:27)
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:86:33
    at Object.<anonymous> (.../gettingStartedDocs/apple/ios.spec.tsx:47:46)
    at Promise.then.completed (.../sentry/sentry/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/sentry/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/sentry/node_modules/jest-circus/build/run.js:316:40)
    at _runTest (.../sentry/sentry/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/sentry/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/sentry/node_modules/jest-circus/build/run.js:121:9)
    at run (.../sentry/sentry/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/sentry/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/sentry/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/sentry/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/sentry/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/sentry/node_modules/jest-runner/build/testWorker.js:106:12)
apple-ios onboarding docs renders performance onboarding docs correctly
Stack Traces | 1.1s run time
Error: Unable to find an element with the text: function (_, element) { return findTextWithMarkup(element, textMatch); } (normalized from 'function (_, element) {
    return findTextWithMarkup(element, textMatch);
  }'). This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
...
    at waitForWrapper (.../sentry/sentry/node_modules/@.../dom/dist/wait-for.js:163:27)
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:86:33
    at Object.<anonymous> (.../gettingStartedDocs/apple/ios.spec.tsx:33:46)
    at Promise.then.completed (.../sentry/sentry/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/sentry/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/sentry/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../sentry/sentry/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/sentry/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/sentry/node_modules/jest-circus/build/run.js:121:9)
    at run (.../sentry/sentry/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/sentry/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/sentry/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/sentry/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/sentry/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/sentry/node_modules/jest-runner/build/testWorker.js:106:12)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Member

@armcknight armcknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my reply here, I think the best non-UI (and indeed, probably the best overall) method to verify an install should be to simply capture a message.

If anyone leaves a delayed crash in by accident, it creeps back in due to weird merge situations, etc, that's much higher risk for customers.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that crashing as pointed out by @armcknight isn't a great idea, but instead of capturing a message I think we should stick to capturing errors. We already do that for most other onboarding docs, and errors are what users use Sentry mostly for.

Comment on lines 240 to 244
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20, 50, 100, 30);
[button setTitle:@"Break the world" forState:UIControlStateNormal];
[button addTarget:self action:@selector(breakTheWorld:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:button];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: IMO, we can ditch this part. It's noisy and I doubt many people are going to use it exactly like this.

Suggested change
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20, 50, 100, 30);
[button setTitle:@"Break the world" forState:UIControlStateNormal];
[button addTarget:self action:@selector(breakTheWorld:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:button];

Instead, I think we should only show how to capture an error like we do in the docs, which you updated here: getsentry/sentry-docs#13878

I think we should do the same for Swift.

Comment on lines 268 to 274
DispatchQueue.global().asyncAfter(deadline: .now() + 10) {
SentrySDK.crash()
}`
: `
@import Sentry;

[SentrySDK performSelector:@selector(crash) withObject:nil afterDelay:10];`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: Why the delay of 10 seconds? I'm pretty sure that could confuse users. Let's simply add a sample how to capture an error and let the user decide if they want to do that async or nor.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@itaybre itaybre merged commit 4e4d46a into master Jun 3, 2025
42 checks passed
@itaybre itaybre deleted the itay/cocoa-170-improve-onboarding-snippets-for-apple-platforms-sdk-setup branch June 3, 2025 18:03
andrewshie-sentry pushed a commit that referenced this pull request Jun 3, 2025
…ion options (#92506)

Apple onboarding only had Swift + UIKit verification steps.

Added:
- Objective C code
- Non UI options to verify the setup

Fixes
[getsentry/sentry-cocoa#4991](getsentry/sentry-cocoa#4991)

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve onboarding snippets for Apple platforms SDK setup verification
3 participants