mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 02:10:12 -06:00
feat: expiresAt should only update on sync in js package (#2253)
Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
This commit is contained in:
committed by
GitHub
parent
7123a620c2
commit
5c9e59b136
@@ -25,13 +25,10 @@ export class Config {
|
||||
|
||||
public update(newConfig: TJsConfigUpdateInput): void {
|
||||
if (newConfig) {
|
||||
const expiresAt = new Date(new Date().getTime() + 2 * 60000); // 2 minutes in the future
|
||||
|
||||
this.config = {
|
||||
...this.config,
|
||||
...newConfig,
|
||||
status: newConfig.status || "success",
|
||||
expiresAt,
|
||||
};
|
||||
|
||||
this.saveToLocalStorage();
|
||||
|
||||
@@ -160,6 +160,7 @@ export const initialize = async (
|
||||
...config.get().state,
|
||||
attributes: { ...config.get().state.attributes, ...c.attributes },
|
||||
},
|
||||
expiresAt: config.get().expiresAt,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@ export const setPersonAttribute = async (
|
||||
[key]: value.toString(),
|
||||
},
|
||||
},
|
||||
expiresAt: config.get().expiresAt,
|
||||
});
|
||||
return okVoid();
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ export const sync = async (params: TJsSyncParams, noCache = false): Promise<void
|
||||
environmentId: params.environmentId,
|
||||
userId: params.userId,
|
||||
state,
|
||||
expiresAt: new Date(new Date().getTime() + 2 * 60000), // 2 minutes in the future
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(`Error during sync: ${error}`);
|
||||
|
||||
@@ -88,7 +88,7 @@ export const ZJsConfigUpdateInput = z.object({
|
||||
apiHost: z.string(),
|
||||
userId: z.string().optional(),
|
||||
state: ZJsState,
|
||||
expiresAt: z.date().optional(),
|
||||
expiresAt: z.date(),
|
||||
status: z.enum(["success", "error"]).optional(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user