From 64d1bd53226dbd9e084d39995338c9057157b9ef Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 15 Jul 2020 17:25:08 +0100 Subject: [PATCH] events for web apps built and web apps deployed --- packages/builder/src/analytics.js | 5 +++++ packages/builder/src/components/start/CreateAppModal.svelte | 5 +++++ packages/builder/src/pages/[application]/deploy/index.svelte | 3 +++ packages/server/src/app.js | 5 +++++ packages/server/src/index.js | 5 +++++ 5 files changed, 23 insertions(+) diff --git a/packages/builder/src/analytics.js b/packages/builder/src/analytics.js index 1e83f2c74d..34550e7305 100644 --- a/packages/builder/src/analytics.js +++ b/packages/builder/src/analytics.js @@ -12,7 +12,12 @@ function captureException(err) { Sentry.captureException(err) } +function captureEvent(event) { + posthog.capture(event) +} + export default { activate, captureException, + captureEvent, } diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index 2f94c75ed2..e0c7f5a420 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -6,6 +6,7 @@ import { getContext } from "svelte" import { fade } from "svelte/transition" import { post } from "builderStore/api" + import analytics from "../../analytics" const { open, close } = getContext("simple-modal") @@ -38,6 +39,10 @@ const res = await response.json() + analytics.captureEvent("web_app_created", { + name, + description, + }) $goto(`./${res._id}`) } catch (error) { console.error(error) diff --git a/packages/builder/src/pages/[application]/deploy/index.svelte b/packages/builder/src/pages/[application]/deploy/index.svelte index e8fb5d3542..ade7f7724a 100644 --- a/packages/builder/src/pages/[application]/deploy/index.svelte +++ b/packages/builder/src/pages/[application]/deploy/index.svelte @@ -26,6 +26,9 @@ notifier.success(`Your Deployment is Complete.`) deployed = true loading = false + analytics.captureEvent("deployment", { + appId, + }) } catch (err) { analytics.captureException(err) notifier.danger("Deployment unsuccessful. Please try again later.") diff --git a/packages/server/src/app.js b/packages/server/src/app.js index 3353ff76d0..e72f61c55b 100644 --- a/packages/server/src/app.js +++ b/packages/server/src/app.js @@ -46,3 +46,8 @@ module.exports = async port => { const server = http.createServer(app.callback()) return server.listen(serverPort || 4001) } + +process.on("SIGINT", function() { + console.log("\nGracefully shutting down from SIGINT") + process.exit(1) +}) diff --git a/packages/server/src/index.js b/packages/server/src/index.js index 41e8656b7d..e9bf52b233 100644 --- a/packages/server/src/index.js +++ b/packages/server/src/index.js @@ -20,3 +20,8 @@ async function runServer() { } runServer() + +process.on("SIGINT", function() { + console.log("\nGracefully shutting down from SIGINT") + process.exit(1) +})