From c7f4b82cdfb6063e1dd0a7d9f3279d0a05d2089a Mon Sep 17 00:00:00 2001 From: clement Date: Fri, 21 Jul 2023 09:41:41 +0200 Subject: [PATCH] fix(*): remove types for hooks --- .../screeb-sdk-angular/docs/classes/Screeb.md | 68 +-- .../docs/classes/ScreebModule.md | 10 +- packages/screeb-sdk-browser/docs/README.md | 578 ++---------------- packages/screeb-sdk-browser/src/index.ts | 296 +-------- 4 files changed, 82 insertions(+), 870 deletions(-) diff --git a/packages/screeb-sdk-angular/docs/classes/Screeb.md b/packages/screeb-sdk-angular/docs/classes/Screeb.md index fd90ec1..a5a7488 100644 --- a/packages/screeb-sdk-angular/docs/classes/Screeb.md +++ b/packages/screeb-sdk-angular/docs/classes/Screeb.md @@ -40,8 +40,8 @@ #### Parameters -| Name | Type | -| :------- | :-------------------------------- | +| Name | Type | +| :------ | :------ | | `config` | [`ScreebConfig`](ScreebConfig.md) | ## Properties @@ -117,10 +117,10 @@ ___ #### Parameters -| Name | Type | Default value | -| :------------- | :-------- | :------------ | -| `functionName` | `string` | `undefined` | -| `onlyLoaded` | `boolean` | `false` | +| Name | Type | Default value | +| :------ | :------ | :------ | +| `functionName` | `string` | `undefined` | +| `onlyLoaded` | `boolean` | `false` | #### Returns @@ -155,9 +155,9 @@ this.screeb.eventTrack( #### Parameters -| Name | Type | Description | -| :----------------- | :--------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `eventName` | `string` | The event name. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | The event name. | | `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. ``` | #### Returns @@ -190,9 +190,9 @@ this.screeb.identity( #### Parameters -| Name | Type | Description | -| :---------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `userId` | `string` | The unique identifier of your user. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | The unique identifier of your user. | | `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. ``` | #### Returns @@ -212,13 +212,13 @@ Retrieves the current user identity. ```ts console.log(await this.screeb.identityGet()); // { +// channel_id: "", // anonymous_id: "", // user_id: "", +// is_ready: true, // session_id: "", // session_start: "2023-05-04T16:30:15.882Z", // session_end: "2023-05-04T17:02:09.087Z", -// channel_id: "", -// is_ready: true, // } ``` @@ -253,10 +253,10 @@ this.screeb.identityGroupAssign( #### Parameters -| Name | Type | Description | -| :----------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `groupName` | `string` | | -| `groupType?` | `string` | | +| Name | Type | Description | +| :------ | :------ | :------ | +| `groupName` | `string` | | +| `groupType?` | `string` | | | `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. ``` | #### Returns @@ -279,9 +279,9 @@ this.screeb.identityGroupUnassign('company', 'Apple'); #### Parameters -| Name | Type | Description | -| :----------- | :------- | :--------------------------- | -| `groupName` | `string` | The name of your user group. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `groupName` | `string` | The name of your user group. | | `groupType?` | `string` | The type of your user group. | #### Returns @@ -322,8 +322,8 @@ this.screeb.identityProperties( #### Parameters -| Name | Type | Description | -| :--------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Name | Type | Description | +| :------ | :------ | :------ | | `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. ``` | #### Returns @@ -380,12 +380,12 @@ this.screeb.init( #### Parameters -| Name | Type | Description | -| :---------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `websiteId` | `string` | Your website/channel id. | -| `userId?` | `string` | The unique identifier of your user. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `websiteId` | `string` | Your website/channel id. | +| `userId?` | `string` | The unique identifier of your user. | | `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 ``` | -| `hooks?` | `GlobalHooks` | - | +| `hooks?` | `GlobalHooks` | - | #### Returns @@ -455,12 +455,12 @@ this.screeb.surveyStart( #### Parameters -| Name | Type | -| :----------------------- | :--------------- | -| `surveyId` | `string` | -| `allowMultipleResponses` | `boolean` | -| `hiddenFields` | `PropertyRecord` | -| `hooks?` | `SurveyHooks` | +| Name | Type | +| :------ | :------ | +| `surveyId` | `string` | +| `allowMultipleResponses` | `boolean` | +| `hiddenFields` | `PropertyRecord` | +| `hooks?` | `SurveyHooks` | #### Returns diff --git a/packages/screeb-sdk-angular/docs/classes/ScreebModule.md b/packages/screeb-sdk-angular/docs/classes/ScreebModule.md index ef40cf4..77ce6cf 100644 --- a/packages/screeb-sdk-angular/docs/classes/ScreebModule.md +++ b/packages/screeb-sdk-angular/docs/classes/ScreebModule.md @@ -20,10 +20,10 @@ #### Parameters -| Name | Type | -| :------- | :-------------------------------- | +| Name | Type | +| :------ | :------ | | `config` | [`ScreebConfig`](ScreebConfig.md) | -| `screeb` | [`Screeb`](Screeb.md) | +| `screeb` | [`Screeb`](Screeb.md) | ## Methods @@ -57,8 +57,8 @@ ScreebModule.forRoot({ #### Parameters -| Name | Type | Description | -| :------- | :-------------------------------- | :------------------------------------------ | +| Name | Type | Description | +| :------ | :------ | :------ | | `config` | [`ScreebConfig`](ScreebConfig.md) | Configuration to pass to Screeb browser SDK | #### Returns diff --git a/packages/screeb-sdk-browser/docs/README.md b/packages/screeb-sdk-browser/docs/README.md index 0a0a2d6..6a6d7bd 100644 --- a/packages/screeb-sdk-browser/docs/README.md +++ b/packages/screeb-sdk-browser/docs/README.md @@ -6,47 +6,11 @@ ### Type Aliases -- [GlobalHooks](README.md#globalhooks) -- [HookType](README.md#hooktype) - [PropertyRecord](README.md#propertyrecord) - [PropertyType](README.md#propertytype) -- [QuestionAnswerPair](README.md#questionanswerpair) -- [ResponseAnswer](README.md#responseanswer) -- [ResponseAnswerValue](README.md#responseanswervalue) -- [ResponseAnswerValueBoolean](README.md#responseanswervalueboolean) -- [ResponseAnswerValueNone](README.md#responseanswervaluenone) -- [ResponseAnswerValueNumber](README.md#responseanswervaluenumber) -- [ResponseAnswerValueString](README.md#responseanswervaluestring) -- [ResponseAnswerValueTime](README.md#responseanswervaluetime) -- [ResponseHook](README.md#responsehook) -- [ResponseHookSDKReady](README.md#responsehooksdkready) -- [ResponseHookSurveyCompleted](README.md#responsehooksurveycompleted) -- [ResponseHookSurveyHidden](README.md#responsehooksurveyhidden) -- [ResponseHookSurveyReplied](README.md#responsehooksurveyreplied) -- [ResponseHookSurveyShowed](README.md#responsehooksurveyshowed) -- [ResponseHookSurveyStarted](README.md#responsehooksurveystarted) -- [ResponseQuestion](README.md#responsequestion) -- [ResponseQuestionActionButton](README.md#responsequestionactionbutton) -- [ResponseQuestionActionInput](README.md#responsequestionactioninput) -- [ResponseQuestionActionInputValidation](README.md#responsequestionactioninputvalidation) -- [ResponseQuestionActionLink](README.md#responsequestionactionlink) -- [ResponseQuestionActionRange](README.md#responsequestionactionrange) -- [ResponseQuestionActionScoring](README.md#responsequestionactionscoring) -- [ResponseQuestionActionSkip](README.md#responsequestionactionskip) -- [ResponseQuestionCTA](README.md#responsequestioncta) -- [ResponseQuestionCTAAppStoreRating](README.md#responsequestionctaappstorerating) -- [ResponseQuestionCTAChoices](README.md#responsequestionctachoices) -- [ResponseQuestionCTAInput](README.md#responsequestionctainput) -- [ResponseQuestionCTANone](README.md#responsequestionctanone) -- [ResponseQuestionCTARange](README.md#responsequestionctarange) -- [ResponseQuestionCTAScores](README.md#responsequestionctascores) -- [ResponseQuestionMessage](README.md#responsequestionmessage) -- [ResponseQuestionMessageText](README.md#responsequestionmessagetext) -- [ResponseStatus](README.md#responsestatus) - [ScreebIdentityGetReturn](README.md#screebidentitygetreturn) - [ScreebObject](README.md#screebobject) - [ScreebOptions](README.md#screeboptions) -- [SurveyHooks](README.md#surveyhooks) ### Functions @@ -69,20 +33,6 @@ ## Type Aliases -### GlobalHooks - -Ƭ **GlobalHooks**: { [key in HookType \| "onReady"]?: Function } - -___ - -### HookType - -Ƭ **HookType**: ``"onSurveyShowed"`` \| ``"onSurveyStarted"`` \| ``"onQuestionReplied"`` \| ``"onSurveyCompleted"`` \| ``"onSurveyHidden"`` - -Hooks - -___ - ### PropertyRecord Ƭ **PropertyRecord**: `Object` @@ -103,446 +53,6 @@ This is property types that are supported by Screeb. ___ -### QuestionAnswerPair - -Ƭ **QuestionAnswerPair**: `Object` - -#### Type declaration - -| Name | Type | -| :--------- | :----------------------------------------------- | -| `answer?` | [`ResponseAnswer`](README.md#responseanswer) | -| `question` | [`ResponseQuestion`](README.md#responsequestion) | - -___ - -### ResponseAnswer - -Ƭ **ResponseAnswer**: `Object` - -#### Type declaration - -| Name | Type | -| :------------ | :------------------------------------------------------- | -| `created_at` | `Date` | -| `id` | `string` | -| `question_id` | `string` | -| `values` | [`ResponseAnswerValue`](README.md#responseanswervalue)[] | - -___ - -### ResponseAnswerValue - -Ƭ **ResponseAnswerValue**: [`ResponseAnswerValueNone`](README.md#responseanswervaluenone) \| [`ResponseAnswerValueString`](README.md#responseanswervaluestring) \| [`ResponseAnswerValueNumber`](README.md#responseanswervaluenumber) \| [`ResponseAnswerValueBoolean`](README.md#responseanswervalueboolean) \| [`ResponseAnswerValueTime`](README.md#responseanswervaluetime) - -Answer - -___ - -### ResponseAnswerValueBoolean - -Ƭ **ResponseAnswerValueBoolean**: `ResponseAnswerValueAbstract` & { `type`: ``"boolean"`` ; `value_boolean`: `boolean` } - -___ - -### ResponseAnswerValueNone - -Ƭ **ResponseAnswerValueNone**: `ResponseAnswerValueAbstract` & { `type`: ``"none"`` } - -___ - -### ResponseAnswerValueNumber - -Ƭ **ResponseAnswerValueNumber**: `ResponseAnswerValueAbstract` & { `type`: ``"number"`` ; `value_number`: `number` } - -___ - -### ResponseAnswerValueString - -Ƭ **ResponseAnswerValueString**: `ResponseAnswerValueAbstract` & { `type`: ``"string"`` ; `value_string`: `string` } - -___ - -### ResponseAnswerValueTime - -Ƭ **ResponseAnswerValueTime**: `ResponseAnswerValueAbstract` & { `type`: ``"time"`` ; `value_time`: `Date` } - -___ - -### ResponseHook - -Ƭ **ResponseHook**: `Object` - -#### Type declaration - -| Name | Type | -| :------------------ | :--------------------------------------------------------------------- | -| `onQuestionReplied` | [`ResponseHookSurveyReplied`](README.md#responsehooksurveyreplied) | -| `onReady` | [`ResponseHookSDKReady`](README.md#responsehooksdkready) | -| `onSurveyCompleted` | [`ResponseHookSurveyCompleted`](README.md#responsehooksurveycompleted) | -| `onSurveyHidden` | [`ResponseHookSurveyHidden`](README.md#responsehooksurveyhidden) | -| `onSurveyShowed` | [`ResponseHookSurveyShowed`](README.md#responsehooksurveyshowed) | -| `onSurveyStarted` | [`ResponseHookSurveyStarted`](README.md#responsehooksurveystarted) | - -___ - -### ResponseHookSDKReady - -Ƭ **ResponseHookSDKReady**: `Object` - -#### Type declaration - -| Name | Type | -| :------------------ | :-------------------------------------------------- | -| `user` | { `anonymous_id`: `string` ; `user_id`: `string` } | -| `user.anonymous_id` | `string` | -| `user.user_id` | `string` | - -___ - -### ResponseHookSurveyCompleted - -Ƭ **ResponseHookSurveyCompleted**: `Object` - -#### Type declaration - -| Name | Type | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | -| `items` | [`QuestionAnswerPair`](README.md#questionanswerpair)[] | -| `response` | { `id`: `string` } | -| `response.id` | `string` | -| `survey` | { `id`: `string` ; `survey_format`: ``"conversationnal"`` \| ``"cards"`` \| `undefined` ; `survey_position`: `number` ; `survey_size`: `number` } | -| `survey.id` | `string` | -| `survey.survey_format` | ``"conversationnal"`` \| ``"cards"`` \| `undefined` | -| `survey.survey_position` | `number` | -| `survey.survey_size` | `number` | -| `user` | { `anonymous_id`: `string` ; `user_id`: `string` } | -| `user.anonymous_id` | `string` | -| `user.user_id` | `string` | - -___ - -### ResponseHookSurveyHidden - -Ƭ **ResponseHookSurveyHidden**: `Object` - -#### Type declaration - -| Name | Type | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | -| `items` | [`QuestionAnswerPair`](README.md#questionanswerpair)[] | -| `response` | { `hide_reason`: [`ResponseStatus`](README.md#responsestatus) ; `id`: `string` } | -| `response.hide_reason` | [`ResponseStatus`](README.md#responsestatus) | -| `response.id` | `string` | -| `survey` | { `id`: `string` ; `survey_format`: ``"conversationnal"`` \| ``"cards"`` \| `undefined` ; `survey_position`: `number` ; `survey_size`: `number` } | -| `survey.id` | `string` | -| `survey.survey_format` | ``"conversationnal"`` \| ``"cards"`` \| `undefined` | -| `survey.survey_position` | `number` | -| `survey.survey_size` | `number` | -| `user` | { `anonymous_id`: `string` ; `user_id`: `string` } | -| `user.anonymous_id` | `string` | -| `user.user_id` | `string` | - -___ - -### ResponseHookSurveyReplied - -Ƭ **ResponseHookSurveyReplied**: `Object` - -#### Type declaration - -| Name | Type | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | -| `items` | [`QuestionAnswerPair`](README.md#questionanswerpair)[] | -| `response` | { `id`: `string` ; `status`: [`ResponseStatus`](README.md#responsestatus) } | -| `response.id` | `string` | -| `response.status` | [`ResponseStatus`](README.md#responsestatus) | -| `survey` | { `id`: `string` ; `survey_format`: ``"conversationnal"`` \| ``"cards"`` \| `undefined` ; `survey_position`: `number` ; `survey_size`: `number` } | -| `survey.id` | `string` | -| `survey.survey_format` | ``"conversationnal"`` \| ``"cards"`` \| `undefined` | -| `survey.survey_position` | `number` | -| `survey.survey_size` | `number` | -| `user` | { `anonymous_id`: `string` ; `user_id`: `string` } | -| `user.anonymous_id` | `string` | -| `user.user_id` | `string` | - -___ - -### ResponseHookSurveyShowed - -Ƭ **ResponseHookSurveyShowed**: `Object` - -#### Type declaration - -| Name | Type | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | -| `items` | [`QuestionAnswerPair`](README.md#questionanswerpair)[] | -| `response` | { `id`: `string` } | -| `response.id` | `string` | -| `survey` | { `id`: `string` ; `survey_format`: ``"conversationnal"`` \| ``"cards"`` \| `undefined` ; `survey_position`: `number` ; `survey_size`: `number` } | -| `survey.id` | `string` | -| `survey.survey_format` | ``"conversationnal"`` \| ``"cards"`` \| `undefined` | -| `survey.survey_position` | `number` | -| `survey.survey_size` | `number` | -| `user` | { `anonymous_id`: `string` ; `user_id`: `string` } | -| `user.anonymous_id` | `string` | -| `user.user_id` | `string` | - -___ - -### ResponseHookSurveyStarted - -Ƭ **ResponseHookSurveyStarted**: `Object` - -#### Type declaration - -| Name | Type | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | -| `response` | { `id`: `string` } | -| `response.id` | `string` | -| `survey` | { `id`: `string` ; `survey_format`: ``"conversationnal"`` \| ``"cards"`` \| `undefined` ; `survey_position`: `number` ; `survey_size`: `number` } | -| `survey.id` | `string` | -| `survey.survey_format` | ``"conversationnal"`` \| ``"cards"`` \| `undefined` | -| `survey.survey_position` | `number` | -| `survey.survey_size` | `number` | -| `user` | { `anonymous_id`: `string` ; `user_id`: `string` } | -| `user.anonymous_id` | `string` | -| `user.user_id` | `string` | - -___ - -### ResponseQuestion - -Ƭ **ResponseQuestion**: `Object` - -#### Type declaration - -| Name | Type | -| :--------------- | :------------------------------------------------------------------- | -| `call_to_action` | [`ResponseQuestionCTA`](README.md#responsequestioncta) | -| `ends` | `boolean` | -| `id` | `string` | -| `messages` | [`ResponseQuestionMessage`](README.md#responsequestionmessage)[] | -| `skip_action?` | [`ResponseQuestionActionSkip`](README.md#responsequestionactionskip) | - -___ - -### ResponseQuestionActionButton - -Ƭ **ResponseQuestionActionButton**: `Object` - -Action - -#### Type declaration - -| Name | Type | -| :-------------- | :------------------------------------------------------------ | -| `id` | `string` | -| `payload` | { `emoji`: `string` ; `label`: `string` ; `url?`: `string` } | -| `payload.emoji` | `string` | -| `payload.label` | `string` | -| `payload.url?` | `string` | -| `type` | ``"button"`` | - -___ - -### ResponseQuestionActionInput - -Ƭ **ResponseQuestionActionInput**: `Object` - -#### Type declaration - -| Name | Type | -| :------------------- | :------------------------------------------------------------------------------------------------------------ | -| `id` | `string` | -| `payload` | { `validation`: [`ResponseQuestionActionInputValidation`](README.md#responsequestionactioninputvalidation) } | -| `payload.validation` | [`ResponseQuestionActionInputValidation`](README.md#responsequestionactioninputvalidation) | -| `type` | ``"text_input"`` | - -___ - -### ResponseQuestionActionInputValidation - -Ƭ **ResponseQuestionActionInputValidation**: ``"text"`` \| ``"email"`` - -___ - -### ResponseQuestionActionLink - -Ƭ **ResponseQuestionActionLink**: `Object` - -#### Type declaration - -| Name | Type | -| :-------------- | :------------------------------------------------------------ | -| `id` | `string` | -| `payload` | { `emoji`: `string` ; `label`: `string` ; `link`: `string` } | -| `payload.emoji` | `string` | -| `payload.label` | `string` | -| `payload.link` | `string` | -| `type` | ``"link"`` | - -___ - -### ResponseQuestionActionRange - -Ƭ **ResponseQuestionActionRange**: `Object` - -#### Type declaration - -| Name | Type | -| :------------------- | :--------------------------------------------------------------------------------------- | -| `id` | `string` | -| `payload` | { `emoji`: `string` ; `max`: `number` ; `min`: `number` ; `validation`: ``"min_max"`` } | -| `payload.emoji` | `string` | -| `payload.max` | `number` | -| `payload.min` | `number` | -| `payload.validation` | ``"min_max"`` | -| `type` | ``"number_input"`` | - -___ - -### ResponseQuestionActionScoring - -Ƭ **ResponseQuestionActionScoring**: `Object` - -#### Type declaration - -| Name | Type | -| :-------------- | :----------------------------------------- | -| `id` | `string` | -| `payload` | { `emoji`: `string` ; `value`: `number` } | -| `payload.emoji` | `string` | -| `payload.value` | `number` | -| `type` | ``"scoring"`` | - -___ - -### ResponseQuestionActionSkip - -Ƭ **ResponseQuestionActionSkip**: `Object` - -#### Type declaration - -| Name | Type | -| :-------- | :--------- | -| `id` | `string` | -| `payload` | `any` | -| `type` | ``"skip"`` | - -___ - -### ResponseQuestionCTA - -Ƭ **ResponseQuestionCTA**: [`ResponseQuestionCTANone`](README.md#responsequestionctanone) \| [`ResponseQuestionCTAChoices`](README.md#responsequestionctachoices) \| [`ResponseQuestionCTAScores`](README.md#responsequestionctascores) \| [`ResponseQuestionCTAInput`](README.md#responsequestionctainput) \| [`ResponseQuestionCTARange`](README.md#responsequestionctarange) \| [`ResponseQuestionCTAAppStoreRating`](README.md#responsequestionctaappstorerating) - -___ - -### ResponseQuestionCTAAppStoreRating - -Ƭ **ResponseQuestionCTAAppStoreRating**: `Object` - -#### Type declaration - -| Name | Type | -| :----- | :-------------------- | -| `type` | ``"appstore_rating"`` | - -___ - -### ResponseQuestionCTAChoices - -Ƭ **ResponseQuestionCTAChoices**: `Object` - -#### Type declaration - -| Name | Type | -| :-------- | :------------------------------------------------------------------------- | -| `choices` | [`ResponseQuestionActionButton`](README.md#responsequestionactionbutton)[] | -| `type` | ``"multiple_choice"`` \| ``"pmf"`` \| ``"link"`` | - -___ - -### ResponseQuestionCTAInput - -Ƭ **ResponseQuestionCTAInput**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :--------------------------------------------------------------------- | -| `input` | [`ResponseQuestionActionInput`](README.md#responsequestionactioninput) | -| `type` | ``"input"`` | - -___ - -### ResponseQuestionCTANone - -Ƭ **ResponseQuestionCTANone**: `Object` - -CTA - -#### Type declaration - -| Name | Type | -| :----- | :--------- | -| `type` | ``"none"`` | - -___ - -### ResponseQuestionCTARange - -Ƭ **ResponseQuestionCTARange**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :--------------------------------------------------------------------- | -| `range` | [`ResponseQuestionActionRange`](README.md#responsequestionactionrange) | -| `type` | ``"range"`` | - -___ - -### ResponseQuestionCTAScores - -Ƭ **ResponseQuestionCTAScores**: `Object` - -#### Type declaration - -| Name | Type | -| :------- | :--------------------------------------------------------------------------- | -| `scores` | [`ResponseQuestionActionScoring`](README.md#responsequestionactionscoring)[] | -| `type` | ``"scoring"`` \| ``"nps"`` \| ``"ces"`` \| ``"csat"`` | - -___ - -### ResponseQuestionMessage - -Ƭ **ResponseQuestionMessage**: { `id`: `string` } & [`ResponseQuestionMessageText`](README.md#responsequestionmessagetext) - -___ - -### ResponseQuestionMessageText - -Ƭ **ResponseQuestionMessageText**: `Object` - -Messages - -#### Type declaration - -| Name | Type | -| :----- | :--------- | -| `text` | `string` | -| `type` | ``"text"`` | - -___ - -### ResponseStatus - -Ƭ **ResponseStatus**: ``"started"`` \| ``"ended"`` \| ``"closed"`` \| ``"interrupted"`` - -___ - ### ScreebIdentityGetReturn Ƭ **ScreebIdentityGetReturn**: `Object` @@ -551,15 +61,15 @@ This is the object returned by the function `identityGet()`. #### Type declaration -| Name | Type | Description | -| :-------------- | :-------- | :--------------------------------------------------------- | -| `channel_id` | `string` | The current channel id with which the tag was initialized | -| `anonymous_id` | `string` | Anonymous id given to each user | -| `user_id` | `string` | The authenticated id assigned to the user. | -| `is_ready` | `boolean` | `true` if the tag us loaded, initialized and ready to rock | -| `session_id` | `string` | The current user session id | -| `session_start` | `string` | The current user session start time | -| `session_end` | `string` | The current user session end time | +| Name | Type | Description | +| :------ | :------ | :------ | +| `anonymous_id` | `string` | Anonymous id given to each user | +| `channel_id` | `string` | The current channel id with which the tag was initialized | +| `is_ready` | `boolean` | `true` if the tag us loaded, initialized and ready to rock | +| `session_end` | `string` | The current user session end time | +| `session_id` | `string` | The current user session id | +| `session_start` | `string` | The current user session start time | +| `user_id` | `string` | The authenticated id assigned to the user. | ___ @@ -579,16 +89,10 @@ This is the Screeb tag options object. #### Type declaration -| Name | Type | Description | -| :---------------- | :------- | :--------------------------------------------------------------------------- | -| `screebEndpoint?` | `string` | Please don't do this. | -| `window?` | `Window` | If you're running Screeb tag in an iframe, please set the inner window here. | - -___ - -### SurveyHooks - -Ƭ **SurveyHooks**: { [key in HookType]?: Function } +| Name | Type | Description | +| :------ | :------ | :------ | +| `screebEndpoint?` | `string` | Please don't do this. | +| `window?` | `Window` | If you're running Screeb tag in an iframe, please set the inner window here. | ## Functions @@ -678,9 +182,9 @@ Screeb.eventTrack( #### Parameters -| Name | Type | Description | -| :----------------- | :------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `eventName` | `string` | The event name. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | The event name. | | `eventProperties?` | [`PropertyRecord`](README.md#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. ``` | #### Returns @@ -715,9 +219,9 @@ Screeb.identity( #### Parameters -| Name | Type | Description | -| :---------------- | :------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `userId` | `string` | The unique identifier of your user. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | The unique identifier of your user. | | `userProperties?` | [`PropertyRecord`](README.md#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. ``` | #### Returns @@ -782,10 +286,10 @@ Screeb.identityGroupAssign( #### Parameters -| Name | Type | Description | -| :----------------- | :------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `groupName` | `string` | | -| `groupType?` | `string` | | +| Name | Type | Description | +| :------ | :------ | :------ | +| `groupName` | `string` | | +| `groupType?` | `string` | | | `groupProperties?` | [`PropertyRecord`](README.md#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. ``` | #### Returns @@ -810,9 +314,9 @@ Screeb.identityGroupUnassign('company', 'Apple'); #### Parameters -| Name | Type | Description | -| :----------- | :------- | :--------------------------- | -| `groupName` | `string` | The name of your user group. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `groupName` | `string` | The name of your user group. | | `groupType?` | `string` | The type of your user group. | #### Returns @@ -855,8 +359,8 @@ Screeb.identityProperties( #### Parameters -| Name | Type | Description | -| :--------------- | :------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Name | Type | Description | +| :------ | :------ | :------ | | `userProperties` | [`PropertyRecord`](README.md#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. ``` | #### Returns @@ -917,12 +421,12 @@ Screeb.init( #### Parameters -| Name | Type | Description | -| :---------------- | :------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `websiteId` | `string` | Your website/channel id. | -| `userId?` | `string` | The unique identifier of your user. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `websiteId` | `string` | Your website/channel id. | +| `userId?` | `string` | The unique identifier of your user. | | `userProperties?` | [`PropertyRecord`](README.md#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 ``` | -| `hooks?` | [`GlobalHooks`](README.md#globalhooks) | Hooks to be called when SDK is ready or a survey is showed, started, completed, hidden or when a question is replied. | +| `hooks?` | `any` | Hooks to be called when SDK is ready or a survey is showed, started, completed, hidden or when a question is replied. | #### Returns @@ -968,8 +472,8 @@ Screeb.load(); #### Parameters -| Name | Type | Description | -| :-------- | :----------------------------------------- | :--------------------- | +| Name | Type | Description | +| :------ | :------ | :------ | | `options` | [`ScreebOptions`](README.md#screeboptions) | Screeb module options. | #### Returns @@ -1026,12 +530,12 @@ Screeb.surveyStart( #### Parameters -| Name | Type | Default value | -| :----------------------- | :---------------------------------------------------- | :------------ | -| `surveyId` | `string` | `undefined` | -| `allowMultipleResponses` | `boolean` | `true` | -| `hiddenFields` | [`PropertyRecord`](README.md#propertyrecord) | `{}` | -| `hooks` | `undefined` \| [`SurveyHooks`](README.md#surveyhooks) | `undefined` | +| Name | Type | Default value | +| :------ | :------ | :------ | +| `surveyId` | `string` | `undefined` | +| `allowMultipleResponses` | `boolean` | `true` | +| `hiddenFields` | [`PropertyRecord`](README.md#propertyrecord) | `{}` | +| `hooks?` | `any` | `undefined` | #### Returns diff --git a/packages/screeb-sdk-browser/src/index.ts b/packages/screeb-sdk-browser/src/index.ts index a57f835..0959428 100644 --- a/packages/screeb-sdk-browser/src/index.ts +++ b/packages/screeb-sdk-browser/src/index.ts @@ -6,298 +6,6 @@ export type PropertyRecord = { [key: string]: PropertyType | PropertyType[]; }; -/** - * Action - */ -export type ResponseQuestionActionButton = { - id: string; - type: "button"; - payload: { - emoji: string; - label: string; - url?: string; - }; -}; - -export type ResponseQuestionActionLink = { - id: string; - type: "link"; - payload: { - emoji: string; - label: string; - link: string; - }; -}; - -export type ResponseQuestionActionScoring = { - id: string; - type: "scoring"; - payload: { - emoji: string; - value: number; - }; -}; - -export type ResponseQuestionActionInputValidation = "text" | "email"; - -export type ResponseQuestionActionInput = { - id: string; - type: "text_input"; - payload: { - validation: ResponseQuestionActionInputValidation; - }; -}; - -export type ResponseQuestionActionRange = { - id: string; - type: "number_input"; - payload: { - validation: "min_max"; - min: number; - max: number; - emoji: string; - }; -}; - -/** - * CTA - */ -export type ResponseQuestionCTANone = { - type: "none"; -}; - -export type ResponseQuestionCTAChoices = { - type: "multiple_choice" | "pmf" | "link"; - choices: ResponseQuestionActionButton[]; -}; - -export type ResponseQuestionCTAScores = { - type: "scoring" | "nps" | "ces" | "csat"; - scores: ResponseQuestionActionScoring[]; -}; - -export type ResponseQuestionCTAInput = { - type: "input"; - input: ResponseQuestionActionInput; -}; - -export type ResponseQuestionCTARange = { - type: "range"; - range: ResponseQuestionActionRange; -}; - -export type ResponseQuestionCTAAppStoreRating = { - type: "appstore_rating"; -}; - -export type ResponseQuestionCTA = - | ResponseQuestionCTANone - | ResponseQuestionCTAChoices - | ResponseQuestionCTAScores - | ResponseQuestionCTAInput - | ResponseQuestionCTARange - | ResponseQuestionCTAAppStoreRating; - -/** - * Answer - */ -export type ResponseAnswerValue = - | ResponseAnswerValueNone - | ResponseAnswerValueString - | ResponseAnswerValueNumber - | ResponseAnswerValueBoolean - | ResponseAnswerValueTime; - -export type ResponseAnswerValueNone = ResponseAnswerValueAbstract & { - type: "none"; -}; - -export type ResponseAnswerValueString = ResponseAnswerValueAbstract & { - type: "string"; - value_string: string; -}; - -export type ResponseAnswerValueNumber = ResponseAnswerValueAbstract & { - type: "number"; - value_number: number; -}; - -export type ResponseAnswerValueBoolean = ResponseAnswerValueAbstract & { - type: "boolean"; - value_boolean: boolean; -}; - -export type ResponseAnswerValueTime = ResponseAnswerValueAbstract & { - type: "time"; - value_time: Date; -}; - -type ResponseAnswerValueAbstract = { - action_id: string; -}; - -export type ResponseAnswer = { - id: string; - question_id: string; - values: ResponseAnswerValue[]; - created_at: Date; -}; - -export type ResponseQuestionActionSkip = { - id: string; - type: "skip"; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - payload: any; -}; - -/** - * Messages - */ -export type ResponseQuestionMessageText = { - type: "text"; - text: string; -}; - -export type ResponseQuestionMessage = { - id: string; -} & ResponseQuestionMessageText; - -export type ResponseQuestion = { - id: string; - messages: ResponseQuestionMessage[]; - call_to_action: ResponseQuestionCTA; - skip_action?: ResponseQuestionActionSkip; - ends: boolean; -}; - -export type QuestionAnswerPair = { - question: ResponseQuestion; - answer?: ResponseAnswer; -}; - -export type ResponseStatus = "started" | "ended" | "closed" | "interrupted"; - -/** - * Hooks - */ -export type HookType = - | "onSurveyShowed" - | "onSurveyStarted" - | "onQuestionReplied" - | "onSurveyCompleted" - | "onSurveyHidden"; - -export type ResponseHookSurveyShowed = { - survey: { - id: string; - survey_position: number; - survey_size: number; - survey_format: "conversationnal" | "cards" | undefined; - }; - response: { - id: string; - }; - user: { - anonymous_id: string; - user_id: string; - }; - items: QuestionAnswerPair[]; -}; - -export type ResponseHookSDKReady = { - user: { - anonymous_id: string; - user_id: string; - }; -}; - -export type ResponseHookSurveyStarted = { - survey: { - id: string; - survey_position: number; - survey_size: number; - survey_format: "conversationnal" | "cards" | undefined; - }; - response: { - id: string; - }; - user: { - anonymous_id: string; - user_id: string; - }; -}; - -export type ResponseHookSurveyHidden = { - survey: { - id: string; - survey_position: number; - survey_size: number; - survey_format: "conversationnal" | "cards" | undefined; - }; - response: { - id: string; - hide_reason: ResponseStatus; - }; - user: { - anonymous_id: string; - user_id: string; - }; - items: QuestionAnswerPair[]; -}; - -export type ResponseHookSurveyReplied = { - survey: { - id: string; - survey_position: number; - survey_size: number; - survey_format: "conversationnal" | "cards" | undefined; - }; - response: { - id: string; - status: ResponseStatus; - }; - user: { - anonymous_id: string; - user_id: string; - }; - items: QuestionAnswerPair[]; -}; - -export type ResponseHookSurveyCompleted = { - survey: { - id: string; - survey_position: number; - survey_size: number; - survey_format: "conversationnal" | "cards" | undefined; - }; - response: { - id: string; - }; - user: { - anonymous_id: string; - user_id: string; - }; - items: QuestionAnswerPair[]; -}; - -export type ResponseHook = { - onReady: ResponseHookSDKReady; - onSurveyShowed: ResponseHookSurveyShowed; - onSurveyStarted: ResponseHookSurveyStarted; - onQuestionReplied: ResponseHookSurveyReplied; - onSurveyCompleted: ResponseHookSurveyCompleted; - onSurveyHidden: ResponseHookSurveyHidden; -}; - -export type GlobalHooks = { - // eslint-disable-next-line no-unused-vars - [key in HookType | "onReady"]?: (payload: ResponseHook[key]) => void; -}; -export type SurveyHooks = { - // eslint-disable-next-line no-unused-vars - [key in HookType]?: (payload: ResponseHook[key]) => void; -}; - /** This is the Screeb tag options object. */ export type ScreebOptions = { /** If you're running Screeb tag in an iframe, please set the inner window here. */ @@ -440,7 +148,7 @@ export const init = ( websiteId: string, userId?: string, userProperties?: PropertyRecord, - hooks?: GlobalHooks + hooks?: any ) => { let identityObject; @@ -749,7 +457,7 @@ export const surveyStart = ( surveyId: string, allowMultipleResponses = true, hiddenFields: PropertyRecord = {}, - hooks: SurveyHooks | undefined = undefined + hooks?: any ) => callScreebCommand("survey.start", surveyId, { allow_multiple_responses: allowMultipleResponses,