@clix-so/react-native-sdk 0.0.1
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/LICENSE +27 -0
- package/README.md +345 -0
- package/lib/module/core/Clix.js +217 -0
- package/lib/module/core/Clix.js.map +1 -0
- package/lib/module/core/ClixConfig.js +4 -0
- package/lib/module/core/ClixConfig.js.map +1 -0
- package/lib/module/core/ClixInitCoordinator.js +58 -0
- package/lib/module/core/ClixInitCoordinator.js.map +1 -0
- package/lib/module/core/ClixVersion.js +17 -0
- package/lib/module/core/ClixVersion.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/ClixDevice.js +51 -0
- package/lib/module/models/ClixDevice.js.map +1 -0
- package/lib/module/models/ClixPushNotificationPayload.js +21 -0
- package/lib/module/models/ClixPushNotificationPayload.js.map +1 -0
- package/lib/module/models/ClixUserProperty.js +44 -0
- package/lib/module/models/ClixUserProperty.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/services/ClixAPIClient.js +172 -0
- package/lib/module/services/ClixAPIClient.js.map +1 -0
- package/lib/module/services/DeviceAPIService.js +112 -0
- package/lib/module/services/DeviceAPIService.js.map +1 -0
- package/lib/module/services/DeviceService.js +157 -0
- package/lib/module/services/DeviceService.js.map +1 -0
- package/lib/module/services/EventAPIService.js +36 -0
- package/lib/module/services/EventAPIService.js.map +1 -0
- package/lib/module/services/EventService.js +29 -0
- package/lib/module/services/EventService.js.map +1 -0
- package/lib/module/services/NotificationService.js +549 -0
- package/lib/module/services/NotificationService.js.map +1 -0
- package/lib/module/services/StorageService.js +76 -0
- package/lib/module/services/StorageService.js.map +1 -0
- package/lib/module/services/TokenService.js +71 -0
- package/lib/module/services/TokenService.js.map +1 -0
- package/lib/module/utils/ClixError.js +63 -0
- package/lib/module/utils/ClixError.js.map +1 -0
- package/lib/module/utils/UUID.js +28 -0
- package/lib/module/utils/UUID.js.map +1 -0
- package/lib/module/utils/logging/ClixLogger.js +55 -0
- package/lib/module/utils/logging/ClixLogger.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/core/Clix.d.ts +67 -0
- package/lib/typescript/src/core/Clix.d.ts.map +1 -0
- package/lib/typescript/src/core/ClixConfig.d.ts +9 -0
- package/lib/typescript/src/core/ClixConfig.d.ts.map +1 -0
- package/lib/typescript/src/core/ClixInitCoordinator.d.ts +16 -0
- package/lib/typescript/src/core/ClixInitCoordinator.d.ts.map +1 -0
- package/lib/typescript/src/core/ClixVersion.d.ts +6 -0
- package/lib/typescript/src/core/ClixVersion.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/ClixDevice.d.ts +42 -0
- package/lib/typescript/src/models/ClixDevice.d.ts.map +1 -0
- package/lib/typescript/src/models/ClixPushNotificationPayload.d.ts +23 -0
- package/lib/typescript/src/models/ClixPushNotificationPayload.d.ts.map +1 -0
- package/lib/typescript/src/models/ClixUserProperty.d.ts +19 -0
- package/lib/typescript/src/models/ClixUserProperty.d.ts.map +1 -0
- package/lib/typescript/src/services/ClixAPIClient.d.ts +35 -0
- package/lib/typescript/src/services/ClixAPIClient.d.ts.map +1 -0
- package/lib/typescript/src/services/DeviceAPIService.d.ts +13 -0
- package/lib/typescript/src/services/DeviceAPIService.d.ts.map +1 -0
- package/lib/typescript/src/services/DeviceService.d.ts +20 -0
- package/lib/typescript/src/services/DeviceService.d.ts.map +1 -0
- package/lib/typescript/src/services/EventAPIService.d.ts +7 -0
- package/lib/typescript/src/services/EventAPIService.d.ts.map +1 -0
- package/lib/typescript/src/services/EventService.d.ts +9 -0
- package/lib/typescript/src/services/EventService.d.ts.map +1 -0
- package/lib/typescript/src/services/NotificationService.d.ts +56 -0
- package/lib/typescript/src/services/NotificationService.d.ts.map +1 -0
- package/lib/typescript/src/services/StorageService.d.ts +10 -0
- package/lib/typescript/src/services/StorageService.d.ts.map +1 -0
- package/lib/typescript/src/services/TokenService.d.ts +15 -0
- package/lib/typescript/src/services/TokenService.d.ts.map +1 -0
- package/lib/typescript/src/utils/ClixError.d.ts +41 -0
- package/lib/typescript/src/utils/ClixError.d.ts.map +1 -0
- package/lib/typescript/src/utils/UUID.d.ts +14 -0
- package/lib/typescript/src/utils/UUID.d.ts.map +1 -0
- package/lib/typescript/src/utils/logging/ClixLogger.d.ts +18 -0
- package/lib/typescript/src/utils/logging/ClixLogger.d.ts.map +1 -0
- package/package.json +151 -0
- package/src/core/Clix.ts +256 -0
- package/src/core/ClixConfig.ts +9 -0
- package/src/core/ClixInitCoordinator.ts +65 -0
- package/src/core/ClixVersion.ts +17 -0
- package/src/index.ts +5 -0
- package/src/models/ClixDevice.ts +88 -0
- package/src/models/ClixPushNotificationPayload.ts +38 -0
- package/src/models/ClixUserProperty.ts +58 -0
- package/src/services/ClixAPIClient.ts +248 -0
- package/src/services/DeviceAPIService.ts +187 -0
- package/src/services/DeviceService.ts +204 -0
- package/src/services/EventAPIService.ts +48 -0
- package/src/services/EventService.ts +45 -0
- package/src/services/NotificationService.ts +730 -0
- package/src/services/StorageService.ts +84 -0
- package/src/services/TokenService.ts +84 -0
- package/src/utils/ClixError.ts +78 -0
- package/src/utils/UUID.ts +29 -0
- package/src/utils/logging/ClixLogger.ts +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceService.d.ts","sourceRoot":"","sources":["../../../../src/services/DeviceService.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IALnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAoB;gBAGtC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB;IAG/C,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAarC,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IActD,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAcpC,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBpE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAepD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YAgC5D,uBAAuB;IA6B/B,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAwC1E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ClixAPIClient } from './ClixAPIClient';
|
|
2
|
+
export declare class EventAPIService {
|
|
3
|
+
private readonly apiClient;
|
|
4
|
+
constructor(apiClient: ClixAPIClient);
|
|
5
|
+
trackEvent(deviceId: string, name: string, properties: Record<string, any>, messageId?: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=EventAPIService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventAPIService.d.ts","sourceRoot":"","sources":["../../../../src/services/EventAPIService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAE/C,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;CAoCjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeviceService } from './DeviceService';
|
|
2
|
+
import { EventAPIService } from './EventAPIService';
|
|
3
|
+
export declare class EventService {
|
|
4
|
+
private readonly eventAPIService;
|
|
5
|
+
private readonly deviceService;
|
|
6
|
+
constructor(eventAPIService: EventAPIService, deviceService: DeviceService);
|
|
7
|
+
trackEvent(name: string, properties?: Record<string, any>, messageId?: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=EventService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventService.d.ts","sourceRoot":"","sources":["../../../../src/services/EventService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa;IAGzC,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;CA8BjB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DeviceService } from './DeviceService';
|
|
2
|
+
import { EventService } from './EventService';
|
|
3
|
+
import { StorageService } from './StorageService';
|
|
4
|
+
import { TokenService } from './TokenService';
|
|
5
|
+
export declare class NotificationService {
|
|
6
|
+
private static instance;
|
|
7
|
+
private static readonly DEFAULT_CHANNEL;
|
|
8
|
+
private messagingService;
|
|
9
|
+
private isInitialized;
|
|
10
|
+
private currentPushToken;
|
|
11
|
+
private processedMessageIds;
|
|
12
|
+
private eventService;
|
|
13
|
+
private storageService;
|
|
14
|
+
private deviceService?;
|
|
15
|
+
private tokenService?;
|
|
16
|
+
private unsubscribeForegroundMessage?;
|
|
17
|
+
private unsubscribeNotificationOpened?;
|
|
18
|
+
private unsubscribeTokenRefresh?;
|
|
19
|
+
private unsubscribeNotificationEvents?;
|
|
20
|
+
private constructor();
|
|
21
|
+
static getInstance(): NotificationService;
|
|
22
|
+
static resetInstance(): void;
|
|
23
|
+
initialize(eventService: EventService, storageService: StorageService, deviceService?: DeviceService, tokenService?: TokenService): Promise<NotificationService>;
|
|
24
|
+
getCurrentToken(): Promise<string | null>;
|
|
25
|
+
cleanup(): void;
|
|
26
|
+
private initializeNotificationDisplayService;
|
|
27
|
+
private createNotificationChannels;
|
|
28
|
+
private setupNotificationEventListeners;
|
|
29
|
+
private handleNotificationEvent;
|
|
30
|
+
private handleActionPress;
|
|
31
|
+
private initializeMessageService;
|
|
32
|
+
private setupMessageHandlers;
|
|
33
|
+
private handleBackgroundMessage;
|
|
34
|
+
private handleForegroundMessage;
|
|
35
|
+
private requestMessagePermission;
|
|
36
|
+
private setupTokenRefreshListener;
|
|
37
|
+
private checkInitialNotification;
|
|
38
|
+
private getAndUpdateToken;
|
|
39
|
+
private getOrFetchToken;
|
|
40
|
+
private saveAndRegisterToken;
|
|
41
|
+
private registerTokenWithServer;
|
|
42
|
+
private displayNotification;
|
|
43
|
+
private createNotificationConfig;
|
|
44
|
+
private createNotificationActions;
|
|
45
|
+
private isValidImageUrl;
|
|
46
|
+
private extractNotificationContent;
|
|
47
|
+
private handlePushReceived;
|
|
48
|
+
private handlePushTapped;
|
|
49
|
+
private handleNotificationTap;
|
|
50
|
+
private handleUrlNavigation;
|
|
51
|
+
private parseClixPayload;
|
|
52
|
+
private trackPushEvent;
|
|
53
|
+
private extractTrackingProperties;
|
|
54
|
+
private trackEventInBackground;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=NotificationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../../../src/services/NotificationService.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;IAE3D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAQrC;IAEF,OAAO,CAAC,gBAAgB,CAAe;IACvC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,mBAAmB,CAAqB;IAEhD,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,aAAa,CAAC,CAAgB;IACtC,OAAO,CAAC,YAAY,CAAC,CAAe;IAEpC,OAAO,CAAC,4BAA4B,CAAC,CAAa;IAClD,OAAO,CAAC,6BAA6B,CAAC,CAAa;IACnD,OAAO,CAAC,uBAAuB,CAAC,CAAa;IAC7C,OAAO,CAAC,6BAA6B,CAAC,CAAa;IAEnD,OAAO;WAEO,WAAW,IAAI,mBAAmB;WAOlC,aAAa,IAAI,IAAI;IAO7B,UAAU,CACd,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,aAAa,CAAC,EAAE,aAAa,EAC7B,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IA4BzB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAU/C,OAAO,IAAI,IAAI;YAUD,oCAAoC;YAgBpC,0BAA0B;IASxC,OAAO,CAAC,+BAA+B;YAQzB,uBAAuB;YAyBvB,iBAAiB;YAUjB,wBAAwB;IAWtC,OAAO,CAAC,oBAAoB;YAoBd,uBAAuB;YA6BvB,uBAAuB;YAgCvB,wBAAwB;IAkBtC,OAAO,CAAC,yBAAyB;YAcnB,wBAAwB;YAgBxB,iBAAiB;YAWjB,eAAe;YAaf,oBAAoB;YAQpB,uBAAuB;YAOvB,mBAAmB;YA2CnB,wBAAwB;IA4DtC,OAAO,CAAC,yBAAyB;IA6BjC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,0BAA0B;YAwCpB,kBAAkB;YAYlB,gBAAgB;YAahB,qBAAqB;YAUrB,mBAAmB;IA8BjC,OAAO,CAAC,gBAAgB;YA8CV,cAAc;IAU5B,OAAO,CAAC,yBAAyB;YAUnB,sBAAsB;CAiDrC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class StorageService {
|
|
2
|
+
private storage;
|
|
3
|
+
constructor();
|
|
4
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
5
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
6
|
+
remove(key: string): Promise<void>;
|
|
7
|
+
clear(): Promise<void>;
|
|
8
|
+
getAllKeys(): Promise<string[]>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=StorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../../../src/services/StorageService.ts"],"names":[],"mappings":"AAGA,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAO;;IAShB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB5C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAsB3C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAStC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StorageService } from './StorageService';
|
|
2
|
+
export declare class TokenService {
|
|
3
|
+
private readonly storageService;
|
|
4
|
+
private static readonly CURRENT_TOKEN_KEY;
|
|
5
|
+
private static readonly PREVIOUS_TOKENS_KEY;
|
|
6
|
+
private static readonly MAX_TOKENS;
|
|
7
|
+
constructor(storageService: StorageService);
|
|
8
|
+
getCurrentToken(): Promise<string | undefined>;
|
|
9
|
+
getPreviousTokens(): Promise<string[]>;
|
|
10
|
+
saveToken(token: string): Promise<void>;
|
|
11
|
+
clearTokens(): Promise<void>;
|
|
12
|
+
convertTokenToString(deviceToken: number[]): string;
|
|
13
|
+
reset(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=TokenService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenService.d.ts","sourceRoot":"","sources":["../../../../src/services/TokenService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qBAAa,YAAY;IAKX,OAAO,CAAC,QAAQ,CAAC,cAAc;IAJ3C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IACtE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAsB;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAK;gBAEV,cAAc,EAAE,cAAc;IAErD,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAW9C,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IActC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BvC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAWlC,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM;IAM7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare enum ClixErrorCode {
|
|
2
|
+
NOT_INITIALIZED = "NOT_INITIALIZED",
|
|
3
|
+
INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
|
|
4
|
+
INVALID_URL = "INVALID_URL",
|
|
5
|
+
INVALID_RESPONSE = "INVALID_RESPONSE",
|
|
6
|
+
ENCODING_ERROR = "ENCODING_ERROR",
|
|
7
|
+
DECODING_ERROR = "DECODING_ERROR",
|
|
8
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
9
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
10
|
+
}
|
|
11
|
+
export declare class ClixError extends Error {
|
|
12
|
+
readonly code: ClixErrorCode;
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
constructor(code: ClixErrorCode, message?: string, options?: {
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
});
|
|
17
|
+
static notInitialized(options?: {
|
|
18
|
+
cause?: unknown;
|
|
19
|
+
}): ClixError;
|
|
20
|
+
static invalidConfiguration(options?: {
|
|
21
|
+
cause?: unknown;
|
|
22
|
+
}): ClixError;
|
|
23
|
+
static invalidURL(options?: {
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
}): ClixError;
|
|
26
|
+
static invalidResponse(options?: {
|
|
27
|
+
cause?: unknown;
|
|
28
|
+
}): ClixError;
|
|
29
|
+
static encodingError(options?: {
|
|
30
|
+
cause?: unknown;
|
|
31
|
+
}): ClixError;
|
|
32
|
+
static decodingError(options?: {
|
|
33
|
+
cause?: unknown;
|
|
34
|
+
}): ClixError;
|
|
35
|
+
static networkError(underlyingError: unknown): ClixError;
|
|
36
|
+
static unknownError(options?: {
|
|
37
|
+
cause?: unknown;
|
|
38
|
+
reason?: string;
|
|
39
|
+
}): ClixError;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=ClixError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClixError.d.ts","sourceRoot":"","sources":["../../../../src/utils/ClixError.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;CAChC;AAeD,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAGvB,IAAI,EAAE,aAAa,EACnB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAU/B,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAGnD,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAOzD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAG/C,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAGpD,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAGlD,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAGlD,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO;IAK5C,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;CASnE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import 'react-native-get-random-values';
|
|
2
|
+
export declare class UUID {
|
|
3
|
+
/**
|
|
4
|
+
* Generates a new UUID v4
|
|
5
|
+
* @returns A new UUID string
|
|
6
|
+
*/
|
|
7
|
+
static generate(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generates a fallback ID when UUID generation fails
|
|
10
|
+
* @returns A fallback ID string
|
|
11
|
+
*/
|
|
12
|
+
private static generateFallbackId;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=UUID.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../src/utils/UUID.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AAIxC,qBAAa,IAAI;IACf;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI,MAAM;IAYzB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAGlC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum ClixLogLevel {
|
|
2
|
+
NONE = 0,
|
|
3
|
+
ERROR = 1,
|
|
4
|
+
WARN = 2,
|
|
5
|
+
INFO = 3,
|
|
6
|
+
DEBUG = 4
|
|
7
|
+
}
|
|
8
|
+
export declare class ClixLogger {
|
|
9
|
+
private static logLevel;
|
|
10
|
+
static setLogLevel(level: ClixLogLevel): void;
|
|
11
|
+
static shouldLog(level: ClixLogLevel): boolean;
|
|
12
|
+
static log(level: ClixLogLevel, message: string, error?: any): void;
|
|
13
|
+
static error(message: string, error?: any): void;
|
|
14
|
+
static warn(message: string, error?: any): void;
|
|
15
|
+
static info(message: string, error?: any): void;
|
|
16
|
+
static debug(message: string, error?: any): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ClixLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClixLogger.d.ts","sourceRoot":"","sources":["../../../../../src/utils/logging/ClixLogger.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmC;IAE1D,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAI7C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAI9C,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IA0BnE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAIhD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAI/C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAI/C,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;CAGjD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clix-so/react-native-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Clix - Mobile push for builders",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"!**/__tests__",
|
|
19
|
+
"!**/__fixtures__",
|
|
20
|
+
"!**/__mocks__",
|
|
21
|
+
"!**/.*"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "jest --passWithNoTests",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
27
|
+
"prepare": "bob build",
|
|
28
|
+
"release": "release-it --only-version"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"react-native",
|
|
32
|
+
"ios",
|
|
33
|
+
"android",
|
|
34
|
+
"clix",
|
|
35
|
+
"sdk"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/clix-so/clix-react-native-sdk.git"
|
|
40
|
+
},
|
|
41
|
+
"author": "Clix <team@clix.so> (https://github.com/clix-so/clix-react-native-sdk)",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/clix-so/clix-react-native-sdk/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/clix-so/clix-react-native-sdk#readme",
|
|
47
|
+
"packageManager": "npm@10.9.2",
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@notifee/react-native": "*",
|
|
50
|
+
"@react-native-firebase/app": "*",
|
|
51
|
+
"@react-native-firebase/messaging": "*",
|
|
52
|
+
"react": "*",
|
|
53
|
+
"react-native": "*",
|
|
54
|
+
"react-native-device-info": "*",
|
|
55
|
+
"react-native-get-random-values": "*",
|
|
56
|
+
"react-native-mmkv": "*",
|
|
57
|
+
"uuid": "*"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@commitlint/config-conventional": "19.6.0",
|
|
61
|
+
"@evilmartians/lefthook": "1.5.0",
|
|
62
|
+
"@notifee/react-native": "9.1.8",
|
|
63
|
+
"@react-native-community/cli": "15.0.0",
|
|
64
|
+
"@react-native-community/eslint-config": "2.0.0",
|
|
65
|
+
"@react-native-firebase/app": "19.3.0",
|
|
66
|
+
"@react-native-firebase/messaging": "19.3.0",
|
|
67
|
+
"@react-native/babel-preset": "0.76.9",
|
|
68
|
+
"@release-it/conventional-changelog": "9.0.2",
|
|
69
|
+
"@types/jest": "29.5.5",
|
|
70
|
+
"@types/react": "18.3.12",
|
|
71
|
+
"commitlint": "19.6.1",
|
|
72
|
+
"del-cli": "5.1.0",
|
|
73
|
+
"eslint": "7.32.0",
|
|
74
|
+
"eslint-config-prettier": "8.5.0",
|
|
75
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
76
|
+
"jest": "29.7.0",
|
|
77
|
+
"pod-install": "0.1.0",
|
|
78
|
+
"prettier": "2.8.8",
|
|
79
|
+
"react": "18.3.1",
|
|
80
|
+
"react-native": "0.76.9",
|
|
81
|
+
"react-native-builder-bob": "0.40.12",
|
|
82
|
+
"react-native-device-info": "13.2.0",
|
|
83
|
+
"react-native-get-random-values": "1.11.0",
|
|
84
|
+
"react-native-mmkv": "2.12.2",
|
|
85
|
+
"release-it": "17.10.0",
|
|
86
|
+
"typescript": "5.8.3",
|
|
87
|
+
"uuid": "11.1.0"
|
|
88
|
+
},
|
|
89
|
+
"jest": {
|
|
90
|
+
"preset": "react-native",
|
|
91
|
+
"modulePathIgnorePatterns": [
|
|
92
|
+
"<rootDir>/samples/BasicApp/node_modules",
|
|
93
|
+
"<rootDir>/lib/"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"commitlint": {
|
|
97
|
+
"extends": [
|
|
98
|
+
"@commitlint/config-conventional"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"release-it": {
|
|
102
|
+
"git": {
|
|
103
|
+
"commitMessage": "chore: release ${version}",
|
|
104
|
+
"tagName": "v${version}"
|
|
105
|
+
},
|
|
106
|
+
"npm": {
|
|
107
|
+
"publish": true
|
|
108
|
+
},
|
|
109
|
+
"github": {
|
|
110
|
+
"release": true
|
|
111
|
+
},
|
|
112
|
+
"plugins": {
|
|
113
|
+
"@release-it/conventional-changelog": {
|
|
114
|
+
"preset": {
|
|
115
|
+
"name": "angular"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"react-native-builder-bob": {
|
|
121
|
+
"source": "src",
|
|
122
|
+
"output": "lib",
|
|
123
|
+
"targets": [
|
|
124
|
+
[
|
|
125
|
+
"module",
|
|
126
|
+
{
|
|
127
|
+
"esm": true
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
"typescript",
|
|
132
|
+
{
|
|
133
|
+
"project": "tsconfig.build.json"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
"codegenConfig": {
|
|
139
|
+
"name": "ClixSpec",
|
|
140
|
+
"type": "modules",
|
|
141
|
+
"jsSrcsDir": "src",
|
|
142
|
+
"android": {
|
|
143
|
+
"javaPackageName": "so.clix"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"create-react-native-library": {
|
|
147
|
+
"languages": "js",
|
|
148
|
+
"type": "library",
|
|
149
|
+
"version": "0.51.1"
|
|
150
|
+
}
|
|
151
|
+
}
|
package/src/core/Clix.ts
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { ClixAPIClient } from '../services/ClixAPIClient';
|
|
2
|
+
import { DeviceAPIService } from '../services/DeviceAPIService';
|
|
3
|
+
import { DeviceService } from '../services/DeviceService';
|
|
4
|
+
import { EventAPIService } from '../services/EventAPIService';
|
|
5
|
+
import { EventService } from '../services/EventService';
|
|
6
|
+
import { NotificationService } from '../services/NotificationService';
|
|
7
|
+
import { StorageService } from '../services/StorageService';
|
|
8
|
+
import { TokenService } from '../services/TokenService';
|
|
9
|
+
import { ClixError } from '../utils/ClixError';
|
|
10
|
+
import { ClixLogger, ClixLogLevel } from '../utils/logging/ClixLogger';
|
|
11
|
+
import type { ClixConfig } from './ClixConfig';
|
|
12
|
+
import { ClixInitCoordinator } from './ClixInitCoordinator';
|
|
13
|
+
|
|
14
|
+
export class Clix {
|
|
15
|
+
private static shared?: Clix;
|
|
16
|
+
private static initCoordinator = new ClixInitCoordinator();
|
|
17
|
+
|
|
18
|
+
protected storageService?: StorageService;
|
|
19
|
+
protected eventService?: EventService;
|
|
20
|
+
protected deviceService?: DeviceService;
|
|
21
|
+
protected notificationService?: NotificationService;
|
|
22
|
+
|
|
23
|
+
private constructor() {}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Initialize Clix SDK
|
|
27
|
+
*/
|
|
28
|
+
static async initialize(config: ClixConfig): Promise<void> {
|
|
29
|
+
try {
|
|
30
|
+
if (this.initCoordinator.isInitializationFailed()) {
|
|
31
|
+
this.initCoordinator.reset();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ClixLogger.setLogLevel(config.logLevel || ClixLogLevel.ERROR);
|
|
35
|
+
ClixLogger.debug('Initializing Clix SDK');
|
|
36
|
+
|
|
37
|
+
this.shared = new Clix();
|
|
38
|
+
await this.shared.setConfig(config);
|
|
39
|
+
|
|
40
|
+
ClixLogger.debug('Clix SDK initialized successfully');
|
|
41
|
+
this.initCoordinator.completeInitialization();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
const errorInstance =
|
|
44
|
+
error instanceof Error ? error : new Error(String(error));
|
|
45
|
+
this.initCoordinator.failInitialization(errorInstance);
|
|
46
|
+
throw ClixError.notInitialized({ cause: errorInstance });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Set user ID
|
|
52
|
+
*/
|
|
53
|
+
static async setUserId(userId: string): Promise<void> {
|
|
54
|
+
try {
|
|
55
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
56
|
+
if (this.shared?.deviceService) {
|
|
57
|
+
await this.shared.deviceService.setProjectUserId(userId);
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
ClixLogger.error(`Failed to set user ID: ${error}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Remove user ID
|
|
66
|
+
*/
|
|
67
|
+
static async removeUserId(): Promise<void> {
|
|
68
|
+
try {
|
|
69
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
70
|
+
if (this.shared?.deviceService) {
|
|
71
|
+
await this.shared.deviceService.removeProjectUserId();
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
ClixLogger.error(`Failed to remove user ID: ${error}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Set user property
|
|
80
|
+
*/
|
|
81
|
+
static async setUserProperty(key: string, value: any): Promise<void> {
|
|
82
|
+
try {
|
|
83
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
84
|
+
if (this.shared?.deviceService) {
|
|
85
|
+
await this.shared.deviceService.updateUserProperties({
|
|
86
|
+
[key]: value,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
ClixLogger.error(`Failed to set user property: ${error}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Set user properties
|
|
96
|
+
*/
|
|
97
|
+
static async setUserProperties(
|
|
98
|
+
userProperties: Record<string, any>
|
|
99
|
+
): Promise<void> {
|
|
100
|
+
try {
|
|
101
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
102
|
+
if (this.shared?.deviceService) {
|
|
103
|
+
await this.shared.deviceService.updateUserProperties(userProperties);
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
ClixLogger.error(`Failed to set user properties: ${error}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Remove user property
|
|
112
|
+
*/
|
|
113
|
+
static async removeUserProperty(key: string): Promise<void> {
|
|
114
|
+
try {
|
|
115
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
116
|
+
if (this.shared?.deviceService) {
|
|
117
|
+
await this.shared.deviceService.removeUserProperties([key]);
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
ClixLogger.error(`Failed to remove user property: ${error}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Remove user properties
|
|
126
|
+
*/
|
|
127
|
+
static async removeUserProperties(keys: string[]): Promise<void> {
|
|
128
|
+
try {
|
|
129
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
130
|
+
if (this.shared?.deviceService) {
|
|
131
|
+
await this.shared.deviceService.removeUserProperties(keys);
|
|
132
|
+
}
|
|
133
|
+
} catch (error) {
|
|
134
|
+
ClixLogger.error(`Failed to remove user properties: ${error}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Get device ID
|
|
140
|
+
*/
|
|
141
|
+
static async getDeviceId(): Promise<string | undefined> {
|
|
142
|
+
try {
|
|
143
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
144
|
+
if (this.shared?.deviceService) {
|
|
145
|
+
const deviceId = await this.shared.deviceService.getCurrentDeviceId();
|
|
146
|
+
return deviceId;
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
ClixLogger.error(`Failed to get device ID: ${error}`);
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get push token
|
|
157
|
+
*/
|
|
158
|
+
static async getPushToken(): Promise<string | undefined> {
|
|
159
|
+
try {
|
|
160
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
161
|
+
if (this.shared?.notificationService) {
|
|
162
|
+
const token = await this.shared.notificationService.getCurrentToken();
|
|
163
|
+
return token || undefined;
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
ClixLogger.error(`Failed to get push token: ${error}`);
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Set log level
|
|
174
|
+
*/
|
|
175
|
+
static setLogLevel(level: ClixLogLevel): void {
|
|
176
|
+
ClixLogger.setLogLevel(level);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Track event
|
|
181
|
+
*/
|
|
182
|
+
protected static async trackEvent(
|
|
183
|
+
name: string,
|
|
184
|
+
options?: {
|
|
185
|
+
properties?: Record<string, any>;
|
|
186
|
+
messageId?: string;
|
|
187
|
+
}
|
|
188
|
+
): Promise<void> {
|
|
189
|
+
try {
|
|
190
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
191
|
+
if (this.shared?.eventService) {
|
|
192
|
+
await this.shared.eventService.trackEvent(
|
|
193
|
+
name,
|
|
194
|
+
options?.properties,
|
|
195
|
+
options?.messageId
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
} catch (error) {
|
|
199
|
+
ClixLogger.error(`Failed to track event: ${error}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Set configuration
|
|
205
|
+
*/
|
|
206
|
+
private async setConfig(config: ClixConfig): Promise<void> {
|
|
207
|
+
this.storageService = new StorageService();
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
await this.storageService.set('project_id', config.projectId);
|
|
211
|
+
await this.storageService.set('api_key', config.apiKey);
|
|
212
|
+
await this.storageService.set('clix_config', {
|
|
213
|
+
projectId: config.projectId,
|
|
214
|
+
apiKey: config.apiKey,
|
|
215
|
+
endpoint: config.endpoint,
|
|
216
|
+
logLevel: config.logLevel,
|
|
217
|
+
extraHeaders: config.extraHeaders,
|
|
218
|
+
});
|
|
219
|
+
} catch (error) {
|
|
220
|
+
ClixLogger.warn(
|
|
221
|
+
'Failed to store configuration in storage, continuing with in-memory config',
|
|
222
|
+
error
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const apiClient = new ClixAPIClient({
|
|
227
|
+
...config,
|
|
228
|
+
endpoint: config.endpoint || 'https://api.clix.so',
|
|
229
|
+
logLevel: config.logLevel || ClixLogLevel.ERROR,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const deviceAPIService = new DeviceAPIService(apiClient);
|
|
233
|
+
const eventAPIService = new EventAPIService(apiClient);
|
|
234
|
+
const tokenService = new TokenService(this.storageService);
|
|
235
|
+
this.deviceService = new DeviceService(
|
|
236
|
+
this.storageService,
|
|
237
|
+
tokenService,
|
|
238
|
+
deviceAPIService
|
|
239
|
+
);
|
|
240
|
+
this.eventService = new EventService(eventAPIService, this.deviceService);
|
|
241
|
+
try {
|
|
242
|
+
this.notificationService =
|
|
243
|
+
await NotificationService.getInstance().initialize(
|
|
244
|
+
this.eventService,
|
|
245
|
+
this.storageService,
|
|
246
|
+
this.deviceService,
|
|
247
|
+
tokenService
|
|
248
|
+
);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
ClixLogger.warn(
|
|
251
|
+
'Failed to fully initialize notification service, some features may be limited',
|
|
252
|
+
error
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|