mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-20 19:30:41 -05:00
fix: prevent exit intent and scroll intent in js package to make api call (#1350)
This commit is contained in:
committed by
GitHub
parent
f70cda6e11
commit
a7072580d3
@@ -6,6 +6,8 @@ import { renderWidget } from "./widget";
|
||||
const logger = Logger.getInstance();
|
||||
const config = Config.getInstance();
|
||||
|
||||
const intentsToNotCreateOnApp = ["Exit Intent (Desktop)", "50% Scroll"];
|
||||
|
||||
export const trackAction = async (
|
||||
name: string,
|
||||
properties: TJsActionInput["properties"] = {}
|
||||
@@ -17,25 +19,27 @@ export const trackAction = async (
|
||||
properties: properties || {},
|
||||
};
|
||||
|
||||
const res = await fetch(`${config.get().apiHost}/api/v1/js/actions`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
if (!intentsToNotCreateOnApp.includes(name)) {
|
||||
const res = await fetch(`${config.get().apiHost}/api/v1/js/actions`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const error = await res.json();
|
||||
|
||||
return err({
|
||||
code: "network_error",
|
||||
message: `Error tracking event: ${JSON.stringify(error)}`,
|
||||
status: res.status,
|
||||
url: res.url,
|
||||
responseMessage: error.message,
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const error = await res.json();
|
||||
|
||||
return err({
|
||||
code: "network_error",
|
||||
message: `Error tracking event: ${JSON.stringify(error)}`,
|
||||
status: res.status,
|
||||
url: res.url,
|
||||
responseMessage: error.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug(`Formbricks: Event "${name}" tracked`);
|
||||
|
||||
Reference in New Issue
Block a user