Skip to content

Commit

Permalink
merge: #2604
Browse files Browse the repository at this point in the history
2604: fix(auth-portal) only send dev env online event once r=theoephraim a=theoephraim



Co-authored-by: Theo Ephraim <[email protected]>
  • Loading branch information
si-bors-ng[bot] and Theo Ephraim authored Aug 16, 2023
2 parents f80aec0 + 31cf584 commit 58f7433
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/auth-portal/src/lib/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ if (!import.meta.env.SSR && import.meta.env.VITE_POSTHOG_PUBLIC_KEY) {
posthog.init(import.meta.env.VITE_POSTHOG_PUBLIC_KEY, {
api_host: import.meta.env.VITE_POSTHOG_API_HOST,
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (window) (window as any).posthog = posthog;
}

// small wrapper makes it easier to swap things later,
Expand Down
9 changes: 6 additions & 3 deletions app/auth-portal/src/store/onboarding.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addStoreHooks, ApiRequest } from "@si/vue-lib/pinia";
import { watch } from "vue";
import Axios from "axios";
import { posthog } from "posthog-js";
import storage from "local-storage-fallback";
import { tracker } from "@/lib/posthog";
import { useAuthStore } from "./auth.store";

Expand Down Expand Up @@ -84,10 +85,12 @@ export const useOnboardingStore = () => {

// this is first time user has dev setup online, track it
if (
!this.stepsCompleted.dev_setup &&
!this.stepsCompleted.install_and_run_system_initiative &&
!storage.getItem("tracked-dev-env-online") &&
this.devFrontendOnline &&
this.devBackendOnline
) {
storage.setItem("tracked-dev-env-online", "y");
tracker.trackEvent("dev_env_online");
// will toggle posthog.isFeatureEnabled("vro_dev-setup-completed") &&
}
Expand Down Expand Up @@ -133,14 +136,14 @@ export const useOnboardingStore = () => {
{ immediate: true },
);

const checkDevEnvInteval = setInterval(this.checkDevEnvOnline, 5000);
const checkDevEnvInterval = setInterval(this.checkDevEnvOnline, 5000);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.checkDevEnvOnline();

return () => {
stopWatchLoggedIn();
clearInterval(refreshFeatureFlagInterval);
clearInterval(checkDevEnvInteval);
clearInterval(checkDevEnvInterval);
};
},
}),
Expand Down

0 comments on commit 58f7433

Please sign in to comment.