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

Update releaseName default value #267

Merged
merged 14 commits into from
Nov 15, 2023
Merged

Conversation

spencertransier
Copy link
Contributor

@spencertransier spencertransier commented Nov 11, 2023

This PR updates the default releaseName attribute from sending only the CFBundleVersionKey to now include the CFBundleIdentifierKey, CFBundleShortVersionString, and CFBundleVersionKey. Sentry releases are global across all projects in an organization, so only relying on the CFBundleVersionKey was causing conflicts between apps that had the same release number. This will now correctly separate the releases.

The releaseName format that we're sending now is the default format that Sentry uses for the releaseName. I decided that it would be good to explicitly define that format in this library so that we can ensure future consistency for release names across all the apps.

I had trouble using the TracksDemo app to test updating the release version in Sentry, so I created a test branch for WooCommerce iOS that points to this dev branch: test/sentry-release-name (The only change there is updating the podfile to point here)

Using that test branch, I was able to verify that the releases are now being sent up to Sentry with the updated attributes. You can see that the 16.2 (16.2.0.0) and 16.1 (16.1.0.1) releases show the full version information now:

Screenshot 2023-11-13 at 4 43 21 PM
  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

@spencertransier spencertransier changed the title Update/release name value Update releaseName default value Nov 11, 2023
@spencertransier spencertransier marked this pull request as ready for review November 14, 2023 00:50
Comment on lines 25 to 33
var releaseName: String {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
let bundleVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] ?? ""
let bundleIdentifier = Bundle.main.infoDictionary?[kCFBundleIdentifierKey as String] ?? ""
let bundleShortVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""

// This is the format that Sentry recommends for version numbers.
// See https://docs.sentry.io/platforms/apple/configuration/releases/#bind-the-version
return "\(bundleIdentifier)@\(bundleShortVersion)+\(bundleVersion)"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the docs from that link, Sentry says it can set the value by itself if none is provided:

image

Have you considered doing that?

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

How do you feel about adding a unit test to verify the format we compute is as we expect it to be right now and ensure it will remain like that in the future (or, rather, have a safeguard against unintentionally changing it)

@mokagio
Copy link
Contributor

mokagio commented Nov 14, 2023

@spencertransier I saw CI failed because the change in the source code now requires changes to the tests too, which makes me wonder whether it might require changes in the clients as well.

Depending on the amount of work required, and given that the release tracking inconsistency is a blocker for a project in WooCommerce (internal ref pdnsEh-1mT-p2) feel free to ship a version with your override since you already proven it works. We can iterate on this with more clam later. 👍

@spencertransier
Copy link
Contributor Author

spencertransier commented Nov 14, 2023

@mokagio When I was chatting with @jkmassel about this the other day, he suggested making releaseName an optional string so that clients could pass in their own release name if needed. Looking through our iOS apps, though, DOiOS/Mac is the only one not relying on the default behavior that's current the Tracks library. And even DO is just passing the same format as the Sentry default so that the DO releases would be configured correctly (what WCiOS is trying to accomplish). Seeing that all the apps want this format anyway, I don't see a need to provide a way to customize the releaseName in this library.

Considering that, what do you think about the changes I just pushed to remove the releaseName from the protocol entirely and only rely on Sentry's default? It would be a breaking change and we would need to bump the library to 3.0.0. DOiOS/Mac is the only A8C app that would actually need to be updated (and it would just be removing their custom releaseName at that). Then the other A8C apps that update to 3.0.0 would get the improved releaseName's for free without needing to making any changes other than updating the library.

I tried out the latest PR change in the WCiOS test branch and it worked great. The new version showed up in Sentry with the expected format.

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

Considering that, what do you think about the changes I just pushed to remove the releaseName from the protocol entirely and only rely on Sentry's default?

I like the idea!

I tried out the latest PR change in the WCiOS test branch and it worked great. The new version showed up in Sentry with the expected format.

Awesome.

It would be a breaking change and we would need to bump the library to 3.0.0.

Would it be a breaking change? The var { get } requirement has been removed from the protocol, which makes me think that clients implementing it would not break as the compiler would consider their property declaration to be one for the object itself and not required by the protocol. If we had added one, then that's when I think the compiler would bark at us.

Regardless of the version number, let's do this!

@spencertransier spencertransier merged commit a9627a0 into trunk Nov 15, 2023
6 of 8 checks passed
@spencertransier spencertransier deleted the update/release-name-value branch November 15, 2023 17:29
wzieba added a commit that referenced this pull request Mar 25, 2024
…alue"

This reverts commit a9627a0, reversing
changes made to 1d192b2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants