@screeb/sdk-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -0
- package/dist/es/context.d.ts +4 -0
- package/dist/es/index.d.ts +3 -0
- package/dist/es/index.js +347 -0
- package/dist/es/logger.d.ts +9 -0
- package/dist/es/provider.d.ts +4 -0
- package/dist/es/types.d.ts +373 -0
- package/dist/es/useScreeb.d.ts +1 -0
- package/dist/es/utils.d.ts +7 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +637 -0
- package/package.json +80 -0
package/docs/README.md
ADDED
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
@screeb/sdk-react
|
|
2
|
+
|
|
3
|
+
# @screeb/sdk-react
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
### Type Aliases
|
|
8
|
+
|
|
9
|
+
- [CloseFunction](README.md#closefunction)
|
|
10
|
+
- [DebugFunction](README.md#debugfunction)
|
|
11
|
+
- [EventTrackFunction](README.md#eventtrackfunction)
|
|
12
|
+
- [IdentityFunction](README.md#identityfunction)
|
|
13
|
+
- [IdentityGetFunction](README.md#identitygetfunction)
|
|
14
|
+
- [IdentityGroupAssignFunction](README.md#identitygroupassignfunction)
|
|
15
|
+
- [IdentityGroupUnassignFunction](README.md#identitygroupunassignfunction)
|
|
16
|
+
- [IdentityPropertiesFunction](README.md#identitypropertiesfunction)
|
|
17
|
+
- [IdentityResetFunction](README.md#identityresetfunction)
|
|
18
|
+
- [InitFunction](README.md#initfunction)
|
|
19
|
+
- [LoadFunction](README.md#loadfunction)
|
|
20
|
+
- [ScreebContextValues](README.md#screebcontextvalues)
|
|
21
|
+
- [ScreebProps](README.md#screebprops)
|
|
22
|
+
- [ScreebProviderProps](README.md#screebproviderprops)
|
|
23
|
+
- [SurveyCloseFunction](README.md#surveyclosefunction)
|
|
24
|
+
- [SurveyStartFunction](README.md#surveystartfunction)
|
|
25
|
+
- [TargetingCheckFunction](README.md#targetingcheckfunction)
|
|
26
|
+
- [TargetingDebugFunction](README.md#targetingdebugfunction)
|
|
27
|
+
|
|
28
|
+
### Functions
|
|
29
|
+
|
|
30
|
+
- [ScreebProvider](README.md#screebprovider)
|
|
31
|
+
- [useScreeb](README.md#usescreeb)
|
|
32
|
+
|
|
33
|
+
## Type Aliases
|
|
34
|
+
|
|
35
|
+
### CloseFunction
|
|
36
|
+
|
|
37
|
+
Ƭ **CloseFunction**: () => `Promise`<`void`\>
|
|
38
|
+
|
|
39
|
+
#### Type declaration
|
|
40
|
+
|
|
41
|
+
▸ (): `Promise`<`void`\>
|
|
42
|
+
|
|
43
|
+
Shutdowns current Screeb session.
|
|
44
|
+
|
|
45
|
+
**`Example`**
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const { close } = useScreeb();
|
|
49
|
+
|
|
50
|
+
close();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
##### Returns
|
|
54
|
+
|
|
55
|
+
`Promise`<`void`\>
|
|
56
|
+
|
|
57
|
+
___
|
|
58
|
+
|
|
59
|
+
### DebugFunction
|
|
60
|
+
|
|
61
|
+
Ƭ **DebugFunction**: () => `Promise`<`unknown`\>
|
|
62
|
+
|
|
63
|
+
#### Type declaration
|
|
64
|
+
|
|
65
|
+
▸ (): `Promise`<`unknown`\>
|
|
66
|
+
|
|
67
|
+
Prints the actual state information of Screeb tag.
|
|
68
|
+
|
|
69
|
+
**`Example`**
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const { debug } = useScreeb();
|
|
73
|
+
|
|
74
|
+
debug();
|
|
75
|
+
// ******************* SCREEB SESSION DEBUG *********************
|
|
76
|
+
// Screeb channel id: <UUID>
|
|
77
|
+
// Screeb channel type: widget
|
|
78
|
+
// Screeb respondent id: <UUID>
|
|
79
|
+
// Screeb survey id: none
|
|
80
|
+
// Screeb response id: none
|
|
81
|
+
//
|
|
82
|
+
// Screeb current session start: Thu May 04 2023 16:53:49 GMT+0200 (Central European Summer Time)
|
|
83
|
+
// Screeb current session last activity: Thu May 04 2023 17:41:30 GMT+0200 (Central European Summer Time)
|
|
84
|
+
//
|
|
85
|
+
// Screeb targeting engine status: disabled
|
|
86
|
+
// Screeb targeting engine: 3 surveys
|
|
87
|
+
//
|
|
88
|
+
// Detected platform: desktop
|
|
89
|
+
// Detected locale: en-GB
|
|
90
|
+
// Detected timezone: -120
|
|
91
|
+
// **************************************************************
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
##### Returns
|
|
95
|
+
|
|
96
|
+
`Promise`<`unknown`\>
|
|
97
|
+
|
|
98
|
+
___
|
|
99
|
+
|
|
100
|
+
### EventTrackFunction
|
|
101
|
+
|
|
102
|
+
Ƭ **EventTrackFunction**: (`eventName`: `string`, `eventProperties?`: `PropertyRecord`) => `Promise`<`unknown`\>
|
|
103
|
+
|
|
104
|
+
#### Type declaration
|
|
105
|
+
|
|
106
|
+
▸ (`eventName`, `eventProperties?`): `Promise`<`unknown`\>
|
|
107
|
+
|
|
108
|
+
Tracks a user event.
|
|
109
|
+
|
|
110
|
+
**`Example`**
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const { eventTrack } = useScreeb();
|
|
114
|
+
|
|
115
|
+
eventTrack(
|
|
116
|
+
"Product added to cart",
|
|
117
|
+
{
|
|
118
|
+
product_name: 'Red bike 2021',
|
|
119
|
+
category: 'sport',
|
|
120
|
+
color: 'red',
|
|
121
|
+
price: 299,
|
|
122
|
+
count: 1,
|
|
123
|
+
reference: '2CF093TG1',
|
|
124
|
+
delivery_method: 'UPS',
|
|
125
|
+
user_logged: false,
|
|
126
|
+
added_at: new Date(),
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
##### Parameters
|
|
132
|
+
|
|
133
|
+
| Name | Type | Description |
|
|
134
|
+
| :------ | :------ | :------ |
|
|
135
|
+
| `eventName` | `string` | The event name. |
|
|
136
|
+
| `eventProperties?` | `PropertyRecord` | The properties of your event. ```text Requirements: - Property names must be limited to 128 characters - No more than 1000 attributes - Supported types for values: string, number, boolean and Date. ``` |
|
|
137
|
+
|
|
138
|
+
##### Returns
|
|
139
|
+
|
|
140
|
+
`Promise`<`unknown`\>
|
|
141
|
+
|
|
142
|
+
___
|
|
143
|
+
|
|
144
|
+
### IdentityFunction
|
|
145
|
+
|
|
146
|
+
Ƭ **IdentityFunction**: (`userId`: `string`, `userProperties?`: `PropertyRecord`) => `Promise`<`unknown`\>
|
|
147
|
+
|
|
148
|
+
#### Type declaration
|
|
149
|
+
|
|
150
|
+
▸ (`userId`, `userProperties?`): `Promise`<`unknown`\>
|
|
151
|
+
|
|
152
|
+
Change the current user identity.
|
|
153
|
+
Warning: Running surveys will be closed.
|
|
154
|
+
|
|
155
|
+
**`Example`**
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const { identity } = useScreeb();
|
|
159
|
+
|
|
160
|
+
identity(
|
|
161
|
+
"<your-user-id>",
|
|
162
|
+
{
|
|
163
|
+
firstname: '<user-firstname>',
|
|
164
|
+
lastname: '<user-lastname>',
|
|
165
|
+
plan: '<user-plan>',
|
|
166
|
+
last_seen_at: new Date(),
|
|
167
|
+
authenticated: true
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
##### Parameters
|
|
173
|
+
|
|
174
|
+
| Name | Type | Description |
|
|
175
|
+
| :------ | :------ | :------ |
|
|
176
|
+
| `userId` | `string` | The unique identifier of your user. |
|
|
177
|
+
| `userProperties?` | `PropertyRecord` | The properties of your user. ```text Requirements: - Property names must be limited to 128 characters - No more than 1000 attributes - Supported types for values: string, number, boolean and Date. ``` |
|
|
178
|
+
|
|
179
|
+
##### Returns
|
|
180
|
+
|
|
181
|
+
`Promise`<`unknown`\>
|
|
182
|
+
|
|
183
|
+
___
|
|
184
|
+
|
|
185
|
+
### IdentityGetFunction
|
|
186
|
+
|
|
187
|
+
Ƭ **IdentityGetFunction**: () => `Promise`<`ScreebIdentityGetReturn`\>
|
|
188
|
+
|
|
189
|
+
#### Type declaration
|
|
190
|
+
|
|
191
|
+
▸ (): `Promise`<`ScreebIdentityGetReturn`\>
|
|
192
|
+
|
|
193
|
+
Retrieves the current user identity.
|
|
194
|
+
|
|
195
|
+
**`Example`**
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const { identityGet } = useScreeb();
|
|
199
|
+
|
|
200
|
+
console.log(await identityGet());
|
|
201
|
+
// {
|
|
202
|
+
// anonymous_id: "<UUID>",
|
|
203
|
+
// user_id: "<UUID>",
|
|
204
|
+
// session_id: "<UUID>",
|
|
205
|
+
// session_start: "2023-05-04T16:30:15.882Z",
|
|
206
|
+
// session_end: "2023-05-04T17:02:09.087Z",
|
|
207
|
+
// channel_id: "<UUID>",
|
|
208
|
+
// is_ready: true,
|
|
209
|
+
// }
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
##### Returns
|
|
213
|
+
|
|
214
|
+
`Promise`<`ScreebIdentityGetReturn`\>
|
|
215
|
+
|
|
216
|
+
___
|
|
217
|
+
|
|
218
|
+
### IdentityGroupAssignFunction
|
|
219
|
+
|
|
220
|
+
Ƭ **IdentityGroupAssignFunction**: (`groupName`: `string`, `groupType?`: `string`, `groupProperties?`: `PropertyRecord`) => `Promise`<`unknown`\>
|
|
221
|
+
|
|
222
|
+
#### Type declaration
|
|
223
|
+
|
|
224
|
+
▸ (`groupName`, `groupType?`, `groupProperties?`): `Promise`<`unknown`\>
|
|
225
|
+
|
|
226
|
+
Assigns the current user to a group.
|
|
227
|
+
|
|
228
|
+
**`Example`**
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
const { identityGroupAssign } = useScreeb();
|
|
232
|
+
|
|
233
|
+
identityGroupAssign(
|
|
234
|
+
'company',
|
|
235
|
+
'Apple',
|
|
236
|
+
{
|
|
237
|
+
address_line_1: 'Apple Campus',
|
|
238
|
+
address_line_2: '1 Infinite Loop',
|
|
239
|
+
city: 'Cupertino',
|
|
240
|
+
zipcode: 95014,
|
|
241
|
+
state: 'California',
|
|
242
|
+
country: 'United states',
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
##### Parameters
|
|
248
|
+
|
|
249
|
+
| Name | Type | Description |
|
|
250
|
+
| :------ | :------ | :------ |
|
|
251
|
+
| `groupName` | `string` | |
|
|
252
|
+
| `groupType?` | `string` | |
|
|
253
|
+
| `groupProperties?` | `PropertyRecord` | The properties of your user group. ```text Requirements: - Property names must be limited to 128 characters - No more than 1000 attributes - Supported types for values: string, number, boolean and Date. ``` |
|
|
254
|
+
|
|
255
|
+
##### Returns
|
|
256
|
+
|
|
257
|
+
`Promise`<`unknown`\>
|
|
258
|
+
|
|
259
|
+
___
|
|
260
|
+
|
|
261
|
+
### IdentityGroupUnassignFunction
|
|
262
|
+
|
|
263
|
+
Ƭ **IdentityGroupUnassignFunction**: (`groupName`: `string`, `groupType?`: `string`) => `Promise`<`unknown`\>
|
|
264
|
+
|
|
265
|
+
#### Type declaration
|
|
266
|
+
|
|
267
|
+
▸ (`groupName`, `groupType?`): `Promise`<`unknown`\>
|
|
268
|
+
|
|
269
|
+
Unassigns the current user to a group.
|
|
270
|
+
|
|
271
|
+
**`Example`**
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
const { identityGroupUnassign } = useScreeb();
|
|
275
|
+
|
|
276
|
+
identityGroupUnassign('company', 'Apple');
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
##### Parameters
|
|
280
|
+
|
|
281
|
+
| Name | Type | Description |
|
|
282
|
+
| :------ | :------ | :------ |
|
|
283
|
+
| `groupName` | `string` | The name of your user group. |
|
|
284
|
+
| `groupType?` | `string` | The type of your user group. |
|
|
285
|
+
|
|
286
|
+
##### Returns
|
|
287
|
+
|
|
288
|
+
`Promise`<`unknown`\>
|
|
289
|
+
|
|
290
|
+
___
|
|
291
|
+
|
|
292
|
+
### IdentityPropertiesFunction
|
|
293
|
+
|
|
294
|
+
Ƭ **IdentityPropertiesFunction**: (`userProperties`: `PropertyRecord`) => `Promise`<`unknown`\>
|
|
295
|
+
|
|
296
|
+
#### Type declaration
|
|
297
|
+
|
|
298
|
+
▸ (`userProperties`): `Promise`<`unknown`\>
|
|
299
|
+
|
|
300
|
+
Adds properties to the current user identity.
|
|
301
|
+
|
|
302
|
+
**`Example`**
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
const { identityProperties } = useScreeb();
|
|
306
|
+
|
|
307
|
+
// Set user properties
|
|
308
|
+
identityProperties(
|
|
309
|
+
{
|
|
310
|
+
firstname: '<user-firstname>',
|
|
311
|
+
lastname: '<user-lastname>',
|
|
312
|
+
plan: '<user-plan>',
|
|
313
|
+
last_seen_at: new Date(),
|
|
314
|
+
authenticated: true
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
// Delete user property : set values to null
|
|
319
|
+
identityProperties(
|
|
320
|
+
{
|
|
321
|
+
age: null,
|
|
322
|
+
company: null,
|
|
323
|
+
logged: true,
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
##### Parameters
|
|
329
|
+
|
|
330
|
+
| Name | Type | Description |
|
|
331
|
+
| :------ | :------ | :------ |
|
|
332
|
+
| `userProperties` | `PropertyRecord` | The properties of your user. ```text Requirements: - Property names must be limited to 128 characters - No more than 1000 attributes - Supported types for values: string, number, boolean and Date. ``` |
|
|
333
|
+
|
|
334
|
+
##### Returns
|
|
335
|
+
|
|
336
|
+
`Promise`<`unknown`\>
|
|
337
|
+
|
|
338
|
+
___
|
|
339
|
+
|
|
340
|
+
### IdentityResetFunction
|
|
341
|
+
|
|
342
|
+
Ƭ **IdentityResetFunction**: () => `Promise`<`unknown`\>
|
|
343
|
+
|
|
344
|
+
#### Type declaration
|
|
345
|
+
|
|
346
|
+
▸ (): `Promise`<`unknown`\>
|
|
347
|
+
|
|
348
|
+
Resets the current user identity.
|
|
349
|
+
Warning: This command must be called only once, since it creates a new identity on Screeb side.
|
|
350
|
+
|
|
351
|
+
**`Example`**
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
const { identityReset } = useScreeb();
|
|
355
|
+
|
|
356
|
+
identityReset();
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
##### Returns
|
|
360
|
+
|
|
361
|
+
`Promise`<`unknown`\>
|
|
362
|
+
|
|
363
|
+
___
|
|
364
|
+
|
|
365
|
+
### InitFunction
|
|
366
|
+
|
|
367
|
+
Ƭ **InitFunction**: (`websiteId`: `string`, `userId?`: `string`, `userProperties?`: `PropertyRecord`) => `Promise`<`void`\>
|
|
368
|
+
|
|
369
|
+
#### Type declaration
|
|
370
|
+
|
|
371
|
+
▸ (`websiteId`, `userId?`, `userProperties?`): `Promise`<`void`\>
|
|
372
|
+
|
|
373
|
+
Initializes Screeb tag.
|
|
374
|
+
|
|
375
|
+
**`Example`**
|
|
376
|
+
|
|
377
|
+
```ts
|
|
378
|
+
const { init } = useScreeb();
|
|
379
|
+
|
|
380
|
+
init(
|
|
381
|
+
"<your-website-id>",
|
|
382
|
+
"<your-user-id>",
|
|
383
|
+
{
|
|
384
|
+
firstname: '<user-firstname>',
|
|
385
|
+
lastname: '<user-lastname>',
|
|
386
|
+
plan: '<user-plan>',
|
|
387
|
+
last_seen_at: new Date(),
|
|
388
|
+
authenticated: true
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
##### Parameters
|
|
394
|
+
|
|
395
|
+
| Name | Type | Description |
|
|
396
|
+
| :------ | :------ | :------ |
|
|
397
|
+
| `websiteId` | `string` | Your website/channel id. |
|
|
398
|
+
| `userId?` | `string` | The unique identifier of your user. |
|
|
399
|
+
| `userProperties?` | `PropertyRecord` | The properties of your user. ```text Requirements: - Property names must be limited to 128 characters - No more than 1000 attributes - Supported types for values: string, number, boolean and Date ``` |
|
|
400
|
+
|
|
401
|
+
##### Returns
|
|
402
|
+
|
|
403
|
+
`Promise`<`void`\>
|
|
404
|
+
|
|
405
|
+
___
|
|
406
|
+
|
|
407
|
+
### LoadFunction
|
|
408
|
+
|
|
409
|
+
Ƭ **LoadFunction**: (`options?`: `ScreebOptions`) => `Promise`<`void`\>
|
|
410
|
+
|
|
411
|
+
#### Type declaration
|
|
412
|
+
|
|
413
|
+
▸ (`options?`): `Promise`<`void`\>
|
|
414
|
+
|
|
415
|
+
Appends Screeb tag into your dom.
|
|
416
|
+
|
|
417
|
+
**`Example`**
|
|
418
|
+
|
|
419
|
+
```ts
|
|
420
|
+
const { load } = useScreeb();
|
|
421
|
+
|
|
422
|
+
load();
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
##### Parameters
|
|
426
|
+
|
|
427
|
+
| Name | Type | Description |
|
|
428
|
+
| :------ | :------ | :------ |
|
|
429
|
+
| `options?` | `ScreebOptions` | Screeb module options. |
|
|
430
|
+
|
|
431
|
+
##### Returns
|
|
432
|
+
|
|
433
|
+
`Promise`<`void`\>
|
|
434
|
+
|
|
435
|
+
___
|
|
436
|
+
|
|
437
|
+
### ScreebContextValues
|
|
438
|
+
|
|
439
|
+
Ƭ **ScreebContextValues**: `Object`
|
|
440
|
+
|
|
441
|
+
Screeb context API
|
|
442
|
+
|
|
443
|
+
#### Type declaration
|
|
444
|
+
|
|
445
|
+
| Name | Type |
|
|
446
|
+
| :------ | :------ |
|
|
447
|
+
| `close` | [`CloseFunction`](README.md#closefunction) |
|
|
448
|
+
| `debug` | [`DebugFunction`](README.md#debugfunction) |
|
|
449
|
+
| `eventTrack` | [`EventTrackFunction`](README.md#eventtrackfunction) |
|
|
450
|
+
| `identity` | [`IdentityFunction`](README.md#identityfunction) |
|
|
451
|
+
| `identityGet` | [`IdentityGetFunction`](README.md#identitygetfunction) |
|
|
452
|
+
| `identityGroupAssign` | [`IdentityGroupAssignFunction`](README.md#identitygroupassignfunction) |
|
|
453
|
+
| `identityGroupUnassign` | [`IdentityGroupUnassignFunction`](README.md#identitygroupunassignfunction) |
|
|
454
|
+
| `identityProperties` | [`IdentityPropertiesFunction`](README.md#identitypropertiesfunction) |
|
|
455
|
+
| `identityReset` | [`IdentityResetFunction`](README.md#identityresetfunction) |
|
|
456
|
+
| `init` | [`InitFunction`](README.md#initfunction) |
|
|
457
|
+
| `load` | [`LoadFunction`](README.md#loadfunction) |
|
|
458
|
+
| `surveyClose` | [`SurveyCloseFunction`](README.md#surveyclosefunction) |
|
|
459
|
+
| `surveyStart` | [`SurveyStartFunction`](README.md#surveystartfunction) |
|
|
460
|
+
| `targetingCheck` | [`TargetingCheckFunction`](README.md#targetingcheckfunction) |
|
|
461
|
+
| `targetingDebug` | [`TargetingDebugFunction`](README.md#targetingdebugfunction) |
|
|
462
|
+
|
|
463
|
+
___
|
|
464
|
+
|
|
465
|
+
### ScreebProps
|
|
466
|
+
|
|
467
|
+
Ƭ **ScreebProps**: `Object`
|
|
468
|
+
|
|
469
|
+
Properties of Screeb provider
|
|
470
|
+
|
|
471
|
+
#### Type declaration
|
|
472
|
+
|
|
473
|
+
| Name | Type | Description |
|
|
474
|
+
| :------ | :------ | :------ |
|
|
475
|
+
| `userId?` | `string` | The unique identifier of your user. |
|
|
476
|
+
| `userProperties?` | `PropertyRecord` | The properties of your user. |
|
|
477
|
+
| `websiteId` | `string` | Your website/channel id. |
|
|
478
|
+
|
|
479
|
+
___
|
|
480
|
+
|
|
481
|
+
### ScreebProviderProps
|
|
482
|
+
|
|
483
|
+
Ƭ **ScreebProviderProps**: { `autoInit?`: `boolean` ; `options?`: `ScreebOptions` ; `shouldLoad?`: `boolean` } & `Partial`<[`ScreebProps`](README.md#screebprops)\>
|
|
484
|
+
|
|
485
|
+
Properties of Screeb provider
|
|
486
|
+
|
|
487
|
+
___
|
|
488
|
+
|
|
489
|
+
### SurveyCloseFunction
|
|
490
|
+
|
|
491
|
+
Ƭ **SurveyCloseFunction**: () => `Promise`<`unknown`\>
|
|
492
|
+
|
|
493
|
+
#### Type declaration
|
|
494
|
+
|
|
495
|
+
▸ (): `Promise`<`unknown`\>
|
|
496
|
+
|
|
497
|
+
Interrupts a running survey.
|
|
498
|
+
|
|
499
|
+
**`Example`**
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
const { surveyClose } = useScreeb();
|
|
503
|
+
|
|
504
|
+
surveyClose();
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
##### Returns
|
|
508
|
+
|
|
509
|
+
`Promise`<`unknown`\>
|
|
510
|
+
|
|
511
|
+
___
|
|
512
|
+
|
|
513
|
+
### SurveyStartFunction
|
|
514
|
+
|
|
515
|
+
Ƭ **SurveyStartFunction**: (`surveyId`: `string`, `allowMultipleResponses`: `boolean`, `hiddenFields`: `PropertyRecord`) => `Promise`<`unknown`\>
|
|
516
|
+
|
|
517
|
+
#### Type declaration
|
|
518
|
+
|
|
519
|
+
▸ (`surveyId`, `allowMultipleResponses`, `hiddenFields`): `Promise`<`unknown`\>
|
|
520
|
+
|
|
521
|
+
Starts a survey by its ID.
|
|
522
|
+
|
|
523
|
+
**`Example`**
|
|
524
|
+
|
|
525
|
+
```ts
|
|
526
|
+
const { surveyStart } = useScreeb();
|
|
527
|
+
|
|
528
|
+
surveyStart(
|
|
529
|
+
'<UUID>',
|
|
530
|
+
false,
|
|
531
|
+
{
|
|
532
|
+
color: "green",
|
|
533
|
+
article_id: 42
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
##### Parameters
|
|
539
|
+
|
|
540
|
+
| Name | Type |
|
|
541
|
+
| :------ | :------ |
|
|
542
|
+
| `surveyId` | `string` |
|
|
543
|
+
| `allowMultipleResponses` | `boolean` |
|
|
544
|
+
| `hiddenFields` | `PropertyRecord` |
|
|
545
|
+
|
|
546
|
+
##### Returns
|
|
547
|
+
|
|
548
|
+
`Promise`<`unknown`\>
|
|
549
|
+
|
|
550
|
+
___
|
|
551
|
+
|
|
552
|
+
### TargetingCheckFunction
|
|
553
|
+
|
|
554
|
+
Ƭ **TargetingCheckFunction**: () => `Promise`<`unknown`\>
|
|
555
|
+
|
|
556
|
+
#### Type declaration
|
|
557
|
+
|
|
558
|
+
▸ (): `Promise`<`unknown`\>
|
|
559
|
+
|
|
560
|
+
Forces a targeting check.
|
|
561
|
+
|
|
562
|
+
**`Example`**
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
const { targetingCheck } = useScreeb();
|
|
566
|
+
|
|
567
|
+
targetingCheck();
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
##### Returns
|
|
571
|
+
|
|
572
|
+
`Promise`<`unknown`\>
|
|
573
|
+
|
|
574
|
+
___
|
|
575
|
+
|
|
576
|
+
### TargetingDebugFunction
|
|
577
|
+
|
|
578
|
+
Ƭ **TargetingDebugFunction**: () => `Promise`<`unknown`\>
|
|
579
|
+
|
|
580
|
+
#### Type declaration
|
|
581
|
+
|
|
582
|
+
▸ (): `Promise`<`unknown`\>
|
|
583
|
+
|
|
584
|
+
Prints the current state of the targeting engine.
|
|
585
|
+
|
|
586
|
+
**`Example`**
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
const { targetingDebug } = useScreeb();
|
|
590
|
+
|
|
591
|
+
console.log(await targetingDebug());
|
|
592
|
+
// targeting ************ SCREEB TARGETING RULES DEBUG **************
|
|
593
|
+
// Disabled surveys are not listed here.
|
|
594
|
+
//
|
|
595
|
+
// Screeb channel id: <UUID>
|
|
596
|
+
// Screeb respondent id: <UUID>
|
|
597
|
+
//
|
|
598
|
+
// Survey <UUID>:
|
|
599
|
+
// https://admin.screeb.app/org/last/survey/<UUID>/share
|
|
600
|
+
//
|
|
601
|
+
// - Rule of type "Device type (desktop/mobile/tablet)": true 🟢
|
|
602
|
+
// - Rule of type "Multiple display": true 🟢
|
|
603
|
+
// - Rule of type "Capping per time between survey display on current respondent": true 🟢
|
|
604
|
+
// - Rule of type "User event count": false 🔴
|
|
605
|
+
// - Rule of type "Capping per respondent display count": false 🔴
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
##### Returns
|
|
609
|
+
|
|
610
|
+
`Promise`<`unknown`\>
|
|
611
|
+
|
|
612
|
+
## Functions
|
|
613
|
+
|
|
614
|
+
### ScreebProvider
|
|
615
|
+
|
|
616
|
+
▸ **ScreebProvider**(`props`, `context?`): ``null`` \| `ReactElement`<`any`, `any`\>
|
|
617
|
+
|
|
618
|
+
#### Parameters
|
|
619
|
+
|
|
620
|
+
| Name | Type |
|
|
621
|
+
| :------ | :------ |
|
|
622
|
+
| `props` | `PropsWithChildren`<[`ScreebProviderProps`](README.md#screebproviderprops)\> |
|
|
623
|
+
| `context?` | `any` |
|
|
624
|
+
|
|
625
|
+
#### Returns
|
|
626
|
+
|
|
627
|
+
``null`` \| `ReactElement`<`any`, `any`\>
|
|
628
|
+
|
|
629
|
+
___
|
|
630
|
+
|
|
631
|
+
### useScreeb
|
|
632
|
+
|
|
633
|
+
▸ **useScreeb**(): [`ScreebContextValues`](README.md#screebcontextvalues)
|
|
634
|
+
|
|
635
|
+
#### Returns
|
|
636
|
+
|
|
637
|
+
[`ScreebContextValues`](README.md#screebcontextvalues)
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@screeb/sdk-react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Screeb's browser sdk, optimized for React.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"product discovery",
|
|
7
|
+
"product management",
|
|
8
|
+
"survey",
|
|
9
|
+
"analytics",
|
|
10
|
+
"user feedback",
|
|
11
|
+
"user voice",
|
|
12
|
+
"user research"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://screeb.app",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/ScreebApp/sdk-js/issues",
|
|
17
|
+
"email": "suuport@screeb.app"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/ScreebApp/sdk-js.git",
|
|
22
|
+
"directory": "packages/screeb-sdk-react"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Screeb's frontend team",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/es/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"module": "dist/es/index.js",
|
|
35
|
+
"types": "dist/es/index.d.ts",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"docs",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "rollup -c ./node_modules/@screeb/typescript-config/src/rollup.config.js",
|
|
43
|
+
"build:doc": "typedoc src/index.ts",
|
|
44
|
+
"clean": "rm -Rf dist",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"test": "echo '@TODO'"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@screeb/eslint-config": "^0.1.4",
|
|
50
|
+
"@screeb/sdk-browser": "^0.1.6",
|
|
51
|
+
"@screeb/typescript-config": "^0.1.4",
|
|
52
|
+
"@types/jest": "^29.5.1",
|
|
53
|
+
"@types/node": "^18.11.19",
|
|
54
|
+
"@types/react": "^18.0.20",
|
|
55
|
+
"@types/react-dom": "^18.0.6",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
57
|
+
"eslint": "^8.41.0",
|
|
58
|
+
"eslint-plugin-import": "^2.27.5",
|
|
59
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
60
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
61
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
62
|
+
"jest": "^29.5.0",
|
|
63
|
+
"prettier": "^2.8.8",
|
|
64
|
+
"react": "^18.2.0",
|
|
65
|
+
"react-dom": "^18.2.0",
|
|
66
|
+
"rollup": "^3.23.0",
|
|
67
|
+
"typedoc": "^0.24.7",
|
|
68
|
+
"typedoc-plugin-markdown": "^3.15.3"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@screeb/sdk-browser": "^0.1.7"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"react": ">=16.8.0",
|
|
78
|
+
"react-dom": ">=16.8.0"
|
|
79
|
+
}
|
|
80
|
+
}
|