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 support for fetching a greeting CTA as part of the update flow MONGOSH-1897 #2254

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nirinchev
Copy link
Contributor

@nirinchev nirinchev commented Nov 6, 2024

This adds support for fetching a greeting CTA via the versions json. The proposed design adds support for reading a cta field in the version objects:

 {
   "version": [
     {
       "version": "1.2.3",
       "downloads": [ ... ],
+      "cta": {
+        "chunks": [
+          { "text": "Fill out our survey ", "style": "bold" }
+          { "text": "https://mongodb.com/survey", "style": "mongosh:uri" }
+        ]
+      }
     }
   ]
 }

These are optional and nothing will be displayed if they're not present. If they are present and the version matches the current version, we'll format the chunks with their corresponding styles and display the message as part of the greeting.

Additionally, we add the following to the update-metadata.json:

 {
     "updateURL": "https://downloads.mongodb.com/compass/mongosh.json",
     "lastChecked": 1730881696340,
     "etag": "\"7f84f631518c4872e3e469c765d1eb03\"",
     "latestKnownMongoshVersion": "1.2.3",
+    "cta": {
+        "1.2.3-alpha.1": {
+           "chunks": [
+                { "text": "This is an alpha version! Use with caution!", "style": "bold" }
+            ]
+        },
+        "1.2.3": {
+           "chunks": [
+                { "text": "This is a stable version and very reliable!", "style": "bold" }
+            ]
+        },
+    }
 }

The greeting CTA for the current version based on package.json will be picked, but locally we're saving both the current and the latest version's CTAs to make it readily available once the user upgrades.

* main: (34 commits)
  chore: update auto-generated files [skip actions]
  chore: update auto-generated files [skip actions]
  chore(ci): use github app tokens instead of bot user (#2282)
  chore: update auto-generated files [skip actions]
  chore(ci): cleanup auto generated file workflow MONGOSH-1927 (#2281)
  chore: update auto-generated files
  chore(ci): use a github app for the generated files credentials MONGOSH-1927 (#2280)
  chore(deps): bump driver, bson, oidc-plugin to latest MONGOSH-1916 (#2279)
  chore(ci): login to docker (#2277)
  chore(ci): don't download chrome for cron tasks (#2278)
  chore: update node.js (#2270)
  chore: push auto-generated files directly instead of using PRs (#2275)
  fix(ci): allocate more memory to fix test_vscode MONGOSH-1892 (#2239)
  chore: update auto-generated files (#2276)
  feat(shell-api): add options in stream processor start, stop, and drop MONGOSH-1920 (#2274)
  chore: update auto-generated files (#2273)
  chore: update auto-generated files (#2272)
  fix: include nonce in oidc request by default MONGOSH-1905 MONGOSH-1917 (#2269)
  chore(ci): filter for explictily set variants in unit tests (#2271)
  chore: update auto-generated files (#2268)
  ...
@nirinchev nirinchev requested review from addaleax and gagik January 9, 2025 14:38
@nirinchev
Copy link
Contributor Author

This is ready for review - I tested it with a custom S3 bucket and feel fairly confident that it works. The only remaining task is provisioning credentials for the downloads S3 bucket, adding them as a secret to GHA, and testing the workflow for updating the cta. Waiting on devprod there and I'll make sure to test it out before merging.

@nirinchev nirinchev marked this pull request as ready for review January 9, 2025 14:41
@@ -93,6 +93,7 @@ module.exports = {
...common.testRules,
...extraJSRules,
...extraTypescriptRules,
'@typescript-eslint/no-non-null-assertion': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

Just going to mention that I think that this is on almost everywhere in our repos and that hasn't been a major issue for the most part

Copy link
Contributor

@gagik gagik Jan 10, 2025

Choose a reason for hiding this comment

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

don't have strong feelings but agree
// eslint-disable-next-line no-non-null-assertion
or a forced type case i.e. ??? as unknown as ... could be better for case by case?

Comment on lines +178 to +180
jsonContents?.versions?.filter(
(v) => v.version === this.latestKnownMongoshVersion
)?.[0]?.cta ?? jsonContents?.cta;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
jsonContents?.versions?.filter(
(v) => v.version === this.latestKnownMongoshVersion
)?.[0]?.cta ?? jsonContents?.cta;
jsonContents?.versions?.find(
(v) => v.version === this.latestKnownMongoshVersion
)?.cta ?? jsonContents?.cta;

?.filter((v) => !semver.prerelease(v))
?.sort(semver.rcompare)?.[0];

this.currentVersionGreetingCTA =
jsonContents?.versions?.filter((v) => v.version === currentVersion)?.[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
jsonContents?.versions?.filter((v) => v.version === currentVersion)?.[0]
jsonContents?.versions?.find((v) => v.version === currentVersion)

@@ -529,4 +532,225 @@ describe('DownloadCenter config', function () {
expect(serverTargets).to.include(target);
});
});

describe('updateJsonFeedCTA', function () {
let dlCenter: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

very nit: also a sinon.SinonStub?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants