From ad90d5d5e167632394c495d8d6624aa5167113cc Mon Sep 17 00:00:00 2001 From: Dhiogo Ramos Brustolin Date: Fri, 22 Sep 2023 09:13:41 +0200 Subject: [PATCH 1/3] More tags --- src/apple/apple-wizard.ts | 16 +++++++++++++--- src/utils/sentrycli-utils.ts | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/apple/apple-wizard.ts b/src/apple/apple-wizard.ts index 9eaf1d9c..853736e2 100644 --- a/src/apple/apple-wizard.ts +++ b/src/apple/apple-wizard.ts @@ -28,6 +28,7 @@ import { confirmContinueIfNoOrDirtyGitRepo, getOrAskForProjectData, } from '../utils/clack-utils'; +import { has } from 'lodash'; export async function runAppleWizard(options: WizardOptions): Promise { return withTelemetry( @@ -109,6 +110,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; } @@ -131,6 +133,7 @@ async function runAppleWizardWithTelementry( ); let hasCocoa = cocoapod.usesCocoaPod(projectDir); + Sentry.setTag('cocoapod-exists', hasCocoa); if (hasCocoa) { const pm = ( @@ -147,6 +150,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", @@ -155,11 +159,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; @@ -170,18 +174,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( @@ -190,6 +199,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.', diff --git a/src/utils/sentrycli-utils.ts b/src/utils/sentrycli-utils.ts index 7668c748..81858465 100644 --- a/src/utils/sentrycli-utils.ts +++ b/src/utils/sentrycli-utils.ts @@ -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'); From 4c45e12be1ce6eafa83769784aa37e3ca30e5232 Mon Sep 17 00:00:00 2001 From: Dhiogo Ramos Brustolin Date: Fri, 22 Sep 2023 09:46:43 +0200 Subject: [PATCH 2/3] Update apple-wizard.ts --- src/apple/apple-wizard.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/apple/apple-wizard.ts b/src/apple/apple-wizard.ts index 853736e2..98fed849 100644 --- a/src/apple/apple-wizard.ts +++ b/src/apple/apple-wizard.ts @@ -28,7 +28,6 @@ import { confirmContinueIfNoOrDirtyGitRepo, getOrAskForProjectData, } from '../utils/clack-utils'; -import { has } from 'lodash'; export async function runAppleWizard(options: WizardOptions): Promise { return withTelemetry( @@ -119,13 +118,13 @@ async function runAppleWizardWithTelementry( availableTargets.length == 1 ? availableTargets[0] : ( - await traceStep('Choose target', () => - askForItemSelection( - availableTargets, - 'Which target do you want to add Sentry to?', - ), - ) - ).value; + await traceStep('Choose target', () => + askForItemSelection( + availableTargets, + 'Which target do you want to add Sentry to?', + ), + ) + ).value; SentryUtils.createSentryCLIRC(projectDir, { auth_token: apiKey.token }); clack.log.info( From 89a2a812c4596e76d56ec3602a5c563c963b5547 Mon Sep 17 00:00:00 2001 From: Dhiogo Ramos Brustolin Date: Fri, 22 Sep 2023 09:52:42 +0200 Subject: [PATCH 3/3] Update apple-wizard.ts --- src/apple/apple-wizard.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/apple/apple-wizard.ts b/src/apple/apple-wizard.ts index 98fed849..a9800939 100644 --- a/src/apple/apple-wizard.ts +++ b/src/apple/apple-wizard.ts @@ -118,13 +118,13 @@ async function runAppleWizardWithTelementry( availableTargets.length == 1 ? availableTargets[0] : ( - await traceStep('Choose target', () => - askForItemSelection( - availableTargets, - 'Which target do you want to add Sentry to?', - ), - ) - ).value; + await traceStep('Choose target', () => + askForItemSelection( + availableTargets, + 'Which target do you want to add Sentry to?', + ), + ) + ).value; SentryUtils.createSentryCLIRC(projectDir, { auth_token: apiKey.token }); clack.log.info(