@census-ai/census-sdk 0.3.0 → 0.4.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 CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var o="https://api.census.ai",d=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(s=>e.apiKey.startsWith(s))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||o,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let t=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!t.includes(e.type))throw new Error(`Census: type must be one of: ${t.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let s=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",s.feedbackId),{feedbackId:s.feedbackId}}async getArticles(e){let t=new URLSearchParams;e?.category&&t.set("category",e.category),e?.search&&t.set("search",e.search),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=t.toString(),r=`/api/sdk/articles${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched articles:",i.articles.length),i}async getArticle(e){try{let t=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),t.article}catch(t){if(t.status===404)return null;throw t}}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let t=new URLSearchParams;t.set("userId",this.currentUserId),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=await this.request(`/api/sdk/requests?${t.toString()}`,"GET");return this.log("Fetched requests:",s.requests.length),s}async track(e,t){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:t}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let t=e.events.map(s=>({eventType:s.eventType,userId:this.currentUserId,articleId:s.articleId,featureId:s.featureId,properties:s.properties}));await this.request("/api/sdk/events","POST",{events:t}),this.log("Batch events tracked:",e.events.length);}async getGuides(e){let t=new URLSearchParams;e?.projectId&&t.set("project_id",e.projectId),e?.url&&t.set("url",e.url),e?.userId&&t.set("user_id",e.userId);let s=t.toString(),r=`/api/sdk/guides${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched guides:",i.guides.length),i}async getGuide(e){try{let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"GET");return this.log("Fetched guide:",e),t.guide}catch(t){if(t.status===404)return null;throw t}}async createGuide(e){if(!e.name||!e.slug)throw new Error("Census: name and slug are required for createGuide()");let t=await this.request("/api/sdk/guides","POST",{name:e.name,slug:e.slug,description:e.description,project_id:e.projectId,trigger_type:e.triggerType||"manual",trigger_config:e.triggerConfig||{},theme:e.theme||{},allow_skip:e.allowSkip??true,show_progress:e.showProgress??true});return this.log("Guide created:",t.guide.id),t.guide}async updateGuide(e,t){if(!e)throw new Error("Census: guideId is required for updateGuide()");let s={};t.name!==void 0&&(s.name=t.name),t.slug!==void 0&&(s.slug=t.slug),t.description!==void 0&&(s.description=t.description),t.triggerType!==void 0&&(s.trigger_type=t.triggerType),t.triggerConfig!==void 0&&(s.trigger_config=t.triggerConfig),t.theme!==void 0&&(s.theme=t.theme),t.allowSkip!==void 0&&(s.allow_skip=t.allowSkip),t.showProgress!==void 0&&(s.show_progress=t.showProgress),t.status!==void 0&&(s.status=t.status);let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"PUT",s);return this.log("Guide updated:",e),r.guide}async deleteGuide(e){if(!e)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"DELETE"),this.log("Guide deleted:",e);}async getGuideSteps(e){let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"GET");return this.log("Fetched steps for guide:",e),t.steps}async addGuideStep(e,t){if(!e)throw new Error("Census: guideId is required for addGuideStep()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"POST",{step_type:t.stepType||"tooltip",sort_order:t.sortOrder,selector_strategy:t.selectorStrategy||{},title:t.title,content:t.content,tooltip_position:t.tooltipPosition||"auto",rich_content:t.richContent||{},display_config:t.displayConfig||{},advance_config:t.advanceConfig||{trigger:"button"},style_config:t.styleConfig||{}});return this.log("Step added to guide:",e),s.step}async updateGuideStep(e,t,s){if(!e||!t)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let r={};s.stepType!==void 0&&(r.step_type=s.stepType),s.sortOrder!==void 0&&(r.sort_order=s.sortOrder),s.selectorStrategy!==void 0&&(r.selector_strategy=s.selectorStrategy),s.title!==void 0&&(r.title=s.title),s.content!==void 0&&(r.content=s.content),s.tooltipPosition!==void 0&&(r.tooltip_position=s.tooltipPosition),s.richContent!==void 0&&(r.rich_content=s.richContent),s.displayConfig!==void 0&&(r.display_config=s.displayConfig),s.advanceConfig!==void 0&&(r.advance_config=s.advanceConfig),s.styleConfig!==void 0&&(r.style_config=s.styleConfig);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"PUT",r);return this.log("Step updated:",t),i.step}async deleteGuideStep(e,t){if(!e||!t)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"DELETE"),this.log("Step deleted:",t);}async reorderGuideSteps(e,t){if(!e)throw new Error("Census: guideId is required for reorderGuideSteps()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"PUT",{steps:t});return this.log("Steps reordered for guide:",e),s.steps}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,t,s){let r=`${this.baseUrl}${e}`,i={"X-Census-Key":this.apiKey};s&&(i["Content-Type"]="application/json"),this.log(`${t} ${e}`,s);let n=await fetch(r,{method:t,headers:i,body:s?JSON.stringify(s):void 0});if(!n.ok){let a=`Request failed with status ${n.status}`;try{a=(await n.json()).error||a;}catch{}throw {error:a,status:n.status}}return n.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function c(u){return new d(u)}
1
+ 'use strict';var o="https://api.census.ai",d=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(s=>e.apiKey.startsWith(s))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||o,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let t=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!t.includes(e.type))throw new Error(`Census: type must be one of: ${t.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let s=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",s.feedbackId),{feedbackId:s.feedbackId}}async getArticles(e){let t=new URLSearchParams;e?.category&&t.set("category",e.category),e?.search&&t.set("search",e.search),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=t.toString(),r=`/api/sdk/articles${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched articles:",i.articles.length),i}async getArticle(e){try{let t=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),t.article}catch(t){if(t.status===404)return null;throw t}}async getFeatureGroups(){let e=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",e.feature_groups.length),e}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let t=new URLSearchParams;t.set("userId",this.currentUserId),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=await this.request(`/api/sdk/requests?${t.toString()}`,"GET");return this.log("Fetched requests:",s.requests.length),s}async track(e,t){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:t}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let t=e.events.map(s=>({eventType:s.eventType,userId:this.currentUserId,articleId:s.articleId,featureId:s.featureId,properties:s.properties}));await this.request("/api/sdk/events","POST",{events:t}),this.log("Batch events tracked:",e.events.length);}async getGuides(e){let t=new URLSearchParams;e?.projectId&&t.set("project_id",e.projectId),e?.url&&t.set("url",e.url),e?.userId&&t.set("user_id",e.userId);let s=t.toString(),r=`/api/sdk/guides${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched guides:",i.guides.length),i}async getGuide(e){try{let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"GET");return this.log("Fetched guide:",e),t.guide}catch(t){if(t.status===404)return null;throw t}}async createGuide(e){if(!e.name||!e.slug)throw new Error("Census: name and slug are required for createGuide()");let t=await this.request("/api/sdk/guides","POST",{name:e.name,slug:e.slug,description:e.description,project_id:e.projectId,trigger_type:e.triggerType||"manual",trigger_config:e.triggerConfig||{},theme:e.theme||{},allow_skip:e.allowSkip??true,show_progress:e.showProgress??true});return this.log("Guide created:",t.guide.id),t.guide}async updateGuide(e,t){if(!e)throw new Error("Census: guideId is required for updateGuide()");let s={};t.name!==void 0&&(s.name=t.name),t.slug!==void 0&&(s.slug=t.slug),t.description!==void 0&&(s.description=t.description),t.triggerType!==void 0&&(s.trigger_type=t.triggerType),t.triggerConfig!==void 0&&(s.trigger_config=t.triggerConfig),t.theme!==void 0&&(s.theme=t.theme),t.allowSkip!==void 0&&(s.allow_skip=t.allowSkip),t.showProgress!==void 0&&(s.show_progress=t.showProgress),t.status!==void 0&&(s.status=t.status);let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"PUT",s);return this.log("Guide updated:",e),r.guide}async deleteGuide(e){if(!e)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"DELETE"),this.log("Guide deleted:",e);}async getGuideSteps(e){let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"GET");return this.log("Fetched steps for guide:",e),t.steps}async addGuideStep(e,t){if(!e)throw new Error("Census: guideId is required for addGuideStep()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"POST",{step_type:t.stepType||"tooltip",sort_order:t.sortOrder,selector_strategy:t.selectorStrategy||{},title:t.title,content:t.content,tooltip_position:t.tooltipPosition||"auto",rich_content:t.richContent||{},display_config:t.displayConfig||{},advance_config:t.advanceConfig||{trigger:"button"},style_config:t.styleConfig||{}});return this.log("Step added to guide:",e),s.step}async updateGuideStep(e,t,s){if(!e||!t)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let r={};s.stepType!==void 0&&(r.step_type=s.stepType),s.sortOrder!==void 0&&(r.sort_order=s.sortOrder),s.selectorStrategy!==void 0&&(r.selector_strategy=s.selectorStrategy),s.title!==void 0&&(r.title=s.title),s.content!==void 0&&(r.content=s.content),s.tooltipPosition!==void 0&&(r.tooltip_position=s.tooltipPosition),s.richContent!==void 0&&(r.rich_content=s.richContent),s.displayConfig!==void 0&&(r.display_config=s.displayConfig),s.advanceConfig!==void 0&&(r.advance_config=s.advanceConfig),s.styleConfig!==void 0&&(r.style_config=s.styleConfig);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"PUT",r);return this.log("Step updated:",t),i.step}async deleteGuideStep(e,t){if(!e||!t)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"DELETE"),this.log("Step deleted:",t);}async reorderGuideSteps(e,t){if(!e)throw new Error("Census: guideId is required for reorderGuideSteps()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"PUT",{steps:t});return this.log("Steps reordered for guide:",e),s.steps}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,t,s){let r=`${this.baseUrl}${e}`,i={"X-Census-Key":this.apiKey};s&&(i["Content-Type"]="application/json"),this.log(`${t} ${e}`,s);let n=await fetch(r,{method:t,headers:i,body:s?JSON.stringify(s):void 0});if(!n.ok){let a=`Request failed with status ${n.status}`;try{a=(await n.json()).error||a;}catch{}throw {error:a,status:n.status}}return n.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function c(u){return new d(u)}
2
2
  exports.CensusClient=d;exports.createCensus=c;//# sourceMappingURL=index.cjs.map
3
3
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":["DEFAULT_BASE_URL","CensusClient","config","prefix","user","options","validTypes","response","params","queryString","url","slugOrId","error","eventType","properties","events","event","guideId","body","stepId","stepOrder","path","method","headers","errorMessage","args","createCensus"],"mappings":"aAy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A,CAAuB,CAChC,KAAK,KAAA,EACP,OAAA,CAAQ,IAAI,UAAA,CAAY,GAAGA,CAAI,EAEnC,CACF,EAkBO,SAASC,EAAaxB,CAAAA,CAAoC,CAC/D,OAAO,IAAID,CAAAA,CAAaC,CAAM,CAChC","file":"index.cjs","sourcesContent":["import type {\n CensusConfig,\n UserIdentity,\n FeedbackOptions,\n ArticlesOptions,\n ArticlesResponse,\n Article,\n RequestsOptions,\n RequestsResponse,\n BatchEventsOptions,\n CensusError,\n Guide,\n GuideStep,\n GuidesOptions,\n GuidesResponse,\n GuideAnalyticsEvent,\n CreateGuideOptions,\n UpdateGuideOptions,\n CreateGuideStepOptions,\n UpdateGuideStepOptions,\n} from './types';\n\n/**\n * Default API base URL\n */\nconst DEFAULT_BASE_URL = 'https://api.census.ai';\n\n/**\n * Census SDK Client\n *\n * The main client for interacting with the Census API.\n * Use `createCensus()` to create an instance.\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({ apiKey: 'cs_live_xxx' });\n *\n * await census.identify({ userId: 'user_123', email: 'user@example.com' });\n * await census.submitFeedback({ type: 'bug_report', message: 'Button is broken' });\n * ```\n */\nexport class CensusClient {\n private apiKey: string;\n private baseUrl: string;\n private debug: boolean;\n private currentUserId: string | null = null;\n\n constructor(config: CensusConfig) {\n if (!config.apiKey) {\n throw new Error('Census: apiKey is required');\n }\n\n // Support both new (cs_) and legacy (op_) key prefixes\n const validPrefixes = ['cs_live_', 'cs_test_', 'op_live_', 'op_test_'];\n if (!validPrefixes.some(prefix => config.apiKey.startsWith(prefix))) {\n console.warn('Census: API key should start with \"cs_live_\" or \"cs_test_\"');\n }\n\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n this.debug = config.debug || false;\n\n this.log('Initialized with base URL:', this.baseUrl);\n }\n\n /**\n * Identify a user for tracking purposes.\n * Call this when a user logs in or when you have user information.\n *\n * @param user - User identity information\n *\n * @example\n * ```typescript\n * await census.identify({\n * userId: 'user_123',\n * email: 'john@example.com',\n * name: 'John Doe',\n * organizationId: 'org_456',\n * organizationName: 'Acme Inc',\n * });\n * ```\n */\n async identify(user: UserIdentity): Promise<void> {\n if (!user.userId) {\n throw new Error('Census: userId is required for identify()');\n }\n\n this.currentUserId = user.userId;\n\n await this.request('/api/sdk/identify', 'POST', {\n userId: user.userId,\n email: user.email,\n name: user.name,\n avatarUrl: user.avatarUrl,\n metadata: user.metadata,\n organizationId: user.organizationId,\n organizationName: user.organizationName,\n organizationDomain: user.organizationDomain,\n organizationPlan: user.organizationPlan,\n });\n\n this.log('User identified:', user.userId);\n }\n\n /**\n * Clear the current user identity.\n * Call this when a user logs out.\n */\n reset(): void {\n this.currentUserId = null;\n this.log('User identity reset');\n }\n\n /**\n * Submit feedback, bug report, or feature request.\n *\n * @param options - Feedback options\n *\n * @example\n * ```typescript\n * // Submit a bug report\n * await census.submitFeedback({\n * type: 'bug_report',\n * message: 'The submit button is not working on Firefox',\n * });\n *\n * // Submit a feature request\n * await census.submitFeedback({\n * type: 'feature_request',\n * message: 'It would be great to have dark mode support',\n * });\n *\n * // Rate an article\n * await census.submitFeedback({\n * type: 'article_rating',\n * articleId: 'article_123',\n * helpful: true,\n * rating: 5,\n * });\n * ```\n */\n async submitFeedback(options: FeedbackOptions): Promise<{ feedbackId: string }> {\n const validTypes = ['feedback', 'bug_report', 'feature_request', 'article_rating'];\n if (!options.type || !validTypes.includes(options.type)) {\n throw new Error(`Census: type must be one of: ${validTypes.join(', ')}`);\n }\n\n if (options.type === 'article_rating') {\n if (options.rating === undefined && options.helpful === undefined) {\n throw new Error('Census: article_rating requires rating or helpful field');\n }\n } else if (!options.message) {\n throw new Error('Census: message is required for this feedback type');\n }\n\n const response = await this.request<{ success: boolean; feedbackId: string }>(\n '/api/sdk/feedback',\n 'POST',\n {\n type: options.type,\n message: options.message,\n rating: options.rating,\n helpful: options.helpful,\n userId: this.currentUserId,\n articleId: options.articleId,\n pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n metadata: options.metadata,\n }\n );\n\n this.log('Feedback submitted:', response.feedbackId);\n return { feedbackId: response.feedbackId };\n }\n\n /**\n * Fetch published articles from the knowledge base.\n *\n * @param options - Query options\n * @returns Articles and pagination info\n *\n * @example\n * ```typescript\n * // Get all articles\n * const { articles } = await census.getArticles();\n *\n * // Search articles\n * const { articles } = await census.getArticles({ search: 'getting started' });\n *\n * // Filter by category\n * const { articles } = await census.getArticles({ category: 'guides' });\n * ```\n */\n async getArticles(options?: ArticlesOptions): Promise<ArticlesResponse> {\n const params = new URLSearchParams();\n if (options?.category) params.set('category', options.category);\n if (options?.search) params.set('search', options.search);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const queryString = params.toString();\n const url = `/api/sdk/articles${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<ArticlesResponse>(url, 'GET');\n this.log('Fetched articles:', response.articles.length);\n return response;\n }\n\n /**\n * Fetch a single article by slug or ID.\n *\n * @param slugOrId - Article slug or ID\n * @returns Article or null if not found\n *\n * @example\n * ```typescript\n * const article = await census.getArticle('getting-started');\n * if (article) {\n * console.log(article.title, article.content_html);\n * }\n * ```\n */\n async getArticle(slugOrId: string): Promise<Article | null> {\n try {\n const response = await this.request<{ article: Article }>(\n `/api/sdk/articles/${encodeURIComponent(slugOrId)}`,\n 'GET'\n );\n this.log('Fetched article:', slugOrId);\n return response.article;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch the current user's submitted requests (feedback, bugs, feature requests).\n * Requires a user to be identified first.\n *\n * @param options - Query options\n * @returns Requests and pagination info\n *\n * @example\n * ```typescript\n * // Get all requests for the current user\n * const { requests } = await census.getRequests();\n *\n * // Filter by status\n * const { requests } = await census.getRequests({ status: 'in_progress' });\n *\n * // Filter by type\n * const { requests } = await census.getRequests({ type: 'bug_report' });\n * ```\n */\n async getRequests(options?: RequestsOptions): Promise<RequestsResponse> {\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before fetching requests. Call identify() first.');\n }\n\n const params = new URLSearchParams();\n params.set('userId', this.currentUserId);\n if (options?.status) params.set('status', options.status);\n if (options?.type) params.set('type', options.type);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const response = await this.request<RequestsResponse>(\n `/api/sdk/requests?${params.toString()}`,\n 'GET'\n );\n this.log('Fetched requests:', response.requests.length);\n return response;\n }\n\n /**\n * Track a custom analytics event.\n *\n * @param eventType - Name of the event\n * @param properties - Additional event properties\n *\n * @example\n * ```typescript\n * // Track a button click\n * await census.track('button_clicked', { buttonId: 'submit-form' });\n *\n * // Track a page view\n * await census.track('page_viewed', { page: '/pricing' });\n * ```\n */\n async track(eventType: string, properties?: Record<string, unknown>): Promise<void> {\n if (!eventType) {\n throw new Error('Census: eventType is required for track()');\n }\n\n await this.request('/api/sdk/events', 'POST', {\n eventType,\n userId: this.currentUserId,\n properties,\n });\n\n this.log('Event tracked:', eventType);\n }\n\n /**\n * Track multiple events in a single request.\n * More efficient than calling track() multiple times.\n *\n * @param events - Array of events to track\n *\n * @example\n * ```typescript\n * await census.trackBatch({\n * events: [\n * { eventType: 'page_viewed', properties: { page: '/home' } },\n * { eventType: 'button_clicked', properties: { button: 'cta' } },\n * ],\n * });\n * ```\n */\n async trackBatch(options: BatchEventsOptions): Promise<void> {\n if (!options.events || options.events.length === 0) {\n throw new Error('Census: at least one event is required');\n }\n\n if (options.events.length > 100) {\n throw new Error('Census: maximum 100 events per batch');\n }\n\n const events = options.events.map((event) => ({\n eventType: event.eventType,\n userId: this.currentUserId,\n articleId: event.articleId,\n featureId: event.featureId,\n properties: event.properties,\n }));\n\n await this.request('/api/sdk/events', 'POST', { events });\n\n this.log('Batch events tracked:', options.events.length);\n }\n\n // ============================================================================\n // Guide Builder Methods\n // ============================================================================\n\n /**\n * Get published guides.\n *\n * @param options - Query options\n * @returns Guides and completion status\n *\n * @example\n * ```typescript\n * const { guides, completedGuides } = await census.getGuides({\n * url: window.location.href,\n * userId: 'user_123',\n * });\n * ```\n */\n async getGuides(options?: GuidesOptions): Promise<GuidesResponse> {\n const params = new URLSearchParams();\n if (options?.projectId) params.set('project_id', options.projectId);\n if (options?.url) params.set('url', options.url);\n if (options?.userId) params.set('user_id', options.userId);\n\n const queryString = params.toString();\n const url = `/api/sdk/guides${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<GuidesResponse>(url, 'GET');\n this.log('Fetched guides:', response.guides.length);\n return response;\n }\n\n /**\n * Get a single guide by ID.\n *\n * @param guideId - Guide ID\n * @returns Guide with steps or null if not found\n *\n * @example\n * ```typescript\n * const guide = await census.getGuide('guide_123');\n * if (guide) {\n * console.log(guide.name, guide.guide_steps.length);\n * }\n * ```\n */\n async getGuide(guideId: string): Promise<Guide | null> {\n try {\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'GET'\n );\n this.log('Fetched guide:', guideId);\n return response.guide;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Create a new guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param options - Guide creation options\n * @returns Created guide\n *\n * @example\n * ```typescript\n * const guide = await census.createGuide({\n * name: 'Welcome Tour',\n * slug: 'welcome-tour',\n * description: 'Introduction to the app',\n * triggerType: 'first_visit',\n * });\n * ```\n */\n async createGuide(options: CreateGuideOptions): Promise<Guide> {\n if (!options.name || !options.slug) {\n throw new Error('Census: name and slug are required for createGuide()');\n }\n\n const response = await this.request<{ guide: Guide }>(\n '/api/sdk/guides',\n 'POST',\n {\n name: options.name,\n slug: options.slug,\n description: options.description,\n project_id: options.projectId,\n trigger_type: options.triggerType || 'manual',\n trigger_config: options.triggerConfig || {},\n theme: options.theme || {},\n allow_skip: options.allowSkip ?? true,\n show_progress: options.showProgress ?? true,\n }\n );\n\n this.log('Guide created:', response.guide.id);\n return response.guide;\n }\n\n /**\n * Update an existing guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID to update\n * @param options - Update options\n * @returns Updated guide\n *\n * @example\n * ```typescript\n * const guide = await census.updateGuide('guide_123', {\n * name: 'Updated Tour Name',\n * status: 'published',\n * });\n * ```\n */\n async updateGuide(guideId: string, options: UpdateGuideOptions): Promise<Guide> {\n if (!guideId) {\n throw new Error('Census: guideId is required for updateGuide()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.name !== undefined) body.name = options.name;\n if (options.slug !== undefined) body.slug = options.slug;\n if (options.description !== undefined) body.description = options.description;\n if (options.triggerType !== undefined) body.trigger_type = options.triggerType;\n if (options.triggerConfig !== undefined) body.trigger_config = options.triggerConfig;\n if (options.theme !== undefined) body.theme = options.theme;\n if (options.allowSkip !== undefined) body.allow_skip = options.allowSkip;\n if (options.showProgress !== undefined) body.show_progress = options.showProgress;\n if (options.status !== undefined) body.status = options.status;\n\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'PUT',\n body\n );\n\n this.log('Guide updated:', guideId);\n return response.guide;\n }\n\n /**\n * Delete a guide.\n * Requires guides:admin scope.\n *\n * @param guideId - Guide ID to delete\n *\n * @example\n * ```typescript\n * await census.deleteGuide('guide_123');\n * ```\n */\n async deleteGuide(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for deleteGuide()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'DELETE'\n );\n\n this.log('Guide deleted:', guideId);\n }\n\n /**\n * Get steps for a guide.\n *\n * @param guideId - Guide ID\n * @returns Array of steps\n *\n * @example\n * ```typescript\n * const steps = await census.getGuideSteps('guide_123');\n * ```\n */\n async getGuideSteps(guideId: string): Promise<GuideStep[]> {\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'GET'\n );\n this.log('Fetched steps for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Add a step to a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param options - Step creation options\n * @returns Created step\n *\n * @example\n * ```typescript\n * const step = await census.addGuideStep('guide_123', {\n * stepType: 'tooltip',\n * selectorStrategy: { css: '.welcome-button' },\n * richContent: {\n * title: 'Welcome!',\n * body: 'Click here to get started',\n * },\n * });\n * ```\n */\n async addGuideStep(guideId: string, options: CreateGuideStepOptions): Promise<GuideStep> {\n if (!guideId) {\n throw new Error('Census: guideId is required for addGuideStep()');\n }\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'POST',\n {\n step_type: options.stepType || 'tooltip',\n sort_order: options.sortOrder,\n selector_strategy: options.selectorStrategy || {},\n title: options.title,\n content: options.content,\n tooltip_position: options.tooltipPosition || 'auto',\n rich_content: options.richContent || {},\n display_config: options.displayConfig || {},\n advance_config: options.advanceConfig || { trigger: 'button' },\n style_config: options.styleConfig || {},\n }\n );\n\n this.log('Step added to guide:', guideId);\n return response.step;\n }\n\n /**\n * Update a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n * @param options - Update options\n * @returns Updated step\n *\n * @example\n * ```typescript\n * const step = await census.updateGuideStep('guide_123', 'step_456', {\n * richContent: { title: 'Updated title' },\n * });\n * ```\n */\n async updateGuideStep(\n guideId: string,\n stepId: string,\n options: UpdateGuideStepOptions\n ): Promise<GuideStep> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for updateGuideStep()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.stepType !== undefined) body.step_type = options.stepType;\n if (options.sortOrder !== undefined) body.sort_order = options.sortOrder;\n if (options.selectorStrategy !== undefined) body.selector_strategy = options.selectorStrategy;\n if (options.title !== undefined) body.title = options.title;\n if (options.content !== undefined) body.content = options.content;\n if (options.tooltipPosition !== undefined) body.tooltip_position = options.tooltipPosition;\n if (options.richContent !== undefined) body.rich_content = options.richContent;\n if (options.displayConfig !== undefined) body.display_config = options.displayConfig;\n if (options.advanceConfig !== undefined) body.advance_config = options.advanceConfig;\n if (options.styleConfig !== undefined) body.style_config = options.styleConfig;\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'PUT',\n body\n );\n\n this.log('Step updated:', stepId);\n return response.step;\n }\n\n /**\n * Delete a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n *\n * @example\n * ```typescript\n * await census.deleteGuideStep('guide_123', 'step_456');\n * ```\n */\n async deleteGuideStep(guideId: string, stepId: string): Promise<void> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for deleteGuideStep()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'DELETE'\n );\n\n this.log('Step deleted:', stepId);\n }\n\n /**\n * Reorder steps in a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepOrder - Array of { id, sort_order } to define new order\n * @returns Updated steps\n *\n * @example\n * ```typescript\n * const steps = await census.reorderGuideSteps('guide_123', [\n * { id: 'step_a', sort_order: 0 },\n * { id: 'step_b', sort_order: 1 },\n * { id: 'step_c', sort_order: 2 },\n * ]);\n * ```\n */\n async reorderGuideSteps(\n guideId: string,\n stepOrder: Array<{ id: string; sort_order: number }>\n ): Promise<GuideStep[]> {\n if (!guideId) {\n throw new Error('Census: guideId is required for reorderGuideSteps()');\n }\n\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'PUT',\n { steps: stepOrder }\n );\n\n this.log('Steps reordered for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Track a guide analytics event.\n * Used to track user progress through guides.\n *\n * @param event - Guide analytics event\n *\n * @example\n * ```typescript\n * await census.trackGuideEvent({\n * guideId: 'guide_123',\n * eventType: 'step_completed',\n * stepId: 'step_456',\n * stepIndex: 2,\n * sessionId: 'session_789',\n * });\n * ```\n */\n async trackGuideEvent(event: GuideAnalyticsEvent): Promise<void> {\n if (!event.guideId || !event.eventType || !event.sessionId) {\n throw new Error('Census: guideId, eventType, and sessionId are required for trackGuideEvent()');\n }\n\n await this.request('/api/sdk/guides/events', 'POST', {\n guideId: event.guideId,\n eventType: event.eventType,\n stepId: event.stepId,\n stepIndex: event.stepIndex,\n pageUrl: event.pageUrl || (typeof window !== 'undefined' ? window.location.href : undefined),\n sessionId: event.sessionId,\n userId: event.userId || this.currentUserId,\n metadata: event.metadata,\n });\n\n this.log('Guide event tracked:', event.eventType, event.guideId);\n }\n\n /**\n * Mark a guide as completed for the current user.\n * Prevents the guide from showing again.\n *\n * @param guideId - ID of the guide to mark as completed\n *\n * @example\n * ```typescript\n * await census.markGuideCompleted('guide_123');\n * ```\n */\n async markGuideCompleted(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for markGuideCompleted()');\n }\n\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before marking guides complete. Call identify() first.');\n }\n\n await this.request('/api/sdk/guides/complete', 'POST', {\n guideId,\n userId: this.currentUserId,\n });\n\n this.log('Guide marked completed:', guideId);\n }\n\n /**\n * Get the current identified user ID\n */\n getCurrentUserId(): string | null {\n return this.currentUserId;\n }\n\n /**\n * Check if a user is currently identified\n */\n isIdentified(): boolean {\n return this.currentUserId !== null;\n }\n\n /**\n * Make an API request\n */\n private async request<T>(path: string, method: string, body?: unknown): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'X-Census-Key': this.apiKey,\n };\n\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n\n this.log(`${method} ${path}`, body);\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n let errorMessage = `Request failed with status ${response.status}`;\n try {\n const errorData = await response.json();\n errorMessage = errorData.error || errorMessage;\n } catch {\n // Use default error message\n }\n\n const error: CensusError = {\n error: errorMessage,\n status: response.status,\n };\n throw error;\n }\n\n return response.json();\n }\n\n /**\n * Log debug messages\n */\n private log(...args: unknown[]): void {\n if (this.debug) {\n console.log('[Census]', ...args);\n }\n }\n}\n\n/**\n * Create a new Census SDK client.\n *\n * @param config - Configuration options\n * @returns Census client instance\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({\n * apiKey: 'cs_live_your_key_here',\n * debug: true, // Enable debug logging\n * });\n * ```\n */\nexport function createCensus(config: CensusConfig): CensusClient {\n return new CensusClient(config);\n}\n"]}
1
+ {"version":3,"sources":["../src/client.ts"],"names":["DEFAULT_BASE_URL","CensusClient","config","prefix","user","options","validTypes","response","params","queryString","url","slugOrId","error","eventType","properties","events","event","guideId","body","stepId","stepOrder","path","method","headers","errorMessage","args","createCensus"],"mappings":"aA0BA,IAAMA,EAAmB,uBAAA,CAkBZC,CAAAA,CAAN,KAAmB,CAMxB,YAAYC,CAAAA,CAAsB,CAFlC,IAAA,CAAQ,aAAA,CAA+B,KAGrC,GAAI,CAACA,EAAO,MAAA,CACV,MAAM,IAAI,KAAA,CAAM,4BAA4B,CAAA,CAIxB,CAAC,WAAY,UAAA,CAAY,UAAA,CAAY,UAAU,CAAA,CAClD,KAAKC,CAAAA,EAAUD,CAAAA,CAAO,MAAA,CAAO,UAAA,CAAWC,CAAM,CAAC,CAAA,EAChE,QAAQ,IAAA,CAAK,4DAA4D,EAG3E,IAAA,CAAK,MAAA,CAASD,CAAAA,CAAO,MAAA,CACrB,KAAK,OAAA,CAAUA,CAAAA,CAAO,OAAA,EAAWF,CAAAA,CACjC,KAAK,KAAA,CAAQE,CAAAA,CAAO,KAAA,EAAS,KAAA,CAE7B,KAAK,GAAA,CAAI,4BAAA,CAA8B,KAAK,OAAO,E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E5BE,CAAAA,CAAkC,CACtC,cAAA,CAAgB,IAAA,CAAK,MACvB,CAAA,CAEIL,CAAAA,GACFK,EAAQ,cAAc,CAAA,CAAI,oBAG5B,IAAA,CAAK,GAAA,CAAI,CAAA,EAAGD,CAAM,IAAID,CAAI,CAAA,CAAA,CAAIH,CAAI,CAAA,CAElC,IAAMX,CAAAA,CAAW,MAAM,KAAA,CAAMG,CAAAA,CAAK,CAChC,MAAA,CAAAY,CAAAA,CACA,QAAAC,CAAAA,CACA,IAAA,CAAML,EAAO,IAAA,CAAK,SAAA,CAAUA,CAAI,CAAA,CAAI,MACtC,CAAC,CAAA,CAED,GAAI,CAACX,CAAAA,CAAS,GAAI,CAChB,IAAIiB,CAAAA,CAAe,CAAA,2BAAA,EAA8BjB,EAAS,MAAM,CAAA,CAAA,CAChE,GAAI,CAEFiB,CAAAA,CAAAA,CADkB,MAAMjB,CAAAA,CAAS,IAAA,EAAK,EACb,KAAA,EAASiB,EACpC,CAAA,KAAQ,CAER,CAMA,MAJ2B,CACzB,KAAA,CAAOA,CAAAA,CACP,MAAA,CAAQjB,CAAAA,CAAS,MACnB,CAEF,CAEA,OAAOA,CAAAA,CAAS,IAAA,EAClB,CAKQ,GAAA,CAAA,GAAOkB,CAAAA,CAAuB,CAChC,KAAK,KAAA,EACP,OAAA,CAAQ,IAAI,UAAA,CAAY,GAAGA,CAAI,EAEnC,CACF,EAkBO,SAASC,EAAaxB,CAAAA,CAAoC,CAC/D,OAAO,IAAID,CAAAA,CAAaC,CAAM,CAChC","file":"index.cjs","sourcesContent":["import type {\n CensusConfig,\n UserIdentity,\n FeedbackOptions,\n ArticlesOptions,\n ArticlesResponse,\n Article,\n FeatureGroupsResponse,\n RequestsOptions,\n RequestsResponse,\n BatchEventsOptions,\n CensusError,\n Guide,\n GuideStep,\n GuidesOptions,\n GuidesResponse,\n GuideAnalyticsEvent,\n CreateGuideOptions,\n UpdateGuideOptions,\n CreateGuideStepOptions,\n UpdateGuideStepOptions,\n} from './types';\n\n/**\n * Default API base URL\n */\nconst DEFAULT_BASE_URL = 'https://api.census.ai';\n\n/**\n * Census SDK Client\n *\n * The main client for interacting with the Census API.\n * Use `createCensus()` to create an instance.\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({ apiKey: 'cs_live_xxx' });\n *\n * await census.identify({ userId: 'user_123', email: 'user@example.com' });\n * await census.submitFeedback({ type: 'bug_report', message: 'Button is broken' });\n * ```\n */\nexport class CensusClient {\n private apiKey: string;\n private baseUrl: string;\n private debug: boolean;\n private currentUserId: string | null = null;\n\n constructor(config: CensusConfig) {\n if (!config.apiKey) {\n throw new Error('Census: apiKey is required');\n }\n\n // Support both new (cs_) and legacy (op_) key prefixes\n const validPrefixes = ['cs_live_', 'cs_test_', 'op_live_', 'op_test_'];\n if (!validPrefixes.some(prefix => config.apiKey.startsWith(prefix))) {\n console.warn('Census: API key should start with \"cs_live_\" or \"cs_test_\"');\n }\n\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n this.debug = config.debug || false;\n\n this.log('Initialized with base URL:', this.baseUrl);\n }\n\n /**\n * Identify a user for tracking purposes.\n * Call this when a user logs in or when you have user information.\n *\n * @param user - User identity information\n *\n * @example\n * ```typescript\n * await census.identify({\n * userId: 'user_123',\n * email: 'john@example.com',\n * name: 'John Doe',\n * organizationId: 'org_456',\n * organizationName: 'Acme Inc',\n * });\n * ```\n */\n async identify(user: UserIdentity): Promise<void> {\n if (!user.userId) {\n throw new Error('Census: userId is required for identify()');\n }\n\n this.currentUserId = user.userId;\n\n await this.request('/api/sdk/identify', 'POST', {\n userId: user.userId,\n email: user.email,\n name: user.name,\n avatarUrl: user.avatarUrl,\n metadata: user.metadata,\n organizationId: user.organizationId,\n organizationName: user.organizationName,\n organizationDomain: user.organizationDomain,\n organizationPlan: user.organizationPlan,\n });\n\n this.log('User identified:', user.userId);\n }\n\n /**\n * Clear the current user identity.\n * Call this when a user logs out.\n */\n reset(): void {\n this.currentUserId = null;\n this.log('User identity reset');\n }\n\n /**\n * Submit feedback, bug report, or feature request.\n *\n * @param options - Feedback options\n *\n * @example\n * ```typescript\n * // Submit a bug report\n * await census.submitFeedback({\n * type: 'bug_report',\n * message: 'The submit button is not working on Firefox',\n * });\n *\n * // Submit a feature request\n * await census.submitFeedback({\n * type: 'feature_request',\n * message: 'It would be great to have dark mode support',\n * });\n *\n * // Rate an article\n * await census.submitFeedback({\n * type: 'article_rating',\n * articleId: 'article_123',\n * helpful: true,\n * rating: 5,\n * });\n * ```\n */\n async submitFeedback(options: FeedbackOptions): Promise<{ feedbackId: string }> {\n const validTypes = ['feedback', 'bug_report', 'feature_request', 'article_rating'];\n if (!options.type || !validTypes.includes(options.type)) {\n throw new Error(`Census: type must be one of: ${validTypes.join(', ')}`);\n }\n\n if (options.type === 'article_rating') {\n if (options.rating === undefined && options.helpful === undefined) {\n throw new Error('Census: article_rating requires rating or helpful field');\n }\n } else if (!options.message) {\n throw new Error('Census: message is required for this feedback type');\n }\n\n const response = await this.request<{ success: boolean; feedbackId: string }>(\n '/api/sdk/feedback',\n 'POST',\n {\n type: options.type,\n message: options.message,\n rating: options.rating,\n helpful: options.helpful,\n userId: this.currentUserId,\n articleId: options.articleId,\n pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n metadata: options.metadata,\n }\n );\n\n this.log('Feedback submitted:', response.feedbackId);\n return { feedbackId: response.feedbackId };\n }\n\n /**\n * Fetch published articles from the knowledge base.\n *\n * @param options - Query options\n * @returns Articles and pagination info\n *\n * @example\n * ```typescript\n * // Get all articles\n * const { articles } = await census.getArticles();\n *\n * // Search articles\n * const { articles } = await census.getArticles({ search: 'getting started' });\n *\n * // Filter by category\n * const { articles } = await census.getArticles({ category: 'guides' });\n * ```\n */\n async getArticles(options?: ArticlesOptions): Promise<ArticlesResponse> {\n const params = new URLSearchParams();\n if (options?.category) params.set('category', options.category);\n if (options?.search) params.set('search', options.search);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const queryString = params.toString();\n const url = `/api/sdk/articles${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<ArticlesResponse>(url, 'GET');\n this.log('Fetched articles:', response.articles.length);\n return response;\n }\n\n /**\n * Fetch a single article by slug or ID.\n *\n * @param slugOrId - Article slug or ID\n * @returns Article or null if not found\n *\n * @example\n * ```typescript\n * const article = await census.getArticle('getting-started');\n * if (article) {\n * console.log(article.title, article.content_html);\n * }\n * ```\n */\n async getArticle(slugOrId: string): Promise<Article | null> {\n try {\n const response = await this.request<{ article: Article }>(\n `/api/sdk/articles/${encodeURIComponent(slugOrId)}`,\n 'GET'\n );\n this.log('Fetched article:', slugOrId);\n return response.article;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch feature groups with their features.\n * Used by the HelpCenter component for navigation.\n *\n * @returns Feature groups with features and article counts\n *\n * @example\n * ```typescript\n * const { feature_groups } = await census.getFeatureGroups();\n * feature_groups.forEach(group => {\n * console.log(group.name, group.features.length);\n * });\n * ```\n */\n async getFeatureGroups(): Promise<FeatureGroupsResponse> {\n const response = await this.request<FeatureGroupsResponse>(\n '/api/sdk/feature-groups',\n 'GET'\n );\n this.log('Fetched feature groups:', response.feature_groups.length);\n return response;\n }\n\n /**\n * Fetch the current user's submitted requests (feedback, bugs, feature requests).\n * Requires a user to be identified first.\n *\n * @param options - Query options\n * @returns Requests and pagination info\n *\n * @example\n * ```typescript\n * // Get all requests for the current user\n * const { requests } = await census.getRequests();\n *\n * // Filter by status\n * const { requests } = await census.getRequests({ status: 'in_progress' });\n *\n * // Filter by type\n * const { requests } = await census.getRequests({ type: 'bug_report' });\n * ```\n */\n async getRequests(options?: RequestsOptions): Promise<RequestsResponse> {\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before fetching requests. Call identify() first.');\n }\n\n const params = new URLSearchParams();\n params.set('userId', this.currentUserId);\n if (options?.status) params.set('status', options.status);\n if (options?.type) params.set('type', options.type);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const response = await this.request<RequestsResponse>(\n `/api/sdk/requests?${params.toString()}`,\n 'GET'\n );\n this.log('Fetched requests:', response.requests.length);\n return response;\n }\n\n /**\n * Track a custom analytics event.\n *\n * @param eventType - Name of the event\n * @param properties - Additional event properties\n *\n * @example\n * ```typescript\n * // Track a button click\n * await census.track('button_clicked', { buttonId: 'submit-form' });\n *\n * // Track a page view\n * await census.track('page_viewed', { page: '/pricing' });\n * ```\n */\n async track(eventType: string, properties?: Record<string, unknown>): Promise<void> {\n if (!eventType) {\n throw new Error('Census: eventType is required for track()');\n }\n\n await this.request('/api/sdk/events', 'POST', {\n eventType,\n userId: this.currentUserId,\n properties,\n });\n\n this.log('Event tracked:', eventType);\n }\n\n /**\n * Track multiple events in a single request.\n * More efficient than calling track() multiple times.\n *\n * @param events - Array of events to track\n *\n * @example\n * ```typescript\n * await census.trackBatch({\n * events: [\n * { eventType: 'page_viewed', properties: { page: '/home' } },\n * { eventType: 'button_clicked', properties: { button: 'cta' } },\n * ],\n * });\n * ```\n */\n async trackBatch(options: BatchEventsOptions): Promise<void> {\n if (!options.events || options.events.length === 0) {\n throw new Error('Census: at least one event is required');\n }\n\n if (options.events.length > 100) {\n throw new Error('Census: maximum 100 events per batch');\n }\n\n const events = options.events.map((event) => ({\n eventType: event.eventType,\n userId: this.currentUserId,\n articleId: event.articleId,\n featureId: event.featureId,\n properties: event.properties,\n }));\n\n await this.request('/api/sdk/events', 'POST', { events });\n\n this.log('Batch events tracked:', options.events.length);\n }\n\n // ============================================================================\n // Guide Builder Methods\n // ============================================================================\n\n /**\n * Get published guides.\n *\n * @param options - Query options\n * @returns Guides and completion status\n *\n * @example\n * ```typescript\n * const { guides, completedGuides } = await census.getGuides({\n * url: window.location.href,\n * userId: 'user_123',\n * });\n * ```\n */\n async getGuides(options?: GuidesOptions): Promise<GuidesResponse> {\n const params = new URLSearchParams();\n if (options?.projectId) params.set('project_id', options.projectId);\n if (options?.url) params.set('url', options.url);\n if (options?.userId) params.set('user_id', options.userId);\n\n const queryString = params.toString();\n const url = `/api/sdk/guides${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<GuidesResponse>(url, 'GET');\n this.log('Fetched guides:', response.guides.length);\n return response;\n }\n\n /**\n * Get a single guide by ID.\n *\n * @param guideId - Guide ID\n * @returns Guide with steps or null if not found\n *\n * @example\n * ```typescript\n * const guide = await census.getGuide('guide_123');\n * if (guide) {\n * console.log(guide.name, guide.guide_steps.length);\n * }\n * ```\n */\n async getGuide(guideId: string): Promise<Guide | null> {\n try {\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'GET'\n );\n this.log('Fetched guide:', guideId);\n return response.guide;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Create a new guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param options - Guide creation options\n * @returns Created guide\n *\n * @example\n * ```typescript\n * const guide = await census.createGuide({\n * name: 'Welcome Tour',\n * slug: 'welcome-tour',\n * description: 'Introduction to the app',\n * triggerType: 'first_visit',\n * });\n * ```\n */\n async createGuide(options: CreateGuideOptions): Promise<Guide> {\n if (!options.name || !options.slug) {\n throw new Error('Census: name and slug are required for createGuide()');\n }\n\n const response = await this.request<{ guide: Guide }>(\n '/api/sdk/guides',\n 'POST',\n {\n name: options.name,\n slug: options.slug,\n description: options.description,\n project_id: options.projectId,\n trigger_type: options.triggerType || 'manual',\n trigger_config: options.triggerConfig || {},\n theme: options.theme || {},\n allow_skip: options.allowSkip ?? true,\n show_progress: options.showProgress ?? true,\n }\n );\n\n this.log('Guide created:', response.guide.id);\n return response.guide;\n }\n\n /**\n * Update an existing guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID to update\n * @param options - Update options\n * @returns Updated guide\n *\n * @example\n * ```typescript\n * const guide = await census.updateGuide('guide_123', {\n * name: 'Updated Tour Name',\n * status: 'published',\n * });\n * ```\n */\n async updateGuide(guideId: string, options: UpdateGuideOptions): Promise<Guide> {\n if (!guideId) {\n throw new Error('Census: guideId is required for updateGuide()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.name !== undefined) body.name = options.name;\n if (options.slug !== undefined) body.slug = options.slug;\n if (options.description !== undefined) body.description = options.description;\n if (options.triggerType !== undefined) body.trigger_type = options.triggerType;\n if (options.triggerConfig !== undefined) body.trigger_config = options.triggerConfig;\n if (options.theme !== undefined) body.theme = options.theme;\n if (options.allowSkip !== undefined) body.allow_skip = options.allowSkip;\n if (options.showProgress !== undefined) body.show_progress = options.showProgress;\n if (options.status !== undefined) body.status = options.status;\n\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'PUT',\n body\n );\n\n this.log('Guide updated:', guideId);\n return response.guide;\n }\n\n /**\n * Delete a guide.\n * Requires guides:admin scope.\n *\n * @param guideId - Guide ID to delete\n *\n * @example\n * ```typescript\n * await census.deleteGuide('guide_123');\n * ```\n */\n async deleteGuide(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for deleteGuide()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'DELETE'\n );\n\n this.log('Guide deleted:', guideId);\n }\n\n /**\n * Get steps for a guide.\n *\n * @param guideId - Guide ID\n * @returns Array of steps\n *\n * @example\n * ```typescript\n * const steps = await census.getGuideSteps('guide_123');\n * ```\n */\n async getGuideSteps(guideId: string): Promise<GuideStep[]> {\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'GET'\n );\n this.log('Fetched steps for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Add a step to a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param options - Step creation options\n * @returns Created step\n *\n * @example\n * ```typescript\n * const step = await census.addGuideStep('guide_123', {\n * stepType: 'tooltip',\n * selectorStrategy: { css: '.welcome-button' },\n * richContent: {\n * title: 'Welcome!',\n * body: 'Click here to get started',\n * },\n * });\n * ```\n */\n async addGuideStep(guideId: string, options: CreateGuideStepOptions): Promise<GuideStep> {\n if (!guideId) {\n throw new Error('Census: guideId is required for addGuideStep()');\n }\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'POST',\n {\n step_type: options.stepType || 'tooltip',\n sort_order: options.sortOrder,\n selector_strategy: options.selectorStrategy || {},\n title: options.title,\n content: options.content,\n tooltip_position: options.tooltipPosition || 'auto',\n rich_content: options.richContent || {},\n display_config: options.displayConfig || {},\n advance_config: options.advanceConfig || { trigger: 'button' },\n style_config: options.styleConfig || {},\n }\n );\n\n this.log('Step added to guide:', guideId);\n return response.step;\n }\n\n /**\n * Update a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n * @param options - Update options\n * @returns Updated step\n *\n * @example\n * ```typescript\n * const step = await census.updateGuideStep('guide_123', 'step_456', {\n * richContent: { title: 'Updated title' },\n * });\n * ```\n */\n async updateGuideStep(\n guideId: string,\n stepId: string,\n options: UpdateGuideStepOptions\n ): Promise<GuideStep> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for updateGuideStep()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.stepType !== undefined) body.step_type = options.stepType;\n if (options.sortOrder !== undefined) body.sort_order = options.sortOrder;\n if (options.selectorStrategy !== undefined) body.selector_strategy = options.selectorStrategy;\n if (options.title !== undefined) body.title = options.title;\n if (options.content !== undefined) body.content = options.content;\n if (options.tooltipPosition !== undefined) body.tooltip_position = options.tooltipPosition;\n if (options.richContent !== undefined) body.rich_content = options.richContent;\n if (options.displayConfig !== undefined) body.display_config = options.displayConfig;\n if (options.advanceConfig !== undefined) body.advance_config = options.advanceConfig;\n if (options.styleConfig !== undefined) body.style_config = options.styleConfig;\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'PUT',\n body\n );\n\n this.log('Step updated:', stepId);\n return response.step;\n }\n\n /**\n * Delete a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n *\n * @example\n * ```typescript\n * await census.deleteGuideStep('guide_123', 'step_456');\n * ```\n */\n async deleteGuideStep(guideId: string, stepId: string): Promise<void> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for deleteGuideStep()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'DELETE'\n );\n\n this.log('Step deleted:', stepId);\n }\n\n /**\n * Reorder steps in a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepOrder - Array of { id, sort_order } to define new order\n * @returns Updated steps\n *\n * @example\n * ```typescript\n * const steps = await census.reorderGuideSteps('guide_123', [\n * { id: 'step_a', sort_order: 0 },\n * { id: 'step_b', sort_order: 1 },\n * { id: 'step_c', sort_order: 2 },\n * ]);\n * ```\n */\n async reorderGuideSteps(\n guideId: string,\n stepOrder: Array<{ id: string; sort_order: number }>\n ): Promise<GuideStep[]> {\n if (!guideId) {\n throw new Error('Census: guideId is required for reorderGuideSteps()');\n }\n\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'PUT',\n { steps: stepOrder }\n );\n\n this.log('Steps reordered for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Track a guide analytics event.\n * Used to track user progress through guides.\n *\n * @param event - Guide analytics event\n *\n * @example\n * ```typescript\n * await census.trackGuideEvent({\n * guideId: 'guide_123',\n * eventType: 'step_completed',\n * stepId: 'step_456',\n * stepIndex: 2,\n * sessionId: 'session_789',\n * });\n * ```\n */\n async trackGuideEvent(event: GuideAnalyticsEvent): Promise<void> {\n if (!event.guideId || !event.eventType || !event.sessionId) {\n throw new Error('Census: guideId, eventType, and sessionId are required for trackGuideEvent()');\n }\n\n await this.request('/api/sdk/guides/events', 'POST', {\n guideId: event.guideId,\n eventType: event.eventType,\n stepId: event.stepId,\n stepIndex: event.stepIndex,\n pageUrl: event.pageUrl || (typeof window !== 'undefined' ? window.location.href : undefined),\n sessionId: event.sessionId,\n userId: event.userId || this.currentUserId,\n metadata: event.metadata,\n });\n\n this.log('Guide event tracked:', event.eventType, event.guideId);\n }\n\n /**\n * Mark a guide as completed for the current user.\n * Prevents the guide from showing again.\n *\n * @param guideId - ID of the guide to mark as completed\n *\n * @example\n * ```typescript\n * await census.markGuideCompleted('guide_123');\n * ```\n */\n async markGuideCompleted(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for markGuideCompleted()');\n }\n\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before marking guides complete. Call identify() first.');\n }\n\n await this.request('/api/sdk/guides/complete', 'POST', {\n guideId,\n userId: this.currentUserId,\n });\n\n this.log('Guide marked completed:', guideId);\n }\n\n /**\n * Get the current identified user ID\n */\n getCurrentUserId(): string | null {\n return this.currentUserId;\n }\n\n /**\n * Check if a user is currently identified\n */\n isIdentified(): boolean {\n return this.currentUserId !== null;\n }\n\n /**\n * Make an API request\n */\n private async request<T>(path: string, method: string, body?: unknown): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'X-Census-Key': this.apiKey,\n };\n\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n\n this.log(`${method} ${path}`, body);\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n let errorMessage = `Request failed with status ${response.status}`;\n try {\n const errorData = await response.json();\n errorMessage = errorData.error || errorMessage;\n } catch {\n // Use default error message\n }\n\n const error: CensusError = {\n error: errorMessage,\n status: response.status,\n };\n throw error;\n }\n\n return response.json();\n }\n\n /**\n * Log debug messages\n */\n private log(...args: unknown[]): void {\n if (this.debug) {\n console.log('[Census]', ...args);\n }\n }\n}\n\n/**\n * Create a new Census SDK client.\n *\n * @param config - Configuration options\n * @returns Census client instance\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({\n * apiKey: 'cs_live_your_key_here',\n * debug: true, // Enable debug logging\n * });\n * ```\n */\nexport function createCensus(config: CensusConfig): CensusClient {\n return new CensusClient(config);\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -103,7 +103,7 @@ interface Article {
103
103
  read_time_minutes: number | null;
104
104
  published_at: string | null;
105
105
  sort_order: number;
106
- content?: unknown;
106
+ content?: string;
107
107
  content_html?: string;
108
108
  features?: {
109
109
  id: string;
@@ -111,6 +111,36 @@ interface Article {
111
111
  slug: string;
112
112
  };
113
113
  }
114
+ /**
115
+ * A feature within a feature group
116
+ */
117
+ interface Feature {
118
+ id: string;
119
+ name: string;
120
+ slug: string;
121
+ description: string | null;
122
+ status: string;
123
+ article_count: number;
124
+ }
125
+ /**
126
+ * A feature group containing features
127
+ */
128
+ interface FeatureGroup {
129
+ id: string;
130
+ name: string;
131
+ slug: string;
132
+ description: string | null;
133
+ color: string | null;
134
+ features: Feature[];
135
+ feature_count: number;
136
+ article_count: number;
137
+ }
138
+ /**
139
+ * Response from feature groups endpoint
140
+ */
141
+ interface FeatureGroupsResponse {
142
+ feature_groups: FeatureGroup[];
143
+ }
114
144
  /**
115
145
  * Options for fetching articles
116
146
  */
@@ -782,6 +812,21 @@ declare class CensusClient {
782
812
  * ```
783
813
  */
784
814
  getArticle(slugOrId: string): Promise<Article | null>;
815
+ /**
816
+ * Fetch feature groups with their features.
817
+ * Used by the HelpCenter component for navigation.
818
+ *
819
+ * @returns Feature groups with features and article counts
820
+ *
821
+ * @example
822
+ * ```typescript
823
+ * const { feature_groups } = await census.getFeatureGroups();
824
+ * feature_groups.forEach(group => {
825
+ * console.log(group.name, group.features.length);
826
+ * });
827
+ * ```
828
+ */
829
+ getFeatureGroups(): Promise<FeatureGroupsResponse>;
785
830
  /**
786
831
  * Fetch the current user's submitted requests (feedback, bugs, feature requests).
787
832
  * Requires a user to be identified first.
package/dist/index.d.ts CHANGED
@@ -103,7 +103,7 @@ interface Article {
103
103
  read_time_minutes: number | null;
104
104
  published_at: string | null;
105
105
  sort_order: number;
106
- content?: unknown;
106
+ content?: string;
107
107
  content_html?: string;
108
108
  features?: {
109
109
  id: string;
@@ -111,6 +111,36 @@ interface Article {
111
111
  slug: string;
112
112
  };
113
113
  }
114
+ /**
115
+ * A feature within a feature group
116
+ */
117
+ interface Feature {
118
+ id: string;
119
+ name: string;
120
+ slug: string;
121
+ description: string | null;
122
+ status: string;
123
+ article_count: number;
124
+ }
125
+ /**
126
+ * A feature group containing features
127
+ */
128
+ interface FeatureGroup {
129
+ id: string;
130
+ name: string;
131
+ slug: string;
132
+ description: string | null;
133
+ color: string | null;
134
+ features: Feature[];
135
+ feature_count: number;
136
+ article_count: number;
137
+ }
138
+ /**
139
+ * Response from feature groups endpoint
140
+ */
141
+ interface FeatureGroupsResponse {
142
+ feature_groups: FeatureGroup[];
143
+ }
114
144
  /**
115
145
  * Options for fetching articles
116
146
  */
@@ -782,6 +812,21 @@ declare class CensusClient {
782
812
  * ```
783
813
  */
784
814
  getArticle(slugOrId: string): Promise<Article | null>;
815
+ /**
816
+ * Fetch feature groups with their features.
817
+ * Used by the HelpCenter component for navigation.
818
+ *
819
+ * @returns Feature groups with features and article counts
820
+ *
821
+ * @example
822
+ * ```typescript
823
+ * const { feature_groups } = await census.getFeatureGroups();
824
+ * feature_groups.forEach(group => {
825
+ * console.log(group.name, group.features.length);
826
+ * });
827
+ * ```
828
+ */
829
+ getFeatureGroups(): Promise<FeatureGroupsResponse>;
785
830
  /**
786
831
  * Fetch the current user's submitted requests (feedback, bugs, feature requests).
787
832
  * Requires a user to be identified first.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var o="https://api.census.ai",d=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(s=>e.apiKey.startsWith(s))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||o,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let t=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!t.includes(e.type))throw new Error(`Census: type must be one of: ${t.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let s=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",s.feedbackId),{feedbackId:s.feedbackId}}async getArticles(e){let t=new URLSearchParams;e?.category&&t.set("category",e.category),e?.search&&t.set("search",e.search),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=t.toString(),r=`/api/sdk/articles${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched articles:",i.articles.length),i}async getArticle(e){try{let t=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),t.article}catch(t){if(t.status===404)return null;throw t}}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let t=new URLSearchParams;t.set("userId",this.currentUserId),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=await this.request(`/api/sdk/requests?${t.toString()}`,"GET");return this.log("Fetched requests:",s.requests.length),s}async track(e,t){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:t}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let t=e.events.map(s=>({eventType:s.eventType,userId:this.currentUserId,articleId:s.articleId,featureId:s.featureId,properties:s.properties}));await this.request("/api/sdk/events","POST",{events:t}),this.log("Batch events tracked:",e.events.length);}async getGuides(e){let t=new URLSearchParams;e?.projectId&&t.set("project_id",e.projectId),e?.url&&t.set("url",e.url),e?.userId&&t.set("user_id",e.userId);let s=t.toString(),r=`/api/sdk/guides${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched guides:",i.guides.length),i}async getGuide(e){try{let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"GET");return this.log("Fetched guide:",e),t.guide}catch(t){if(t.status===404)return null;throw t}}async createGuide(e){if(!e.name||!e.slug)throw new Error("Census: name and slug are required for createGuide()");let t=await this.request("/api/sdk/guides","POST",{name:e.name,slug:e.slug,description:e.description,project_id:e.projectId,trigger_type:e.triggerType||"manual",trigger_config:e.triggerConfig||{},theme:e.theme||{},allow_skip:e.allowSkip??true,show_progress:e.showProgress??true});return this.log("Guide created:",t.guide.id),t.guide}async updateGuide(e,t){if(!e)throw new Error("Census: guideId is required for updateGuide()");let s={};t.name!==void 0&&(s.name=t.name),t.slug!==void 0&&(s.slug=t.slug),t.description!==void 0&&(s.description=t.description),t.triggerType!==void 0&&(s.trigger_type=t.triggerType),t.triggerConfig!==void 0&&(s.trigger_config=t.triggerConfig),t.theme!==void 0&&(s.theme=t.theme),t.allowSkip!==void 0&&(s.allow_skip=t.allowSkip),t.showProgress!==void 0&&(s.show_progress=t.showProgress),t.status!==void 0&&(s.status=t.status);let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"PUT",s);return this.log("Guide updated:",e),r.guide}async deleteGuide(e){if(!e)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"DELETE"),this.log("Guide deleted:",e);}async getGuideSteps(e){let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"GET");return this.log("Fetched steps for guide:",e),t.steps}async addGuideStep(e,t){if(!e)throw new Error("Census: guideId is required for addGuideStep()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"POST",{step_type:t.stepType||"tooltip",sort_order:t.sortOrder,selector_strategy:t.selectorStrategy||{},title:t.title,content:t.content,tooltip_position:t.tooltipPosition||"auto",rich_content:t.richContent||{},display_config:t.displayConfig||{},advance_config:t.advanceConfig||{trigger:"button"},style_config:t.styleConfig||{}});return this.log("Step added to guide:",e),s.step}async updateGuideStep(e,t,s){if(!e||!t)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let r={};s.stepType!==void 0&&(r.step_type=s.stepType),s.sortOrder!==void 0&&(r.sort_order=s.sortOrder),s.selectorStrategy!==void 0&&(r.selector_strategy=s.selectorStrategy),s.title!==void 0&&(r.title=s.title),s.content!==void 0&&(r.content=s.content),s.tooltipPosition!==void 0&&(r.tooltip_position=s.tooltipPosition),s.richContent!==void 0&&(r.rich_content=s.richContent),s.displayConfig!==void 0&&(r.display_config=s.displayConfig),s.advanceConfig!==void 0&&(r.advance_config=s.advanceConfig),s.styleConfig!==void 0&&(r.style_config=s.styleConfig);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"PUT",r);return this.log("Step updated:",t),i.step}async deleteGuideStep(e,t){if(!e||!t)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"DELETE"),this.log("Step deleted:",t);}async reorderGuideSteps(e,t){if(!e)throw new Error("Census: guideId is required for reorderGuideSteps()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"PUT",{steps:t});return this.log("Steps reordered for guide:",e),s.steps}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,t,s){let r=`${this.baseUrl}${e}`,i={"X-Census-Key":this.apiKey};s&&(i["Content-Type"]="application/json"),this.log(`${t} ${e}`,s);let n=await fetch(r,{method:t,headers:i,body:s?JSON.stringify(s):void 0});if(!n.ok){let a=`Request failed with status ${n.status}`;try{a=(await n.json()).error||a;}catch{}throw {error:a,status:n.status}}return n.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function c(u){return new d(u)}
1
+ var o="https://api.census.ai",d=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(s=>e.apiKey.startsWith(s))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||o,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let t=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!t.includes(e.type))throw new Error(`Census: type must be one of: ${t.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let s=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",s.feedbackId),{feedbackId:s.feedbackId}}async getArticles(e){let t=new URLSearchParams;e?.category&&t.set("category",e.category),e?.search&&t.set("search",e.search),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=t.toString(),r=`/api/sdk/articles${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched articles:",i.articles.length),i}async getArticle(e){try{let t=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),t.article}catch(t){if(t.status===404)return null;throw t}}async getFeatureGroups(){let e=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",e.feature_groups.length),e}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let t=new URLSearchParams;t.set("userId",this.currentUserId),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=await this.request(`/api/sdk/requests?${t.toString()}`,"GET");return this.log("Fetched requests:",s.requests.length),s}async track(e,t){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:t}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let t=e.events.map(s=>({eventType:s.eventType,userId:this.currentUserId,articleId:s.articleId,featureId:s.featureId,properties:s.properties}));await this.request("/api/sdk/events","POST",{events:t}),this.log("Batch events tracked:",e.events.length);}async getGuides(e){let t=new URLSearchParams;e?.projectId&&t.set("project_id",e.projectId),e?.url&&t.set("url",e.url),e?.userId&&t.set("user_id",e.userId);let s=t.toString(),r=`/api/sdk/guides${s?`?${s}`:""}`,i=await this.request(r,"GET");return this.log("Fetched guides:",i.guides.length),i}async getGuide(e){try{let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"GET");return this.log("Fetched guide:",e),t.guide}catch(t){if(t.status===404)return null;throw t}}async createGuide(e){if(!e.name||!e.slug)throw new Error("Census: name and slug are required for createGuide()");let t=await this.request("/api/sdk/guides","POST",{name:e.name,slug:e.slug,description:e.description,project_id:e.projectId,trigger_type:e.triggerType||"manual",trigger_config:e.triggerConfig||{},theme:e.theme||{},allow_skip:e.allowSkip??true,show_progress:e.showProgress??true});return this.log("Guide created:",t.guide.id),t.guide}async updateGuide(e,t){if(!e)throw new Error("Census: guideId is required for updateGuide()");let s={};t.name!==void 0&&(s.name=t.name),t.slug!==void 0&&(s.slug=t.slug),t.description!==void 0&&(s.description=t.description),t.triggerType!==void 0&&(s.trigger_type=t.triggerType),t.triggerConfig!==void 0&&(s.trigger_config=t.triggerConfig),t.theme!==void 0&&(s.theme=t.theme),t.allowSkip!==void 0&&(s.allow_skip=t.allowSkip),t.showProgress!==void 0&&(s.show_progress=t.showProgress),t.status!==void 0&&(s.status=t.status);let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"PUT",s);return this.log("Guide updated:",e),r.guide}async deleteGuide(e){if(!e)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"DELETE"),this.log("Guide deleted:",e);}async getGuideSteps(e){let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"GET");return this.log("Fetched steps for guide:",e),t.steps}async addGuideStep(e,t){if(!e)throw new Error("Census: guideId is required for addGuideStep()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"POST",{step_type:t.stepType||"tooltip",sort_order:t.sortOrder,selector_strategy:t.selectorStrategy||{},title:t.title,content:t.content,tooltip_position:t.tooltipPosition||"auto",rich_content:t.richContent||{},display_config:t.displayConfig||{},advance_config:t.advanceConfig||{trigger:"button"},style_config:t.styleConfig||{}});return this.log("Step added to guide:",e),s.step}async updateGuideStep(e,t,s){if(!e||!t)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let r={};s.stepType!==void 0&&(r.step_type=s.stepType),s.sortOrder!==void 0&&(r.sort_order=s.sortOrder),s.selectorStrategy!==void 0&&(r.selector_strategy=s.selectorStrategy),s.title!==void 0&&(r.title=s.title),s.content!==void 0&&(r.content=s.content),s.tooltipPosition!==void 0&&(r.tooltip_position=s.tooltipPosition),s.richContent!==void 0&&(r.rich_content=s.richContent),s.displayConfig!==void 0&&(r.display_config=s.displayConfig),s.advanceConfig!==void 0&&(r.advance_config=s.advanceConfig),s.styleConfig!==void 0&&(r.style_config=s.styleConfig);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"PUT",r);return this.log("Step updated:",t),i.step}async deleteGuideStep(e,t){if(!e||!t)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"DELETE"),this.log("Step deleted:",t);}async reorderGuideSteps(e,t){if(!e)throw new Error("Census: guideId is required for reorderGuideSteps()");let s=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"PUT",{steps:t});return this.log("Steps reordered for guide:",e),s.steps}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,t,s){let r=`${this.baseUrl}${e}`,i={"X-Census-Key":this.apiKey};s&&(i["Content-Type"]="application/json"),this.log(`${t} ${e}`,s);let n=await fetch(r,{method:t,headers:i,body:s?JSON.stringify(s):void 0});if(!n.ok){let a=`Request failed with status ${n.status}`;try{a=(await n.json()).error||a;}catch{}throw {error:a,status:n.status}}return n.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function c(u){return new d(u)}
2
2
  export{d as CensusClient,c as createCensus};//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":["DEFAULT_BASE_URL","CensusClient","config","prefix","user","options","validTypes","response","params","queryString","url","slugOrId","error","eventType","properties","events","event","guideId","body","stepId","stepOrder","path","method","headers","errorMessage","args","createCensus"],"mappings":"AAyBA,IAAMA,EAAmB,uBAAA,CAkBZC,CAAAA,CAAN,KAAmB,CAMxB,YAAYC,CAAAA,CAAsB,CAFlC,IAAA,CAAQ,aAAA,CAA+B,KAGrC,GAAI,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D,OAAO,IAAID,CAAAA,CAAaC,CAAM,CAChC","file":"index.js","sourcesContent":["import type {\n CensusConfig,\n UserIdentity,\n FeedbackOptions,\n ArticlesOptions,\n ArticlesResponse,\n Article,\n RequestsOptions,\n RequestsResponse,\n BatchEventsOptions,\n CensusError,\n Guide,\n GuideStep,\n GuidesOptions,\n GuidesResponse,\n GuideAnalyticsEvent,\n CreateGuideOptions,\n UpdateGuideOptions,\n CreateGuideStepOptions,\n UpdateGuideStepOptions,\n} from './types';\n\n/**\n * Default API base URL\n */\nconst DEFAULT_BASE_URL = 'https://api.census.ai';\n\n/**\n * Census SDK Client\n *\n * The main client for interacting with the Census API.\n * Use `createCensus()` to create an instance.\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({ apiKey: 'cs_live_xxx' });\n *\n * await census.identify({ userId: 'user_123', email: 'user@example.com' });\n * await census.submitFeedback({ type: 'bug_report', message: 'Button is broken' });\n * ```\n */\nexport class CensusClient {\n private apiKey: string;\n private baseUrl: string;\n private debug: boolean;\n private currentUserId: string | null = null;\n\n constructor(config: CensusConfig) {\n if (!config.apiKey) {\n throw new Error('Census: apiKey is required');\n }\n\n // Support both new (cs_) and legacy (op_) key prefixes\n const validPrefixes = ['cs_live_', 'cs_test_', 'op_live_', 'op_test_'];\n if (!validPrefixes.some(prefix => config.apiKey.startsWith(prefix))) {\n console.warn('Census: API key should start with \"cs_live_\" or \"cs_test_\"');\n }\n\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n this.debug = config.debug || false;\n\n this.log('Initialized with base URL:', this.baseUrl);\n }\n\n /**\n * Identify a user for tracking purposes.\n * Call this when a user logs in or when you have user information.\n *\n * @param user - User identity information\n *\n * @example\n * ```typescript\n * await census.identify({\n * userId: 'user_123',\n * email: 'john@example.com',\n * name: 'John Doe',\n * organizationId: 'org_456',\n * organizationName: 'Acme Inc',\n * });\n * ```\n */\n async identify(user: UserIdentity): Promise<void> {\n if (!user.userId) {\n throw new Error('Census: userId is required for identify()');\n }\n\n this.currentUserId = user.userId;\n\n await this.request('/api/sdk/identify', 'POST', {\n userId: user.userId,\n email: user.email,\n name: user.name,\n avatarUrl: user.avatarUrl,\n metadata: user.metadata,\n organizationId: user.organizationId,\n organizationName: user.organizationName,\n organizationDomain: user.organizationDomain,\n organizationPlan: user.organizationPlan,\n });\n\n this.log('User identified:', user.userId);\n }\n\n /**\n * Clear the current user identity.\n * Call this when a user logs out.\n */\n reset(): void {\n this.currentUserId = null;\n this.log('User identity reset');\n }\n\n /**\n * Submit feedback, bug report, or feature request.\n *\n * @param options - Feedback options\n *\n * @example\n * ```typescript\n * // Submit a bug report\n * await census.submitFeedback({\n * type: 'bug_report',\n * message: 'The submit button is not working on Firefox',\n * });\n *\n * // Submit a feature request\n * await census.submitFeedback({\n * type: 'feature_request',\n * message: 'It would be great to have dark mode support',\n * });\n *\n * // Rate an article\n * await census.submitFeedback({\n * type: 'article_rating',\n * articleId: 'article_123',\n * helpful: true,\n * rating: 5,\n * });\n * ```\n */\n async submitFeedback(options: FeedbackOptions): Promise<{ feedbackId: string }> {\n const validTypes = ['feedback', 'bug_report', 'feature_request', 'article_rating'];\n if (!options.type || !validTypes.includes(options.type)) {\n throw new Error(`Census: type must be one of: ${validTypes.join(', ')}`);\n }\n\n if (options.type === 'article_rating') {\n if (options.rating === undefined && options.helpful === undefined) {\n throw new Error('Census: article_rating requires rating or helpful field');\n }\n } else if (!options.message) {\n throw new Error('Census: message is required for this feedback type');\n }\n\n const response = await this.request<{ success: boolean; feedbackId: string }>(\n '/api/sdk/feedback',\n 'POST',\n {\n type: options.type,\n message: options.message,\n rating: options.rating,\n helpful: options.helpful,\n userId: this.currentUserId,\n articleId: options.articleId,\n pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n metadata: options.metadata,\n }\n );\n\n this.log('Feedback submitted:', response.feedbackId);\n return { feedbackId: response.feedbackId };\n }\n\n /**\n * Fetch published articles from the knowledge base.\n *\n * @param options - Query options\n * @returns Articles and pagination info\n *\n * @example\n * ```typescript\n * // Get all articles\n * const { articles } = await census.getArticles();\n *\n * // Search articles\n * const { articles } = await census.getArticles({ search: 'getting started' });\n *\n * // Filter by category\n * const { articles } = await census.getArticles({ category: 'guides' });\n * ```\n */\n async getArticles(options?: ArticlesOptions): Promise<ArticlesResponse> {\n const params = new URLSearchParams();\n if (options?.category) params.set('category', options.category);\n if (options?.search) params.set('search', options.search);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const queryString = params.toString();\n const url = `/api/sdk/articles${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<ArticlesResponse>(url, 'GET');\n this.log('Fetched articles:', response.articles.length);\n return response;\n }\n\n /**\n * Fetch a single article by slug or ID.\n *\n * @param slugOrId - Article slug or ID\n * @returns Article or null if not found\n *\n * @example\n * ```typescript\n * const article = await census.getArticle('getting-started');\n * if (article) {\n * console.log(article.title, article.content_html);\n * }\n * ```\n */\n async getArticle(slugOrId: string): Promise<Article | null> {\n try {\n const response = await this.request<{ article: Article }>(\n `/api/sdk/articles/${encodeURIComponent(slugOrId)}`,\n 'GET'\n );\n this.log('Fetched article:', slugOrId);\n return response.article;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch the current user's submitted requests (feedback, bugs, feature requests).\n * Requires a user to be identified first.\n *\n * @param options - Query options\n * @returns Requests and pagination info\n *\n * @example\n * ```typescript\n * // Get all requests for the current user\n * const { requests } = await census.getRequests();\n *\n * // Filter by status\n * const { requests } = await census.getRequests({ status: 'in_progress' });\n *\n * // Filter by type\n * const { requests } = await census.getRequests({ type: 'bug_report' });\n * ```\n */\n async getRequests(options?: RequestsOptions): Promise<RequestsResponse> {\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before fetching requests. Call identify() first.');\n }\n\n const params = new URLSearchParams();\n params.set('userId', this.currentUserId);\n if (options?.status) params.set('status', options.status);\n if (options?.type) params.set('type', options.type);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const response = await this.request<RequestsResponse>(\n `/api/sdk/requests?${params.toString()}`,\n 'GET'\n );\n this.log('Fetched requests:', response.requests.length);\n return response;\n }\n\n /**\n * Track a custom analytics event.\n *\n * @param eventType - Name of the event\n * @param properties - Additional event properties\n *\n * @example\n * ```typescript\n * // Track a button click\n * await census.track('button_clicked', { buttonId: 'submit-form' });\n *\n * // Track a page view\n * await census.track('page_viewed', { page: '/pricing' });\n * ```\n */\n async track(eventType: string, properties?: Record<string, unknown>): Promise<void> {\n if (!eventType) {\n throw new Error('Census: eventType is required for track()');\n }\n\n await this.request('/api/sdk/events', 'POST', {\n eventType,\n userId: this.currentUserId,\n properties,\n });\n\n this.log('Event tracked:', eventType);\n }\n\n /**\n * Track multiple events in a single request.\n * More efficient than calling track() multiple times.\n *\n * @param events - Array of events to track\n *\n * @example\n * ```typescript\n * await census.trackBatch({\n * events: [\n * { eventType: 'page_viewed', properties: { page: '/home' } },\n * { eventType: 'button_clicked', properties: { button: 'cta' } },\n * ],\n * });\n * ```\n */\n async trackBatch(options: BatchEventsOptions): Promise<void> {\n if (!options.events || options.events.length === 0) {\n throw new Error('Census: at least one event is required');\n }\n\n if (options.events.length > 100) {\n throw new Error('Census: maximum 100 events per batch');\n }\n\n const events = options.events.map((event) => ({\n eventType: event.eventType,\n userId: this.currentUserId,\n articleId: event.articleId,\n featureId: event.featureId,\n properties: event.properties,\n }));\n\n await this.request('/api/sdk/events', 'POST', { events });\n\n this.log('Batch events tracked:', options.events.length);\n }\n\n // ============================================================================\n // Guide Builder Methods\n // ============================================================================\n\n /**\n * Get published guides.\n *\n * @param options - Query options\n * @returns Guides and completion status\n *\n * @example\n * ```typescript\n * const { guides, completedGuides } = await census.getGuides({\n * url: window.location.href,\n * userId: 'user_123',\n * });\n * ```\n */\n async getGuides(options?: GuidesOptions): Promise<GuidesResponse> {\n const params = new URLSearchParams();\n if (options?.projectId) params.set('project_id', options.projectId);\n if (options?.url) params.set('url', options.url);\n if (options?.userId) params.set('user_id', options.userId);\n\n const queryString = params.toString();\n const url = `/api/sdk/guides${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<GuidesResponse>(url, 'GET');\n this.log('Fetched guides:', response.guides.length);\n return response;\n }\n\n /**\n * Get a single guide by ID.\n *\n * @param guideId - Guide ID\n * @returns Guide with steps or null if not found\n *\n * @example\n * ```typescript\n * const guide = await census.getGuide('guide_123');\n * if (guide) {\n * console.log(guide.name, guide.guide_steps.length);\n * }\n * ```\n */\n async getGuide(guideId: string): Promise<Guide | null> {\n try {\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'GET'\n );\n this.log('Fetched guide:', guideId);\n return response.guide;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Create a new guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param options - Guide creation options\n * @returns Created guide\n *\n * @example\n * ```typescript\n * const guide = await census.createGuide({\n * name: 'Welcome Tour',\n * slug: 'welcome-tour',\n * description: 'Introduction to the app',\n * triggerType: 'first_visit',\n * });\n * ```\n */\n async createGuide(options: CreateGuideOptions): Promise<Guide> {\n if (!options.name || !options.slug) {\n throw new Error('Census: name and slug are required for createGuide()');\n }\n\n const response = await this.request<{ guide: Guide }>(\n '/api/sdk/guides',\n 'POST',\n {\n name: options.name,\n slug: options.slug,\n description: options.description,\n project_id: options.projectId,\n trigger_type: options.triggerType || 'manual',\n trigger_config: options.triggerConfig || {},\n theme: options.theme || {},\n allow_skip: options.allowSkip ?? true,\n show_progress: options.showProgress ?? true,\n }\n );\n\n this.log('Guide created:', response.guide.id);\n return response.guide;\n }\n\n /**\n * Update an existing guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID to update\n * @param options - Update options\n * @returns Updated guide\n *\n * @example\n * ```typescript\n * const guide = await census.updateGuide('guide_123', {\n * name: 'Updated Tour Name',\n * status: 'published',\n * });\n * ```\n */\n async updateGuide(guideId: string, options: UpdateGuideOptions): Promise<Guide> {\n if (!guideId) {\n throw new Error('Census: guideId is required for updateGuide()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.name !== undefined) body.name = options.name;\n if (options.slug !== undefined) body.slug = options.slug;\n if (options.description !== undefined) body.description = options.description;\n if (options.triggerType !== undefined) body.trigger_type = options.triggerType;\n if (options.triggerConfig !== undefined) body.trigger_config = options.triggerConfig;\n if (options.theme !== undefined) body.theme = options.theme;\n if (options.allowSkip !== undefined) body.allow_skip = options.allowSkip;\n if (options.showProgress !== undefined) body.show_progress = options.showProgress;\n if (options.status !== undefined) body.status = options.status;\n\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'PUT',\n body\n );\n\n this.log('Guide updated:', guideId);\n return response.guide;\n }\n\n /**\n * Delete a guide.\n * Requires guides:admin scope.\n *\n * @param guideId - Guide ID to delete\n *\n * @example\n * ```typescript\n * await census.deleteGuide('guide_123');\n * ```\n */\n async deleteGuide(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for deleteGuide()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'DELETE'\n );\n\n this.log('Guide deleted:', guideId);\n }\n\n /**\n * Get steps for a guide.\n *\n * @param guideId - Guide ID\n * @returns Array of steps\n *\n * @example\n * ```typescript\n * const steps = await census.getGuideSteps('guide_123');\n * ```\n */\n async getGuideSteps(guideId: string): Promise<GuideStep[]> {\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'GET'\n );\n this.log('Fetched steps for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Add a step to a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param options - Step creation options\n * @returns Created step\n *\n * @example\n * ```typescript\n * const step = await census.addGuideStep('guide_123', {\n * stepType: 'tooltip',\n * selectorStrategy: { css: '.welcome-button' },\n * richContent: {\n * title: 'Welcome!',\n * body: 'Click here to get started',\n * },\n * });\n * ```\n */\n async addGuideStep(guideId: string, options: CreateGuideStepOptions): Promise<GuideStep> {\n if (!guideId) {\n throw new Error('Census: guideId is required for addGuideStep()');\n }\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'POST',\n {\n step_type: options.stepType || 'tooltip',\n sort_order: options.sortOrder,\n selector_strategy: options.selectorStrategy || {},\n title: options.title,\n content: options.content,\n tooltip_position: options.tooltipPosition || 'auto',\n rich_content: options.richContent || {},\n display_config: options.displayConfig || {},\n advance_config: options.advanceConfig || { trigger: 'button' },\n style_config: options.styleConfig || {},\n }\n );\n\n this.log('Step added to guide:', guideId);\n return response.step;\n }\n\n /**\n * Update a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n * @param options - Update options\n * @returns Updated step\n *\n * @example\n * ```typescript\n * const step = await census.updateGuideStep('guide_123', 'step_456', {\n * richContent: { title: 'Updated title' },\n * });\n * ```\n */\n async updateGuideStep(\n guideId: string,\n stepId: string,\n options: UpdateGuideStepOptions\n ): Promise<GuideStep> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for updateGuideStep()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.stepType !== undefined) body.step_type = options.stepType;\n if (options.sortOrder !== undefined) body.sort_order = options.sortOrder;\n if (options.selectorStrategy !== undefined) body.selector_strategy = options.selectorStrategy;\n if (options.title !== undefined) body.title = options.title;\n if (options.content !== undefined) body.content = options.content;\n if (options.tooltipPosition !== undefined) body.tooltip_position = options.tooltipPosition;\n if (options.richContent !== undefined) body.rich_content = options.richContent;\n if (options.displayConfig !== undefined) body.display_config = options.displayConfig;\n if (options.advanceConfig !== undefined) body.advance_config = options.advanceConfig;\n if (options.styleConfig !== undefined) body.style_config = options.styleConfig;\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'PUT',\n body\n );\n\n this.log('Step updated:', stepId);\n return response.step;\n }\n\n /**\n * Delete a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n *\n * @example\n * ```typescript\n * await census.deleteGuideStep('guide_123', 'step_456');\n * ```\n */\n async deleteGuideStep(guideId: string, stepId: string): Promise<void> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for deleteGuideStep()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'DELETE'\n );\n\n this.log('Step deleted:', stepId);\n }\n\n /**\n * Reorder steps in a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepOrder - Array of { id, sort_order } to define new order\n * @returns Updated steps\n *\n * @example\n * ```typescript\n * const steps = await census.reorderGuideSteps('guide_123', [\n * { id: 'step_a', sort_order: 0 },\n * { id: 'step_b', sort_order: 1 },\n * { id: 'step_c', sort_order: 2 },\n * ]);\n * ```\n */\n async reorderGuideSteps(\n guideId: string,\n stepOrder: Array<{ id: string; sort_order: number }>\n ): Promise<GuideStep[]> {\n if (!guideId) {\n throw new Error('Census: guideId is required for reorderGuideSteps()');\n }\n\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'PUT',\n { steps: stepOrder }\n );\n\n this.log('Steps reordered for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Track a guide analytics event.\n * Used to track user progress through guides.\n *\n * @param event - Guide analytics event\n *\n * @example\n * ```typescript\n * await census.trackGuideEvent({\n * guideId: 'guide_123',\n * eventType: 'step_completed',\n * stepId: 'step_456',\n * stepIndex: 2,\n * sessionId: 'session_789',\n * });\n * ```\n */\n async trackGuideEvent(event: GuideAnalyticsEvent): Promise<void> {\n if (!event.guideId || !event.eventType || !event.sessionId) {\n throw new Error('Census: guideId, eventType, and sessionId are required for trackGuideEvent()');\n }\n\n await this.request('/api/sdk/guides/events', 'POST', {\n guideId: event.guideId,\n eventType: event.eventType,\n stepId: event.stepId,\n stepIndex: event.stepIndex,\n pageUrl: event.pageUrl || (typeof window !== 'undefined' ? window.location.href : undefined),\n sessionId: event.sessionId,\n userId: event.userId || this.currentUserId,\n metadata: event.metadata,\n });\n\n this.log('Guide event tracked:', event.eventType, event.guideId);\n }\n\n /**\n * Mark a guide as completed for the current user.\n * Prevents the guide from showing again.\n *\n * @param guideId - ID of the guide to mark as completed\n *\n * @example\n * ```typescript\n * await census.markGuideCompleted('guide_123');\n * ```\n */\n async markGuideCompleted(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for markGuideCompleted()');\n }\n\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before marking guides complete. Call identify() first.');\n }\n\n await this.request('/api/sdk/guides/complete', 'POST', {\n guideId,\n userId: this.currentUserId,\n });\n\n this.log('Guide marked completed:', guideId);\n }\n\n /**\n * Get the current identified user ID\n */\n getCurrentUserId(): string | null {\n return this.currentUserId;\n }\n\n /**\n * Check if a user is currently identified\n */\n isIdentified(): boolean {\n return this.currentUserId !== null;\n }\n\n /**\n * Make an API request\n */\n private async request<T>(path: string, method: string, body?: unknown): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'X-Census-Key': this.apiKey,\n };\n\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n\n this.log(`${method} ${path}`, body);\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n let errorMessage = `Request failed with status ${response.status}`;\n try {\n const errorData = await response.json();\n errorMessage = errorData.error || errorMessage;\n } catch {\n // Use default error message\n }\n\n const error: CensusError = {\n error: errorMessage,\n status: response.status,\n };\n throw error;\n }\n\n return response.json();\n }\n\n /**\n * Log debug messages\n */\n private log(...args: unknown[]): void {\n if (this.debug) {\n console.log('[Census]', ...args);\n }\n }\n}\n\n/**\n * Create a new Census SDK client.\n *\n * @param config - Configuration options\n * @returns Census client instance\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({\n * apiKey: 'cs_live_your_key_here',\n * debug: true, // Enable debug logging\n * });\n * ```\n */\nexport function createCensus(config: CensusConfig): CensusClient {\n return new CensusClient(config);\n}\n"]}
1
+ {"version":3,"sources":["../src/client.ts"],"names":["DEFAULT_BASE_URL","CensusClient","config","prefix","user","options","validTypes","response","params","queryString","url","slugOrId","error","eventType","properties","events","event","guideId","body","stepId","stepOrder","path","method","headers","errorMessage","args","createCensus"],"mappings":"AA0BA,IAAMA,EAAmB,uBAAA,CAkBZC,CAAAA,CAAN,KAAmB,CAMxB,YAAYC,CAAAA,CAAsB,CAFlC,IAAA,CAAQ,aAAA,CAA+B,KAGrC,GAAI,CAACA,EAAO,MAAA,CACV,MAAM,IAAI,KAAA,CAAM,4BAA4B,CAAA,CAIxB,CAAC,WAAY,UAAA,CAAY,UAAA,CAAY,UAAU,CAAA,CAClD,KAAKC,CAAAA,EAAUD,CAAAA,CAAO,MAAA,CAAO,UAAA,CAAWC,CAAM,CAAC,CAAA,EAChE,QAAQ,IAAA,CAAK,4DAA4D,EAG3E,IAAA,CAAK,MAAA,CAASD,CAAAA,CAAO,MAAA,CACrB,KAAK,OAAA,CAAUA,CAAAA,CAAO,OAAA,EAAWF,CAAAA,CACjC,KAAK,KAAA,CAAQE,CAAAA,CAAO,KAAA,EAAS,KAAA,CAE7B,KAAK,GAAA,CAAI,4BAAA,CAA8B,KAAK,OAAO,EACrD,CAmBA,MAAM,QAAA,CAASE,CAAAA,CAAmC,CAChD,GAAI,CAACA,CAAAA,CAAK,OACR,MAAM,IAAI,MAAM,2CAA2C,CAAA,CAG7D,IAAA,CAAK,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AA,CAAI,CAAA,EAAGD,CAAM,IAAID,CAAI,CAAA,CAAA,CAAIH,CAAI,CAAA,CAElC,IAAMX,CAAAA,CAAW,MAAM,KAAA,CAAMG,CAAAA,CAAK,CAChC,MAAA,CAAAY,CAAAA,CACA,QAAAC,CAAAA,CACA,IAAA,CAAML,EAAO,IAAA,CAAK,SAAA,CAAUA,CAAI,CAAA,CAAI,MACtC,CAAC,CAAA,CAED,GAAI,CAACX,CAAAA,CAAS,GAAI,CAChB,IAAIiB,CAAAA,CAAe,CAAA,2BAAA,EAA8BjB,EAAS,MAAM,CAAA,CAAA,CAChE,GAAI,CAEFiB,CAAAA,CAAAA,CADkB,MAAMjB,CAAAA,CAAS,IAAA,EAAK,EACb,KAAA,EAASiB,EACpC,CAAA,KAAQ,CAER,CAMA,MAJ2B,CACzB,KAAA,CAAOA,CAAAA,CACP,MAAA,CAAQjB,CAAAA,CAAS,MACnB,CAEF,CAEA,OAAOA,CAAAA,CAAS,IAAA,EAClB,CAKQ,GAAA,CAAA,GAAOkB,CAAAA,CAAuB,CAChC,KAAK,KAAA,EACP,OAAA,CAAQ,IAAI,UAAA,CAAY,GAAGA,CAAI,EAEnC,CACF,EAkBO,SAASC,EAAaxB,CAAAA,CAAoC,CAC/D,OAAO,IAAID,CAAAA,CAAaC,CAAM,CAChC","file":"index.js","sourcesContent":["import type {\n CensusConfig,\n UserIdentity,\n FeedbackOptions,\n ArticlesOptions,\n ArticlesResponse,\n Article,\n FeatureGroupsResponse,\n RequestsOptions,\n RequestsResponse,\n BatchEventsOptions,\n CensusError,\n Guide,\n GuideStep,\n GuidesOptions,\n GuidesResponse,\n GuideAnalyticsEvent,\n CreateGuideOptions,\n UpdateGuideOptions,\n CreateGuideStepOptions,\n UpdateGuideStepOptions,\n} from './types';\n\n/**\n * Default API base URL\n */\nconst DEFAULT_BASE_URL = 'https://api.census.ai';\n\n/**\n * Census SDK Client\n *\n * The main client for interacting with the Census API.\n * Use `createCensus()` to create an instance.\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({ apiKey: 'cs_live_xxx' });\n *\n * await census.identify({ userId: 'user_123', email: 'user@example.com' });\n * await census.submitFeedback({ type: 'bug_report', message: 'Button is broken' });\n * ```\n */\nexport class CensusClient {\n private apiKey: string;\n private baseUrl: string;\n private debug: boolean;\n private currentUserId: string | null = null;\n\n constructor(config: CensusConfig) {\n if (!config.apiKey) {\n throw new Error('Census: apiKey is required');\n }\n\n // Support both new (cs_) and legacy (op_) key prefixes\n const validPrefixes = ['cs_live_', 'cs_test_', 'op_live_', 'op_test_'];\n if (!validPrefixes.some(prefix => config.apiKey.startsWith(prefix))) {\n console.warn('Census: API key should start with \"cs_live_\" or \"cs_test_\"');\n }\n\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n this.debug = config.debug || false;\n\n this.log('Initialized with base URL:', this.baseUrl);\n }\n\n /**\n * Identify a user for tracking purposes.\n * Call this when a user logs in or when you have user information.\n *\n * @param user - User identity information\n *\n * @example\n * ```typescript\n * await census.identify({\n * userId: 'user_123',\n * email: 'john@example.com',\n * name: 'John Doe',\n * organizationId: 'org_456',\n * organizationName: 'Acme Inc',\n * });\n * ```\n */\n async identify(user: UserIdentity): Promise<void> {\n if (!user.userId) {\n throw new Error('Census: userId is required for identify()');\n }\n\n this.currentUserId = user.userId;\n\n await this.request('/api/sdk/identify', 'POST', {\n userId: user.userId,\n email: user.email,\n name: user.name,\n avatarUrl: user.avatarUrl,\n metadata: user.metadata,\n organizationId: user.organizationId,\n organizationName: user.organizationName,\n organizationDomain: user.organizationDomain,\n organizationPlan: user.organizationPlan,\n });\n\n this.log('User identified:', user.userId);\n }\n\n /**\n * Clear the current user identity.\n * Call this when a user logs out.\n */\n reset(): void {\n this.currentUserId = null;\n this.log('User identity reset');\n }\n\n /**\n * Submit feedback, bug report, or feature request.\n *\n * @param options - Feedback options\n *\n * @example\n * ```typescript\n * // Submit a bug report\n * await census.submitFeedback({\n * type: 'bug_report',\n * message: 'The submit button is not working on Firefox',\n * });\n *\n * // Submit a feature request\n * await census.submitFeedback({\n * type: 'feature_request',\n * message: 'It would be great to have dark mode support',\n * });\n *\n * // Rate an article\n * await census.submitFeedback({\n * type: 'article_rating',\n * articleId: 'article_123',\n * helpful: true,\n * rating: 5,\n * });\n * ```\n */\n async submitFeedback(options: FeedbackOptions): Promise<{ feedbackId: string }> {\n const validTypes = ['feedback', 'bug_report', 'feature_request', 'article_rating'];\n if (!options.type || !validTypes.includes(options.type)) {\n throw new Error(`Census: type must be one of: ${validTypes.join(', ')}`);\n }\n\n if (options.type === 'article_rating') {\n if (options.rating === undefined && options.helpful === undefined) {\n throw new Error('Census: article_rating requires rating or helpful field');\n }\n } else if (!options.message) {\n throw new Error('Census: message is required for this feedback type');\n }\n\n const response = await this.request<{ success: boolean; feedbackId: string }>(\n '/api/sdk/feedback',\n 'POST',\n {\n type: options.type,\n message: options.message,\n rating: options.rating,\n helpful: options.helpful,\n userId: this.currentUserId,\n articleId: options.articleId,\n pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n metadata: options.metadata,\n }\n );\n\n this.log('Feedback submitted:', response.feedbackId);\n return { feedbackId: response.feedbackId };\n }\n\n /**\n * Fetch published articles from the knowledge base.\n *\n * @param options - Query options\n * @returns Articles and pagination info\n *\n * @example\n * ```typescript\n * // Get all articles\n * const { articles } = await census.getArticles();\n *\n * // Search articles\n * const { articles } = await census.getArticles({ search: 'getting started' });\n *\n * // Filter by category\n * const { articles } = await census.getArticles({ category: 'guides' });\n * ```\n */\n async getArticles(options?: ArticlesOptions): Promise<ArticlesResponse> {\n const params = new URLSearchParams();\n if (options?.category) params.set('category', options.category);\n if (options?.search) params.set('search', options.search);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const queryString = params.toString();\n const url = `/api/sdk/articles${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<ArticlesResponse>(url, 'GET');\n this.log('Fetched articles:', response.articles.length);\n return response;\n }\n\n /**\n * Fetch a single article by slug or ID.\n *\n * @param slugOrId - Article slug or ID\n * @returns Article or null if not found\n *\n * @example\n * ```typescript\n * const article = await census.getArticle('getting-started');\n * if (article) {\n * console.log(article.title, article.content_html);\n * }\n * ```\n */\n async getArticle(slugOrId: string): Promise<Article | null> {\n try {\n const response = await this.request<{ article: Article }>(\n `/api/sdk/articles/${encodeURIComponent(slugOrId)}`,\n 'GET'\n );\n this.log('Fetched article:', slugOrId);\n return response.article;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch feature groups with their features.\n * Used by the HelpCenter component for navigation.\n *\n * @returns Feature groups with features and article counts\n *\n * @example\n * ```typescript\n * const { feature_groups } = await census.getFeatureGroups();\n * feature_groups.forEach(group => {\n * console.log(group.name, group.features.length);\n * });\n * ```\n */\n async getFeatureGroups(): Promise<FeatureGroupsResponse> {\n const response = await this.request<FeatureGroupsResponse>(\n '/api/sdk/feature-groups',\n 'GET'\n );\n this.log('Fetched feature groups:', response.feature_groups.length);\n return response;\n }\n\n /**\n * Fetch the current user's submitted requests (feedback, bugs, feature requests).\n * Requires a user to be identified first.\n *\n * @param options - Query options\n * @returns Requests and pagination info\n *\n * @example\n * ```typescript\n * // Get all requests for the current user\n * const { requests } = await census.getRequests();\n *\n * // Filter by status\n * const { requests } = await census.getRequests({ status: 'in_progress' });\n *\n * // Filter by type\n * const { requests } = await census.getRequests({ type: 'bug_report' });\n * ```\n */\n async getRequests(options?: RequestsOptions): Promise<RequestsResponse> {\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before fetching requests. Call identify() first.');\n }\n\n const params = new URLSearchParams();\n params.set('userId', this.currentUserId);\n if (options?.status) params.set('status', options.status);\n if (options?.type) params.set('type', options.type);\n if (options?.limit) params.set('limit', String(options.limit));\n if (options?.offset) params.set('offset', String(options.offset));\n\n const response = await this.request<RequestsResponse>(\n `/api/sdk/requests?${params.toString()}`,\n 'GET'\n );\n this.log('Fetched requests:', response.requests.length);\n return response;\n }\n\n /**\n * Track a custom analytics event.\n *\n * @param eventType - Name of the event\n * @param properties - Additional event properties\n *\n * @example\n * ```typescript\n * // Track a button click\n * await census.track('button_clicked', { buttonId: 'submit-form' });\n *\n * // Track a page view\n * await census.track('page_viewed', { page: '/pricing' });\n * ```\n */\n async track(eventType: string, properties?: Record<string, unknown>): Promise<void> {\n if (!eventType) {\n throw new Error('Census: eventType is required for track()');\n }\n\n await this.request('/api/sdk/events', 'POST', {\n eventType,\n userId: this.currentUserId,\n properties,\n });\n\n this.log('Event tracked:', eventType);\n }\n\n /**\n * Track multiple events in a single request.\n * More efficient than calling track() multiple times.\n *\n * @param events - Array of events to track\n *\n * @example\n * ```typescript\n * await census.trackBatch({\n * events: [\n * { eventType: 'page_viewed', properties: { page: '/home' } },\n * { eventType: 'button_clicked', properties: { button: 'cta' } },\n * ],\n * });\n * ```\n */\n async trackBatch(options: BatchEventsOptions): Promise<void> {\n if (!options.events || options.events.length === 0) {\n throw new Error('Census: at least one event is required');\n }\n\n if (options.events.length > 100) {\n throw new Error('Census: maximum 100 events per batch');\n }\n\n const events = options.events.map((event) => ({\n eventType: event.eventType,\n userId: this.currentUserId,\n articleId: event.articleId,\n featureId: event.featureId,\n properties: event.properties,\n }));\n\n await this.request('/api/sdk/events', 'POST', { events });\n\n this.log('Batch events tracked:', options.events.length);\n }\n\n // ============================================================================\n // Guide Builder Methods\n // ============================================================================\n\n /**\n * Get published guides.\n *\n * @param options - Query options\n * @returns Guides and completion status\n *\n * @example\n * ```typescript\n * const { guides, completedGuides } = await census.getGuides({\n * url: window.location.href,\n * userId: 'user_123',\n * });\n * ```\n */\n async getGuides(options?: GuidesOptions): Promise<GuidesResponse> {\n const params = new URLSearchParams();\n if (options?.projectId) params.set('project_id', options.projectId);\n if (options?.url) params.set('url', options.url);\n if (options?.userId) params.set('user_id', options.userId);\n\n const queryString = params.toString();\n const url = `/api/sdk/guides${queryString ? `?${queryString}` : ''}`;\n\n const response = await this.request<GuidesResponse>(url, 'GET');\n this.log('Fetched guides:', response.guides.length);\n return response;\n }\n\n /**\n * Get a single guide by ID.\n *\n * @param guideId - Guide ID\n * @returns Guide with steps or null if not found\n *\n * @example\n * ```typescript\n * const guide = await census.getGuide('guide_123');\n * if (guide) {\n * console.log(guide.name, guide.guide_steps.length);\n * }\n * ```\n */\n async getGuide(guideId: string): Promise<Guide | null> {\n try {\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'GET'\n );\n this.log('Fetched guide:', guideId);\n return response.guide;\n } catch (error) {\n if ((error as CensusError).status === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Create a new guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param options - Guide creation options\n * @returns Created guide\n *\n * @example\n * ```typescript\n * const guide = await census.createGuide({\n * name: 'Welcome Tour',\n * slug: 'welcome-tour',\n * description: 'Introduction to the app',\n * triggerType: 'first_visit',\n * });\n * ```\n */\n async createGuide(options: CreateGuideOptions): Promise<Guide> {\n if (!options.name || !options.slug) {\n throw new Error('Census: name and slug are required for createGuide()');\n }\n\n const response = await this.request<{ guide: Guide }>(\n '/api/sdk/guides',\n 'POST',\n {\n name: options.name,\n slug: options.slug,\n description: options.description,\n project_id: options.projectId,\n trigger_type: options.triggerType || 'manual',\n trigger_config: options.triggerConfig || {},\n theme: options.theme || {},\n allow_skip: options.allowSkip ?? true,\n show_progress: options.showProgress ?? true,\n }\n );\n\n this.log('Guide created:', response.guide.id);\n return response.guide;\n }\n\n /**\n * Update an existing guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID to update\n * @param options - Update options\n * @returns Updated guide\n *\n * @example\n * ```typescript\n * const guide = await census.updateGuide('guide_123', {\n * name: 'Updated Tour Name',\n * status: 'published',\n * });\n * ```\n */\n async updateGuide(guideId: string, options: UpdateGuideOptions): Promise<Guide> {\n if (!guideId) {\n throw new Error('Census: guideId is required for updateGuide()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.name !== undefined) body.name = options.name;\n if (options.slug !== undefined) body.slug = options.slug;\n if (options.description !== undefined) body.description = options.description;\n if (options.triggerType !== undefined) body.trigger_type = options.triggerType;\n if (options.triggerConfig !== undefined) body.trigger_config = options.triggerConfig;\n if (options.theme !== undefined) body.theme = options.theme;\n if (options.allowSkip !== undefined) body.allow_skip = options.allowSkip;\n if (options.showProgress !== undefined) body.show_progress = options.showProgress;\n if (options.status !== undefined) body.status = options.status;\n\n const response = await this.request<{ guide: Guide }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'PUT',\n body\n );\n\n this.log('Guide updated:', guideId);\n return response.guide;\n }\n\n /**\n * Delete a guide.\n * Requires guides:admin scope.\n *\n * @param guideId - Guide ID to delete\n *\n * @example\n * ```typescript\n * await census.deleteGuide('guide_123');\n * ```\n */\n async deleteGuide(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for deleteGuide()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}`,\n 'DELETE'\n );\n\n this.log('Guide deleted:', guideId);\n }\n\n /**\n * Get steps for a guide.\n *\n * @param guideId - Guide ID\n * @returns Array of steps\n *\n * @example\n * ```typescript\n * const steps = await census.getGuideSteps('guide_123');\n * ```\n */\n async getGuideSteps(guideId: string): Promise<GuideStep[]> {\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'GET'\n );\n this.log('Fetched steps for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Add a step to a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param options - Step creation options\n * @returns Created step\n *\n * @example\n * ```typescript\n * const step = await census.addGuideStep('guide_123', {\n * stepType: 'tooltip',\n * selectorStrategy: { css: '.welcome-button' },\n * richContent: {\n * title: 'Welcome!',\n * body: 'Click here to get started',\n * },\n * });\n * ```\n */\n async addGuideStep(guideId: string, options: CreateGuideStepOptions): Promise<GuideStep> {\n if (!guideId) {\n throw new Error('Census: guideId is required for addGuideStep()');\n }\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'POST',\n {\n step_type: options.stepType || 'tooltip',\n sort_order: options.sortOrder,\n selector_strategy: options.selectorStrategy || {},\n title: options.title,\n content: options.content,\n tooltip_position: options.tooltipPosition || 'auto',\n rich_content: options.richContent || {},\n display_config: options.displayConfig || {},\n advance_config: options.advanceConfig || { trigger: 'button' },\n style_config: options.styleConfig || {},\n }\n );\n\n this.log('Step added to guide:', guideId);\n return response.step;\n }\n\n /**\n * Update a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n * @param options - Update options\n * @returns Updated step\n *\n * @example\n * ```typescript\n * const step = await census.updateGuideStep('guide_123', 'step_456', {\n * richContent: { title: 'Updated title' },\n * });\n * ```\n */\n async updateGuideStep(\n guideId: string,\n stepId: string,\n options: UpdateGuideStepOptions\n ): Promise<GuideStep> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for updateGuideStep()');\n }\n\n const body: Record<string, unknown> = {};\n if (options.stepType !== undefined) body.step_type = options.stepType;\n if (options.sortOrder !== undefined) body.sort_order = options.sortOrder;\n if (options.selectorStrategy !== undefined) body.selector_strategy = options.selectorStrategy;\n if (options.title !== undefined) body.title = options.title;\n if (options.content !== undefined) body.content = options.content;\n if (options.tooltipPosition !== undefined) body.tooltip_position = options.tooltipPosition;\n if (options.richContent !== undefined) body.rich_content = options.richContent;\n if (options.displayConfig !== undefined) body.display_config = options.displayConfig;\n if (options.advanceConfig !== undefined) body.advance_config = options.advanceConfig;\n if (options.styleConfig !== undefined) body.style_config = options.styleConfig;\n\n const response = await this.request<{ step: GuideStep }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'PUT',\n body\n );\n\n this.log('Step updated:', stepId);\n return response.step;\n }\n\n /**\n * Delete a guide step.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepId - Step ID\n *\n * @example\n * ```typescript\n * await census.deleteGuideStep('guide_123', 'step_456');\n * ```\n */\n async deleteGuideStep(guideId: string, stepId: string): Promise<void> {\n if (!guideId || !stepId) {\n throw new Error('Census: guideId and stepId are required for deleteGuideStep()');\n }\n\n await this.request(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps/${encodeURIComponent(stepId)}`,\n 'DELETE'\n );\n\n this.log('Step deleted:', stepId);\n }\n\n /**\n * Reorder steps in a guide.\n * Requires guides:create or guides:admin scope.\n *\n * @param guideId - Guide ID\n * @param stepOrder - Array of { id, sort_order } to define new order\n * @returns Updated steps\n *\n * @example\n * ```typescript\n * const steps = await census.reorderGuideSteps('guide_123', [\n * { id: 'step_a', sort_order: 0 },\n * { id: 'step_b', sort_order: 1 },\n * { id: 'step_c', sort_order: 2 },\n * ]);\n * ```\n */\n async reorderGuideSteps(\n guideId: string,\n stepOrder: Array<{ id: string; sort_order: number }>\n ): Promise<GuideStep[]> {\n if (!guideId) {\n throw new Error('Census: guideId is required for reorderGuideSteps()');\n }\n\n const response = await this.request<{ steps: GuideStep[] }>(\n `/api/sdk/guides/${encodeURIComponent(guideId)}/steps`,\n 'PUT',\n { steps: stepOrder }\n );\n\n this.log('Steps reordered for guide:', guideId);\n return response.steps;\n }\n\n /**\n * Track a guide analytics event.\n * Used to track user progress through guides.\n *\n * @param event - Guide analytics event\n *\n * @example\n * ```typescript\n * await census.trackGuideEvent({\n * guideId: 'guide_123',\n * eventType: 'step_completed',\n * stepId: 'step_456',\n * stepIndex: 2,\n * sessionId: 'session_789',\n * });\n * ```\n */\n async trackGuideEvent(event: GuideAnalyticsEvent): Promise<void> {\n if (!event.guideId || !event.eventType || !event.sessionId) {\n throw new Error('Census: guideId, eventType, and sessionId are required for trackGuideEvent()');\n }\n\n await this.request('/api/sdk/guides/events', 'POST', {\n guideId: event.guideId,\n eventType: event.eventType,\n stepId: event.stepId,\n stepIndex: event.stepIndex,\n pageUrl: event.pageUrl || (typeof window !== 'undefined' ? window.location.href : undefined),\n sessionId: event.sessionId,\n userId: event.userId || this.currentUserId,\n metadata: event.metadata,\n });\n\n this.log('Guide event tracked:', event.eventType, event.guideId);\n }\n\n /**\n * Mark a guide as completed for the current user.\n * Prevents the guide from showing again.\n *\n * @param guideId - ID of the guide to mark as completed\n *\n * @example\n * ```typescript\n * await census.markGuideCompleted('guide_123');\n * ```\n */\n async markGuideCompleted(guideId: string): Promise<void> {\n if (!guideId) {\n throw new Error('Census: guideId is required for markGuideCompleted()');\n }\n\n if (!this.currentUserId) {\n throw new Error('Census: User must be identified before marking guides complete. Call identify() first.');\n }\n\n await this.request('/api/sdk/guides/complete', 'POST', {\n guideId,\n userId: this.currentUserId,\n });\n\n this.log('Guide marked completed:', guideId);\n }\n\n /**\n * Get the current identified user ID\n */\n getCurrentUserId(): string | null {\n return this.currentUserId;\n }\n\n /**\n * Check if a user is currently identified\n */\n isIdentified(): boolean {\n return this.currentUserId !== null;\n }\n\n /**\n * Make an API request\n */\n private async request<T>(path: string, method: string, body?: unknown): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'X-Census-Key': this.apiKey,\n };\n\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n\n this.log(`${method} ${path}`, body);\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n let errorMessage = `Request failed with status ${response.status}`;\n try {\n const errorData = await response.json();\n errorMessage = errorData.error || errorMessage;\n } catch {\n // Use default error message\n }\n\n const error: CensusError = {\n error: errorMessage,\n status: response.status,\n };\n throw error;\n }\n\n return response.json();\n }\n\n /**\n * Log debug messages\n */\n private log(...args: unknown[]): void {\n if (this.debug) {\n console.log('[Census]', ...args);\n }\n }\n}\n\n/**\n * Create a new Census SDK client.\n *\n * @param config - Configuration options\n * @returns Census client instance\n *\n * @example\n * ```typescript\n * import { createCensus } from '@census-ai/census-sdk';\n *\n * const census = createCensus({\n * apiKey: 'cs_live_your_key_here',\n * debug: true, // Enable debug logging\n * });\n * ```\n */\nexport function createCensus(config: CensusConfig): CensusClient {\n return new CensusClient(config);\n}\n"]}