Skip to content

Commit d7c33d0

Browse files
committed
ref(getting-started-docs): Migrate apple wizards to the main sentry repo (#53436)
1 parent 77f5862 commit d7c33d0

File tree

7 files changed

+681
-0
lines changed

7 files changed

+681
-0
lines changed

static/app/components/onboarding/gettingStartedDoc/sdkDocumentation.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export const migratedDocs = [
8282
'capacitor',
8383
'cordova',
8484
'unreal',
85+
'apple',
86+
'apple-ios',
87+
'apple-macos',
8588
'flutter',
8689
'dart',
8790
];
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {render, screen} from 'sentry-test/reactTestingLibrary';
2+
3+
import {StepTitle} from 'sentry/components/onboarding/gettingStartedDoc/step';
4+
5+
import {GettingStartedWithIos, steps} from './apple-ios';
6+
7+
describe('GettingStartedWithIos', function () {
8+
it('renders doc correctly', function () {
9+
const {container} = render(<GettingStartedWithIos dsn="test-dsn" />);
10+
11+
// Steps
12+
for (const step of steps()) {
13+
expect(
14+
screen.getByRole('heading', {name: step.title ?? StepTitle[step.type]})
15+
).toBeInTheDocument();
16+
}
17+
18+
expect(container).toSnapshot();
19+
});
20+
});
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
import ExternalLink from 'sentry/components/links/externalLink';
2+
import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
3+
import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
4+
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
5+
import {t, tct} from 'sentry/locale';
6+
7+
// Configuration Start
8+
export const steps = ({
9+
dsn,
10+
}: {
11+
dsn?: string;
12+
} = {}): LayoutProps['steps'] => [
13+
{
14+
type: StepType.INSTALL,
15+
description: (
16+
<p>
17+
{tct(
18+
'We recommend installing the SDK with Swift Package Manager (SPM), but we also support [alternateMethods: alternate installation methods]. To integrate Sentry into your Xcode project using SPM, open your App in Xcode and open [addPackage: File > Add Packages]. Then add the SDK by entering the Git repo url in the top right search field:',
19+
{
20+
alternateMethods: (
21+
<ExternalLink href="https://docs.sentry.io/platforms/apple/install/" />
22+
),
23+
addPackage: <strong />,
24+
}
25+
)}
26+
</p>
27+
),
28+
configurations: [
29+
{
30+
language: 'text',
31+
code: `
32+
https://github.com/getsentry/sentry-cocoa.git
33+
`,
34+
},
35+
{
36+
description: (
37+
<p>
38+
{tct(
39+
'Alternatively, when your project uses a [packageSwift: Package.swift] file to manage dependencies, you can specify the target with:',
40+
{
41+
packageSwift: <code />,
42+
}
43+
)}
44+
</p>
45+
),
46+
language: 'swift',
47+
code: `
48+
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.9.2"),
49+
`,
50+
},
51+
],
52+
},
53+
{
54+
type: StepType.CONFIGURE,
55+
description: (
56+
<p>
57+
{tct(
58+
'Make sure you initialize the SDK as soon as possible in your application lifecycle e.g. in your AppDelegate [appDelegate: application:didFinishLaunchingWithOptions] method:',
59+
{
60+
appDelegate: <code />,
61+
}
62+
)}
63+
</p>
64+
),
65+
configurations: [
66+
{
67+
language: 'swift',
68+
code: `
69+
import Sentry
70+
71+
// ....
72+
73+
func application(_ application: UIApplication,
74+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
75+
76+
SentrySDK.start { options in
77+
options.dsn = "${dsn}"
78+
options.debug = true // Enabled debug when first installing is always helpful
79+
80+
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
81+
// We recommend adjusting this value in production.
82+
options.tracesSampleRate = 1.0
83+
}
84+
85+
return true
86+
}
87+
`,
88+
},
89+
{
90+
description: (
91+
<p>
92+
{tct(
93+
"When using SwiftUI and your app doesn't implement an app delegate, initialize the SDK within the [initializer: App conformer's initializer]:",
94+
{
95+
initializer: (
96+
<ExternalLink href="https://developer.apple.com/documentation/swiftui/app/main()" />
97+
),
98+
}
99+
)}
100+
</p>
101+
),
102+
language: 'swift',
103+
code: `
104+
import Sentry
105+
106+
@main
107+
struct SwiftUIApp: App {
108+
init() {
109+
SentrySDK.start { options in
110+
options.dsn = "${dsn}"
111+
options.debug = true // Enabled debug when first installing is always helpful
112+
113+
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
114+
// We recommend adjusting this value in production.
115+
options.tracesSampleRate = 1.0
116+
}
117+
}
118+
}
119+
`,
120+
},
121+
],
122+
},
123+
{
124+
type: StepType.VERIFY,
125+
description: (
126+
<p>
127+
{tct(
128+
'This snippet contains an intentional error you can use to test that errors are uploaded to Sentry correctly. You can add it to your main [viewController: ViewController].',
129+
{
130+
viewController: <code />,
131+
}
132+
)}
133+
</p>
134+
),
135+
configurations: [
136+
{
137+
language: 'swift',
138+
code: `
139+
let button = UIButton(type: .roundedRect)
140+
button.frame = CGRect(x: 20, y: 50, width: 100, height: 30)
141+
button.setTitle("Break the world", for: [])
142+
button.addTarget(self, action: #selector(self.breakTheWorld(_:)), for: .touchUpInside)
143+
view.addSubview(button)
144+
145+
@IBAction func breakTheWorld(_ sender: AnyObject) {
146+
fatalError("Break the world")
147+
}
148+
`,
149+
},
150+
],
151+
},
152+
{
153+
title: t('Experimental Features'),
154+
description: (
155+
<p>
156+
{tct(
157+
'Want to play with some new features? Try out our experimental features for [vh: View Hierarchy], [ttfd: Time to Full Display (TTFD)], [metricKit: MetricKit], [prewarmedAppStart: Prewarmed App Start Tracing], and [asyncStacktraces: Swift Async Stacktraces]. Experimental features are still a work-in-progress and may have bugs. We recognize the irony. [break] Let us know if you have feedback through [gh: GitHub issues].',
158+
{
159+
vh: (
160+
<ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/enriching-events/viewhierarchy/" />
161+
),
162+
ttfd: (
163+
<ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/performance/instrumentation/automatic-instrumentation/#time-to-full-display" />
164+
),
165+
metricKit: (
166+
<ExternalLink href="https://docs.sentry.io/platforms/apple/guides/watchos/configuration/metric-kit/" />
167+
),
168+
prewarmedAppStart: (
169+
<ExternalLink href="https://docs.sentry.io/platforms/apple/performance/instrumentation/automatic-instrumentation/#prewarmed-app-start-tracing" />
170+
),
171+
asyncStacktraces: (
172+
<ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/#stitch-together-swift-concurrency-stack-traces" />
173+
),
174+
gh: <ExternalLink href="https://github.com/getsentry/sentry-cocoa/issues" />,
175+
break: <br />,
176+
}
177+
)}
178+
</p>
179+
),
180+
configurations: [
181+
{
182+
language: 'swift',
183+
code: `
184+
import Sentry
185+
186+
SentrySDK.start { options in
187+
// ...
188+
189+
// Enable all experimental features
190+
options.attachViewHierarchy = true
191+
options.enablePreWarmedAppStartTracing = true
192+
options.enableMetricKit = true
193+
options.enableTimeToFullDisplayTracing = true
194+
options.swiftAsyncStacktraces = true
195+
}
196+
`,
197+
},
198+
],
199+
},
200+
];
201+
202+
export const nextSteps = [
203+
{
204+
id: 'cocoapods-carthage',
205+
name: t('CocoaPods/Carthage'),
206+
description: t(
207+
'Learn about integrating Sentry into your project using CocoaPods or Carthage.'
208+
),
209+
link: 'https://docs.sentry.io/platforms/apple/install/',
210+
},
211+
{
212+
id: 'debug-symbols',
213+
name: t('Debug Symbols'),
214+
description: t('Symbolicate and get readable stacktraces in your Sentry errors.'),
215+
link: 'https://docs.sentry.io/platforms/apple/dsym/',
216+
},
217+
{
218+
id: 'swiftui',
219+
name: t('SwiftUI'),
220+
description: t('Learn about our first class integration with SwiftUI.'),
221+
link: 'https://docs.sentry.io/platforms/apple/performance/instrumentation/swiftui-instrumentation/',
222+
},
223+
{
224+
id: 'profiling',
225+
name: t('Profiling'),
226+
description: t(
227+
'Collect and analyze performance profiles from real user devices in production.'
228+
),
229+
link: 'https://docs.sentry.io/platforms/apple/profiling/',
230+
},
231+
];
232+
// Configuration End
233+
234+
export function GettingStartedWithIos({dsn, ...props}: ModuleProps) {
235+
return <Layout steps={steps({dsn})} nextSteps={nextSteps} {...props} />;
236+
}
237+
238+
export default GettingStartedWithIos;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {render, screen} from 'sentry-test/reactTestingLibrary';
2+
3+
import {StepTitle} from 'sentry/components/onboarding/gettingStartedDoc/step';
4+
5+
import {GettingStartedWithMacos, steps} from './apple-macos';
6+
7+
describe('GettingStartedWithMacos', function () {
8+
it('renders doc correctly', function () {
9+
const {container} = render(<GettingStartedWithMacos dsn="test-dsn" />);
10+
11+
// Steps
12+
for (const step of steps()) {
13+
expect(
14+
screen.getByRole('heading', {name: step.title ?? StepTitle[step.type]})
15+
).toBeInTheDocument();
16+
}
17+
18+
expect(container).toSnapshot();
19+
});
20+
});

0 commit comments

Comments
 (0)