From 083ae7a7eafae9295589abe6b14d7441188000e2 Mon Sep 17 00:00:00 2001 From: makarkotlov Date: Tue, 30 Apr 2024 10:29:38 +0200 Subject: [PATCH 1/2] feat: add storage interface --- index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 20f63da6..19eda107 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,12 +1,18 @@ type MixpanelType = any; type MixpanelProperties = {[key: string]: MixpanelType}; +export type Storage = { + getItem: (id: string) => Promise; + setItem: (item: string) => Promise; + removeItem: (id: string) => Promise; +}; + export class Mixpanel { constructor( token: string, trackAutomaticEvents: boolean, useNative?: boolean, - storage?: any + storage?: Storage ); static init( token: string, From fac904943073b0a1da4c26e94edb99c7bd621f88 Mon Sep 17 00:00:00 2001 From: makarkotlov Date: Tue, 30 Apr 2024 11:08:05 +0200 Subject: [PATCH 2/2] fix: allow storage getItem to return null or undefined --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 19eda107..1420987b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,8 +1,8 @@ type MixpanelType = any; type MixpanelProperties = {[key: string]: MixpanelType}; -export type Storage = { - getItem: (id: string) => Promise; +export type StorageType = { + getItem: (id: string) => Promise; setItem: (item: string) => Promise; removeItem: (id: string) => Promise; }; @@ -12,7 +12,7 @@ export class Mixpanel { token: string, trackAutomaticEvents: boolean, useNative?: boolean, - storage?: Storage + storage?: StorageType ); static init( token: string,