@suprsend/web-sdk 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.js +479 -416
- package/dist/es/index.js.map +1 -1
- package/dist/types/interface.d.ts +20 -0
- package/dist/types/main.d.ts +7 -5
- package/dist/types/utils.d.ts +13 -1
- package/package.json +1 -1
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
export type Dictionary = Record<string, unknown>;
|
|
2
|
+
export interface AppInfo {
|
|
3
|
+
name?: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ClientUserAgentConfig {
|
|
7
|
+
sdk?: string;
|
|
8
|
+
sdk_version?: string;
|
|
9
|
+
lang?: string;
|
|
10
|
+
platform?: string;
|
|
11
|
+
environment?: string;
|
|
12
|
+
os?: string;
|
|
13
|
+
os_version?: string;
|
|
14
|
+
app_info?: AppInfo;
|
|
15
|
+
browser?: string;
|
|
16
|
+
browser_version?: string;
|
|
17
|
+
device_model?: string;
|
|
18
|
+
}
|
|
2
19
|
export interface SuprSendOptions {
|
|
3
20
|
host?: string;
|
|
4
21
|
vapidKey?: string;
|
|
5
22
|
swFileName?: string;
|
|
23
|
+
appInfo?: AppInfo;
|
|
24
|
+
clientUserAgent?: ClientUserAgentConfig;
|
|
6
25
|
}
|
|
7
26
|
export type RefreshTokenCallback = (oldUserToken: string, tokenPayload: Dictionary) => Promise<string>;
|
|
8
27
|
export interface AuthenticateOptions {
|
|
9
28
|
refreshUserToken?: RefreshTokenCallback;
|
|
29
|
+
createUser?: boolean;
|
|
10
30
|
}
|
|
11
31
|
export interface ResponseOptions {
|
|
12
32
|
status: RESPONSE_STATUS.ERROR | RESPONSE_STATUS.SUCCESS;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'mitt';
|
|
2
|
-
import { SuprSendOptions, Dictionary, EmitterEvents, AuthenticateOptions } from './interface';
|
|
2
|
+
import { SuprSendOptions, Dictionary, EmitterEvents, AuthenticateOptions, ApiResponse, ClientUserAgentConfig } from './interface';
|
|
3
3
|
import { default as ApiClient } from './api';
|
|
4
4
|
import { default as User } from './user';
|
|
5
5
|
import { default as WebPush } from './webpush';
|
|
@@ -12,6 +12,8 @@ export default class SuprSend {
|
|
|
12
12
|
userToken?: string;
|
|
13
13
|
vapidKey: string;
|
|
14
14
|
swFileName: string;
|
|
15
|
+
clientUserAgent: ClientUserAgentConfig;
|
|
16
|
+
userAgent: string;
|
|
15
17
|
private apiClient;
|
|
16
18
|
private userTokenExpirationTimer;
|
|
17
19
|
authenticateOptions?: AuthenticateOptions;
|
|
@@ -22,12 +24,12 @@ export default class SuprSend {
|
|
|
22
24
|
constructor(publicApiKey: string, options?: SuprSendOptions);
|
|
23
25
|
private handleRefreshUserToken;
|
|
24
26
|
client(): ApiClient;
|
|
25
|
-
eventApi(payload: Dictionary): Promise<
|
|
27
|
+
eventApi(payload: Dictionary): Promise<ApiResponse>;
|
|
26
28
|
/**
|
|
27
29
|
* Used to authenticate user. Usually called just after successful login and on reload of loggedin route to re-authenticate loggedin user.
|
|
28
30
|
* In production env's userToken is mandatory for security purposes.
|
|
29
31
|
*/
|
|
30
|
-
identify(distinctId: unknown, userToken?: string, options?: AuthenticateOptions): Promise<
|
|
32
|
+
identify(distinctId: unknown, userToken?: string, options?: AuthenticateOptions): Promise<ApiResponse>;
|
|
31
33
|
/**
|
|
32
34
|
* Check's if SuprSend instance is authenticated. To check if userToken is also present pass true.
|
|
33
35
|
*/
|
|
@@ -35,11 +37,11 @@ export default class SuprSend {
|
|
|
35
37
|
/**
|
|
36
38
|
* Used to trigger events to suprsend.
|
|
37
39
|
*/
|
|
38
|
-
track(event: string, properties?: Dictionary): Promise<
|
|
40
|
+
track(event: string, properties?: Dictionary): Promise<ApiResponse>;
|
|
39
41
|
/**
|
|
40
42
|
* Clears user related data attached to SuprSend instance. Usually called during logout.
|
|
41
43
|
*/
|
|
42
44
|
reset(options?: {
|
|
43
45
|
unsubscribePush?: boolean;
|
|
44
|
-
}): Promise<
|
|
46
|
+
}): Promise<ApiResponse>;
|
|
45
47
|
}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiResponse, Dictionary, ResponseOptions } from './interface';
|
|
1
|
+
import { ApiResponse, AppInfo, ClientUserAgentConfig, Dictionary, ResponseOptions } from './interface';
|
|
2
2
|
|
|
3
3
|
export declare function uuid(): string;
|
|
4
4
|
export declare function epochMs(): number;
|
|
@@ -9,7 +9,19 @@ export declare function debounce<T extends unknown[], U>(callback: (...args: T)
|
|
|
9
9
|
export declare function debounceByType(func: any, wait: any): (...args: any[]) => any;
|
|
10
10
|
export declare function getResponsePayload(options: ResponseOptions): ApiResponse;
|
|
11
11
|
export declare function windowSupport(): boolean;
|
|
12
|
+
export declare function localStorageSupport(): boolean;
|
|
12
13
|
export declare function setLocalStorageData(key: string, value: string): void;
|
|
13
14
|
export declare function getLocalStorageData(key: string): any;
|
|
14
15
|
export declare function removeLocalStorageData(key: string): void;
|
|
16
|
+
export declare function detectOS(ua?: string): {
|
|
17
|
+
os: string;
|
|
18
|
+
os_version: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function detectBrowser(ua?: string): {
|
|
21
|
+
browser: string;
|
|
22
|
+
browser_version: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function detectEnvironment(ua?: string): string;
|
|
25
|
+
export declare function buildClientUserAgent(appInfo?: AppInfo, override?: ClientUserAgentConfig): ClientUserAgentConfig;
|
|
26
|
+
export declare function buildUserAgent(config: ClientUserAgentConfig): string;
|
|
15
27
|
export declare function sha256Hash(input: string): Promise<string>;
|