@census-ai/census-sdk 0.1.0 → 0.2.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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +215 -1
- package/dist/index.d.ts +215 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +272 -2
- package/dist/react/index.d.ts +272 -2
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -188,6 +188,21 @@ interface Request {
|
|
|
188
188
|
rating: number | null;
|
|
189
189
|
helpful: boolean | null;
|
|
190
190
|
metadata: Record<string, unknown>;
|
|
191
|
+
vote_count: number;
|
|
192
|
+
user_has_voted: boolean;
|
|
193
|
+
is_own: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Feedback visibility setting
|
|
197
|
+
*/
|
|
198
|
+
type FeedbackVisibility = 'own' | 'organization' | 'all';
|
|
199
|
+
/**
|
|
200
|
+
* Project settings for requests
|
|
201
|
+
*/
|
|
202
|
+
interface RequestsSettings {
|
|
203
|
+
feedbackVisibility: FeedbackVisibility;
|
|
204
|
+
allowVoting: boolean;
|
|
205
|
+
allowRequestCreation: boolean;
|
|
191
206
|
}
|
|
192
207
|
/**
|
|
193
208
|
* Options for fetching requests
|
|
@@ -223,6 +238,7 @@ interface RequestsResponse {
|
|
|
223
238
|
offset: number;
|
|
224
239
|
hasMore: boolean;
|
|
225
240
|
};
|
|
241
|
+
settings: RequestsSettings;
|
|
226
242
|
}
|
|
227
243
|
/**
|
|
228
244
|
* Position for floating UI elements
|
|
@@ -389,6 +405,99 @@ interface CensusProviderProps {
|
|
|
389
405
|
*/
|
|
390
406
|
children: React.ReactNode;
|
|
391
407
|
}
|
|
408
|
+
interface GuideStep {
|
|
409
|
+
id: string;
|
|
410
|
+
sort_order: number;
|
|
411
|
+
selector_strategy: SelectorStrategy;
|
|
412
|
+
title: string | null;
|
|
413
|
+
content: string | null;
|
|
414
|
+
tooltip_position: TooltipPosition;
|
|
415
|
+
actions: GuideAction[];
|
|
416
|
+
wait_for: WaitForType;
|
|
417
|
+
wait_config: Record<string, unknown>;
|
|
418
|
+
}
|
|
419
|
+
interface SelectorStrategy {
|
|
420
|
+
css?: string;
|
|
421
|
+
xpath?: string;
|
|
422
|
+
text?: string;
|
|
423
|
+
testId?: string;
|
|
424
|
+
}
|
|
425
|
+
type TooltipPosition = 'auto' | 'top' | 'bottom' | 'left' | 'right';
|
|
426
|
+
type WaitForType = 'click' | 'next_button' | 'delay' | 'custom';
|
|
427
|
+
interface GuideAction {
|
|
428
|
+
type: 'click' | 'input' | 'navigate' | 'custom';
|
|
429
|
+
config: Record<string, unknown>;
|
|
430
|
+
}
|
|
431
|
+
interface Guide {
|
|
432
|
+
id: string;
|
|
433
|
+
name: string;
|
|
434
|
+
slug: string;
|
|
435
|
+
description: string | null;
|
|
436
|
+
trigger_type: GuideTriggerType;
|
|
437
|
+
trigger_config: TriggerConfig;
|
|
438
|
+
theme: GuideTheme;
|
|
439
|
+
allow_skip: boolean;
|
|
440
|
+
show_progress: boolean;
|
|
441
|
+
guide_steps: GuideStep[];
|
|
442
|
+
}
|
|
443
|
+
type GuideTriggerType = 'manual' | 'url_match' | 'first_visit' | 'event';
|
|
444
|
+
interface TriggerConfig {
|
|
445
|
+
url_pattern?: string;
|
|
446
|
+
event_name?: string;
|
|
447
|
+
delay_ms?: number;
|
|
448
|
+
}
|
|
449
|
+
interface GuideTheme {
|
|
450
|
+
primaryColor?: string;
|
|
451
|
+
backgroundColor?: string;
|
|
452
|
+
textColor?: string;
|
|
453
|
+
borderRadius?: string;
|
|
454
|
+
fontFamily?: string;
|
|
455
|
+
}
|
|
456
|
+
interface GuidesResponse {
|
|
457
|
+
guides: Guide[];
|
|
458
|
+
completedGuides: string[];
|
|
459
|
+
}
|
|
460
|
+
type GuideEventType = 'started' | 'step_viewed' | 'step_completed' | 'completed' | 'skipped' | 'dismissed';
|
|
461
|
+
/**
|
|
462
|
+
* A feature within a feature group
|
|
463
|
+
*/
|
|
464
|
+
interface Feature {
|
|
465
|
+
id: string;
|
|
466
|
+
name: string;
|
|
467
|
+
slug: string;
|
|
468
|
+
description: string | null;
|
|
469
|
+
status: string;
|
|
470
|
+
article_count: number;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* A group of related features
|
|
474
|
+
*/
|
|
475
|
+
interface FeatureGroup {
|
|
476
|
+
id: string;
|
|
477
|
+
name: string;
|
|
478
|
+
slug: string;
|
|
479
|
+
description: string | null;
|
|
480
|
+
color: string | null;
|
|
481
|
+
features: Feature[];
|
|
482
|
+
feature_count: number;
|
|
483
|
+
article_count: number;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Response from feature groups endpoint
|
|
487
|
+
*/
|
|
488
|
+
interface FeatureGroupsResponse {
|
|
489
|
+
feature_groups: FeatureGroup[];
|
|
490
|
+
}
|
|
491
|
+
interface GuideAnalyticsEvent {
|
|
492
|
+
guideId: string;
|
|
493
|
+
eventType: GuideEventType;
|
|
494
|
+
stepId?: string;
|
|
495
|
+
stepIndex?: number;
|
|
496
|
+
pageUrl?: string;
|
|
497
|
+
sessionId: string;
|
|
498
|
+
userId?: string;
|
|
499
|
+
metadata?: Record<string, unknown>;
|
|
500
|
+
}
|
|
392
501
|
|
|
393
502
|
/**
|
|
394
503
|
* Census SDK Client
|
|
@@ -500,6 +609,21 @@ declare class CensusClient {
|
|
|
500
609
|
* ```
|
|
501
610
|
*/
|
|
502
611
|
getArticle(slugOrId: string): Promise<Article | null>;
|
|
612
|
+
/**
|
|
613
|
+
* Fetch feature groups with their features and article counts.
|
|
614
|
+
* Used for navigation in the knowledge base.
|
|
615
|
+
*
|
|
616
|
+
* @returns Feature groups with nested features
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* ```typescript
|
|
620
|
+
* const { feature_groups } = await census.getFeatureGroups();
|
|
621
|
+
* feature_groups.forEach(group => {
|
|
622
|
+
* console.log(group.name, group.features.length);
|
|
623
|
+
* });
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
getFeatureGroups(): Promise<FeatureGroupsResponse>;
|
|
503
627
|
/**
|
|
504
628
|
* Fetch the current user's submitted requests (feedback, bugs, feature requests).
|
|
505
629
|
* Requires a user to be identified first.
|
|
@@ -520,6 +644,29 @@ declare class CensusClient {
|
|
|
520
644
|
* ```
|
|
521
645
|
*/
|
|
522
646
|
getRequests(options?: RequestsOptions): Promise<RequestsResponse>;
|
|
647
|
+
/**
|
|
648
|
+
* Vote on a feedback request (toggle).
|
|
649
|
+
* If the user has already voted, removes the vote.
|
|
650
|
+
* If the user hasn't voted, adds a vote.
|
|
651
|
+
*
|
|
652
|
+
* @param feedbackId - ID of the feedback to vote on
|
|
653
|
+
* @returns Vote result with action taken and new vote count
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* ```typescript
|
|
657
|
+
* // Vote on a feedback request
|
|
658
|
+
* const result = await census.vote('feedback-id-123');
|
|
659
|
+
* console.log(result.action); // 'added' or 'removed'
|
|
660
|
+
* console.log(result.vote_count); // 5
|
|
661
|
+
* console.log(result.user_has_voted); // true
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
vote(feedbackId: string): Promise<{
|
|
665
|
+
success: boolean;
|
|
666
|
+
action: 'added' | 'removed';
|
|
667
|
+
vote_count: number;
|
|
668
|
+
user_has_voted: boolean;
|
|
669
|
+
}>;
|
|
523
670
|
/**
|
|
524
671
|
* Track a custom analytics event.
|
|
525
672
|
*
|
|
@@ -553,6 +700,64 @@ declare class CensusClient {
|
|
|
553
700
|
* ```
|
|
554
701
|
*/
|
|
555
702
|
trackBatch(options: BatchEventsOptions): Promise<void>;
|
|
703
|
+
/**
|
|
704
|
+
* Fetch available guides for the current user.
|
|
705
|
+
* Returns guides that match the user's context and haven't been completed.
|
|
706
|
+
*
|
|
707
|
+
* @returns Guides and list of completed guide IDs
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* const { guides, completedGuides } = await census.getGuides();
|
|
712
|
+
* guides.forEach(guide => console.log(guide.name));
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
715
|
+
getGuides(): Promise<GuidesResponse>;
|
|
716
|
+
/**
|
|
717
|
+
* Fetch a single guide by slug or ID.
|
|
718
|
+
*
|
|
719
|
+
* @param slugOrId - Guide slug or ID
|
|
720
|
+
* @returns Guide or null if not found
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const guide = await census.getGuide('onboarding-tour');
|
|
725
|
+
* if (guide) {
|
|
726
|
+
* console.log(guide.name, guide.guide_steps.length);
|
|
727
|
+
* }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
getGuide(slugOrId: string): Promise<Guide | null>;
|
|
731
|
+
/**
|
|
732
|
+
* Track a guide analytics event.
|
|
733
|
+
* Used to track user progress through guides.
|
|
734
|
+
*
|
|
735
|
+
* @param event - Guide analytics event
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* await census.trackGuideEvent({
|
|
740
|
+
* guideId: 'guide_123',
|
|
741
|
+
* eventType: 'step_completed',
|
|
742
|
+
* stepId: 'step_456',
|
|
743
|
+
* stepIndex: 2,
|
|
744
|
+
* sessionId: 'session_789',
|
|
745
|
+
* });
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
trackGuideEvent(event: GuideAnalyticsEvent): Promise<void>;
|
|
749
|
+
/**
|
|
750
|
+
* Mark a guide as completed for the current user.
|
|
751
|
+
* Prevents the guide from showing again.
|
|
752
|
+
*
|
|
753
|
+
* @param guideId - ID of the guide to mark as completed
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
* ```typescript
|
|
757
|
+
* await census.markGuideCompleted('guide_123');
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
markGuideCompleted(guideId: string): Promise<void>;
|
|
556
761
|
/**
|
|
557
762
|
* Get the current identified user ID
|
|
558
763
|
*/
|
|
@@ -768,7 +973,7 @@ declare function useArticle(slugOrId: string): {
|
|
|
768
973
|
* @example
|
|
769
974
|
* ```tsx
|
|
770
975
|
* function MyRequests() {
|
|
771
|
-
* const { requests, isLoading, error, refetch } = useRequests();
|
|
976
|
+
* const { requests, isLoading, error, refetch, settings } = useRequests();
|
|
772
977
|
*
|
|
773
978
|
* if (isLoading) return <p>Loading...</p>;
|
|
774
979
|
* if (error) return <p>Error: {error.message}</p>;
|
|
@@ -791,10 +996,44 @@ declare function useRequests(options?: RequestsOptions): {
|
|
|
791
996
|
offset: number;
|
|
792
997
|
hasMore: boolean;
|
|
793
998
|
} | undefined;
|
|
999
|
+
settings: RequestsSettings;
|
|
794
1000
|
isLoading: boolean;
|
|
795
1001
|
error: Error | null;
|
|
796
1002
|
refetch: () => Promise<void>;
|
|
797
1003
|
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Hook for voting on requests.
|
|
1006
|
+
*
|
|
1007
|
+
* @returns Object with vote function and loading state
|
|
1008
|
+
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```tsx
|
|
1011
|
+
* function VoteButton({ feedbackId }: { feedbackId: string }) {
|
|
1012
|
+
* const { vote, isVoting } = useVote();
|
|
1013
|
+
*
|
|
1014
|
+
* const handleVote = async () => {
|
|
1015
|
+
* const result = await vote(feedbackId);
|
|
1016
|
+
* console.log('Voted:', result.action); // 'added' or 'removed'
|
|
1017
|
+
* };
|
|
1018
|
+
*
|
|
1019
|
+
* return (
|
|
1020
|
+
* <button onClick={handleVote} disabled={isVoting}>
|
|
1021
|
+
* Vote
|
|
1022
|
+
* </button>
|
|
1023
|
+
* );
|
|
1024
|
+
* }
|
|
1025
|
+
* ```
|
|
1026
|
+
*/
|
|
1027
|
+
declare function useVote(): {
|
|
1028
|
+
vote: (feedbackId: string) => Promise<{
|
|
1029
|
+
success: boolean;
|
|
1030
|
+
action: "added" | "removed";
|
|
1031
|
+
vote_count: number;
|
|
1032
|
+
user_has_voted: boolean;
|
|
1033
|
+
}>;
|
|
1034
|
+
isVoting: boolean;
|
|
1035
|
+
error: Error | null;
|
|
1036
|
+
};
|
|
798
1037
|
/**
|
|
799
1038
|
* Hook for tracking events.
|
|
800
1039
|
*
|
|
@@ -822,6 +1061,37 @@ declare function useTrack(): {
|
|
|
822
1061
|
properties?: Record<string, unknown>;
|
|
823
1062
|
}>) => Promise<void>;
|
|
824
1063
|
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Hook for fetching feature groups with their features.
|
|
1066
|
+
*
|
|
1067
|
+
* @returns Object with feature groups data and loading state
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* ```tsx
|
|
1071
|
+
* function FeatureNav() {
|
|
1072
|
+
* const { featureGroups, isLoading, error } = useFeatureGroups();
|
|
1073
|
+
*
|
|
1074
|
+
* if (isLoading) return <p>Loading...</p>;
|
|
1075
|
+
* if (error) return <p>Error: {error.message}</p>;
|
|
1076
|
+
*
|
|
1077
|
+
* return (
|
|
1078
|
+
* <ul>
|
|
1079
|
+
* {featureGroups.map(group => (
|
|
1080
|
+
* <li key={group.id}>
|
|
1081
|
+
* {group.name} ({group.feature_count} features)
|
|
1082
|
+
* </li>
|
|
1083
|
+
* ))}
|
|
1084
|
+
* </ul>
|
|
1085
|
+
* );
|
|
1086
|
+
* }
|
|
1087
|
+
* ```
|
|
1088
|
+
*/
|
|
1089
|
+
declare function useFeatureGroups(): {
|
|
1090
|
+
featureGroups: FeatureGroup[];
|
|
1091
|
+
isLoading: boolean;
|
|
1092
|
+
error: Error | null;
|
|
1093
|
+
refetch: () => Promise<void>;
|
|
1094
|
+
};
|
|
825
1095
|
|
|
826
1096
|
/**
|
|
827
1097
|
* Floating feedback button component.
|
|
@@ -889,4 +1159,4 @@ declare function KnowledgeBase({ showSearch, showCategories, defaultCategory, th
|
|
|
889
1159
|
*/
|
|
890
1160
|
declare function Requests({ status, type, limit, className, showEmptyState, onRequestClick, }: RequestsProps): react_jsx_runtime.JSX.Element | null;
|
|
891
1161
|
|
|
892
|
-
export { type Article, type ArticlesOptions, CensusProvider, type CensusProviderProps, type CensusTheme, FeedbackButton, type FeedbackButtonProps, type FeedbackOptions, type FeedbackType, KnowledgeBase, type KnowledgeBaseProps, type Position, type Request, Requests, type RequestsOptions, type RequestsProps, type UserIdentity, useArticle, useArticles, useCensus, useCensusContext, useFeedback, useIdentify, useRequests, useTrack };
|
|
1162
|
+
export { type Article, type ArticlesOptions, CensusProvider, type CensusProviderProps, type CensusTheme, type Feature, type FeatureGroup, FeedbackButton, type FeedbackButtonProps, type FeedbackOptions, type FeedbackType, type FeedbackVisibility, KnowledgeBase, type KnowledgeBaseProps, type Position, type Request, Requests, type RequestsOptions, type RequestsProps, type RequestsSettings, type UserIdentity, useArticle, useArticles, useCensus, useCensusContext, useFeatureGroups, useFeedback, useIdentify, useRequests, useTrack, useVote };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -188,6 +188,21 @@ interface Request {
|
|
|
188
188
|
rating: number | null;
|
|
189
189
|
helpful: boolean | null;
|
|
190
190
|
metadata: Record<string, unknown>;
|
|
191
|
+
vote_count: number;
|
|
192
|
+
user_has_voted: boolean;
|
|
193
|
+
is_own: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Feedback visibility setting
|
|
197
|
+
*/
|
|
198
|
+
type FeedbackVisibility = 'own' | 'organization' | 'all';
|
|
199
|
+
/**
|
|
200
|
+
* Project settings for requests
|
|
201
|
+
*/
|
|
202
|
+
interface RequestsSettings {
|
|
203
|
+
feedbackVisibility: FeedbackVisibility;
|
|
204
|
+
allowVoting: boolean;
|
|
205
|
+
allowRequestCreation: boolean;
|
|
191
206
|
}
|
|
192
207
|
/**
|
|
193
208
|
* Options for fetching requests
|
|
@@ -223,6 +238,7 @@ interface RequestsResponse {
|
|
|
223
238
|
offset: number;
|
|
224
239
|
hasMore: boolean;
|
|
225
240
|
};
|
|
241
|
+
settings: RequestsSettings;
|
|
226
242
|
}
|
|
227
243
|
/**
|
|
228
244
|
* Position for floating UI elements
|
|
@@ -389,6 +405,99 @@ interface CensusProviderProps {
|
|
|
389
405
|
*/
|
|
390
406
|
children: React.ReactNode;
|
|
391
407
|
}
|
|
408
|
+
interface GuideStep {
|
|
409
|
+
id: string;
|
|
410
|
+
sort_order: number;
|
|
411
|
+
selector_strategy: SelectorStrategy;
|
|
412
|
+
title: string | null;
|
|
413
|
+
content: string | null;
|
|
414
|
+
tooltip_position: TooltipPosition;
|
|
415
|
+
actions: GuideAction[];
|
|
416
|
+
wait_for: WaitForType;
|
|
417
|
+
wait_config: Record<string, unknown>;
|
|
418
|
+
}
|
|
419
|
+
interface SelectorStrategy {
|
|
420
|
+
css?: string;
|
|
421
|
+
xpath?: string;
|
|
422
|
+
text?: string;
|
|
423
|
+
testId?: string;
|
|
424
|
+
}
|
|
425
|
+
type TooltipPosition = 'auto' | 'top' | 'bottom' | 'left' | 'right';
|
|
426
|
+
type WaitForType = 'click' | 'next_button' | 'delay' | 'custom';
|
|
427
|
+
interface GuideAction {
|
|
428
|
+
type: 'click' | 'input' | 'navigate' | 'custom';
|
|
429
|
+
config: Record<string, unknown>;
|
|
430
|
+
}
|
|
431
|
+
interface Guide {
|
|
432
|
+
id: string;
|
|
433
|
+
name: string;
|
|
434
|
+
slug: string;
|
|
435
|
+
description: string | null;
|
|
436
|
+
trigger_type: GuideTriggerType;
|
|
437
|
+
trigger_config: TriggerConfig;
|
|
438
|
+
theme: GuideTheme;
|
|
439
|
+
allow_skip: boolean;
|
|
440
|
+
show_progress: boolean;
|
|
441
|
+
guide_steps: GuideStep[];
|
|
442
|
+
}
|
|
443
|
+
type GuideTriggerType = 'manual' | 'url_match' | 'first_visit' | 'event';
|
|
444
|
+
interface TriggerConfig {
|
|
445
|
+
url_pattern?: string;
|
|
446
|
+
event_name?: string;
|
|
447
|
+
delay_ms?: number;
|
|
448
|
+
}
|
|
449
|
+
interface GuideTheme {
|
|
450
|
+
primaryColor?: string;
|
|
451
|
+
backgroundColor?: string;
|
|
452
|
+
textColor?: string;
|
|
453
|
+
borderRadius?: string;
|
|
454
|
+
fontFamily?: string;
|
|
455
|
+
}
|
|
456
|
+
interface GuidesResponse {
|
|
457
|
+
guides: Guide[];
|
|
458
|
+
completedGuides: string[];
|
|
459
|
+
}
|
|
460
|
+
type GuideEventType = 'started' | 'step_viewed' | 'step_completed' | 'completed' | 'skipped' | 'dismissed';
|
|
461
|
+
/**
|
|
462
|
+
* A feature within a feature group
|
|
463
|
+
*/
|
|
464
|
+
interface Feature {
|
|
465
|
+
id: string;
|
|
466
|
+
name: string;
|
|
467
|
+
slug: string;
|
|
468
|
+
description: string | null;
|
|
469
|
+
status: string;
|
|
470
|
+
article_count: number;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* A group of related features
|
|
474
|
+
*/
|
|
475
|
+
interface FeatureGroup {
|
|
476
|
+
id: string;
|
|
477
|
+
name: string;
|
|
478
|
+
slug: string;
|
|
479
|
+
description: string | null;
|
|
480
|
+
color: string | null;
|
|
481
|
+
features: Feature[];
|
|
482
|
+
feature_count: number;
|
|
483
|
+
article_count: number;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Response from feature groups endpoint
|
|
487
|
+
*/
|
|
488
|
+
interface FeatureGroupsResponse {
|
|
489
|
+
feature_groups: FeatureGroup[];
|
|
490
|
+
}
|
|
491
|
+
interface GuideAnalyticsEvent {
|
|
492
|
+
guideId: string;
|
|
493
|
+
eventType: GuideEventType;
|
|
494
|
+
stepId?: string;
|
|
495
|
+
stepIndex?: number;
|
|
496
|
+
pageUrl?: string;
|
|
497
|
+
sessionId: string;
|
|
498
|
+
userId?: string;
|
|
499
|
+
metadata?: Record<string, unknown>;
|
|
500
|
+
}
|
|
392
501
|
|
|
393
502
|
/**
|
|
394
503
|
* Census SDK Client
|
|
@@ -500,6 +609,21 @@ declare class CensusClient {
|
|
|
500
609
|
* ```
|
|
501
610
|
*/
|
|
502
611
|
getArticle(slugOrId: string): Promise<Article | null>;
|
|
612
|
+
/**
|
|
613
|
+
* Fetch feature groups with their features and article counts.
|
|
614
|
+
* Used for navigation in the knowledge base.
|
|
615
|
+
*
|
|
616
|
+
* @returns Feature groups with nested features
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* ```typescript
|
|
620
|
+
* const { feature_groups } = await census.getFeatureGroups();
|
|
621
|
+
* feature_groups.forEach(group => {
|
|
622
|
+
* console.log(group.name, group.features.length);
|
|
623
|
+
* });
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
getFeatureGroups(): Promise<FeatureGroupsResponse>;
|
|
503
627
|
/**
|
|
504
628
|
* Fetch the current user's submitted requests (feedback, bugs, feature requests).
|
|
505
629
|
* Requires a user to be identified first.
|
|
@@ -520,6 +644,29 @@ declare class CensusClient {
|
|
|
520
644
|
* ```
|
|
521
645
|
*/
|
|
522
646
|
getRequests(options?: RequestsOptions): Promise<RequestsResponse>;
|
|
647
|
+
/**
|
|
648
|
+
* Vote on a feedback request (toggle).
|
|
649
|
+
* If the user has already voted, removes the vote.
|
|
650
|
+
* If the user hasn't voted, adds a vote.
|
|
651
|
+
*
|
|
652
|
+
* @param feedbackId - ID of the feedback to vote on
|
|
653
|
+
* @returns Vote result with action taken and new vote count
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* ```typescript
|
|
657
|
+
* // Vote on a feedback request
|
|
658
|
+
* const result = await census.vote('feedback-id-123');
|
|
659
|
+
* console.log(result.action); // 'added' or 'removed'
|
|
660
|
+
* console.log(result.vote_count); // 5
|
|
661
|
+
* console.log(result.user_has_voted); // true
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
vote(feedbackId: string): Promise<{
|
|
665
|
+
success: boolean;
|
|
666
|
+
action: 'added' | 'removed';
|
|
667
|
+
vote_count: number;
|
|
668
|
+
user_has_voted: boolean;
|
|
669
|
+
}>;
|
|
523
670
|
/**
|
|
524
671
|
* Track a custom analytics event.
|
|
525
672
|
*
|
|
@@ -553,6 +700,64 @@ declare class CensusClient {
|
|
|
553
700
|
* ```
|
|
554
701
|
*/
|
|
555
702
|
trackBatch(options: BatchEventsOptions): Promise<void>;
|
|
703
|
+
/**
|
|
704
|
+
* Fetch available guides for the current user.
|
|
705
|
+
* Returns guides that match the user's context and haven't been completed.
|
|
706
|
+
*
|
|
707
|
+
* @returns Guides and list of completed guide IDs
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* const { guides, completedGuides } = await census.getGuides();
|
|
712
|
+
* guides.forEach(guide => console.log(guide.name));
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
715
|
+
getGuides(): Promise<GuidesResponse>;
|
|
716
|
+
/**
|
|
717
|
+
* Fetch a single guide by slug or ID.
|
|
718
|
+
*
|
|
719
|
+
* @param slugOrId - Guide slug or ID
|
|
720
|
+
* @returns Guide or null if not found
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const guide = await census.getGuide('onboarding-tour');
|
|
725
|
+
* if (guide) {
|
|
726
|
+
* console.log(guide.name, guide.guide_steps.length);
|
|
727
|
+
* }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
getGuide(slugOrId: string): Promise<Guide | null>;
|
|
731
|
+
/**
|
|
732
|
+
* Track a guide analytics event.
|
|
733
|
+
* Used to track user progress through guides.
|
|
734
|
+
*
|
|
735
|
+
* @param event - Guide analytics event
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* await census.trackGuideEvent({
|
|
740
|
+
* guideId: 'guide_123',
|
|
741
|
+
* eventType: 'step_completed',
|
|
742
|
+
* stepId: 'step_456',
|
|
743
|
+
* stepIndex: 2,
|
|
744
|
+
* sessionId: 'session_789',
|
|
745
|
+
* });
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
trackGuideEvent(event: GuideAnalyticsEvent): Promise<void>;
|
|
749
|
+
/**
|
|
750
|
+
* Mark a guide as completed for the current user.
|
|
751
|
+
* Prevents the guide from showing again.
|
|
752
|
+
*
|
|
753
|
+
* @param guideId - ID of the guide to mark as completed
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
* ```typescript
|
|
757
|
+
* await census.markGuideCompleted('guide_123');
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
markGuideCompleted(guideId: string): Promise<void>;
|
|
556
761
|
/**
|
|
557
762
|
* Get the current identified user ID
|
|
558
763
|
*/
|
|
@@ -768,7 +973,7 @@ declare function useArticle(slugOrId: string): {
|
|
|
768
973
|
* @example
|
|
769
974
|
* ```tsx
|
|
770
975
|
* function MyRequests() {
|
|
771
|
-
* const { requests, isLoading, error, refetch } = useRequests();
|
|
976
|
+
* const { requests, isLoading, error, refetch, settings } = useRequests();
|
|
772
977
|
*
|
|
773
978
|
* if (isLoading) return <p>Loading...</p>;
|
|
774
979
|
* if (error) return <p>Error: {error.message}</p>;
|
|
@@ -791,10 +996,44 @@ declare function useRequests(options?: RequestsOptions): {
|
|
|
791
996
|
offset: number;
|
|
792
997
|
hasMore: boolean;
|
|
793
998
|
} | undefined;
|
|
999
|
+
settings: RequestsSettings;
|
|
794
1000
|
isLoading: boolean;
|
|
795
1001
|
error: Error | null;
|
|
796
1002
|
refetch: () => Promise<void>;
|
|
797
1003
|
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Hook for voting on requests.
|
|
1006
|
+
*
|
|
1007
|
+
* @returns Object with vote function and loading state
|
|
1008
|
+
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```tsx
|
|
1011
|
+
* function VoteButton({ feedbackId }: { feedbackId: string }) {
|
|
1012
|
+
* const { vote, isVoting } = useVote();
|
|
1013
|
+
*
|
|
1014
|
+
* const handleVote = async () => {
|
|
1015
|
+
* const result = await vote(feedbackId);
|
|
1016
|
+
* console.log('Voted:', result.action); // 'added' or 'removed'
|
|
1017
|
+
* };
|
|
1018
|
+
*
|
|
1019
|
+
* return (
|
|
1020
|
+
* <button onClick={handleVote} disabled={isVoting}>
|
|
1021
|
+
* Vote
|
|
1022
|
+
* </button>
|
|
1023
|
+
* );
|
|
1024
|
+
* }
|
|
1025
|
+
* ```
|
|
1026
|
+
*/
|
|
1027
|
+
declare function useVote(): {
|
|
1028
|
+
vote: (feedbackId: string) => Promise<{
|
|
1029
|
+
success: boolean;
|
|
1030
|
+
action: "added" | "removed";
|
|
1031
|
+
vote_count: number;
|
|
1032
|
+
user_has_voted: boolean;
|
|
1033
|
+
}>;
|
|
1034
|
+
isVoting: boolean;
|
|
1035
|
+
error: Error | null;
|
|
1036
|
+
};
|
|
798
1037
|
/**
|
|
799
1038
|
* Hook for tracking events.
|
|
800
1039
|
*
|
|
@@ -822,6 +1061,37 @@ declare function useTrack(): {
|
|
|
822
1061
|
properties?: Record<string, unknown>;
|
|
823
1062
|
}>) => Promise<void>;
|
|
824
1063
|
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Hook for fetching feature groups with their features.
|
|
1066
|
+
*
|
|
1067
|
+
* @returns Object with feature groups data and loading state
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* ```tsx
|
|
1071
|
+
* function FeatureNav() {
|
|
1072
|
+
* const { featureGroups, isLoading, error } = useFeatureGroups();
|
|
1073
|
+
*
|
|
1074
|
+
* if (isLoading) return <p>Loading...</p>;
|
|
1075
|
+
* if (error) return <p>Error: {error.message}</p>;
|
|
1076
|
+
*
|
|
1077
|
+
* return (
|
|
1078
|
+
* <ul>
|
|
1079
|
+
* {featureGroups.map(group => (
|
|
1080
|
+
* <li key={group.id}>
|
|
1081
|
+
* {group.name} ({group.feature_count} features)
|
|
1082
|
+
* </li>
|
|
1083
|
+
* ))}
|
|
1084
|
+
* </ul>
|
|
1085
|
+
* );
|
|
1086
|
+
* }
|
|
1087
|
+
* ```
|
|
1088
|
+
*/
|
|
1089
|
+
declare function useFeatureGroups(): {
|
|
1090
|
+
featureGroups: FeatureGroup[];
|
|
1091
|
+
isLoading: boolean;
|
|
1092
|
+
error: Error | null;
|
|
1093
|
+
refetch: () => Promise<void>;
|
|
1094
|
+
};
|
|
825
1095
|
|
|
826
1096
|
/**
|
|
827
1097
|
* Floating feedback button component.
|
|
@@ -889,4 +1159,4 @@ declare function KnowledgeBase({ showSearch, showCategories, defaultCategory, th
|
|
|
889
1159
|
*/
|
|
890
1160
|
declare function Requests({ status, type, limit, className, showEmptyState, onRequestClick, }: RequestsProps): react_jsx_runtime.JSX.Element | null;
|
|
891
1161
|
|
|
892
|
-
export { type Article, type ArticlesOptions, CensusProvider, type CensusProviderProps, type CensusTheme, FeedbackButton, type FeedbackButtonProps, type FeedbackOptions, type FeedbackType, KnowledgeBase, type KnowledgeBaseProps, type Position, type Request, Requests, type RequestsOptions, type RequestsProps, type UserIdentity, useArticle, useArticles, useCensus, useCensusContext, useFeedback, useIdentify, useRequests, useTrack };
|
|
1162
|
+
export { type Article, type ArticlesOptions, CensusProvider, type CensusProviderProps, type CensusTheme, type Feature, type FeatureGroup, FeedbackButton, type FeedbackButtonProps, type FeedbackOptions, type FeedbackType, type FeedbackVisibility, KnowledgeBase, type KnowledgeBaseProps, type Position, type Request, Requests, type RequestsOptions, type RequestsProps, type RequestsSettings, type UserIdentity, useArticle, useArticles, useCensus, useCensusContext, useFeatureGroups, useFeedback, useIdentify, useRequests, useTrack, useVote };
|