@survicate/survicate-web-package 28.1.3-npm → 28.1.13-npm
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/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +33 -0
- package/package.json +1 -1
- package/survicate_widget.d.ts +395 -7
- package/survicate_widget.js +1 -1
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="46016ead-299b-4c15-88ab-980c8fc8f909" name="Changes" comment="" />
|
|
5
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
6
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
7
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
8
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
9
|
+
</component>
|
|
10
|
+
<component name="ProjectColorInfo"><![CDATA[{
|
|
11
|
+
"customColor": "",
|
|
12
|
+
"associatedIndex": 1
|
|
13
|
+
}]]></component>
|
|
14
|
+
<component name="ProjectId" id="31rws5QAPkeU87u5d1oUWJwqf16" />
|
|
15
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
16
|
+
"keyToString": {
|
|
17
|
+
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
|
18
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
19
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
20
|
+
"last_opened_file_path": "/Users/janjaniak"
|
|
21
|
+
}
|
|
22
|
+
}]]></component>
|
|
23
|
+
<component name="TaskManager">
|
|
24
|
+
<task active="true" id="Default" summary="Default task">
|
|
25
|
+
<changelist id="46016ead-299b-4c15-88ab-980c8fc8f909" name="Changes" comment="" />
|
|
26
|
+
<created>1756295748045</created>
|
|
27
|
+
<option name="number" value="Default" />
|
|
28
|
+
<option name="presentableId" value="Default" />
|
|
29
|
+
<updated>1756295748045</updated>
|
|
30
|
+
</task>
|
|
31
|
+
<servers />
|
|
32
|
+
</component>
|
|
33
|
+
</project>
|
package/package.json
CHANGED
package/survicate_widget.d.ts
CHANGED
|
@@ -1,106 +1,494 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Survicate JavaScript SDK Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file contains TypeScript definitions for the Survicate JavaScript SDK,
|
|
5
|
+
* which allows you to collect feedback from your website and web app users.
|
|
6
|
+
* The SDK enables you to trigger surveys to understand your users
|
|
7
|
+
* better and collect feedback about your product or service.
|
|
8
|
+
*
|
|
9
|
+
* @see https://developers.survicate.com/javascript/methods/
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Callback function type for general survey events
|
|
14
|
+
* @param surveyId - The unique identifier of the survey
|
|
15
|
+
* @param answer - Optional answer data (for completion events)
|
|
16
|
+
*/
|
|
1
17
|
type CallbackType = (surveyId: string, answer?: any) => void;
|
|
2
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Callback function type for question answered events
|
|
21
|
+
* @param surveyId - The unique identifier of the survey
|
|
22
|
+
* @param questionId - The unique identifier of the question that was answered
|
|
23
|
+
* @param answer - The answer data provided by the user
|
|
24
|
+
*/
|
|
3
25
|
type QuestionAnsweredCallback = (surveyId: string, questionId: number, answer: any) => void;
|
|
4
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Valid attribute value types that can be set for visitor traits
|
|
29
|
+
* Please note that Date is serialized to ISO string
|
|
30
|
+
*/
|
|
5
31
|
type AttributeValue = string | number | boolean | Date;
|
|
6
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Interface for visitor attributes/traits
|
|
35
|
+
* Allows setting custom properties for visitor identification and targeting
|
|
36
|
+
*/
|
|
7
37
|
interface VisitorAttributes {
|
|
8
38
|
[key: string]: AttributeValue;
|
|
9
39
|
}
|
|
10
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Union type for all possible callback types
|
|
43
|
+
*/
|
|
11
44
|
export type CallbackTypes = CallbackType | QuestionAnsweredCallback;
|
|
12
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Enumeration of available survey types in Survicate
|
|
48
|
+
*/
|
|
13
49
|
export enum SurveyType {
|
|
50
|
+
/** Website or in-product surveys */
|
|
14
51
|
WidgetSurvey = 'WidgetSurvey',
|
|
52
|
+
/** Email or shareable link surveys */
|
|
15
53
|
PageSurvey = 'PageSurvey',
|
|
54
|
+
/** Mobile survey for mobile apps */
|
|
16
55
|
MobileSurvey = 'MobileSurvey',
|
|
56
|
+
/** Feedback button survey */
|
|
17
57
|
FeedbackButton = 'FeedbackButton',
|
|
58
|
+
/** Intercom integrated surveys */
|
|
18
59
|
IntercomSurvey = 'IntercomSurvey',
|
|
19
60
|
}
|
|
20
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Options for controlling how a survey is displayed
|
|
64
|
+
*/
|
|
21
65
|
export interface ShowSurveyOptions {
|
|
66
|
+
/** Force display the survey regardless of targeting rules */
|
|
22
67
|
forceDisplay?: boolean;
|
|
68
|
+
/** Method used to display the survey */
|
|
23
69
|
displayMethod?: AppearMethodApi;
|
|
70
|
+
/** Additional display configuration options */
|
|
24
71
|
displayOptions?: {
|
|
72
|
+
/** Delay in seconds before showing the survey */
|
|
25
73
|
delay?: number;
|
|
74
|
+
/** Percentage of page scrolled before showing the survey */
|
|
26
75
|
scrolledPercentage?: number;
|
|
27
76
|
};
|
|
28
77
|
}
|
|
29
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Available methods for survey appearance
|
|
81
|
+
*/
|
|
30
82
|
export enum AppearMethodApi {
|
|
83
|
+
/** Show survey immediately */
|
|
31
84
|
immediately = 'immediately',
|
|
85
|
+
/** Show survey after a delay */
|
|
32
86
|
delayed = 'delayed',
|
|
87
|
+
/** Show survey on exit intent (when user tries to leave) */
|
|
33
88
|
exitIntent = 'exitIntent',
|
|
89
|
+
/** Show survey when user scrolls to a certain point */
|
|
34
90
|
scroll = 'onScroll',
|
|
35
91
|
}
|
|
36
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Available API events that can be listened to
|
|
95
|
+
*/
|
|
37
96
|
export enum ApiEvents {
|
|
97
|
+
/** Fired when a user answers a question */
|
|
38
98
|
questionAnswered = 'question_answered',
|
|
99
|
+
/** Fired when a survey is displayed to the user */
|
|
39
100
|
surveyDisplayed = 'survey_displayed',
|
|
101
|
+
/** Fired when a survey is completed */
|
|
40
102
|
surveyCompleted = 'survey_completed',
|
|
103
|
+
/** Fired when a survey is closed without completion */
|
|
41
104
|
surveyClosed = 'survey_closed',
|
|
42
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Configuration model for initializing the Survicate SDK
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```javascript
|
|
112
|
+
* const config = {
|
|
113
|
+
* workspaceKey: 'your-workspace-key',
|
|
114
|
+
* traits: { user_id: '123', plan: 'premium' },
|
|
115
|
+
* hiddenSurveys: ['survey-1', 'survey-2'],
|
|
116
|
+
* nonce: 'your-csp-nonce'
|
|
117
|
+
* };
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
43
120
|
export interface ConfigModel {
|
|
121
|
+
/** Disable targeting rules and show surveys to all visitors */
|
|
44
122
|
disableTargeting?: true;
|
|
123
|
+
/** Disable persistence of sensitive visitor data */
|
|
45
124
|
disableSensitiveDataPersistence?: boolean;
|
|
125
|
+
/** Array of survey IDs to hide from targeting */
|
|
46
126
|
hiddenSurveys?: string[];
|
|
127
|
+
/** Content Security Policy nonce for script injection */
|
|
47
128
|
nonce?: string;
|
|
48
|
-
|
|
129
|
+
/** Initial visitor traits/attributes to set */
|
|
130
|
+
traits?: VisitorAttributes;
|
|
131
|
+
/** Your Survicate workspace key that can be found here https://panel.survicate.com/o/0/w/0/settings/access-keys*/
|
|
49
132
|
workspaceKey: string;
|
|
50
133
|
}
|
|
51
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Available answer types for survey questions
|
|
137
|
+
*/
|
|
52
138
|
export enum SurveyQuestionAnswerType {
|
|
139
|
+
/** Single choice question with radio buttons */
|
|
53
140
|
single = 'single',
|
|
141
|
+
/** Multiple choice question with checkboxes */
|
|
142
|
+
multiple = 'multiple',
|
|
143
|
+
/** Text input question for free-form responses */
|
|
54
144
|
text = 'text',
|
|
145
|
+
/** Smiley scale question */
|
|
146
|
+
smileyScale = 'smiley_scale',
|
|
147
|
+
/** Date question */
|
|
148
|
+
date = 'date',
|
|
149
|
+
/** Rating question (stars,hearts, thumbs up/down, etc.) */
|
|
55
150
|
rating = 'rating',
|
|
151
|
+
/** Dropdown list question */
|
|
152
|
+
dropdown = 'dropdown_list',
|
|
153
|
+
/** Matrix question for multiple related questions */
|
|
154
|
+
matrix = 'matrix',
|
|
155
|
+
/** Ranking question for ordering preferences */
|
|
56
156
|
ranking = 'ranking',
|
|
157
|
+
/** Numerical scale question (1-10, etc.) */
|
|
57
158
|
numericalScale = 'numerical_scale',
|
|
159
|
+
/** Customer satisfaction question */
|
|
58
160
|
customerSatisfaction = 'csat',
|
|
59
161
|
}
|
|
60
162
|
|
|
163
|
+
/**
|
|
164
|
+
* NPS (Net Promoter Score) answer type
|
|
165
|
+
*/
|
|
61
166
|
export enum SurveyNpsAnswerType {
|
|
167
|
+
/** Net Promoter Score question */
|
|
62
168
|
nps = 'nps',
|
|
63
169
|
}
|
|
64
170
|
|
|
171
|
+
/**
|
|
172
|
+
* CTA (Call to Action) answer types
|
|
173
|
+
*/
|
|
174
|
+
export enum SurveyCtaAnswerType {
|
|
175
|
+
/** Next button */
|
|
176
|
+
button = 'button_next',
|
|
177
|
+
/** Thank you message */
|
|
178
|
+
thankYouMessage = 'empty',
|
|
179
|
+
/** Link button */
|
|
180
|
+
buttonLink = 'button_link',
|
|
181
|
+
/** Close button */
|
|
182
|
+
buttonClose = 'button_close',
|
|
183
|
+
/** Redirect with timeout */
|
|
184
|
+
redirect = 'redirect_timeout',
|
|
185
|
+
/** Social media CTA */
|
|
186
|
+
social = 'social_cta',
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Information about a survey point (question)
|
|
191
|
+
*/
|
|
65
192
|
export interface SurveyPointInfo {
|
|
193
|
+
/** Unique identifier of the survey point */
|
|
66
194
|
pointId: number;
|
|
67
|
-
|
|
195
|
+
/** Type of answer expected for this point */
|
|
196
|
+
answerType: SurveyQuestionAnswerType | SurveyNpsAnswerType | SurveyCtaAnswerType;
|
|
197
|
+
/** Available answer options (for choice-based questions) */
|
|
68
198
|
answers?: Array<{ id: number }>;
|
|
69
199
|
}
|
|
70
200
|
|
|
71
201
|
export interface SurveyApi {
|
|
72
|
-
|
|
73
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Add an event listener for survey events
|
|
204
|
+
* @param event - The event type to listen for
|
|
205
|
+
* @param callback - Function to call when the event occurs
|
|
206
|
+
* @returns Event listener ID for removal
|
|
207
|
+
*/
|
|
208
|
+
addEventListener: (event: typeof ApiEvents, callback: CallbackTypes) => number | void;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Destroy the current visitor session and reset all data
|
|
212
|
+
* @param callback - Optional callback to execute after destruction
|
|
213
|
+
*/
|
|
214
|
+
destroyVisitor: (callback?: () => void) => Promise<void>;
|
|
215
|
+
|
|
216
|
+
/** Disable targeting set in the Survicate panel */
|
|
74
217
|
disableTargeting?: boolean;
|
|
218
|
+
|
|
219
|
+
/** Whether sensitive data persistence is disabled */
|
|
220
|
+
disableSensitiveDataPersistence?: boolean;
|
|
221
|
+
|
|
222
|
+
/** Array of survey IDs to hide from targeting */
|
|
223
|
+
hiddenSurveys?: string[];
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get the unique visitor ID for the specified survey type
|
|
227
|
+
* @param surveyType - Optional survey type to get visitor ID for
|
|
228
|
+
* @returns Unique visitor identifier
|
|
229
|
+
*/
|
|
75
230
|
getVisitorId: (surveyType?: SurveyType) => string;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Get metadata about survey points (questions)
|
|
234
|
+
*
|
|
235
|
+
* This method returns information about all questions in a survey,
|
|
236
|
+
* including their types and available answer options.
|
|
237
|
+
*
|
|
238
|
+
* @param surveyId - ID of the survey to get metadata for
|
|
239
|
+
* @returns Array of survey point information or null if survey not found
|
|
240
|
+
*/
|
|
241
|
+
getSurveyPointsMetadata: (surveyId: string) => SurveyPointInfo[] | null;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Invoke a custom event that can be used for targeting
|
|
245
|
+
* @param eventName - Name of the custom event
|
|
246
|
+
* @param eventProperties - Optional properties to attach to the event
|
|
247
|
+
*/
|
|
76
248
|
invokeEvent: (eventName: string, eventProperties?: Record<string, string>) => void;
|
|
77
|
-
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Remove an event listener
|
|
252
|
+
* @param eventId - Event listener ID or event type to remove
|
|
253
|
+
*/
|
|
254
|
+
removeEventListener: (eventId: number | typeof ApiEvents) => void;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Re-evaluate targeting rules and show surveys if conditions are met
|
|
258
|
+
*/
|
|
78
259
|
retarget: () => void;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Set visitor traits/attributes for targeting and identification
|
|
263
|
+
* @param attributes - Object containing visitor attributes
|
|
264
|
+
*/
|
|
79
265
|
setVisitorTraits: (attributes: VisitorAttributes) => void;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Manually trigger a survey to be displayed
|
|
269
|
+
* @param id - Survey ID to display
|
|
270
|
+
* @param options - Display options for the survey
|
|
271
|
+
* @returns Whether the survey was successfully triggered
|
|
272
|
+
*/
|
|
80
273
|
showSurvey: (id: string, options: ShowSurveyOptions) => boolean;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Submit an answer to a survey question programmatically
|
|
277
|
+
*
|
|
278
|
+
* This method allows you to submit answers to the following survey questions:
|
|
279
|
+
* Text, Single, Rating, Numerical, CSAT and NPS.
|
|
280
|
+
* without user interaction, useful for integrations or testing.
|
|
281
|
+
*
|
|
282
|
+
* @param params - Object containing survey, point, and answer information
|
|
283
|
+
*/
|
|
284
|
+
submitAnswer: (params: {
|
|
285
|
+
/** Survey ID */
|
|
286
|
+
surveyId: string;
|
|
287
|
+
/** Question/point ID */
|
|
288
|
+
pointId: number;
|
|
289
|
+
/** Answer option ID (for single choice questions) */
|
|
290
|
+
answerId?: number;
|
|
291
|
+
/** Answer value (for text or numeric questions) */
|
|
292
|
+
answer?: string | number;
|
|
293
|
+
}) => void;
|
|
294
|
+
|
|
295
|
+
/** Current visitor traits/attributes */
|
|
81
296
|
traits?: VisitorAttributes;
|
|
82
297
|
}
|
|
83
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Global Survicate object providing access to all SDK functionality
|
|
301
|
+
*
|
|
302
|
+
* This is the main entry point for the Survicate JavaScript SDK.
|
|
303
|
+
* It provides methods for initializing the SDK, managing surveys,
|
|
304
|
+
* handling visitor data, and responding to survey events.
|
|
305
|
+
*/
|
|
84
306
|
declare const Survicate: {
|
|
307
|
+
/** Enumeration of available API events */
|
|
85
308
|
ApiEvent: typeof ApiEvents;
|
|
309
|
+
|
|
310
|
+
/** Enumeration of available appear methods */
|
|
86
311
|
AppearMethod: typeof AppearMethodApi;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Add an event listener for survey events
|
|
315
|
+
*
|
|
316
|
+
* Listen for events like survey display, completion, question answers, etc.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```javascript
|
|
320
|
+
* Survicate.addEventListener(Survicate.ApiEvent.surveyCompleted, (surveyId) => {
|
|
321
|
+
* console.log(`Survey ${surveyId} was completed`);
|
|
322
|
+
* });
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @param event - The event type to listen for
|
|
326
|
+
* @param callback - Function to call when the event occurs
|
|
327
|
+
* @returns Event listener ID for removal
|
|
328
|
+
*/
|
|
87
329
|
addEventListener: (event: ApiEvents, callback: CallbackTypes) => number | void;
|
|
88
|
-
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Destroy the current visitor session and reset all data
|
|
333
|
+
*
|
|
334
|
+
* This method clears all visitor data, resets the visit counter,
|
|
335
|
+
* and reinitializes the visitor with a new session. Useful for
|
|
336
|
+
* testing or when you want to start fresh with a new visitor.
|
|
337
|
+
*
|
|
338
|
+
* @param callback - Optional callback to execute after destruction
|
|
339
|
+
*/
|
|
340
|
+
destroyVisitor: (callback?: () => void) => Promise<void>;
|
|
341
|
+
|
|
342
|
+
/** Disable targeting set in the Survicate panel */
|
|
89
343
|
disableTargeting?: boolean;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Get the unique visitor ID for the specified survey type
|
|
347
|
+
*
|
|
348
|
+
* Each visitor gets a unique identifier that persists across sessions.
|
|
349
|
+
* This ID is used for tracking visitor behavior and ensuring survey targeting.
|
|
350
|
+
*
|
|
351
|
+
* @param surveyType - Optional survey type (Widget or Feedback Button) to get visitor ID for
|
|
352
|
+
* @returns Unique visitor identifier
|
|
353
|
+
*/
|
|
90
354
|
getVisitorId: (surveyType?: SurveyType) => string;
|
|
91
|
-
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Initialize the Survicate SDK with configuration
|
|
358
|
+
*
|
|
359
|
+
* This method must be called before using any other SDK functionality.
|
|
360
|
+
* It loads survey data, sets up event listeners, and prepares the SDK
|
|
361
|
+
* for use.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```javascript
|
|
365
|
+
* await Survicate.init({
|
|
366
|
+
* workspaceKey: 'your-workspace-key',
|
|
367
|
+
* traits: { user_id: '123', plan: 'premium' }
|
|
368
|
+
* });
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* @param config - Configuration object for the SDK
|
|
372
|
+
* @returns Promise that resolves when initialization is complete
|
|
373
|
+
*/
|
|
374
|
+
init: (config: ConfigModel) => Promise<void>;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Invoke a custom event that can be used for targeting
|
|
378
|
+
*
|
|
379
|
+
* Custom events can be used in survey targeting rules to show
|
|
380
|
+
* surveys based on specific user actions or behaviors.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```javascript
|
|
384
|
+
* Survicate.invokeEvent('purchase_completed', {
|
|
385
|
+
* amount: '99.99',
|
|
386
|
+
* product: 'premium_plan'
|
|
387
|
+
* });
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @param eventName - Name of the custom event
|
|
391
|
+
* @param eventProperties - Optional properties to attach to the event
|
|
392
|
+
*/
|
|
92
393
|
invokeEvent: (eventName: string, eventProperties?: Record<string, string>) => void;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Remove an event listener
|
|
397
|
+
*
|
|
398
|
+
* Use this method to clean up event listeners when they're no longer needed.
|
|
399
|
+
*
|
|
400
|
+
* @param eventId - Event listener ID or event type to remove
|
|
401
|
+
*/
|
|
93
402
|
removeEventListener: (eventId: number | ApiEvents) => void;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Re-evaluate targeting rules and show surveys if conditions are met
|
|
406
|
+
*
|
|
407
|
+
* This method rechecks all targeting rules for available surveys
|
|
408
|
+
* and displays them if the current visitor meets the criteria.
|
|
409
|
+
* Useful after setting new visitor traits or invoking events.
|
|
410
|
+
*/
|
|
94
411
|
retarget: () => void;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Set visitor traits/attributes for targeting and identification
|
|
415
|
+
*
|
|
416
|
+
* Visitor traits are used for survey targeting and can include for example
|
|
417
|
+
* information like user ID, plan type, location, etc.
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```javascript
|
|
421
|
+
* Survicate.setVisitorTraits({
|
|
422
|
+
* user_id: '12345',
|
|
423
|
+
* plan: 'premium',
|
|
424
|
+
* country: 'US',
|
|
425
|
+
* is_subscriber: true
|
|
426
|
+
* });
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @param attributes - Object containing visitor attributes
|
|
430
|
+
*/
|
|
95
431
|
setVisitorTraits: (attributes: VisitorAttributes) => void;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Manually trigger a survey to be displayed
|
|
435
|
+
*
|
|
436
|
+
* This method allows you to programmatically show a specific survey,
|
|
437
|
+
* bypassing normal targeting rules if forceDisplay is set to true.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```javascript
|
|
441
|
+
* // Show survey immediately
|
|
442
|
+
* Survicate.showSurvey('survey-123', {
|
|
443
|
+
* forceDisplay: true,
|
|
444
|
+
* displayMethod: Survicate.AppearMethod.immediately
|
|
445
|
+
* });
|
|
446
|
+
*
|
|
447
|
+
* // Show survey after 5 seconds
|
|
448
|
+
* Survicate.showSurvey('survey-123', {
|
|
449
|
+
* displayMethod: Survicate.AppearMethod.delayed,
|
|
450
|
+
* displayOptions: { delay: 5000 }
|
|
451
|
+
* });
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* @param id - Survey ID to display
|
|
455
|
+
* @param options - Display options for the survey
|
|
456
|
+
* @returns Whether the survey was successfully triggered
|
|
457
|
+
*/
|
|
96
458
|
showSurvey: (id: string, options: ShowSurveyOptions) => boolean;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Submit an answer to a survey question programmatically
|
|
462
|
+
*
|
|
463
|
+
* This method allows you to submit answers to the following survey questions:
|
|
464
|
+
* Text, Single, Rating, Numerical, CSAT and NPS.
|
|
465
|
+
* without user interaction, useful for integrations or testing.
|
|
466
|
+
*
|
|
467
|
+
* @param params - Object containing survey, point, and answer information
|
|
468
|
+
*/
|
|
97
469
|
submitAnswer: (params: {
|
|
470
|
+
/** Survey ID */
|
|
98
471
|
surveyId: string;
|
|
472
|
+
/** Question/point ID */
|
|
99
473
|
pointId: number;
|
|
474
|
+
/** Answer option ID (for single choice questions) */
|
|
100
475
|
answerId: number;
|
|
476
|
+
/** Answer value (for text or numeric questions) */
|
|
101
477
|
answer: string | number;
|
|
102
478
|
}) => void;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Get metadata about survey points (questions)
|
|
482
|
+
*
|
|
483
|
+
* This method returns information about all questions in a survey,
|
|
484
|
+
* including their types and available answer options.
|
|
485
|
+
*
|
|
486
|
+
* @param surveyId - ID of the survey to get metadata for
|
|
487
|
+
* @returns Array of survey point information or null if survey not found
|
|
488
|
+
*/
|
|
103
489
|
getSurveyPointsMetadata: (surveyId: string) => SurveyPointInfo[] | null;
|
|
490
|
+
|
|
491
|
+
/** Current visitor traits/attributes */
|
|
104
492
|
traits?: VisitorAttributes;
|
|
105
493
|
};
|
|
106
494
|
|