@inappstory/react-sdk 1.16.3 → 1.16.5

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.
@@ -3,4 +3,5 @@ export * from "./story-list";
3
3
  export * from "./storyManager";
4
4
  export * from "./ias-container";
5
5
  export * from "./in-app-messaging"
6
- export * from "./events"
6
+ export * from "./events"
7
+ export * from "./logger"
@@ -0,0 +1,135 @@
1
+ /** Log level */
2
+ export type LogLevel = "debug" | "info" | "warn" | "error";
3
+
4
+ /** Log domain */
5
+ export declare enum LogDomain {
6
+ /** Stories domain */
7
+ Stories = "stories",
8
+ /** Core domain */
9
+ Core = "core",
10
+ /** Games domain */
11
+ Games = "games",
12
+ /** In-app messaging domain */
13
+ InAppMessaging = "in-app-messaging",
14
+ /** Banners domain */
15
+ Banners = "banners"
16
+ }
17
+
18
+ /** Log module */
19
+ export declare enum LogModule {
20
+ /** Story reader module */
21
+ StoryReader = "story-reader",
22
+ /** API module */
23
+ Api = "api",
24
+ /** Game reader module */
25
+ GameReader = "game-reader",
26
+ /** IAM reader module */
27
+ IamReader = "iam-reader",
28
+ /** Banners module */
29
+ Banners = "banners"
30
+ }
31
+
32
+ /** Log component */
33
+ export declare enum LogComponent {
34
+ /** Story component */
35
+ Story = "story",
36
+ /** Story slide component */
37
+ StorySlide = "story-slide",
38
+ /** Session component */
39
+ Session = "session",
40
+ /** Session store component */
41
+ SessionStore = "session-store",
42
+ /** HTTP client component */
43
+ HttpClient = "http-client",
44
+ /** Game component */
45
+ Game = "game",
46
+ /** Game session component */
47
+ GameSession = "game-session",
48
+ /** IAM component */
49
+ Iam = "iam",
50
+ /** IAM visibility observer component */
51
+ IamVisibilityObserver = "iam-visibility-observer",
52
+ /** IAM display service component */
53
+ IamDisplayService = "iam-display-service",
54
+ /** Banner place component */
55
+ BannerPlace = "banner-place",
56
+ /** Banner component */
57
+ Banner = "banner"
58
+ }
59
+
60
+ /** Log execution context scope */
61
+ export type LogContextScope = {
62
+ domain?: LogDomain;
63
+ module?: LogModule;
64
+ component?: LogComponent;
65
+ };
66
+
67
+ /** Log execution context with optional dynamic business fields */
68
+ export type LogContext = LogContextScope & {
69
+ /** User ID */
70
+ userId?: string;
71
+ /** User ID signature for validation of the user ID */
72
+ userIdSign?: string;
73
+ /** Session ID for the current session */
74
+ sessionId?: string;
75
+ /** Device ID for the current device */
76
+ deviceId?: string;
77
+ /** Platform (e.g. "web", "android", "ios") */
78
+ platform?: string;
79
+ /** Whether the user is anonymous */
80
+ anonymous?: boolean;
81
+ /** Environment (e.g. "development", "staging", "production") */
82
+ environment?: string;
83
+ [key: string]: any;
84
+ };
85
+
86
+ /** Log event type */
87
+ export type LogEventType = "log" | LogLevel;
88
+
89
+ /** Log entry */
90
+ export interface LogEntry {
91
+ /** Log level */
92
+ level: LogLevel;
93
+ /** Log message */
94
+ message: string;
95
+ /** Log timestamp */
96
+ timestamp: Date;
97
+ /** Log context */
98
+ context?: LogContext;
99
+ /** Log error */
100
+ error?: Error;
101
+ /** Additional custom fields for integrations (Sentry, Datadog, etc.) */
102
+ [key: string]: any;
103
+ }
104
+
105
+ export type LogListener = (entry: LogEntry) => void;
106
+
107
+ export interface LoggerConfig {
108
+ /** Threshold logging level (levels below are excluded) */
109
+ level?: LogLevel;
110
+ /** Disable all logging */
111
+ silent?: boolean;
112
+ /** Include timestamps in console output */
113
+ timestamps?: boolean;
114
+ /** Runtime environment label */
115
+ environment?: string;
116
+ }
117
+
118
+ /**
119
+ * SDK logger with level filtering, component-scoped logging, and event subscriptions.
120
+ *
121
+ * @example
122
+ * // Subscribe to all logs
123
+ * storyManager.logger.on("log", entry => console.log(entry));
124
+ */
125
+ export interface IasLogger {
126
+ debug(message: string, context?: LogContext): void;
127
+ info(message: string, context?: LogContext): void;
128
+ warn(message: string, context?: LogContext, error?: Error): void;
129
+ error(message: string, context?: LogContext, error?: Error): void;
130
+ on(event: LogEventType | string, listener: LogListener): this;
131
+ off(event: LogEventType | string, listener: LogListener): this;
132
+ once(event: LogEventType | string, listener: LogListener): this;
133
+ }
134
+
135
+ export interface StoryManagerLoggerConfig extends LoggerConfig {}
@@ -1,6 +1,7 @@
1
1
  import type { StoryManagerEvents } from "./events";
2
2
  import type { InAppMessaging } from "./in-app-messaging/inAppMessaging";
3
3
  import type { Products } from "./products";
4
+ import type { IasLogger, StoryManagerLoggerConfig } from "./logger";
4
5
 
5
6
  /**
6
7
  * Behaviour of the close button in the game reader.
@@ -144,6 +145,18 @@ export type StoryManagerConfig = {
144
145
  };
145
146
 
146
147
  /**
148
+ * SDK logging configuration.
149
+ * @example
150
+ * logger: {
151
+ * level: "debug",
152
+ * silent: false,
153
+ * timestamps: true,
154
+ * environment: "production"
155
+ * }
156
+ */
157
+
158
+ /*
159
+ logger?: StoryManagerLoggerConfig;
147
160
  * Behaviour of the close button in the game reader.
148
161
  * @default GameCloseButtonBehavior.CloseGame
149
162
  */
@@ -221,6 +234,14 @@ export declare class StoryManager {
221
234
  /** Products widget API */
222
235
  products: Products;
223
236
 
237
+ /**
238
+ * SDK logger for debugging and monitoring integrations.
239
+ * @example
240
+ * storyManager.logger.on("log", console.log);
241
+ * storyManager.logger.on("gameReader", console.log);
242
+ */
243
+ logger: IasLogger;
244
+
224
245
  /** Handler for story link clicks
225
246
  *
226
247
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/react-sdk",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "description": "React SDK",
5
5
  "keywords": [
6
6
  "stories",
@@ -58,7 +58,7 @@
58
58
  "Samsung >= 5"
59
59
  ],
60
60
  "dependencies": {
61
- "@inappstory/slide-api": "^0.1.52",
61
+ "@inappstory/slide-api": "^0.1.53",
62
62
  "async-mutex": "^0.5.0",
63
63
  "bowser": "^2.14.1",
64
64
  "classnames": "^2.5.1",