@sprig-technologies/sprig-browser 2.24.4 → 2.24.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -351,6 +351,34 @@ interface PassthroughData {
351
351
  responseGroupUid: UUID;
352
352
  }
353
353
 
354
+ interface Experiment {
355
+ id: string;
356
+ variation?: string;
357
+ }
358
+
359
+ type QueueItem = [string, ...unknown[]] | (() => void);
360
+ declare class SprigQueue {
361
+ paused: boolean;
362
+ queue: QueueItem[];
363
+ ul: WindowSprig;
364
+ constructor(ul: WindowSprig, queue: QueueItem[]);
365
+ flush(queue: QueueItem[]): void;
366
+ isPaused(): boolean;
367
+ pause(): void;
368
+ unpause(): void;
369
+ push(action: QueueItem): void;
370
+ perform(func: () => void): void | Promise<unknown>;
371
+ /**
372
+ * Removes all queued items
373
+ */
374
+ empty(): void;
375
+ }
376
+
377
+ declare enum SurveyState {
378
+ Ready = "ready",
379
+ NoSurvey = "no survey"
380
+ }
381
+
354
382
  interface RecordedTaskResponseValueType {
355
383
  mediaRecordingUids?: string[] | null;
356
384
  taskDurationMillisecond?: number;
@@ -374,7 +402,7 @@ declare const enum CardType {
374
402
  Uploading = "uploading",
375
403
  VideoVoice = "videovoice"
376
404
  }
377
- declare type ConceptUrl = string | null;
405
+ type ConceptUrl = string | null;
378
406
  interface BaseCard {
379
407
  name: number;
380
408
  surveyId: number;
@@ -398,28 +426,28 @@ declare const enum Comparator {
398
426
  Contains = "contains",
399
427
  DoesNotContain = "notcontains"
400
428
  }
401
- declare type DefaultComparator = Comparator.Answered | Comparator.Skipped;
402
- declare type RoutingOption<C extends Comparator = DefaultComparator> = OldRoutingOption<C> | GroupRoutingOption;
403
- declare type OldRoutingOption<C extends Comparator = DefaultComparator> = {
429
+ type DefaultComparator = Comparator.Answered | Comparator.Skipped;
430
+ type RoutingOption<C extends Comparator = DefaultComparator> = OldRoutingOption<C> | GroupRoutingOption;
431
+ type OldRoutingOption<C extends Comparator = DefaultComparator> = {
404
432
  comparator: C;
405
433
  target: number;
406
434
  /** @example '', 'option_2', ['option_1'] */
407
435
  value: number | string | string[];
408
436
  };
409
- declare type GroupRoutingOption = {
437
+ type GroupRoutingOption = {
410
438
  group: (RoutingGroupOption | BooleanOperator)[];
411
439
  target: number;
412
440
  };
413
- declare type RoutingGroupOption = {
441
+ type RoutingGroupOption = {
414
442
  comparator: Comparator;
415
443
  questionIndex: number;
416
444
  value: number | string | string[] | {
417
445
  skipped: true;
418
446
  } | null | undefined;
419
447
  };
420
- declare type RoutingOptions<C extends Comparator = DefaultComparator> = RoutingOption<C | DefaultComparator>[] | null;
448
+ type RoutingOptions<C extends Comparator = DefaultComparator> = RoutingOption<C | DefaultComparator>[] | null;
421
449
  /** @example <p>Body</p> */
422
- declare type RichTextBody = string;
450
+ type RichTextBody = string;
423
451
  declare const enum PromptActionType {
424
452
  Continue = "CONTINUE",
425
453
  External = "EXTERNAL"
@@ -514,7 +542,7 @@ interface CompleteTaskPage extends BaseTaskPage {
514
542
  taskDetail: string;
515
543
  type: RecordedTaskPageType.CompleteTask;
516
544
  }
517
- declare type RecordedTaskPage = PermissionTaskPage | ScreenTaskPage | StartTaskPage | CompleteTaskPage;
545
+ type RecordedTaskPage = PermissionTaskPage | ScreenTaskPage | StartTaskPage | CompleteTaskPage;
518
546
  interface RecordedTaskCardProperties {
519
547
  captionText: string;
520
548
  conceptUrl: ConceptUrl;
@@ -659,7 +687,7 @@ interface VideoVoiceCard extends BaseCard {
659
687
  };
660
688
  type: CardType.VideoVoice;
661
689
  }
662
- declare type Card = TextUrlPromptCard | ConsentLegalCard | RecordedTaskCard | LikertCard | OpenTextCard | MultipleChoiceSingleSelectCard | MultipleChoiceMultiSelectCard | NPSCard | VideoVoiceCard;
690
+ type Card = TextUrlPromptCard | ConsentLegalCard | RecordedTaskCard | LikertCard | OpenTextCard | MultipleChoiceSingleSelectCard | MultipleChoiceMultiSelectCard | NPSCard | VideoVoiceCard;
663
691
 
664
692
  interface RecordedTaskResponseType {
665
693
  questionId: number;
@@ -667,7 +695,7 @@ interface RecordedTaskResponseType {
667
695
  value: RecordedTaskResponseValueType;
668
696
  }
669
697
 
670
- declare type SprigEventMap = {
698
+ type SprigEventMap = {
671
699
  [InternalEventName.CurrentQuestion]: [
672
700
  {
673
701
  [InternalEventData.QuestionId]: number;
@@ -774,9 +802,9 @@ declare type SprigEventMap = {
774
802
  [SprigRecordingEvent.StartTask]: [];
775
803
  };
776
804
  declare const eventEmitter: Emitter<SprigEventMap>;
777
- declare type SprigEventEmitter = typeof eventEmitter;
805
+ type SprigEventEmitter = typeof eventEmitter;
778
806
 
779
- declare type MatchType = "exactly" | "legacy";
807
+ type MatchType = "exactly" | "legacy";
780
808
  interface InteractiveEvent {
781
809
  id: number;
782
810
  matchType: MatchType;
@@ -856,6 +884,8 @@ interface Config {
856
884
  /** @example "SJcVfq-7QQ" */
857
885
  envId: string;
858
886
  environmentId?: string;
887
+ exitOnOverlayClick?: boolean;
888
+ exitOnOverlayClickMobile?: boolean;
859
889
  eventEmitFn: SprigEventEmitter["emit"];
860
890
  fontFamily?: string;
861
891
  fontFamilyURL: undefined;
@@ -891,6 +921,7 @@ interface Config {
891
921
  maxAttrValueLength: number;
892
922
  maxEmailLength: number;
893
923
  maxEventLength: number;
924
+ maxReplayDurationSeconds?: number;
894
925
  maxUserIdLength: number;
895
926
  mobileSDKVersion: undefined;
896
927
  mode?: string;
@@ -927,33 +958,34 @@ interface Config {
927
958
  };
928
959
  }
929
960
 
930
- declare enum SurveyState {
931
- Ready = "ready",
932
- NoSurvey = "no survey"
933
- }
934
-
935
- interface Experiment {
936
- id: string;
937
- variation?: string;
938
- }
939
-
940
- declare type QueueItem = [string, ...unknown[]] | (() => void);
941
- declare class SprigQueue {
942
- paused: boolean;
943
- queue: QueueItem[];
944
- ul: WindowSprig;
945
- constructor(ul: WindowSprig, queue: QueueItem[]);
946
- flush(queue: QueueItem[]): void;
947
- isPaused(): boolean;
948
- pause(): void;
949
- unpause(): void;
950
- push(action: QueueItem): void;
951
- perform(func: () => void): void | Promise<unknown>;
952
- /**
953
- * Removes all queued items
954
- */
955
- empty(): void;
961
+ declare enum ReplayEventType {
962
+ Click = "Sprig_Click",
963
+ Event = "Sprig_TrackEvent",
964
+ PageView = "Sprig_PageView",
965
+ SurveyShown = "Sprig_ShowSurvey",
966
+ SurveySubmitted = "Sprig_SubmitSurvey",
967
+ Noop = "Sprig_Noop"
956
968
  }
969
+ type EventDigest = {
970
+ timestamp: number;
971
+ type: ReplayEventType.Click;
972
+ } | {
973
+ timestamp: number;
974
+ name: string;
975
+ type: ReplayEventType.Event;
976
+ } | {
977
+ timestamp: number;
978
+ type: ReplayEventType.PageView;
979
+ url: string;
980
+ } | {
981
+ timestamp: number;
982
+ surveyId: string;
983
+ type: ReplayEventType.SurveyShown;
984
+ } | {
985
+ timestamp: number;
986
+ surveyId: string;
987
+ type: ReplayEventType.SurveySubmitted;
988
+ };
957
989
 
958
990
  declare namespace optimizely {
959
991
  interface Optimizely {
@@ -1034,7 +1066,14 @@ declare namespace upchunk {
1034
1066
 
1035
1067
  declare namespace sprigConfig {
1036
1068
  type IdentifyResult = Promise<
1037
- { success: boolean; message?: string } | undefined
1069
+ | {
1070
+ success: boolean;
1071
+ message?: string;
1072
+ surveyState?: SurveyState;
1073
+ surveyId?: number;
1074
+ responseGroupUid?: string;
1075
+ }
1076
+ | undefined
1038
1077
  >;
1039
1078
 
1040
1079
  interface TrackPayload {
@@ -1047,17 +1086,30 @@ declare namespace sprigConfig {
1047
1086
  }
1048
1087
 
1049
1088
  interface SprigAPIActions {
1089
+ // internal apis
1090
+ _completeSessionReplay: (payload: {
1091
+ surveyId: number;
1092
+ responseGroupUuid: string;
1093
+ eventDigest?: EventDigest[];
1094
+ }) => Promise<void>;
1095
+ _generateVideoUploadUrl: (body: {
1096
+ mediaRecordingUid?: string;
1097
+ mediaType?: MediaType;
1098
+ questionId?: number;
1099
+ responseGroupUid?: string;
1100
+ surveyId?: number;
1101
+ updatedAt?: string;
1102
+ visitorId?: string | null;
1103
+ }) => Promise<string | null>;
1050
1104
  _previewSurvey: (surveyTemplateId: UUID) => void;
1051
1105
  _reviewSurvey: (surveyId: number) => void;
1106
+
1107
+ // external apis
1052
1108
  addListener: (event: SprigEvent, listener: SprigListener) => Promise<void>;
1053
1109
  addSurveyListener: (listener: SprigListener) => Promise<void>;
1054
1110
  applyStyles: (styleString: string) => void;
1055
1111
  dismissActiveSurvey: (reason?: DismissReason) => void;
1056
- displaySurvey: (surveyId: number) => Promise<{
1057
- success: boolean;
1058
- message?: string;
1059
- surveyState: SurveyState;
1060
- }>;
1112
+ displaySurvey: (surveyId: number) => IdentifyResult;
1061
1113
  identifyAndSetAttributes: (payload: {
1062
1114
  anonymousId?: string;
1063
1115
  attributes?: SprigAttributes;
@@ -1147,7 +1199,7 @@ declare namespace sprigConfig {
1147
1199
  partnerAnonymousId: string | null;
1148
1200
  replayNonce?: string;
1149
1201
  reportError: (name: string, err: Error, extraInfo?: object) => void;
1150
- sampleRate?: unknown; // TODO: determine type
1202
+ sampleRate?: number;
1151
1203
  token: string | null;
1152
1204
  UPDATES: typeof EVENTS;
1153
1205
  viewSDKURL?: string;
@@ -1205,7 +1257,8 @@ declare class SprigAPI {
1205
1257
  SURVEY_WILL_CLOSE: SprigEvent;
1206
1258
  SURVEY_WILL_PRESENT: SprigEvent;
1207
1259
  QUESTION_ANSWERED: SprigEvent;
1208
- CLOSE_SURVEY_ON_OVERLAY_CLICK: SprigEvent; /**
1260
+ CLOSE_SURVEY_ON_OVERLAY_CLICK: SprigEvent;
1261
+ /**
1209
1262
  * Attach an email address to visitor
1210
1263
  */
1211
1264
  VISITOR_ID_UPDATED: SprigEvent;
@@ -1315,7 +1368,7 @@ declare class SprigAPI {
1315
1368
  */
1316
1369
  teardown(): void;
1317
1370
  }
1318
- declare type NpmConfig = {
1371
+ type NpmConfig = {
1319
1372
  envId?: string;
1320
1373
  environmentId?: string;
1321
1374
  path?: string;
@@ -1328,7 +1381,7 @@ declare const sprig: {
1328
1381
  */
1329
1382
  configure: (config: NpmConfig) => sprigConfig.WindowSprig;
1330
1383
  };
1331
- declare type WindowSprig$1 = typeof window.Sprig;
1384
+ type WindowSprig$1 = typeof window.Sprig;
1332
1385
 
1333
1386
  declare const _default: {
1334
1387
  sprig: {