apps-sdk 1.0.4 → 1.0.6
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/package.json +1 -1
- package/src/libraries/Networking.js +14 -0
- package/src/libraries/Session.js +14 -1
- package/types/index.d.ts +52 -18
package/package.json
CHANGED
|
@@ -39,6 +39,20 @@ class Networking {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
getUserID = async () => {
|
|
43
|
+
config.DEBUG_MODE && console.debug("getUserID");
|
|
44
|
+
try {
|
|
45
|
+
let userID = await this.request(config.ENDPOINTS.GET_USER_ID);
|
|
46
|
+
if (userID) {
|
|
47
|
+
config.DEBUG_MODE && console.debug("new userID", userID);
|
|
48
|
+
return userID;
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(error);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
async setToken(token) {
|
|
43
57
|
try {
|
|
44
58
|
const installID = await storage.getData('install_id');
|
package/src/libraries/Session.js
CHANGED
|
@@ -14,6 +14,7 @@ class Session {
|
|
|
14
14
|
isDevUser = false;
|
|
15
15
|
|
|
16
16
|
init = async () => {
|
|
17
|
+
config.DEBUG_MODE && console.debug("init");
|
|
17
18
|
await this.storeSessionStructure();
|
|
18
19
|
this.sessionID = this.generateSessionID();
|
|
19
20
|
await this.checkFirstOpen();
|
|
@@ -60,7 +61,6 @@ class Session {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
generateSessionID = () => {
|
|
63
|
-
config.DEBUG_MODE && console.debug("generateSessionID");
|
|
64
64
|
const dateNow = new Date();
|
|
65
65
|
const sessionID =
|
|
66
66
|
'' +
|
|
@@ -75,6 +75,19 @@ class Session {
|
|
|
75
75
|
return sessionID;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
checkUserID = async () => {
|
|
79
|
+
config.DEBUG_MODE && console.debug("checkUserID");
|
|
80
|
+
let userID = await Storage.getData("userID");
|
|
81
|
+
if (!userID) {
|
|
82
|
+
userID = await Networking.getUserID();
|
|
83
|
+
if (userID) {
|
|
84
|
+
await Storage.storeData("userID", userID);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
config.DEBUG_MODE && console.debug("checkUserID - userID: ", userID);
|
|
88
|
+
return userID;
|
|
89
|
+
}
|
|
90
|
+
|
|
78
91
|
getSessionData = () => {
|
|
79
92
|
return this.sessionData;
|
|
80
93
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
declare module 'apps-sdk' {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
export interface SessionData {
|
|
3
|
+
app: {
|
|
4
|
+
shortVersion: string;
|
|
5
|
+
package: string;
|
|
6
|
+
languageCode: string;
|
|
7
|
+
regionCode: string;
|
|
8
|
+
buildVersionNumber: string;
|
|
9
|
+
};
|
|
10
|
+
device: {
|
|
11
|
+
name: string;
|
|
12
|
+
systemName: string;
|
|
13
|
+
systemVersion: string;
|
|
14
|
+
model: string;
|
|
15
|
+
};
|
|
16
|
+
sandbox: {
|
|
17
|
+
"domains": string;
|
|
18
|
+
};
|
|
19
|
+
adjust: any;
|
|
20
|
+
dev: boolean;
|
|
21
|
+
lowPower: boolean;
|
|
22
|
+
lang: string;
|
|
23
|
+
package: string;
|
|
12
24
|
}
|
|
13
25
|
|
|
14
|
-
class Session {
|
|
15
|
-
sessionData:
|
|
26
|
+
export class Session {
|
|
27
|
+
sessionData: SessionData;
|
|
16
28
|
sessionID: string | null;
|
|
17
29
|
isFirstOpen: boolean;
|
|
18
30
|
isSubscribed: boolean;
|
|
@@ -21,7 +33,7 @@ declare module 'apps-sdk' {
|
|
|
21
33
|
storeSessionStructure(): Promise<void>;
|
|
22
34
|
checkFirstOpen(): Promise<void>;
|
|
23
35
|
generateSessionID(): string;
|
|
24
|
-
getSessionData():
|
|
36
|
+
getSessionData(): SessionData;
|
|
25
37
|
getSessionID(): string | null;
|
|
26
38
|
getIsFirstOpen(): boolean;
|
|
27
39
|
getIsSubscribed(): boolean;
|
|
@@ -30,12 +42,34 @@ declare module 'apps-sdk' {
|
|
|
30
42
|
setIsDevUser(isDevUser: boolean): void;
|
|
31
43
|
}
|
|
32
44
|
|
|
33
|
-
class
|
|
45
|
+
export class Networking {
|
|
46
|
+
trackEvent(wid: string, event: string, user_id?: string | null): Promise<void>;
|
|
47
|
+
executeInit(): Promise<void>;
|
|
48
|
+
setToken(token: string): Promise<boolean | null>;
|
|
49
|
+
request(url: string, data?: any): Promise<any>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class Storage {
|
|
53
|
+
storeData(key: string, value: any): Promise<void>;
|
|
54
|
+
getData(key: string): Promise<any>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class NotificationsPush {
|
|
58
|
+
initialize(): Promise<void>;
|
|
59
|
+
registerForPushNotificationsAsync(): Promise<string>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class AppsSDK {
|
|
63
|
+
initializePushNotifications(): Promise<string>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface AppsSDK {
|
|
34
67
|
initializePushNotifications(): Promise<string>;
|
|
68
|
+
networking: Networking;
|
|
69
|
+
storage: Storage;
|
|
70
|
+
session: Session;
|
|
35
71
|
}
|
|
36
72
|
|
|
37
|
-
|
|
38
|
-
export
|
|
39
|
-
export const session: Session;
|
|
40
|
-
export const SDK: AppsSDK;
|
|
73
|
+
const Core: AppsSDK;
|
|
74
|
+
export default Core;
|
|
41
75
|
}
|