posthog-js 1.347.2 → 1.349.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/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/conversations.js +1 -1
- package/dist/conversations.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +56 -2
- package/dist/module.full.d.ts +56 -2
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +56 -2
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +56 -2
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/product-tours-preview.d.ts +14 -0
- package/dist/product-tours-preview.js +1 -1
- package/dist/product-tours-preview.js.map +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/product-tours.js.map +1 -1
- package/dist/src/extensions/conversations/external/components/ConversationsWidget.d.ts +43 -2
- package/dist/src/extensions/conversations/external/components/TicketListItem.d.ts +13 -0
- package/dist/src/extensions/conversations/external/components/TicketListView.d.ts +15 -0
- package/dist/src/extensions/conversations/external/components/styles.d.ts +184 -0
- package/dist/src/extensions/conversations/external/components/utils.d.ts +8 -0
- package/dist/src/extensions/conversations/external/index.d.ts +39 -1
- package/dist/src/extensions/product-tours/product-tours-utils.d.ts +1 -0
- package/dist/src/extensions/product-tours/product-tours.d.ts +3 -0
- package/dist/src/posthog-product-tours-types.d.ts +54 -0
- package/dist/surveys-preview.d.ts +14 -0
- package/lib/package.json +1 -1
- package/lib/src/extensions/conversations/external/components/ConversationsWidget.d.ts +43 -2
- package/lib/src/extensions/conversations/external/components/ConversationsWidget.js +96 -28
- package/lib/src/extensions/conversations/external/components/ConversationsWidget.js.map +1 -1
- package/lib/src/extensions/conversations/external/components/TicketListItem.d.ts +13 -0
- package/lib/src/extensions/conversations/external/components/TicketListItem.js +47 -0
- package/lib/src/extensions/conversations/external/components/TicketListItem.js.map +1 -0
- package/lib/src/extensions/conversations/external/components/TicketListView.d.ts +15 -0
- package/lib/src/extensions/conversations/external/components/TicketListView.js +75 -0
- package/lib/src/extensions/conversations/external/components/TicketListView.js.map +1 -0
- package/lib/src/extensions/conversations/external/components/styles.d.ts +184 -0
- package/lib/src/extensions/conversations/external/components/styles.js +189 -0
- package/lib/src/extensions/conversations/external/components/styles.js.map +1 -1
- package/lib/src/extensions/conversations/external/components/utils.d.ts +8 -0
- package/lib/src/extensions/conversations/external/components/utils.js +49 -0
- package/lib/src/extensions/conversations/external/components/utils.js.map +1 -0
- package/lib/src/extensions/conversations/external/index.d.ts +39 -1
- package/lib/src/extensions/conversations/external/index.js +253 -31
- package/lib/src/extensions/conversations/external/index.js.map +1 -1
- package/lib/src/extensions/product-tours/components/ProductTourSurveyStepInner.js +1 -1
- package/lib/src/extensions/product-tours/components/ProductTourSurveyStepInner.js.map +1 -1
- package/lib/src/extensions/product-tours/product-tours-utils.d.ts +1 -0
- package/lib/src/extensions/product-tours/product-tours-utils.js +34 -0
- package/lib/src/extensions/product-tours/product-tours-utils.js.map +1 -1
- package/lib/src/extensions/product-tours/product-tours.d.ts +3 -0
- package/lib/src/extensions/product-tours/product-tours.js +104 -75
- package/lib/src/extensions/product-tours/product-tours.js.map +1 -1
- package/lib/src/posthog-product-tours-types.d.ts +54 -0
- package/lib/src/posthog-product-tours-types.js +43 -1
- package/lib/src/posthog-product-tours-types.js.map +1 -1
- package/lib/src/utils/product-tour-event-receiver.js +2 -1
- package/lib/src/utils/product-tour-event-receiver.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/react/dist/esm/index.js +25 -1
- package/react/dist/esm/index.js.map +1 -1
- package/react/dist/types/index.d.ts +4 -2
- package/react/dist/umd/index.js +25 -0
- package/react/dist/umd/index.js.map +1 -1
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { h, Component } from 'preact';
|
|
2
|
-
import { ConversationsRemoteConfig, Message, ConversationsWidgetState, UserProvidedTraits } from '../../../../posthog-conversations-types';
|
|
2
|
+
import { ConversationsRemoteConfig, Message, ConversationsWidgetState, UserProvidedTraits, Ticket } from '../../../../posthog-conversations-types';
|
|
3
|
+
/**
|
|
4
|
+
* Type for the current view in the widget
|
|
5
|
+
*/
|
|
6
|
+
export type WidgetView = 'tickets' | 'messages';
|
|
3
7
|
interface WidgetProps {
|
|
4
8
|
config: ConversationsRemoteConfig;
|
|
5
9
|
initialState?: ConversationsWidgetState;
|
|
6
10
|
initialUserTraits?: UserProvidedTraits | null;
|
|
7
11
|
isUserIdentified?: boolean;
|
|
12
|
+
initialView?: WidgetView;
|
|
13
|
+
initialTickets?: Ticket[];
|
|
14
|
+
hasMultipleTickets?: boolean;
|
|
8
15
|
onSendMessage: (message: string) => Promise<void>;
|
|
9
16
|
onStateChange?: (state: ConversationsWidgetState) => void;
|
|
10
17
|
onIdentify?: (traits: UserProvidedTraits) => void;
|
|
18
|
+
onSelectTicket?: (ticketId: string) => void;
|
|
19
|
+
onNewConversation?: () => void;
|
|
20
|
+
onBackToTickets?: () => void;
|
|
21
|
+
onViewChange?: (view: WidgetView) => void;
|
|
11
22
|
}
|
|
12
23
|
interface WidgetState {
|
|
13
24
|
state: ConversationsWidgetState;
|
|
25
|
+
view: WidgetView;
|
|
14
26
|
messages: Message[];
|
|
27
|
+
tickets: Ticket[];
|
|
28
|
+
ticketsLoading: boolean;
|
|
15
29
|
inputValue: string;
|
|
16
30
|
isLoading: boolean;
|
|
17
31
|
error: string | null;
|
|
@@ -21,6 +35,7 @@ interface WidgetState {
|
|
|
21
35
|
formEmailError: string | null;
|
|
22
36
|
userTraits: UserProvidedTraits | null;
|
|
23
37
|
unreadCount: number;
|
|
38
|
+
hasMultipleTickets: boolean;
|
|
24
39
|
}
|
|
25
40
|
export declare class ConversationsWidget extends Component<WidgetProps, WidgetState> {
|
|
26
41
|
private _messagesEndRef;
|
|
@@ -37,6 +52,9 @@ export declare class ConversationsWidget extends Component<WidgetProps, WidgetSt
|
|
|
37
52
|
private _focusInput;
|
|
38
53
|
private _handleToggleOpen;
|
|
39
54
|
private _handleClose;
|
|
55
|
+
private _handleSelectTicket;
|
|
56
|
+
private _handleNewConversation;
|
|
57
|
+
private _handleBackToTickets;
|
|
40
58
|
private _handleInputChange;
|
|
41
59
|
private _handleKeyPress;
|
|
42
60
|
private _handleFormNameChange;
|
|
@@ -44,7 +62,6 @@ export declare class ConversationsWidget extends Component<WidgetProps, WidgetSt
|
|
|
44
62
|
private _validateEmail;
|
|
45
63
|
private _handleFormSubmit;
|
|
46
64
|
private _handleSendMessage;
|
|
47
|
-
private _formatTime;
|
|
48
65
|
/**
|
|
49
66
|
* Public method to add messages from outside
|
|
50
67
|
*/
|
|
@@ -74,8 +91,32 @@ export declare class ConversationsWidget extends Component<WidgetProps, WidgetSt
|
|
|
74
91
|
* Set the unread message count (called by manager)
|
|
75
92
|
*/
|
|
76
93
|
setUnreadCount(count: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Update the tickets list (called by manager during polling)
|
|
96
|
+
*/
|
|
97
|
+
updateTickets(tickets: Ticket[]): void;
|
|
98
|
+
/**
|
|
99
|
+
* Set the current view (tickets list or messages)
|
|
100
|
+
*/
|
|
101
|
+
setView(view: WidgetView): void;
|
|
102
|
+
/**
|
|
103
|
+
* Get the current view
|
|
104
|
+
*/
|
|
105
|
+
getView(): WidgetView;
|
|
106
|
+
/**
|
|
107
|
+
* Set tickets loading state
|
|
108
|
+
*/
|
|
109
|
+
setTicketsLoading(loading: boolean): void;
|
|
110
|
+
/**
|
|
111
|
+
* Clear messages (used when switching tickets or starting new conversation)
|
|
112
|
+
* @param addGreeting - If true, adds the greeting message after clearing
|
|
113
|
+
*/
|
|
114
|
+
clearMessages(addGreeting?: boolean): void;
|
|
77
115
|
private _renderIdentificationForm;
|
|
78
116
|
private _renderMessage;
|
|
117
|
+
private _renderBackButton;
|
|
118
|
+
private _renderTicketList;
|
|
119
|
+
private _renderMessages;
|
|
79
120
|
render(): h.JSX.Element;
|
|
80
121
|
}
|
|
81
122
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
import { Ticket } from '../../../../posthog-conversations-types';
|
|
3
|
+
import { getStyles } from './styles';
|
|
4
|
+
interface TicketListItemProps {
|
|
5
|
+
ticket: Ticket;
|
|
6
|
+
styles: ReturnType<typeof getStyles>;
|
|
7
|
+
onClick: (ticketId: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A single ticket item in the ticket list
|
|
11
|
+
*/
|
|
12
|
+
export declare const TicketListItem: FunctionComponent<TicketListItemProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
import { Ticket } from '../../../../posthog-conversations-types';
|
|
3
|
+
import { getStyles } from './styles';
|
|
4
|
+
interface TicketListViewProps {
|
|
5
|
+
tickets: Ticket[];
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
styles: ReturnType<typeof getStyles>;
|
|
8
|
+
onSelectTicket: (ticketId: string) => void;
|
|
9
|
+
onNewConversation: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Ticket list view showing all user's tickets
|
|
13
|
+
*/
|
|
14
|
+
export declare const TicketListView: FunctionComponent<TicketListViewProps>;
|
|
15
|
+
export {};
|
|
@@ -166,6 +166,7 @@ export declare const getStyles: (primaryColor: string, position?: WidgetPosition
|
|
|
166
166
|
};
|
|
167
167
|
windowOpen: {
|
|
168
168
|
width: string;
|
|
169
|
+
maxWidth: string;
|
|
169
170
|
height: string;
|
|
170
171
|
maxHeight: string;
|
|
171
172
|
};
|
|
@@ -371,4 +372,187 @@ export declare const getStyles: (primaryColor: string, position?: WidgetPosition
|
|
|
371
372
|
color: string;
|
|
372
373
|
fontWeight: number;
|
|
373
374
|
};
|
|
375
|
+
ticketListContainer: {
|
|
376
|
+
flex: number;
|
|
377
|
+
display: string;
|
|
378
|
+
flexDirection: "column";
|
|
379
|
+
background: string;
|
|
380
|
+
overflowY: "auto";
|
|
381
|
+
};
|
|
382
|
+
ticketList: {
|
|
383
|
+
flex: number;
|
|
384
|
+
overflowY: "auto";
|
|
385
|
+
};
|
|
386
|
+
ticketItem: {
|
|
387
|
+
padding: string;
|
|
388
|
+
borderBottom: string;
|
|
389
|
+
cursor: string;
|
|
390
|
+
transition: string;
|
|
391
|
+
background: string;
|
|
392
|
+
display: string;
|
|
393
|
+
alignItems: string;
|
|
394
|
+
gap: string;
|
|
395
|
+
};
|
|
396
|
+
ticketItemUnread: {
|
|
397
|
+
background: string;
|
|
398
|
+
};
|
|
399
|
+
ticketItemContent: {
|
|
400
|
+
display: string;
|
|
401
|
+
flexDirection: "column";
|
|
402
|
+
gap: string;
|
|
403
|
+
flex: number;
|
|
404
|
+
minWidth: number;
|
|
405
|
+
};
|
|
406
|
+
ticketItemArrow: {
|
|
407
|
+
color: string;
|
|
408
|
+
flexShrink: number;
|
|
409
|
+
display: string;
|
|
410
|
+
alignItems: string;
|
|
411
|
+
};
|
|
412
|
+
ticketItemHeader: {
|
|
413
|
+
display: string;
|
|
414
|
+
justifyContent: string;
|
|
415
|
+
alignItems: string;
|
|
416
|
+
gap: string;
|
|
417
|
+
};
|
|
418
|
+
ticketPreview: {
|
|
419
|
+
fontSize: string;
|
|
420
|
+
color: string;
|
|
421
|
+
lineHeight: number;
|
|
422
|
+
flex: number;
|
|
423
|
+
overflow: string;
|
|
424
|
+
textOverflow: string;
|
|
425
|
+
whiteSpace: "nowrap";
|
|
426
|
+
};
|
|
427
|
+
ticketPreviewUnread: {
|
|
428
|
+
fontSize: string;
|
|
429
|
+
color: string;
|
|
430
|
+
lineHeight: number;
|
|
431
|
+
flex: number;
|
|
432
|
+
overflow: string;
|
|
433
|
+
textOverflow: string;
|
|
434
|
+
whiteSpace: "nowrap";
|
|
435
|
+
fontWeight: number;
|
|
436
|
+
};
|
|
437
|
+
ticketUnreadBadge: {
|
|
438
|
+
minWidth: string;
|
|
439
|
+
height: string;
|
|
440
|
+
borderRadius: string;
|
|
441
|
+
background: string;
|
|
442
|
+
color: string;
|
|
443
|
+
fontSize: string;
|
|
444
|
+
fontWeight: number;
|
|
445
|
+
display: string;
|
|
446
|
+
alignItems: string;
|
|
447
|
+
justifyContent: string;
|
|
448
|
+
padding: string;
|
|
449
|
+
flexShrink: number;
|
|
450
|
+
};
|
|
451
|
+
ticketMeta: {
|
|
452
|
+
display: string;
|
|
453
|
+
alignItems: string;
|
|
454
|
+
gap: string;
|
|
455
|
+
};
|
|
456
|
+
ticketTime: {
|
|
457
|
+
fontSize: string;
|
|
458
|
+
color: string;
|
|
459
|
+
};
|
|
460
|
+
ticketStatus: {
|
|
461
|
+
fontSize: string;
|
|
462
|
+
color: string;
|
|
463
|
+
background: string;
|
|
464
|
+
padding: string;
|
|
465
|
+
borderRadius: string;
|
|
466
|
+
textTransform: "uppercase";
|
|
467
|
+
letterSpacing: string;
|
|
468
|
+
};
|
|
469
|
+
newConversationButton: {
|
|
470
|
+
display: string;
|
|
471
|
+
alignItems: string;
|
|
472
|
+
justifyContent: string;
|
|
473
|
+
margin: string;
|
|
474
|
+
padding: string;
|
|
475
|
+
borderRadius: string;
|
|
476
|
+
background: string;
|
|
477
|
+
color: string;
|
|
478
|
+
border: string;
|
|
479
|
+
cursor: string;
|
|
480
|
+
fontSize: string;
|
|
481
|
+
fontWeight: number;
|
|
482
|
+
transition: string;
|
|
483
|
+
};
|
|
484
|
+
ticketListLoading: {
|
|
485
|
+
flex: number;
|
|
486
|
+
display: string;
|
|
487
|
+
flexDirection: "column";
|
|
488
|
+
alignItems: string;
|
|
489
|
+
justifyContent: string;
|
|
490
|
+
gap: string;
|
|
491
|
+
color: string;
|
|
492
|
+
fontSize: string;
|
|
493
|
+
};
|
|
494
|
+
loadingSpinner: {
|
|
495
|
+
width: string;
|
|
496
|
+
height: string;
|
|
497
|
+
border: string;
|
|
498
|
+
borderTop: string;
|
|
499
|
+
borderRadius: string;
|
|
500
|
+
animation: string;
|
|
501
|
+
};
|
|
502
|
+
ticketListEmpty: {
|
|
503
|
+
flex: number;
|
|
504
|
+
display: string;
|
|
505
|
+
flexDirection: "column";
|
|
506
|
+
alignItems: string;
|
|
507
|
+
justifyContent: string;
|
|
508
|
+
padding: string;
|
|
509
|
+
textAlign: "center";
|
|
510
|
+
};
|
|
511
|
+
emptyStateIcon: {
|
|
512
|
+
color: string;
|
|
513
|
+
marginBottom: string;
|
|
514
|
+
};
|
|
515
|
+
emptyStateTitle: {
|
|
516
|
+
fontSize: string;
|
|
517
|
+
fontWeight: number;
|
|
518
|
+
color: string;
|
|
519
|
+
marginBottom: string;
|
|
520
|
+
};
|
|
521
|
+
emptyStateDescription: {
|
|
522
|
+
fontSize: string;
|
|
523
|
+
color: string;
|
|
524
|
+
lineHeight: number;
|
|
525
|
+
marginBottom: string;
|
|
526
|
+
};
|
|
527
|
+
newConversationButtonLarge: {
|
|
528
|
+
padding: string;
|
|
529
|
+
borderRadius: string;
|
|
530
|
+
background: string;
|
|
531
|
+
color: string;
|
|
532
|
+
border: string;
|
|
533
|
+
cursor: string;
|
|
534
|
+
fontSize: string;
|
|
535
|
+
fontWeight: number;
|
|
536
|
+
transition: string;
|
|
537
|
+
};
|
|
538
|
+
backButton: {
|
|
539
|
+
background: string;
|
|
540
|
+
border: string;
|
|
541
|
+
color: string;
|
|
542
|
+
cursor: string;
|
|
543
|
+
padding: string;
|
|
544
|
+
marginRight: string;
|
|
545
|
+
fontSize: string;
|
|
546
|
+
lineHeight: number;
|
|
547
|
+
borderRadius: string;
|
|
548
|
+
transition: string;
|
|
549
|
+
opacity: number;
|
|
550
|
+
display: string;
|
|
551
|
+
alignItems: string;
|
|
552
|
+
justifyContent: string;
|
|
553
|
+
};
|
|
554
|
+
headerWithBack: {
|
|
555
|
+
display: string;
|
|
556
|
+
alignItems: string;
|
|
557
|
+
};
|
|
374
558
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a timestamp to a relative time string
|
|
3
|
+
*/
|
|
4
|
+
export declare function formatRelativeTime(isoString: string | undefined): string;
|
|
5
|
+
/**
|
|
6
|
+
* Truncate text to a maximum length with ellipsis
|
|
7
|
+
*/
|
|
8
|
+
export declare function truncateText(text: string | undefined, maxLength: number): string;
|
|
@@ -17,6 +17,10 @@ export declare class ConversationsManager implements ConversationsManagerInterfa
|
|
|
17
17
|
private _isWidgetEnabled;
|
|
18
18
|
private _isDomainAllowed;
|
|
19
19
|
private _isWidgetRendered;
|
|
20
|
+
private _initializeWidgetPromise;
|
|
21
|
+
private _currentView;
|
|
22
|
+
private _tickets;
|
|
23
|
+
private _hasMultipleTickets;
|
|
20
24
|
constructor(config: ConversationsRemoteConfig, _posthog: PostHog);
|
|
21
25
|
/**
|
|
22
26
|
* Send a message programmatically via the API
|
|
@@ -45,8 +49,10 @@ export declare class ConversationsManager implements ConversationsManagerInterfa
|
|
|
45
49
|
private _initialize;
|
|
46
50
|
/**
|
|
47
51
|
* Initialize and render the widget UI
|
|
52
|
+
* Uses a promise guard to prevent race conditions from concurrent calls
|
|
48
53
|
*/
|
|
49
54
|
private _initializeWidget;
|
|
55
|
+
private _doInitializeWidget;
|
|
50
56
|
/**
|
|
51
57
|
* Get initial user traits from PostHog or localStorage
|
|
52
58
|
*/
|
|
@@ -80,7 +86,39 @@ export declare class ConversationsManager implements ConversationsManagerInterfa
|
|
|
80
86
|
*/
|
|
81
87
|
private _pollMessages;
|
|
82
88
|
/**
|
|
83
|
-
*
|
|
89
|
+
* Poll for tickets list
|
|
90
|
+
*/
|
|
91
|
+
private _pollTickets;
|
|
92
|
+
/**
|
|
93
|
+
* Load tickets list from API
|
|
94
|
+
*/
|
|
95
|
+
private _loadTickets;
|
|
96
|
+
/**
|
|
97
|
+
* Main poll function that polls based on current view
|
|
98
|
+
*/
|
|
99
|
+
private _poll;
|
|
100
|
+
/**
|
|
101
|
+
* Handle view changes from the widget
|
|
102
|
+
*/
|
|
103
|
+
private _handleViewChange;
|
|
104
|
+
/**
|
|
105
|
+
* Handle ticket selection from the list
|
|
106
|
+
*/
|
|
107
|
+
private _handleSelectTicket;
|
|
108
|
+
/**
|
|
109
|
+
* Handle new conversation request
|
|
110
|
+
*/
|
|
111
|
+
private _handleNewConversation;
|
|
112
|
+
/**
|
|
113
|
+
* Handle back to tickets request
|
|
114
|
+
*/
|
|
115
|
+
private _handleBackToTickets;
|
|
116
|
+
/**
|
|
117
|
+
* Determine initial view based on ticket count
|
|
118
|
+
*/
|
|
119
|
+
private _determineInitialView;
|
|
120
|
+
/**
|
|
121
|
+
* Start polling based on current view
|
|
84
122
|
*/
|
|
85
123
|
private _startPolling;
|
|
86
124
|
/**
|
|
@@ -37,5 +37,6 @@ export declare function getSpotlightStyle(targetRect: DOMRect, padding?: number)
|
|
|
37
37
|
export declare function addProductTourCSSVariablesToElement(element: HTMLElement, appearance?: ProductTourAppearance): void;
|
|
38
38
|
export declare function renderTipTapContent(content: any): string;
|
|
39
39
|
export declare function normalizeUrl(url: string): string;
|
|
40
|
+
export declare function resolveStepTranslation(step: ProductTourStep, lang: string | null): ProductTourStep;
|
|
40
41
|
export declare function getStepImageUrls(step: ProductTourStep): string[];
|
|
41
42
|
export declare function getStepHtml(step: ProductTourStep): string;
|
|
@@ -14,6 +14,7 @@ export declare class ProductTourManager {
|
|
|
14
14
|
private _preloadedImageUrls;
|
|
15
15
|
constructor(instance: PostHog);
|
|
16
16
|
private _preloadTourImages;
|
|
17
|
+
private _getCurrentStep;
|
|
17
18
|
private _setStepIndex;
|
|
18
19
|
private _saveSessionState;
|
|
19
20
|
private _clearSessionState;
|
|
@@ -44,6 +45,8 @@ export declare class ProductTourManager {
|
|
|
44
45
|
private _removeTriggerSelectorListener;
|
|
45
46
|
private _removeAllTriggerListeners;
|
|
46
47
|
private _captureEvent;
|
|
48
|
+
private _captureStepShown;
|
|
49
|
+
private _captureStepSelectorFailed;
|
|
47
50
|
getActiveProductTours(callback: ProductTourCallback): void;
|
|
48
51
|
resetTour(tourId: string): void;
|
|
49
52
|
resetAllTours(): void;
|
|
@@ -48,6 +48,8 @@ export interface ProductTourSurveyQuestion {
|
|
|
48
48
|
lowerBoundLabel?: string;
|
|
49
49
|
/** Label for high end of rating scale (e.g., "Very likely") */
|
|
50
50
|
upperBoundLabel?: string;
|
|
51
|
+
submitButtonText?: string;
|
|
52
|
+
backButtonText?: string;
|
|
51
53
|
}
|
|
52
54
|
export interface ProductTourStep {
|
|
53
55
|
id: string;
|
|
@@ -75,6 +77,18 @@ export interface ProductTourStep {
|
|
|
75
77
|
buttons?: ProductTourStepButtons;
|
|
76
78
|
/** Banner configuration (only for banner steps) */
|
|
77
79
|
bannerConfig?: ProductTourBannerConfig;
|
|
80
|
+
/** translation data for this tour step */
|
|
81
|
+
translations?: Record<string, ProductTourStepTranslation>;
|
|
82
|
+
}
|
|
83
|
+
/** all translatable content for a given tour step */
|
|
84
|
+
export interface ProductTourStepTranslation {
|
|
85
|
+
content?: ProductTourStep['content'];
|
|
86
|
+
contentHtml?: ProductTourStep['contentHtml'];
|
|
87
|
+
buttons?: {
|
|
88
|
+
primary?: Pick<ProductTourStepButton, 'text'>;
|
|
89
|
+
secondary?: Pick<ProductTourStepButton, 'text'>;
|
|
90
|
+
};
|
|
91
|
+
survey?: Pick<ProductTourSurveyQuestion, 'questionText' | 'lowerBoundLabel' | 'upperBoundLabel' | 'submitButtonText' | 'backButtonText'>;
|
|
78
92
|
}
|
|
79
93
|
export interface ProductTourConditions {
|
|
80
94
|
url?: string;
|
|
@@ -137,3 +151,43 @@ export interface ShowTourOptions {
|
|
|
137
151
|
reason?: ProductTourRenderReason;
|
|
138
152
|
enableStrictValidation?: boolean;
|
|
139
153
|
}
|
|
154
|
+
export declare enum ProductTourEventName {
|
|
155
|
+
SHOWN = "product tour shown",
|
|
156
|
+
DISMISSED = "product tour dismissed",
|
|
157
|
+
COMPLETED = "product tour completed",
|
|
158
|
+
STEP_SHOWN = "product tour step shown",
|
|
159
|
+
STEP_COMPLETED = "product tour step completed",
|
|
160
|
+
BUTTON_CLICKED = "product tour button clicked",
|
|
161
|
+
STEP_SELECTOR_FAILED = "product tour step selector failed",
|
|
162
|
+
BANNER_CONTAINER_SELECTOR_FAILED = "product tour banner container selector failed"
|
|
163
|
+
}
|
|
164
|
+
export declare enum ProductTourEventProperties {
|
|
165
|
+
TOUR_ID = "$product_tour_id",
|
|
166
|
+
TOUR_NAME = "$product_tour_name",
|
|
167
|
+
TOUR_ITERATION = "$product_tour_iteration",
|
|
168
|
+
TOUR_RENDER_REASON = "$product_tour_render_reason",
|
|
169
|
+
TOUR_STEP_ID = "$product_tour_step_id",
|
|
170
|
+
TOUR_STEP_ORDER = "$product_tour_step_order",
|
|
171
|
+
TOUR_STEP_TYPE = "$product_tour_step_type",
|
|
172
|
+
TOUR_DISMISS_REASON = "$product_tour_dismiss_reason",
|
|
173
|
+
TOUR_BUTTON_TEXT = "$product_tour_button_text",
|
|
174
|
+
TOUR_BUTTON_ACTION = "$product_tour_button_action",
|
|
175
|
+
TOUR_BUTTON_LINK = "$product_tour_button_link",
|
|
176
|
+
TOUR_BUTTON_TOUR_ID = "$product_tour_button_tour_id",
|
|
177
|
+
TOUR_STEPS_COUNT = "$product_tour_steps_count",
|
|
178
|
+
TOUR_STEP_SELECTOR = "$product_tour_step_selector",
|
|
179
|
+
TOUR_STEP_SELECTOR_FOUND = "$product_tour_step_selector_found",
|
|
180
|
+
TOUR_STEP_ELEMENT_TAG = "$product_tour_step_element_tag",
|
|
181
|
+
TOUR_STEP_ELEMENT_ID = "$product_tour_step_element_id",
|
|
182
|
+
TOUR_STEP_ELEMENT_CLASSES = "$product_tour_step_element_classes",
|
|
183
|
+
TOUR_STEP_ELEMENT_TEXT = "$product_tour_step_element_text",
|
|
184
|
+
TOUR_ERROR = "$product_tour_error",
|
|
185
|
+
TOUR_MATCHES_COUNT = "$product_tour_matches_count",
|
|
186
|
+
TOUR_FAILURE_PHASE = "$product_tour_failure_phase",
|
|
187
|
+
TOUR_WAITED_FOR_ELEMENT = "$product_tour_waited_for_element",
|
|
188
|
+
TOUR_WAIT_DURATION_MS = "$product_tour_wait_duration_ms",
|
|
189
|
+
TOUR_BANNER_SELECTOR = "$product_tour_banner_selector",
|
|
190
|
+
TOUR_LINKED_SURVEY_ID = "$product_tour_linked_survey_id",
|
|
191
|
+
USE_MANUAL_SELECTOR = "$use_manual_selector",
|
|
192
|
+
INFERENCE_DATA_PRESENT = "$inference_data_present"
|
|
193
|
+
}
|
|
@@ -1733,6 +1733,8 @@ interface ProductTourSurveyQuestion {
|
|
|
1733
1733
|
lowerBoundLabel?: string;
|
|
1734
1734
|
/** Label for high end of rating scale (e.g., "Very likely") */
|
|
1735
1735
|
upperBoundLabel?: string;
|
|
1736
|
+
submitButtonText?: string;
|
|
1737
|
+
backButtonText?: string;
|
|
1736
1738
|
}
|
|
1737
1739
|
interface ProductTourStep {
|
|
1738
1740
|
id: string;
|
|
@@ -1760,6 +1762,18 @@ interface ProductTourStep {
|
|
|
1760
1762
|
buttons?: ProductTourStepButtons;
|
|
1761
1763
|
/** Banner configuration (only for banner steps) */
|
|
1762
1764
|
bannerConfig?: ProductTourBannerConfig;
|
|
1765
|
+
/** translation data for this tour step */
|
|
1766
|
+
translations?: Record<string, ProductTourStepTranslation>;
|
|
1767
|
+
}
|
|
1768
|
+
/** all translatable content for a given tour step */
|
|
1769
|
+
interface ProductTourStepTranslation {
|
|
1770
|
+
content?: ProductTourStep['content'];
|
|
1771
|
+
contentHtml?: ProductTourStep['contentHtml'];
|
|
1772
|
+
buttons?: {
|
|
1773
|
+
primary?: Pick<ProductTourStepButton, 'text'>;
|
|
1774
|
+
secondary?: Pick<ProductTourStepButton, 'text'>;
|
|
1775
|
+
};
|
|
1776
|
+
survey?: Pick<ProductTourSurveyQuestion, 'questionText' | 'lowerBoundLabel' | 'upperBoundLabel' | 'submitButtonText' | 'backButtonText'>;
|
|
1763
1777
|
}
|
|
1764
1778
|
interface ProductTourConditions {
|
|
1765
1779
|
url?: string;
|
package/lib/package.json
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { h, Component } from 'preact';
|
|
2
|
-
import { ConversationsRemoteConfig, Message, ConversationsWidgetState, UserProvidedTraits } from '../../../../posthog-conversations-types';
|
|
2
|
+
import { ConversationsRemoteConfig, Message, ConversationsWidgetState, UserProvidedTraits, Ticket } from '../../../../posthog-conversations-types';
|
|
3
|
+
/**
|
|
4
|
+
* Type for the current view in the widget
|
|
5
|
+
*/
|
|
6
|
+
export type WidgetView = 'tickets' | 'messages';
|
|
3
7
|
interface WidgetProps {
|
|
4
8
|
config: ConversationsRemoteConfig;
|
|
5
9
|
initialState?: ConversationsWidgetState;
|
|
6
10
|
initialUserTraits?: UserProvidedTraits | null;
|
|
7
11
|
isUserIdentified?: boolean;
|
|
12
|
+
initialView?: WidgetView;
|
|
13
|
+
initialTickets?: Ticket[];
|
|
14
|
+
hasMultipleTickets?: boolean;
|
|
8
15
|
onSendMessage: (message: string) => Promise<void>;
|
|
9
16
|
onStateChange?: (state: ConversationsWidgetState) => void;
|
|
10
17
|
onIdentify?: (traits: UserProvidedTraits) => void;
|
|
18
|
+
onSelectTicket?: (ticketId: string) => void;
|
|
19
|
+
onNewConversation?: () => void;
|
|
20
|
+
onBackToTickets?: () => void;
|
|
21
|
+
onViewChange?: (view: WidgetView) => void;
|
|
11
22
|
}
|
|
12
23
|
interface WidgetState {
|
|
13
24
|
state: ConversationsWidgetState;
|
|
25
|
+
view: WidgetView;
|
|
14
26
|
messages: Message[];
|
|
27
|
+
tickets: Ticket[];
|
|
28
|
+
ticketsLoading: boolean;
|
|
15
29
|
inputValue: string;
|
|
16
30
|
isLoading: boolean;
|
|
17
31
|
error: string | null;
|
|
@@ -21,6 +35,7 @@ interface WidgetState {
|
|
|
21
35
|
formEmailError: string | null;
|
|
22
36
|
userTraits: UserProvidedTraits | null;
|
|
23
37
|
unreadCount: number;
|
|
38
|
+
hasMultipleTickets: boolean;
|
|
24
39
|
}
|
|
25
40
|
export declare class ConversationsWidget extends Component<WidgetProps, WidgetState> {
|
|
26
41
|
private _messagesEndRef;
|
|
@@ -37,6 +52,9 @@ export declare class ConversationsWidget extends Component<WidgetProps, WidgetSt
|
|
|
37
52
|
private _focusInput;
|
|
38
53
|
private _handleToggleOpen;
|
|
39
54
|
private _handleClose;
|
|
55
|
+
private _handleSelectTicket;
|
|
56
|
+
private _handleNewConversation;
|
|
57
|
+
private _handleBackToTickets;
|
|
40
58
|
private _handleInputChange;
|
|
41
59
|
private _handleKeyPress;
|
|
42
60
|
private _handleFormNameChange;
|
|
@@ -44,7 +62,6 @@ export declare class ConversationsWidget extends Component<WidgetProps, WidgetSt
|
|
|
44
62
|
private _validateEmail;
|
|
45
63
|
private _handleFormSubmit;
|
|
46
64
|
private _handleSendMessage;
|
|
47
|
-
private _formatTime;
|
|
48
65
|
/**
|
|
49
66
|
* Public method to add messages from outside
|
|
50
67
|
*/
|
|
@@ -74,8 +91,32 @@ export declare class ConversationsWidget extends Component<WidgetProps, WidgetSt
|
|
|
74
91
|
* Set the unread message count (called by manager)
|
|
75
92
|
*/
|
|
76
93
|
setUnreadCount(count: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Update the tickets list (called by manager during polling)
|
|
96
|
+
*/
|
|
97
|
+
updateTickets(tickets: Ticket[]): void;
|
|
98
|
+
/**
|
|
99
|
+
* Set the current view (tickets list or messages)
|
|
100
|
+
*/
|
|
101
|
+
setView(view: WidgetView): void;
|
|
102
|
+
/**
|
|
103
|
+
* Get the current view
|
|
104
|
+
*/
|
|
105
|
+
getView(): WidgetView;
|
|
106
|
+
/**
|
|
107
|
+
* Set tickets loading state
|
|
108
|
+
*/
|
|
109
|
+
setTicketsLoading(loading: boolean): void;
|
|
110
|
+
/**
|
|
111
|
+
* Clear messages (used when switching tickets or starting new conversation)
|
|
112
|
+
* @param addGreeting - If true, adds the greeting message after clearing
|
|
113
|
+
*/
|
|
114
|
+
clearMessages(addGreeting?: boolean): void;
|
|
77
115
|
private _renderIdentificationForm;
|
|
78
116
|
private _renderMessage;
|
|
117
|
+
private _renderBackButton;
|
|
118
|
+
private _renderTicketList;
|
|
119
|
+
private _renderMessages;
|
|
79
120
|
render(): h.JSX.Element;
|
|
80
121
|
}
|
|
81
122
|
export {};
|