@survicate/survicate-web-package 21.0.0-npm → 21.0.1-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/README.md CHANGED
@@ -7,14 +7,24 @@ It's built on top of [Preact](https://github.com/preactjs/preact) using [Typescr
7
7
 
8
8
 
9
9
  # Initialization
10
- Find your workspace key under *settings > survey settings > web surveys* in the [Survicate Panel](https://panel.survicate.com/).
10
+ Find your workspace key in the [Survicate Panel](https://panel.survicate.com/o/0/w/0/settings/access-keys).
11
11
 
12
12
  ```
13
13
  import Survicate from '@survicate/survicate-web-package/survicate_widget'
14
14
 
15
- Survicate.init({workspaceKey: `${key}`});
15
+ const key = "..." // Your key from the panel
16
+ Survicate.init({workspaceKey: key});
16
17
  ```
17
18
 
18
19
  # Available methods
20
+ All available methods can be found in our [documentation](https://developers.survicate.com/javascript/methods/).
19
21
 
20
- All available methods can be found in our [documentation](https://developers.survicate.com/javascript/methods/).
22
+
23
+ ## Examples:
24
+
25
+ Based on the respondent's interaction with our surveys you can trigger actions in your app or website:
26
+
27
+ ```
28
+ Survicate.addEventListener(Survicate.ApiEvent.questionAnswered, () => console.log("question answered"));
29
+
30
+ ```
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
- "version": "21.0.0-npm",
2
+ "version": "21.0.1-npm",
3
3
  "name": "@survicate/survicate-web-package",
4
4
  "description": "Survicate Web Package",
5
5
  "author": {
6
6
  "name": "Survicate",
7
7
  "email": "help@survicate.com"
8
8
  },
9
- "engines": {
10
- "node": "18.7.1"
11
- },
12
9
  "repository": {
13
10
  "type": "git",
14
11
  "url": "git+https://github.com/Survicate/survicate-web-package.git"
@@ -19,5 +16,5 @@
19
16
  "url": "https://github.com/Survicate/survicate-web-package/issues"
20
17
  },
21
18
  "main": "survicate_widget.js",
22
- "types": "./survicate_widget.d.ts"
19
+ "types": "survicate_widget.d.ts"
23
20
  }
@@ -1,30 +1,5 @@
1
- declare const Survicate: {
2
- init: (config: { workspaceKey: string }) => Promise<null | void>;
3
- load: () => void;
4
- addEventListener: (
5
- event: SurvicateApiEvents,
6
- callback: SurvicateCallbackTypes
7
- ) => void;
8
- destroyVisitor: (callback?: () => void) => void;
9
- disableTargeting?: boolean;
10
- getState: () => SurvicateState;
11
- getSurvey: () => { id: string | null; name: string | null };
12
- getVisitorId: () => string;
13
- removeEventListener: (eventId: number) => void;
14
- retarget: () => void;
15
- setVisitorTraits: (attributes: SurvicateVisitorAttributes) => void;
16
- showSurvey: (id: string, options: ShowSurveyOptions) => void;
17
- traits?: SurvicateVisitorAttributes;
18
- };
19
-
20
- export enum SurvicateApiEvents {
21
- questionAnswered = 'question_answered',
22
- surveyDisplayed = 'survey_displayed',
23
- surveyCompleted = 'survey_completed',
24
- surveyClosed = 'survey_closed',
25
- }
26
-
27
1
  type SurvicateCallbackType = (surveyId: string, answer?: unknown) => void;
2
+
28
3
  type SurvicateQuestionAnsweredCallback = (
29
4
  surveyId: string,
30
5
  questionId: number,
@@ -39,60 +14,46 @@ export interface SurvicateVisitorAttributes {
39
14
  [key: string]: string;
40
15
  }
41
16
 
42
- type WindowWithSvd = Window & {
43
- _svd: unknown;
44
- };
45
-
46
- export interface SurvicateState {
47
- backendData: unknown;
48
- backendService: unknown | null;
49
- isKioskMode: boolean;
50
- isPreview: boolean;
51
- previewDevice: unknown;
52
- sampledSurveys: unknown | null;
53
- storageService: unknown | null;
54
- surveyApiState: unknown;
55
- surveyState: SurvicateSurveyState;
56
- tabId: number;
57
- update: WindowWithSvd | Record<string, unknown>;
58
- visit: unknown;
59
- visitor: unknown;
60
- }
61
-
62
- export interface SurvicateSurveyState {
63
- survey: unknown | null;
64
- theme: unknown | null;
65
- pointsDisplayed: unknown[];
66
- pointsForward: unknown[];
67
- pointsAnswered: {
68
- [id: number]: boolean;
69
- };
70
- responseUuid: string;
71
- isMinimized: boolean;
72
- isOverlayActive: boolean;
73
- isFinished: boolean;
74
- isAlreadyAnswered: boolean;
75
- isAnsweredByEmail: boolean;
76
- triggeredPointPreview: number | null;
77
- forceDisplay?: boolean;
78
- translations: unknown | null;
79
- translationLanguage: string | null;
80
- }
81
-
82
17
  export interface ShowSurveyOptions {
83
18
  forceDisplay?: true;
84
- displayMethod?: SurvicateAppearMethod;
19
+ displayMethod?: AppearMethod;
85
20
  displayOptions?: {
86
21
  delay?: number;
87
22
  scrolledPercentage?: number;
88
23
  };
89
24
  }
90
25
 
91
- export enum SurvicateAppearMethod {
26
+ export enum AppearMethod {
92
27
  immediately = 'immediately',
93
28
  delayed = 'delayed',
94
29
  exitIntent = 'exitIntent',
95
30
  scroll = 'onScroll',
96
31
  }
97
32
 
33
+ export enum ApiEvent {
34
+ questionAnswered = 'question_answered',
35
+ surveyDisplayed = 'survey_displayed',
36
+ surveyCompleted = 'survey_completed',
37
+ surveyClosed = 'survey_closed',
38
+ }
39
+
40
+ declare const Survicate: {
41
+ init: (config: { workspaceKey: string }) => Promise<null | void>;
42
+ addEventListener: (
43
+ event: ApiEvent,
44
+ callback: SurvicateCallbackTypes
45
+ ) => number | void;
46
+ destroyVisitor: (callback?: () => void) => void;
47
+ disableTargeting?: boolean;
48
+ getSurvey: () => { id: string | null; name: string | null };
49
+ getVisitorId: () => string;
50
+ removeEventListener: (eventId: number | ApiEvent) => void;
51
+ retarget: () => void;
52
+ setVisitorTraits: (attributes: SurvicateVisitorAttributes) => void;
53
+ showSurvey: (id: string, options: ShowSurveyOptions) => boolean;
54
+ traits?: SurvicateVisitorAttributes;
55
+ ApiEvent: typeof ApiEvent;
56
+ AppearMethod: typeof AppearMethod;
57
+ };
58
+
98
59
  export default Survicate;