feat: expiresAt should only update on sync in js package (#2253)

Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
This commit is contained in:
Shubham Palriwala
2024-03-18 17:47:00 +05:30
committed by GitHub
parent 7123a620c2
commit 5c9e59b136
5 changed files with 4 additions and 4 deletions

View File

@@ -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();

View File

@@ -160,6 +160,7 @@ export const initialize = async (
...config.get().state,
attributes: { ...config.get().state.attributes, ...c.attributes },
},
expiresAt: config.get().expiresAt,
});
}

View File

@@ -160,6 +160,7 @@ export const setPersonAttribute = async (
[key]: value.toString(),
},
},
expiresAt: config.get().expiresAt,
});
return okVoid();
}

View File

@@ -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}`);

View File

@@ -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(),
});