@product7/feedback-sdk 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +63 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@product7/feedback-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/feedback-sdk.js",
6
6
  "module": "src/index.js",
package/types/index.d.ts CHANGED
@@ -1,42 +1,68 @@
1
+
1
2
  declare module '@product7/feedback-sdk' {
2
- export interface FeedbackConfig {
3
- workspace: string;
4
- debug?: boolean;
5
- boardId?: string;
6
- position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
7
- }
3
+ export interface FeedbackConfig {
4
+ workspace: string;
5
+ userContext: UserContext;
6
+ debug?: boolean;
7
+ boardId?: string;
8
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
9
+ theme?: 'light' | 'dark';
10
+ apiUrl?: string;
11
+ autoShow?: boolean;
12
+ }
13
+
14
+ export interface UserContext {
15
+ user_id?: string;
16
+ email?: string;
17
+ name?: string;
18
+ custom_fields?: Record<string, any>;
19
+ company?: {
20
+ id?: string;
21
+ name?: string;
22
+ monthly_spend?: number;
23
+ };
24
+ }
8
25
 
9
- export interface ButtonWidget {
10
- mount(container?: string | HTMLElement): this;
11
- destroy(): void;
12
- show(): this;
13
- hide(): this;
14
- openModal(): void;
15
- closeModal(): void;
16
- }
26
+ export interface ButtonWidget {
27
+ id: string;
28
+ type: 'button';
29
+ mount(container?: string | HTMLElement): this;
30
+ destroy(): void;
31
+ show(): this;
32
+ hide(): this;
33
+ openModal(): void;
34
+ closeModal(): void;
35
+ }
17
36
 
18
- export class FeedbackSDK {
19
- constructor(config: FeedbackConfig);
20
- init(): Promise<any>;
21
- createWidget(
22
- type: 'button',
23
- options?: Partial<FeedbackConfig>
24
- ): ButtonWidget;
25
- readonly initialized: boolean;
26
- }
37
+ export class FeedbackSDK {
38
+ constructor(config: FeedbackConfig);
39
+ init(): Promise<{
40
+ initialized: boolean;
41
+ config?: any;
42
+ sessionToken?: string;
43
+ expiresIn?: number;
44
+ }>;
45
+ createWidget(type: 'button', options?: Partial<FeedbackConfig>): ButtonWidget;
46
+ setUserContext(userContext: UserContext): void;
47
+ getUserContext(): UserContext | null;
48
+ destroy(): void;
49
+ readonly initialized: boolean;
50
+ }
27
51
 
28
- interface FeedbackSDKExport {
29
- FeedbackSDK: typeof FeedbackSDK;
30
- ButtonWidget: any;
31
- create: (config: FeedbackConfig) => FeedbackSDK;
32
- getInstance: () => FeedbackSDK | null;
33
- isReady: () => boolean;
34
- version: string;
35
- instance: FeedbackSDK | null;
36
- onReady: (callback: (sdk: FeedbackSDK) => void) => void;
37
- onError: (callback: (error: Error) => void) => void;
38
- }
52
+ interface FeedbackSDKExport {
53
+ FeedbackSDK: typeof FeedbackSDK;
54
+ ButtonWidget: any;
55
+ create: (config: FeedbackConfig) => FeedbackSDK;
56
+ initWithUser: (config: Omit<FeedbackConfig, 'userContext'>, userContext: UserContext) => Promise<FeedbackSDK>;
57
+ getInstance: () => FeedbackSDK | null;
58
+ isReady: () => boolean;
59
+ setUserContext: (userContext: UserContext) => void;
60
+ onReady: (callback: (sdk: FeedbackSDK) => void) => void;
61
+ onError: (callback: (error: Error) => void) => void;
62
+ version: string;
63
+ instance: FeedbackSDK | null;
64
+ }
39
65
 
40
- const FeedbackSDKDefault: FeedbackSDKExport;
41
- export default FeedbackSDKDefault;
42
- }
66
+ const FeedbackSDKDefault: FeedbackSDKExport;
67
+ export default FeedbackSDKDefault;
68
+ }