Skip to content
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

feat(Apple):More Telemetry #467

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/apple/apple-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ async function runAppleWizardWithTelementry(

if (availableTargets.length == 0) {
clack.log.error(`No suttable target found in ${xcodeProjFile}`);
Sentry.setTag('No-Target', true);
await abort();
return;
}
Expand All @@ -131,6 +132,7 @@ async function runAppleWizardWithTelementry(
);

let hasCocoa = cocoapod.usesCocoaPod(projectDir);
Sentry.setTag('cocoapod-exists', hasCocoa);

if (hasCocoa) {
const pm = (
Expand All @@ -147,6 +149,7 @@ async function runAppleWizardWithTelementry(
const podAdded = await traceStep('Add CocoaPods reference', () =>
cocoapod.addCocoaPods(projectDir),
);
Sentry.setTag('cocoapod-added', podAdded);
if (!podAdded) {
clack.log.warn(
"Could not add Sentry pod to your Podfile. You'll have to add it manually.\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install",
Expand All @@ -155,11 +158,11 @@ async function runAppleWizardWithTelementry(
}
}

Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');
traceStep('Update Xcode project', () => {
xcProject.updateXcodeProject(project, target, apiKey, !hasCocoa, true);
});

Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');
const codeAdded = traceStep('Add code snippet', () => {
const files = xcProject.filesForTarget(target);
if (files === undefined || files.length == 0) return false;
Expand All @@ -170,18 +173,23 @@ async function runAppleWizardWithTelementry(
project.keys[0].dsn.public,
);
});

Sentry.setTag('Snippet-Added', codeAdded);

if (!codeAdded) {
clack.log.warn(
'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',
);
return;
}

if (fastlane.fastFile(projectDir)) {
const hasFastlane = fastlane.fastFile(projectDir);
Sentry.setTag('fastlane-exists', hasFastlane);
if (hasFastlane) {
const addLane = await clack.confirm({
message:
'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?',
});
Sentry.setTag('fastlane-desired', addLane);
if (addLane) {
const added = await traceStep('Configure fastlane', () =>
fastlane.addSentryToFastlane(
Expand All @@ -190,6 +198,7 @@ async function runAppleWizardWithTelementry(
project.slug,
),
);
Sentry.setTag('fastlane-added', added);
if (added) {
clack.log.step(
'A new step was added to your fastlane file. Now and you build your project with fastlane, debug symbols and source context will be uploaded to Sentry.',
Expand Down
4 changes: 3 additions & 1 deletion src/utils/sentrycli-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function createSentryCLIRC(
const rcPath = path.join(directory, '.sentryclirc');
fs.writeFileSync(rcPath, '[auth]\ntoken=' + params.auth_token);

if (fs.existsSync('.gitignore')) {
if (!fs.existsSync('.gitignore')) {
fs.writeFileSync('.gitignore', '.sentryclirc');
} else {
const gitIgnore = fs.readFileSync('.gitignore').toString();
if (!gitIgnore.includes('.sentryclirc')) {
fs.appendFileSync('.gitignore', '\n.sentryclirc');
Expand Down