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: add mobile app release version in Sentry issues #3249

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

Aniruddha-Shriwant
Copy link
Contributor

@Aniruddha-Shriwant Aniruddha-Shriwant commented Nov 4, 2024

Clickup

https://app.clickup.com/t/86cwz8r36

Easier to track issues based on Mobile app version

image

image

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for environment variables during the build process.
    • Updated mobile app version tracking in Sentry to reflect the actual app version.
    • Created configuration files for Google services for both Android and iOS.
    • Introduced ECMAScript 6 environment support in the linting configuration.
  • Bug Fixes

    • Ensured live update version matches the app version, throwing errors if they don't.
  • Refactor

    • Modified the handling of various configuration files for improved clarity and functionality.

Copy link

coderabbitai bot commented Nov 4, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request enhance the functionality of the hooks/prebuild.js script and modify the Sentry configuration in src/main.ts. Key updates include improved error handling for environment variables, adjustments to version tracking in Sentry, and modifications to configuration files for Google services. The script now ensures version consistency between live updates and the app version, while also updating various placeholders in several files to reflect current values.

Changes

File(s) Change Summary
hooks/prebuild.js Enhanced error handling for undefined environment variables, created environment.prod.ts, updated strings.xml, modified intent flags in AppPlugin.java, added version checks, commented out audio permission in CameraPreview.java, and created Google services configuration files.
src/main.ts Updated Sentry configuration's release property to reflect the mobile app version.
.eslintrc.json Added new environment setting for ECMAScript 6 by including "es6": true.

Possibly related PRs

Suggested reviewers

  • suyashpatil78
  • Chethan-Fyle
  • arjunaj5

🎉 In the land of code where changes flow,
Rajinikanth's magic makes the scripts glow!
Error handling tight, versions in sync,
With every new line, we’re closer, I think!
From Android to iOS, all services align,
With each commit, our project will shine! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the size/XS Extra Small PR label Nov 4, 2024
@@ -46,12 +46,12 @@ module.exports = function (ctx) {
'/node_modules/@capacitor-community/camera-preview/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java',
};

// Adding GIT_COMMIT_SHA for sentry
// Adding mobile app version for tracking the release in sentry
Copy link
Contributor Author

Choose a reason for hiding this comment

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

git commit sha wasn't working earlier, check release property

image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between d9b879e and 5a0f792.

📒 Files selected for processing (2)
  • hooks/prebuild.js (1 hunks)
  • src/main.ts (1 hunks)
🧰 Additional context used
🪛 Biome
hooks/prebuild.js

[error] 50-50: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 51-51: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)

🔇 Additional comments (4)
src/main.ts (1)

21-21: Mind-blowing change, but let's verify the magic happens correctly!

Thalaiva says the change looks perfect for tracking mobile app versions in Sentry, but we must ensure the placeholder gets replaced properly during build time, machaan!

✅ Verification successful

Superstar approves this style, mind it! The placeholder replacement is working perfectly!

The verification shows the prebuild script is handling our placeholder like a well-choreographed action sequence, machaan! Here's what's happening:

  • The placeholder please-replace-your-mobile-app-version gets replaced with FYLE_MOBILE_RELEASE_VERSION environment variable
  • The same version gets synchronized across multiple files including build.gradle and pbxproj
  • The script even performs version comparison checks to ensure everything is in perfect rhythm

This is a blockbuster implementation that will make Sentry tracking as powerful as Rajini's punch dialogues! 🌟

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that prebuild script handles this placeholder replacement

# Check if prebuild script exists and contains the replacement logic
rg -A 5 "please-replace-your-mobile-app-version" "hooks/prebuild.js"

# Also check for the environment variable that should provide the version
rg "FYLE_MOBILE_RELEASE_VERSION" "hooks/prebuild.js"

Length of output: 797

hooks/prebuild.js (3)

49-54: Ensure the path to 'main.ts' is correct

Just make sure the src/main.ts file exists at that location. We don't want any surprises later.

Check with this command:

#!/bin/bash
# Description: Verify that src/main.ts exists

if [ -f src/main.ts ]; then
  echo "File exists. Proceed ahead!"
else
  echo "Hold on! src/main.ts not found."
fi
🧰 Tools
🪛 Biome

[error] 50-50: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 51-51: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


54-54: Confirm the Sentry release version is set correctly

Setting the correct release version in Sentry is crucial for tracking. Let's ensure it's updated properly.

Here's a script to double-check:

#!/bin/bash
# Description: Verify the Sentry release version in main.ts

grep 'Sentry\.init' src/main.ts -A 5 | grep 'release'

Expect to see:

release: 'your-mobile-app-version',

Ensure 'your-mobile-app-version' matches ctx.env.FYLE_MOBILE_RELEASE_VERSION.


54-54: Double-check that the mobile app version is correctly replaced

Make sure 'please-replace-your-mobile-app-version' is properly swapped with the actual app version in main.ts.

Run this script to confirm:

Comment on lines 50 to 51
var mainPath = path.resolve(process.cwd(), 'src/main.ts');
var mainPathContent = fs.readFileSync(mainPath).toString();
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Listen, my friend! Let's use 'let' or 'const' instead of 'var'

Using 'let' or 'const' helps avoid hoisting issues and keeps your code tight and clean.

Here's how we can fix it:

- var mainPath = path.resolve(process.cwd(), 'src/main.ts');
- var mainPathContent = fs.readFileSync(mainPath).toString();
+ const mainPath = path.resolve(process.cwd(), 'src/main.ts');
+ const mainPathContent = fs.readFileSync(mainPath).toString();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var mainPath = path.resolve(process.cwd(), 'src/main.ts');
var mainPathContent = fs.readFileSync(mainPath).toString();
const mainPath = path.resolve(process.cwd(), 'src/main.ts');
const mainPathContent = fs.readFileSync(mainPath).toString();
🧰 Tools
🪛 Biome

[error] 50-50: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 51-51: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)

@Aniruddha-Shriwant Aniruddha-Shriwant merged commit 46e2c96 into master Nov 5, 2024
6 checks passed
Copy link

github-actions bot commented Nov 5, 2024

Unit Test Coverage % values
Statements 95.95% ( 19167 / 19976 )
Branches 91.11% ( 10564 / 11594 )
Functions 94.34% ( 5721 / 6064 )
Lines 95.98% ( 18297 / 19063 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Extra Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants