Skip to content

Commit

Permalink
Merge pull request #1116 from crowdbotics/qa
Browse files Browse the repository at this point in the history
Release QA to Production
  • Loading branch information
driverdan committed Mar 12, 2024
2 parents 6059531 + 332f6be commit 079cc8e
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 158 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
name: ${{ needs.set_environment.outputs.my_env }}-release
steps:
- name: Generate Heroku Config
id: heroku-config
run: |
cat <<EOF > ~/.netrc
machine api.heroku.com
Expand All @@ -44,6 +45,16 @@ jobs:
password ${{ secrets.HEROKU_API_TOKEN }}
EOF
- name: release modules
id: release-modules
run: |
heroku config:set MODULES_REPO_BRANCH=$GITHUB_REF_NAME -a ${{ secrets.HEROKU_APP }}
heroku run 'python manage.py update_crowdbotics_components --quiet --no-input --no-log-file --public' --size=standard-2x -a ${{ secrets.HEROKU_APP }}
heroku run 'python manage.py update_crowdbotics_components --quiet --no-input --no-log-file --public' --size=standard-2x -a ${{ secrets.HEROKU_APP }}
- uses: act10ns/slack@v2
if: ${{ needs.set_environment.outputs.my_env }} == 'production'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}

1 change: 1 addition & 0 deletions .github/workflows/create-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ jobs:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
release_branch: ${{ github.event.client_payload.release_branch }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
74 changes: 49 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@ import { info } from "./scripts/info.js";
import { removeModules } from "./scripts/remove.js";
import { commitModules } from "./scripts/commit-module.js";
import { upgradeScaffold } from "./scripts/upgrade.js";
import { valid, invalid, isNameValid, section } from "./utils.js";
import {
valid,
invalid,
isNameValid,
section,
isUserEnvironment
} from "./utils.js";
import { createModule } from "./scripts/create.js";
import { login } from "./scripts/login.js";
import { configFile } from "./scripts/utils/configFile.js";
import { sendFeedback } from "./scripts/feedback.js";
import { logout } from "./scripts/logout.js";
import { modulesArchive, modulesGet, modulesList } from "./scripts/modules.js";
import { publish } from "./scripts/publish.js";
import { Amplitude } from "./scripts/amplitude/wrapper.js";
import { preExecuteChecks } from "./scripts/utils/environment.js";
import { analytics } from "./scripts/analytics/wrapper.js";
import { HAS_ASKED_OPT_IN_NAME } from "./scripts/analytics/config.js";
import { EVENT } from "./scripts/analytics/constants.js";
import { askOptIn } from "./scripts/analytics/scripts.js";
import { sentryMonitoring } from "./scripts/utils/sentry.js";

const pkg = JSON.parse(
fs.readFileSync(new URL("package.json", import.meta.url), "utf8")
Expand All @@ -62,7 +73,15 @@ Visit our official documentation for more information and try again: https://doc
}
};

function dispatcher() {
async function dispatcher() {
const useDefaults = process.env.npm_config_yes;

// check config if they have been asked opted in or out of amplitude
const hasAskedOptIn = configFile.get(HAS_ASKED_OPT_IN_NAME) || false;
if (!hasAskedOptIn && isUserEnvironment && !useDefaults) {
await askOptIn();
}

const command = process.argv[2];

if (!command) {
Expand All @@ -73,11 +92,24 @@ function dispatcher() {
invalid(`command doesn't exist: ${command}`);
}

return commands[command]();
sentryMonitoring.registerCommandName(command);

await commands[command]();

if (!analytics.event.name && !useDefaults) {
analytics.sendEvent({
name: EVENT.OTHER,
properties: {
command,
fullCommand: process.argv.slice(2, process.argv.length).join(" ")
}
});
}
}

const commands = {
demo: () => {
preExecuteChecks();
createDemo(
path.join(gitRoot(), "demo"),
path.join(sourceDir, "cookiecutter.yaml")
Expand Down Expand Up @@ -107,6 +139,7 @@ const commands = {
}
},
add: () => {
preExecuteChecks();
const args = arg({
"--source": String,
"--project": String
Expand All @@ -129,6 +162,7 @@ const commands = {
removeModules(modules, args["--source"], args["--project"], gitRoot());
},
create: () => {
preExecuteChecks(true);
const args = arg({
"--name": String,
"--type": String,
Expand All @@ -147,8 +181,8 @@ const commands = {
);
}

Amplitude.sendEvent({
name: "Create Module",
analytics.sendEvent({
name: EVENT.CREATE_MODULE,
properties: { Name: args["--name"] }
});

Expand Down Expand Up @@ -205,7 +239,7 @@ demo`;
const args = arg({
"--version": String
});
Amplitude.sendEvent({ name: "Upgrade Scaffold" });
analytics.sendEvent({ name: EVENT.UPGRADE });
upgradeScaffold(args["--version"]);
},
login: () => {
Expand Down Expand Up @@ -254,7 +288,7 @@ demo`;
}
},

modules: () => {
modules: async () => {
const args = arg({
"--search": String,
"--visibility": String,
Expand All @@ -275,8 +309,8 @@ demo`;

switch (action) {
case "list":
Amplitude.sendEvent({ name: "List Modules" });
modulesList({
analytics.sendEvent({ name: EVENT.LIST_MODULES });
await modulesList({
search: args["--search"],
status: args["--status"],
visibility: args["--visibility"],
Expand All @@ -292,12 +326,7 @@ demo`;
);
}

Amplitude.sendEvent({
name: "View Module Details",
properties: { "Module Id": id }
});

modulesGet(id);
await modulesGet(id);
break;

case "archive":
Expand All @@ -308,12 +337,7 @@ demo`;
);
}

Amplitude.sendEvent({
name: args["--unarchive"] ? "Unarchive Module" : "Archive Module",
properties: { "Module Id": id }
});

modulesArchive(id, !!args["--unarchive"]);
await modulesArchive(id, !!args["--unarchive"]);
break;

case "help":
Expand All @@ -335,8 +359,8 @@ demo`;
}
},
publish: () => {
Amplitude.sendEvent({
name: "Publish Modules"
analytics.sendEvent({
name: EVENT.PUBLISH_MODULES
});
publish();
},
Expand All @@ -359,7 +383,7 @@ demo`;
Please contact Support for help using Crowdbotics or to report errors, bugs, and
other issues.
https://crowdbotics-slack-dev.crowdbotics.com/dashboard/user/support
https://app.crowdbotics.com/dashboard/user/support
`);
break;

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"type": "module",
"engines": {
"node": ">16.0"
"node": ">18.0"
},
"scripts": {
"demo": "npx . demo",
Expand All @@ -29,14 +29,15 @@
},
"homepage": "https://github.com/crowdbotics/modules#readme",
"dependencies": {
"@amplitude/analytics-node": "^1.3.5",
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.5",
"@babel/generator": "^7.14.9",
"@babel/parser": "^7.18.8",
"@babel/preset-env": "^7.18.2",
"@babel/template": "^7.16.7",
"@babel/types": "^7.18.8",
"@segment/analytics-node": "^2.0.0",
"@sentry/node": "^7.103.0",
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1",
"arg": "^5.0.2",
Expand Down
8 changes: 0 additions & 8 deletions scripts/amplitude/config.js

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/amplitude/constants.js

This file was deleted.

71 changes: 0 additions & 71 deletions scripts/amplitude/wrapper.js

This file was deleted.

14 changes: 14 additions & 0 deletions scripts/analytics/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { configFile } from "../utils/configFile.js";
import { HOST_CONFIG_NAME } from "../utils/constants.js";
import {
DEVELOPMENT_SEGMENT_KEY,
PRODUCTION_SEGMENT_KEY
} from "./constants.js";

export const HAS_ASKED_OPT_IN_NAME = "has-asked-opt-in";
export const OPT_IN_NAME = "opt-in";

export const SEGMENT_API_KEY =
configFile.get(HOST_CONFIG_NAME) === "https://app.crowdbotics.com/"
? PRODUCTION_SEGMENT_KEY
: DEVELOPMENT_SEGMENT_KEY;
18 changes: 18 additions & 0 deletions scripts/analytics/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const PRODUCTION_SEGMENT_KEY = "J7ScSXeIOb8KrCJT8HHcMr7yDRDdCsUw";
export const DEVELOPMENT_SEGMENT_KEY = "WrYiRf1pEB74S4RhSDKC0rQ3db3uVHiE";

export const CUSTOMER_TYPE = {
SMB: "SMB",
ENT: "ENT"
};

export const EVENT = {
OTHER: "Other CLI Commands",
UPGRADE: "Upgrade Scaffold",
LIST_MODULES: "List Modules",
CREATE_MODULE: "Create Module",
PUBLISH_MODULES: "Publish Modules",
VIEW_MODULE: "View Module Details",
ARCHIVE_MODULE: "Archive Module",
UNARCHIVE_MODULE: "Unarchive Module"
};
File renamed without changes.

0 comments on commit 079cc8e

Please sign in to comment.