fix: close formbricks-js surveys on logout (#1655)

This commit is contained in:
Matti Nannt
2023-11-21 10:29:31 +01:00
committed by GitHub
parent 860630dd5a
commit 94bf1fd6fe
3 changed files with 8 additions and 1 deletions

View File

@@ -75,6 +75,10 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NEXTAUTH_SECRET=${{ env.NEXTAUTH_SECRET }}
DATABASE_URL=${{ env.DATABASE_URL }}
ENCRYPTION_KEY=${{ env.ENCRYPTION_KEY }}
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker

View File

@@ -14,7 +14,7 @@ import { addCleanupEventListeners, addEventListeners, removeAllEventListeners }
import { Logger } from "./logger";
import { checkPageUrl } from "./noCodeActions";
import { sync } from "./sync";
import { addWidgetContainer } from "./widget";
import { addWidgetContainer, closeSurvey } from "./widget";
import { trackAction } from "./actions";
const config = Config.getInstance();
@@ -128,6 +128,7 @@ export const checkInitialized = (): Result<void, NotInitializedError> => {
export const deinitalize = (): void => {
logger.debug("Deinitializing");
closeSurvey();
removeAllEventListeners();
config.resetConfig();
isInitialized = false;

View File

@@ -5,6 +5,7 @@ import { deinitalize, initialize } from "./initialize";
import { Logger } from "./logger";
import { sync } from "./sync";
import { FormbricksAPI } from "@formbricks/api";
import { closeSurvey } from "./widget";
const config = Config.getInstance();
const logger = Logger.getInstance();
@@ -102,6 +103,7 @@ export const logoutPerson = async (): Promise<void> => {
export const resetPerson = async (): Promise<Result<void, NetworkError>> => {
logger.debug("Resetting state & getting new state from backend");
closeSurvey();
const syncParams = {
environmentId: config.get().environmentId,
apiHost: config.get().apiHost,