surveysparrow-ionic-plugin 2.0.2-beta.1 → 2.0.2-beta.2

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.
Files changed (44) hide show
  1. package/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +81 -100
  2. package/dist/angular-ui/esm2022/spotchecks/SpotCheckEventListener.mjs +26 -0
  3. package/dist/angular-ui/esm2022/spotchecks/SpotcheckStateService.mjs +1 -3
  4. package/dist/angular-ui/esm2022/spotchecks/api.mjs +3 -3
  5. package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +14 -18
  6. package/dist/angular-ui/esm2022/spotchecks/index.mjs +2 -1
  7. package/dist/angular-ui/esm2022/spotchecks/types.mjs +1 -1
  8. package/dist/angular-ui/fesm2022/angular-ui.mjs +120 -122
  9. package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
  10. package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +10 -5
  11. package/dist/angular-ui/spotchecks/SpotCheckEventListener.d.ts +16 -0
  12. package/dist/angular-ui/spotchecks/helpers.d.ts +1 -2
  13. package/dist/angular-ui/spotchecks/index.d.ts +1 -0
  14. package/dist/angular-ui/spotchecks/types.d.ts +0 -2
  15. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +10 -5
  16. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +75 -95
  17. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +1 -1
  18. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.d.ts +16 -0
  19. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js +28 -0
  20. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js.map +1 -0
  21. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js +0 -2
  22. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js.map +1 -1
  23. package/dist/esm/angular-ui/lib/spotchecks/api.js +3 -4
  24. package/dist/esm/angular-ui/lib/spotchecks/api.js.map +1 -1
  25. package/dist/esm/angular-ui/lib/spotchecks/helpers.d.ts +1 -2
  26. package/dist/esm/angular-ui/lib/spotchecks/helpers.js +15 -18
  27. package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +1 -1
  28. package/dist/esm/angular-ui/lib/spotchecks/index.d.ts +1 -0
  29. package/dist/esm/angular-ui/lib/spotchecks/index.js +1 -0
  30. package/dist/esm/angular-ui/lib/spotchecks/index.js.map +1 -1
  31. package/dist/esm/angular-ui/lib/spotchecks/types.d.ts +0 -2
  32. package/dist/esm/angular-ui/lib/spotchecks/types.js.map +1 -1
  33. package/dist/plugin.cjs.js +116 -116
  34. package/dist/plugin.cjs.js.map +1 -1
  35. package/dist/plugin.js +116 -116
  36. package/dist/plugin.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +76 -98
  39. package/src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts +50 -0
  40. package/src/angular-ui/lib/spotchecks/SpotcheckStateService.ts +0 -2
  41. package/src/angular-ui/lib/spotchecks/api.ts +4 -4
  42. package/src/angular-ui/lib/spotchecks/helpers.ts +14 -23
  43. package/src/angular-ui/lib/spotchecks/index.ts +3 -0
  44. package/src/angular-ui/lib/spotchecks/types.ts +0 -2
@@ -7,15 +7,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { Component, Input, ViewChild, ElementRef, HostListener, } from '@angular/core';
10
+ import { Component, Input, ViewChild, ElementRef, HostListener, NgZone, ChangeDetectorRef, } from '@angular/core';
11
11
  import { CommonModule } from '@angular/common';
12
12
  import { DomSanitizer } from '@angular/platform-browser';
13
13
  import { closeSpotCheck, closeSpotCheckAndHandleSurveyEnd, getSpotcheckComponentCssStyles, handleSurveyEnd, ischatSurvey } from './helpers';
14
14
  import { getSpotcheckStateService } from './helpers';
15
+ import { getSpotCheckEventListener } from './SpotCheckEventListener';
15
16
  import axios from 'axios';
16
17
  let WebViewComponent = class WebViewComponent {
17
- constructor(sanitizer) {
18
+ constructor(sanitizer, ngZone, cdr) {
18
19
  this.sanitizer = sanitizer;
20
+ this.ngZone = ngZone;
21
+ this.cdr = cdr;
19
22
  this.url = '';
20
23
  this.webviewType = 'classic';
21
24
  this.isMiniCard = false;
@@ -46,92 +49,53 @@ let WebViewComponent = class WebViewComponent {
46
49
  setupIframeLoadListener() {
47
50
  const iframe = this.iframe.nativeElement;
48
51
  iframe.addEventListener('load', () => {
49
- this.injectNativeBridgeAdapters(iframe);
50
- const stateService = getSpotcheckStateService();
51
- if (this.webviewType === 'classic') {
52
- stateService.setState({ isClassicLoading: false });
53
- }
54
- else {
55
- stateService.setState({ isChatLoading: false });
56
- }
57
- });
58
- }
59
- injectNativeBridgeAdapters(iframe) {
60
- if (iframe && iframe.contentWindow) {
61
- try {
62
- const iframeWindow = iframe.contentWindow;
63
- if (!iframeWindow.SsAndroidSdk) {
64
- iframeWindow.SsAndroidSdk = {
65
- shareData: function () { },
66
- sendPartialSubmissionData: function () { }
67
- };
68
- }
69
- if (!iframeWindow.Android) {
70
- iframeWindow.Android = {
71
- onMessageReceive: function () { }
72
- };
52
+ this.ngZone.run(() => {
53
+ const stateService = getSpotcheckStateService();
54
+ if (this.webviewType === 'classic') {
55
+ stateService.setState({ isClassicLoading: false });
73
56
  }
74
- if (!iframeWindow.webkit) {
75
- iframeWindow.webkit = {
76
- messageHandlers: {
77
- surveyResponse: {
78
- postMessage: function () { }
79
- },
80
- spotCheckData: {
81
- postMessage: function () { }
82
- },
83
- flutterSpotCheckData: {
84
- postMessage: function () { }
85
- }
86
- }
87
- };
88
- }
89
- if (!iframeWindow.flutterSpotCheckData) {
90
- iframeWindow.flutterSpotCheckData = {
91
- postMessage: function () { }
92
- };
57
+ else {
58
+ stateService.setState({ isChatLoading: false });
93
59
  }
94
- }
95
- catch (error) { }
96
- }
60
+ });
61
+ });
97
62
  }
98
63
  onMessage(event) {
99
- const stateService = getSpotcheckStateService();
100
- const { data } = event;
101
- switch (data.type) {
102
- case 'slideInFrame':
103
- if (data.mounted) {
104
- stateService.setState({ isMounted: true });
105
- }
106
- break;
107
- case 'resizeWindow':
108
- if (data.size) {
109
- stateService.setState({
110
- currentQuestionHeight: data.size.height,
111
- });
112
- }
113
- else if (data.isCloseButtonEnabled) {
114
- stateService.setState({
115
- isCloseButtonEnabled: data.isCloseButtonEnabled,
64
+ this.ngZone.run(() => {
65
+ const stateService = getSpotcheckStateService();
66
+ const { data } = event;
67
+ switch (data.type) {
68
+ case 'slideInFrame':
69
+ if (data.mounted) {
70
+ stateService.setState({ isMounted: true });
71
+ }
72
+ break;
73
+ case 'resizeWindow':
74
+ if (data.size) {
75
+ stateService.setState({
76
+ currentQuestionHeight: data.size.height,
77
+ });
78
+ }
79
+ else if (data.isCloseButtonEnabled) {
80
+ stateService.setState({
81
+ isCloseButtonEnabled: data.isCloseButtonEnabled,
82
+ });
83
+ }
84
+ break;
85
+ case 'surveyCompleted':
86
+ closeSpotCheckAndHandleSurveyEnd().then(() => {
87
+ getSpotCheckEventListener().emit('surveyCompleted', data.response);
88
+ this.cdr.detectChanges();
116
89
  });
117
- }
118
- break;
119
- case 'surveyCompleted':
120
- closeSpotCheckAndHandleSurveyEnd();
121
- // spotchecksListener.emitSurveyCompleted(data.response);
122
- break;
123
- case 'surveyLoadStarted':
124
- // spotchecksListener.emitSurveyLoadStarted(data.surveyDetails);
125
- break;
126
- case 'classicLoadEvent':
127
- stateService.setState({ isClassicLoadEventReceived: true });
128
- break;
129
- case 'chatLoadEvent':
130
- stateService.setState({ isChatLoadEventReceived: true });
131
- break;
132
- default:
133
- break;
134
- }
90
+ break;
91
+ case 'surveyLoadStarted':
92
+ getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);
93
+ break;
94
+ default:
95
+ break;
96
+ }
97
+ this.cdr.detectChanges();
98
+ });
135
99
  }
136
100
  };
137
101
  __decorate([
@@ -162,8 +126,7 @@ WebViewComponent = __decorate([
162
126
  template: `
163
127
  <div style="overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;">
164
128
  <iframe
165
- allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write; fullscreen"
166
- allowfullscreen
129
+ allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;"
167
130
  #iframeRef
168
131
  [src]="safeUrl"
169
132
  style="width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;"
@@ -175,7 +138,9 @@ WebViewComponent = __decorate([
175
138
  standalone: true,
176
139
  imports: [CommonModule],
177
140
  }),
178
- __metadata("design:paramtypes", [DomSanitizer])
141
+ __metadata("design:paramtypes", [DomSanitizer,
142
+ NgZone,
143
+ ChangeDetectorRef])
179
144
  ], WebViewComponent);
180
145
  export { WebViewComponent };
181
146
  let CloseSVGComponent = class CloseSVGComponent {
@@ -223,7 +188,9 @@ CloseSVGComponent = __decorate([
223
188
  ], CloseSVGComponent);
224
189
  export { CloseSVGComponent };
225
190
  let CloseButtonComponent = class CloseButtonComponent {
226
- constructor() {
191
+ constructor(ngZone, cdr) {
192
+ this.ngZone = ngZone;
193
+ this.cdr = cdr;
227
194
  this.size = 30;
228
195
  this.strokeWidth = 1.2;
229
196
  this.isVisible = false;
@@ -232,13 +199,19 @@ let CloseButtonComponent = class CloseButtonComponent {
232
199
  this.onClick = async () => {
233
200
  await closeSpotCheck();
234
201
  handleSurveyEnd();
202
+ this.ngZone.run(() => {
203
+ this.cdr.detectChanges();
204
+ });
235
205
  };
236
206
  this.stateService = getSpotcheckStateService();
237
207
  this.state = this.stateService.getState();
238
208
  this.updateComponentState();
239
209
  this.stateSubscription = this.stateService.state$.subscribe((newState) => {
240
- this.state = newState;
241
- this.updateComponentState();
210
+ this.ngZone.run(() => {
211
+ this.state = newState;
212
+ this.updateComponentState();
213
+ this.cdr.detectChanges();
214
+ });
242
215
  });
243
216
  }
244
217
  ngOnDestroy() {
@@ -282,11 +255,14 @@ CloseButtonComponent = __decorate([
282
255
  standalone: true,
283
256
  imports: [CommonModule, CloseSVGComponent],
284
257
  }),
285
- __metadata("design:paramtypes", [])
258
+ __metadata("design:paramtypes", [NgZone,
259
+ ChangeDetectorRef])
286
260
  ], CloseButtonComponent);
287
261
  export { CloseButtonComponent };
288
262
  let SpotCheckComponent = class SpotCheckComponent {
289
- constructor() {
263
+ constructor(ngZone, cdr) {
264
+ this.ngZone = ngZone;
265
+ this.cdr = cdr;
290
266
  this.componentStyles = {};
291
267
  this.avatarUrl = '';
292
268
  this.initializeComponent = async () => {
@@ -329,9 +305,12 @@ let SpotCheckComponent = class SpotCheckComponent {
329
305
  this.state = this.spotcheckStateService.getState();
330
306
  this.updateComponentStyles();
331
307
  this.stateSubscription = this.spotcheckStateService.state$.subscribe((newState) => {
332
- this.state = newState;
333
- this.updateComponentStyles();
334
- this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
308
+ this.ngZone.run(() => {
309
+ this.state = newState;
310
+ this.updateComponentStyles();
311
+ this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
312
+ this.cdr.detectChanges();
313
+ });
335
314
  });
336
315
  }
337
316
  ngOnInit() {
@@ -354,7 +333,8 @@ SpotCheckComponent = __decorate([
354
333
  standalone: true,
355
334
  imports: [CommonModule, WebViewComponent, CloseButtonComponent],
356
335
  }),
357
- __metadata("design:paramtypes", [])
336
+ __metadata("design:paramtypes", [NgZone,
337
+ ChangeDetectorRef])
358
338
  ], SpotCheckComponent);
359
339
  export { SpotCheckComponent };
360
340
  //# sourceMappingURL=SpotCheckComponent.js.map
@@ -1 +1 @@
1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I,CAAC,KAAK,CAAC,SAAS,IAAI,iEAAiE,CAAC;QAC7G,CAAC,CACF,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAEO,qBAAqB;QAC3B,IAAI,CAAC,eAAe,GAAG,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CA2CF,CAAA;AA5EY,kBAAkB;IAP9B,SAAS,CAAC;QACT,QAAQ,EAAE,oBAAoB;QAC9B,WAAW,EAAE,2BAA2B;QACxC,SAAS,EAAE,CAAC,0BAA0B,CAAC;QACvC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,CAAC;KAChE,CAAC;;GACW,kBAAkB,CA4E9B","sourcesContent":["import {\n OnInit,\n Component,\n Input,\n OnDestroy,\n ViewChild,\n ElementRef,\n AfterViewInit,\n HostListener,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { Subscription } from 'rxjs';\nimport { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';\nimport { closeSpotCheck, closeSpotCheckAndHandleSurveyEnd, getSpotcheckComponentCssStyles, handleSurveyEnd, ischatSurvey } from './helpers';\nimport { SpotcheckState } from './types';\nimport { getSpotcheckStateService } from './helpers';\nimport { SpotcheckStateService } from './SpotcheckStateService';\nimport axios from 'axios';\n\n@Component({\n selector: 'WebViewComponent',\n template: `\n <div style=\"overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;\">\n <iframe\n allow=\"camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write; fullscreen\"\n allowfullscreen\n #iframeRef\n [src]=\"safeUrl\"\n style=\"width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;\"\n frameborder=\"0\"\n >\n </iframe>\n </div>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class WebViewComponent implements OnInit, AfterViewInit {\n @Input() url: string = '';\n @Input() webviewType: 'classic' | 'chat' = 'classic';\n @Input() isMiniCard: boolean = false;\n\n safeUrl: SafeResourceUrl | null = null;\n @ViewChild('iframeRef') iframe!: ElementRef<HTMLIFrameElement>;\n\n constructor(private sanitizer: DomSanitizer) {}\n ngOnInit() {\n if (this.url) {\n this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);\n }\n }\n\n ngAfterViewInit() {\n const stateService = getSpotcheckStateService();\n const webViewRef = this.iframe.nativeElement;\n\n if (this.webviewType === 'classic') {\n stateService.setState({\n classicWebViewRef: webViewRef,\n isClassicLoading: false,\n });\n } else {\n stateService.setState({\n chatWebViewRef: webViewRef,\n isChatLoading: false,\n });\n }\n this.setupIframeLoadListener();\n }\n\n private setupIframeLoadListener() {\n const iframe = this.iframe.nativeElement;\n iframe.addEventListener('load', () => {\n this.injectNativeBridgeAdapters(iframe);\n const stateService = getSpotcheckStateService();\n if (this.webviewType === 'classic') {\n stateService.setState({ isClassicLoading: false });\n } else {\n stateService.setState({ isChatLoading: false });\n }\n });\n }\n\n private injectNativeBridgeAdapters(iframe: HTMLIFrameElement) {\n if (iframe && iframe.contentWindow) {\n try {\n const iframeWindow = iframe.contentWindow as any;\n \n if (!iframeWindow.SsAndroidSdk) {\n iframeWindow.SsAndroidSdk = {\n shareData: function() {},\n sendPartialSubmissionData: function() {}\n };\n }\n\n if (!iframeWindow.Android) {\n iframeWindow.Android = {\n onMessageReceive: function() {}\n };\n }\n\n if (!iframeWindow.webkit) {\n iframeWindow.webkit = {\n messageHandlers: {\n surveyResponse: {\n postMessage: function() {}\n },\n spotCheckData: {\n postMessage: function() {}\n },\n flutterSpotCheckData: {\n postMessage: function() {}\n }\n }\n };\n }\n\n if (!iframeWindow.flutterSpotCheckData) {\n iframeWindow.flutterSpotCheckData = {\n postMessage: function() {}\n };\n }\n } catch (error) {}\n }\n }\n\n @HostListener('window:message', ['$event'])\n onMessage(event: MessageEvent) {\n const stateService = getSpotcheckStateService();\n const { data } = event;\n switch (data.type) {\n case 'slideInFrame':\n if (data.mounted) {\n stateService.setState({ isMounted: true });\n }\n break;\n\n case 'resizeWindow':\n if (data.size) {\n stateService.setState({\n currentQuestionHeight: data.size.height,\n });\n } else if (data.isCloseButtonEnabled) {\n stateService.setState({\n isCloseButtonEnabled: data.isCloseButtonEnabled,\n });\n }\n break;\n\n case 'surveyCompleted':\n closeSpotCheckAndHandleSurveyEnd();\n // spotchecksListener.emitSurveyCompleted(data.response);\n break;\n\n case 'surveyLoadStarted':\n // spotchecksListener.emitSurveyLoadStarted(data.surveyDetails);\n break;\n\n case 'classicLoadEvent':\n stateService.setState({ isClassicLoadEventReceived: true });\n break;\n\n case 'chatLoadEvent':\n stateService.setState({ isChatLoadEventReceived: true });\n break;\n\n default:\n break;\n }\n }\n}\n\n@Component({\n selector: 'close-svg',\n template: `\n <svg\n [attr.width]=\"size\"\n [attr.height]=\"size\"\n viewBox=\"0 0 32 32\"\n fill=\"none\"\n xmlns=\"https://www.w3.org/2000/svg\"\n >\n <path\n d=\"M10.6665 10.667L21.3332 21.3337M21.3332 10.667L10.6665 21.3337\"\n [attr.stroke]=\"stroke\"\n [attr.stroke-width]=\"strokeWidth\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class CloseSVGComponent {\n @Input() size: number = 32;\n @Input() stroke: string = '#919191';\n @Input() strokeWidth: number = 1.5;\n}\n\n@Component({\n selector: 'spotcheck-close-button',\n template: `\n <div style=\"position: absolute; top: -36px; right: 16px; z-index: 100001; cursor: pointer; background-color: white; border-radius: 50px;\" (click)=\"onClick()\" *ngIf=\"isVisible && isMiniCard\">\n <close-svg [size]=\"size\" [stroke]=\"stroke\" [strokeWidth]=\"strokeWidth\" style=\"display: flex; align-items: center; justify-content: center;\"/>\n </div>\n <div style=\"position: absolute; top: 16px; right: 16px; z-index: 100001; cursor: pointer;\" (click)=\"onClick()\" *ngIf=\"isVisible && !isMiniCard\">\n <close-svg [size]=\"size\" [stroke]=\"stroke\" [strokeWidth]=\"strokeWidth\"/>\n </div>\n `,\n standalone: true,\n imports: [CommonModule, CloseSVGComponent],\n})\nexport class CloseButtonComponent implements OnDestroy {\n @Input() size: number = 30;\n @Input() strokeWidth: number = 1.2;\n \n state: SpotcheckState;\n private stateService: SpotcheckStateService;\n private stateSubscription!: Subscription;\n \n isVisible: boolean = false;\n isMiniCard: boolean = false;\n stroke: string = 'black';\n \n constructor() {\n this.stateService = getSpotcheckStateService();\n this.state = this.stateService.getState();\n this.updateComponentState();\n\n this.stateSubscription = this.stateService.state$.subscribe(\n (newState: SpotcheckState) => {\n this.state = newState;\n this.updateComponentState();\n }\n );\n }\n\n ngOnDestroy(): void {\n if (this.stateSubscription) {\n this.stateSubscription.unsubscribe();\n }\n }\n\n private updateComponentState(): void {\n this.isVisible =\n this.state.isCloseButtonEnabled &&\n ((this.state.currentQuestionHeight > 0 && !this.state.isFullScreenMode) ||\n (this.state.isFullScreenMode &&\n ((!this.state.isClassicLoading &&\n this.state.spotCheckType === 'classic') ||\n (!this.state.isChatLoading &&\n this.state.spotCheckType === 'chat'))));\n this.isMiniCard = this.state.spotChecksMode === 'miniCard';\n this.stroke = this.isMiniCard ? 'black' : this.state.closeButtonStyle?.['ctaButton'] || 'black';\n }\n\n onClick = async () => {\n await closeSpotCheck();\n handleSurveyEnd();\n };\n}\n\n\n@Component({\n selector: 'SpotCheckComponent',\n templateUrl: './SpotCheckComponent.html',\n styleUrls: ['./SpotCheckComponent.css'],\n standalone: true,\n imports: [CommonModule, WebViewComponent, CloseButtonComponent],\n})\nexport class SpotCheckComponent implements OnInit, OnDestroy {\n state: SpotcheckState;\n private spotcheckStateService: SpotcheckStateService;\n private stateSubscription: Subscription;\n componentStyles: any = {};\n avatarUrl: string = '';\n\n constructor() {\n this.spotcheckStateService = getSpotcheckStateService();\n this.state = this.spotcheckStateService.getState();\n this.updateComponentStyles();\n\n this.stateSubscription = this.spotcheckStateService.state$.subscribe(\n (newState: SpotcheckState) => {\n this.state = newState;\n this.updateComponentStyles();\n this.avatarUrl = this.state.avatarUrl || \"https://static.surveysparrow.com/application/images/profile.png\";\n }\n );\n }\n\n ngOnInit(): void {\n this.initializeComponent();\n }\n\n ngOnDestroy(): void {\n if (this.stateSubscription) {\n this.stateSubscription.unsubscribe();\n }\n }\n\n private updateComponentStyles(): void {\n this.componentStyles = getSpotcheckComponentCssStyles(this.state);\n }\n\n initializeComponent = async () => {\n try {\n const domainName = this.state.domainName;\n const targetToken = this.state.targetToken;\n const response = await axios.get(\n `https://${domainName}/api/internal/spotcheck/widget/${targetToken}/init`\n );\n const data = response.data;\n\n if (data.filteredSpotChecks && data.filteredSpotChecks.length > 0) {\n let classicIframe = false;\n let chatIframe = false;\n\n data.filteredSpotChecks.forEach((spotcheck: any) => {\n if (\n spotcheck.appearance.mode === 'fullScreen' &&\n ischatSurvey(spotcheck?.survey?.surveyType)\n ) {\n chatIframe = true;\n } else {\n classicIframe = true;\n }\n });\n\n const newClassicUrl = classicIframe\n ? `https://${domainName}/eui-template/classic`\n : '';\n const newChatUrl = chatIframe\n ? `https://${domainName}/eui-template/chat`\n : '';\n\n this.spotcheckStateService.setState({\n filteredSpotChecks: data.filteredSpotChecks,\n classicUrl: newClassicUrl,\n chatUrl: newChatUrl,\n });\n }\n } catch (error) {\n console.log('Error initializing widget:', JSON.stringify(error));\n }\n };\n}\n"]}
1
+ {"version":3,"file":"SpotCheckComponent.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/SpotCheckComponent.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAEL,SAA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IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAEO,qBAAqB;QAC3B,IAAI,CAAC,eAAe,GAAG,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CA6CF,CAAA;AApFY,kBAAkB;IAP9B,SAAS,CAAC;QACT,QAAQ,EAAE,oBAAoB;QAC9B,WAAW,EAAE,2BAA2B;QACxC,SAAS,EAAE,CAAC,0BAA0B,CAAC;QACvC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,CAAC;KAChE,CAAC;qCASkB,MAAM;QACT,iBAAiB;GATrB,kBAAkB,CAoF9B","sourcesContent":["import {\n OnInit,\n Component,\n Input,\n OnDestroy,\n ViewChild,\n ElementRef,\n AfterViewInit,\n HostListener,\n NgZone,\n ChangeDetectorRef,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { Subscription } from 'rxjs';\nimport { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';\nimport { closeSpotCheck, closeSpotCheckAndHandleSurveyEnd, getSpotcheckComponentCssStyles, handleSurveyEnd, ischatSurvey } from './helpers';\nimport { SpotcheckState } from './types';\nimport { getSpotcheckStateService } from './helpers';\nimport { SpotcheckStateService } from './SpotcheckStateService';\nimport { getSpotCheckEventListener } from './SpotCheckEventListener';\nimport axios from 'axios';\n\n@Component({\n selector: 'WebViewComponent',\n template: `\n <div style=\"overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;\">\n <iframe\n allow=\"camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;\"\n #iframeRef\n [src]=\"safeUrl\"\n style=\"width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;\"\n frameborder=\"0\"\n >\n </iframe>\n </div>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class WebViewComponent implements OnInit, AfterViewInit {\n @Input() url: string = '';\n @Input() webviewType: 'classic' | 'chat' = 'classic';\n @Input() isMiniCard: boolean = false;\n\n safeUrl: SafeResourceUrl | null = null;\n @ViewChild('iframeRef') iframe!: ElementRef<HTMLIFrameElement>;\n\n constructor(\n private sanitizer: DomSanitizer,\n private ngZone: NgZone,\n private cdr: ChangeDetectorRef,\n ) {}\n ngOnInit() {\n if (this.url) {\n this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);\n }\n }\n\n ngAfterViewInit() {\n const stateService = getSpotcheckStateService();\n const webViewRef = this.iframe.nativeElement;\n\n if (this.webviewType === 'classic') {\n stateService.setState({\n classicWebViewRef: webViewRef,\n isClassicLoading: false,\n });\n } else {\n stateService.setState({\n chatWebViewRef: webViewRef,\n isChatLoading: false,\n });\n }\n this.setupIframeLoadListener();\n }\n\n private setupIframeLoadListener() {\n const iframe = this.iframe.nativeElement;\n iframe.addEventListener('load', () => {\n this.ngZone.run(() => {\n const stateService = getSpotcheckStateService();\n if (this.webviewType === 'classic') {\n stateService.setState({ isClassicLoading: false });\n } else {\n stateService.setState({ isChatLoading: false });\n }\n });\n });\n }\n\n @HostListener('window:message', ['$event'])\n onMessage(event: MessageEvent) {\n this.ngZone.run(() => {\n const stateService = getSpotcheckStateService();\n const { data } = event;\n switch (data.type) {\n case 'slideInFrame':\n if (data.mounted) {\n stateService.setState({ isMounted: true });\n }\n break;\n\n case 'resizeWindow':\n if (data.size) {\n stateService.setState({\n currentQuestionHeight: data.size.height,\n });\n } else if (data.isCloseButtonEnabled) {\n stateService.setState({\n isCloseButtonEnabled: data.isCloseButtonEnabled,\n });\n }\n break;\n\n case 'surveyCompleted':\n closeSpotCheckAndHandleSurveyEnd().then(() => {\n getSpotCheckEventListener().emit('surveyCompleted', data.response);\n this.cdr.detectChanges();\n });\n break;\n\n case 'surveyLoadStarted':\n getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);\n break;\n\n default:\n break;\n }\n this.cdr.detectChanges();\n });\n }\n}\n\n@Component({\n selector: 'close-svg',\n template: `\n <svg\n [attr.width]=\"size\"\n [attr.height]=\"size\"\n viewBox=\"0 0 32 32\"\n fill=\"none\"\n xmlns=\"https://www.w3.org/2000/svg\"\n >\n <path\n d=\"M10.6665 10.667L21.3332 21.3337M21.3332 10.667L10.6665 21.3337\"\n [attr.stroke]=\"stroke\"\n [attr.stroke-width]=\"strokeWidth\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class CloseSVGComponent {\n @Input() size: number = 32;\n @Input() stroke: string = '#919191';\n @Input() strokeWidth: number = 1.5;\n}\n\n@Component({\n selector: 'spotcheck-close-button',\n template: `\n <div style=\"position: absolute; top: -36px; right: 16px; z-index: 100001; cursor: pointer; background-color: white; border-radius: 50px;\" (click)=\"onClick()\" *ngIf=\"isVisible && isMiniCard\">\n <close-svg [size]=\"size\" [stroke]=\"stroke\" [strokeWidth]=\"strokeWidth\" style=\"display: flex; align-items: center; justify-content: center;\"/>\n </div>\n <div style=\"position: absolute; top: 16px; right: 16px; z-index: 100001; cursor: pointer;\" (click)=\"onClick()\" *ngIf=\"isVisible && !isMiniCard\">\n <close-svg [size]=\"size\" [stroke]=\"stroke\" [strokeWidth]=\"strokeWidth\"/>\n </div>\n `,\n standalone: true,\n imports: [CommonModule, CloseSVGComponent],\n})\nexport class CloseButtonComponent implements OnDestroy {\n @Input() size: number = 30;\n @Input() strokeWidth: number = 1.2;\n \n state: SpotcheckState;\n private stateService: SpotcheckStateService;\n private stateSubscription!: Subscription;\n \n isVisible: boolean = false;\n isMiniCard: boolean = false;\n stroke: string = 'black';\n \n constructor(\n private ngZone: NgZone,\n private cdr: ChangeDetectorRef,\n ) {\n this.stateService = getSpotcheckStateService();\n this.state = this.stateService.getState();\n this.updateComponentState();\n\n this.stateSubscription = this.stateService.state$.subscribe(\n (newState: SpotcheckState) => {\n this.ngZone.run(() => {\n this.state = newState;\n this.updateComponentState();\n this.cdr.detectChanges();\n });\n }\n );\n }\n\n ngOnDestroy(): void {\n if (this.stateSubscription) {\n this.stateSubscription.unsubscribe();\n }\n }\n\n private updateComponentState(): void {\n this.isVisible =\n this.state.isCloseButtonEnabled &&\n ((this.state.currentQuestionHeight > 0 && !this.state.isFullScreenMode) ||\n (this.state.isFullScreenMode &&\n ((!this.state.isClassicLoading &&\n this.state.spotCheckType === 'classic') ||\n (!this.state.isChatLoading &&\n this.state.spotCheckType === 'chat'))));\n this.isMiniCard = this.state.spotChecksMode === 'miniCard';\n this.stroke = this.isMiniCard ? 'black' : this.state.closeButtonStyle?.['ctaButton'] || 'black';\n }\n\n onClick = async () => {\n await closeSpotCheck();\n handleSurveyEnd();\n this.ngZone.run(() => {\n this.cdr.detectChanges();\n });\n };\n}\n\n\n@Component({\n selector: 'SpotCheckComponent',\n templateUrl: './SpotCheckComponent.html',\n styleUrls: ['./SpotCheckComponent.css'],\n standalone: true,\n imports: [CommonModule, WebViewComponent, CloseButtonComponent],\n})\nexport class SpotCheckComponent implements OnInit, OnDestroy {\n state: SpotcheckState;\n private spotcheckStateService: SpotcheckStateService;\n private stateSubscription: Subscription;\n componentStyles: any = {};\n avatarUrl: string = '';\n\n constructor(\n private ngZone: NgZone,\n private cdr: ChangeDetectorRef,\n ) {\n this.spotcheckStateService = getSpotcheckStateService();\n this.state = this.spotcheckStateService.getState();\n this.updateComponentStyles();\n\n this.stateSubscription = this.spotcheckStateService.state$.subscribe(\n (newState: SpotcheckState) => {\n this.ngZone.run(() => {\n this.state = newState;\n this.updateComponentStyles();\n this.avatarUrl = this.state.avatarUrl || \"https://static.surveysparrow.com/application/images/profile.png\";\n this.cdr.detectChanges();\n });\n }\n );\n }\n\n ngOnInit(): void {\n this.initializeComponent();\n }\n\n ngOnDestroy(): void {\n if (this.stateSubscription) {\n this.stateSubscription.unsubscribe();\n }\n }\n\n private updateComponentStyles(): void {\n this.componentStyles = getSpotcheckComponentCssStyles(this.state);\n }\n\n initializeComponent = async () => {\n try {\n const domainName = this.state.domainName;\n const targetToken = this.state.targetToken;\n\n const response = await axios.get<any>(\n `https://${domainName}/api/internal/spotcheck/widget/${targetToken}/init`\n );\n\n const data = response.data;\n\n if (data.filteredSpotChecks && data.filteredSpotChecks.length > 0) {\n let classicIframe = false;\n let chatIframe = false;\n\n data.filteredSpotChecks.forEach((spotcheck: any) => {\n if (\n spotcheck.appearance.mode === 'fullScreen' &&\n ischatSurvey(spotcheck?.survey?.surveyType)\n ) {\n chatIframe = true;\n } else {\n classicIframe = true;\n }\n });\n\n const newClassicUrl = classicIframe\n ? `https://${domainName}/eui-template/classic`\n : '';\n const newChatUrl = chatIframe\n ? `https://${domainName}/eui-template/chat`\n : '';\n\n this.spotcheckStateService.setState({\n filteredSpotChecks: data.filteredSpotChecks,\n classicUrl: newClassicUrl,\n chatUrl: newChatUrl,\n });\n }\n } catch (error) {\n console.log('Error initializing widget:', JSON.stringify(error));\n }\n };\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { Subscription } from 'rxjs';
2
+ export type SpotCheckEventType = 'surveyCompleted' | 'surveyDismissed' | 'surveyLoadStarted';
3
+ export interface SpotCheckEvent {
4
+ type: SpotCheckEventType;
5
+ data?: any;
6
+ }
7
+ type EventCallback = (data?: any) => void;
8
+ declare class SpotCheckEventListenerService {
9
+ private eventSubject;
10
+ private event$;
11
+ emit(type: SpotCheckEventType, data?: any): void;
12
+ addListener(eventType: SpotCheckEventType, callback: EventCallback): Subscription;
13
+ }
14
+ export declare const getSpotCheckEventListener: () => SpotCheckEventListenerService;
15
+ export declare const addSpotCheckListener: (eventType: SpotCheckEventType, callback: EventCallback) => Subscription;
16
+ export {};
@@ -0,0 +1,28 @@
1
+ import { Subject } from 'rxjs';
2
+ class SpotCheckEventListenerService {
3
+ constructor() {
4
+ this.eventSubject = new Subject();
5
+ this.event$ = this.eventSubject.asObservable();
6
+ }
7
+ emit(type, data) {
8
+ this.eventSubject.next({ type, data });
9
+ }
10
+ addListener(eventType, callback) {
11
+ return this.event$.subscribe((event) => {
12
+ if (event.type === eventType) {
13
+ callback(event.data);
14
+ }
15
+ });
16
+ }
17
+ }
18
+ let globalInstance;
19
+ export const getSpotCheckEventListener = () => {
20
+ if (!globalInstance) {
21
+ globalInstance = new SpotCheckEventListenerService();
22
+ }
23
+ return globalInstance;
24
+ };
25
+ export const addSpotCheckListener = (eventType, callback) => {
26
+ return getSpotCheckEventListener().addListener(eventType, callback);
27
+ };
28
+ //# sourceMappingURL=SpotCheckEventListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpotCheckEventListener.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAe/B,MAAM,6BAA6B;IAAnC;QACU,iBAAY,GAAG,IAAI,OAAO,EAAkB,CAAC;QAC7C,WAAM,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;IAgBpD,CAAC;IAdC,IAAI,CAAC,IAAwB,EAAE,IAAU;QACvC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,WAAW,CACT,SAA6B,EAC7B,QAAuB;QAEvB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAqB,EAAE,EAAE;YACrD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC7B,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,IAAI,cAA6C,CAAC;AAElD,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAkC,EAAE;IAC3E,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,6BAA6B,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,SAA6B,EAC7B,QAAuB,EACT,EAAE;IAChB,OAAO,yBAAyB,EAAE,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACtE,CAAC,CAAC","sourcesContent":["import { Subject } from 'rxjs';\nimport type { Subscription } from 'rxjs';\n\nexport type SpotCheckEventType =\n | 'surveyCompleted'\n | 'surveyDismissed'\n | 'surveyLoadStarted';\n\nexport interface SpotCheckEvent {\n type: SpotCheckEventType;\n data?: any;\n}\n\ntype EventCallback = (data?: any) => void;\n\nclass SpotCheckEventListenerService {\n private eventSubject = new Subject<SpotCheckEvent>();\n private event$ = this.eventSubject.asObservable();\n\n emit(type: SpotCheckEventType, data?: any): void {\n this.eventSubject.next({ type, data });\n }\n\n addListener(\n eventType: SpotCheckEventType,\n callback: EventCallback\n ): Subscription {\n return this.event$.subscribe((event: SpotCheckEvent) => {\n if (event.type === eventType) {\n callback(event.data);\n }\n });\n }\n}\n\nlet globalInstance: SpotCheckEventListenerService;\n\nexport const getSpotCheckEventListener = (): SpotCheckEventListenerService => {\n if (!globalInstance) {\n globalInstance = new SpotCheckEventListenerService();\n }\n return globalInstance;\n};\n\nexport const addSpotCheckListener = (\n eventType: SpotCheckEventType,\n callback: EventCallback\n): Subscription => {\n return getSpotCheckEventListener().addListener(eventType, callback);\n};\n"]}
@@ -33,8 +33,6 @@ let SpotcheckStateService = class SpotcheckStateService {
33
33
  traceId: '',
34
34
  isClassicLoading: true,
35
35
  isChatLoading: true,
36
- isClassicLoadEventReceived: false,
37
- isChatLoadEventReceived: false,
38
36
  classicUrl: '',
39
37
  chatUrl: '',
40
38
  classicWebViewRef: null,
@@ -1 +1 @@
1
- {"version":3,"file":"SpotcheckStateService.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E;SAC1B,CAAC;QAEM,mBAAc,GAAG,IAAI,eAAe,CAAiB,IAAI,CAAC,YAAY,CAAC,CAAC;QAChF,WAAM,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IAa9C,CAAC;IAXC,QAAQ,CAAC,KAA8B;QACrC,IAAI,CAAC,cAAc,CAAC,IAAI,iCAAM,IAAI,CAAC,cAAc,CAAC,KAAK,GAAK,KAAK,EAAG,CAAC;IACvE,CAAC;IAED,UAAU;QACR,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACxC,CAAC;CACF,CAAA;AA1DY,qBAAqB;IAHjC,UAAU,CAAC;QACV,UAAU,EAAE,MAAM;KACnB,CAAC;GACW,qBAAqB,CA0DjC","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\nimport { SpotcheckState } from './types';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SpotcheckStateService {\n private initialState: SpotcheckState = {\n isVisible: false,\n spotcheckPosition: 'bottom',\n spotcheckURL: '',\n spotcheckID: 0,\n spotcheckContactID: 0,\n afterDelay: 0.0,\n maxHeight: 0.5,\n currentQuestionHeight: 0,\n isFullScreenMode: false,\n isBannerImageOn: false,\n triggerToken: '',\n closeButtonStyle: {},\n isCloseButtonEnabled: false,\n isSpotPassed: false,\n isChecksPassed: false,\n customEventsSpotChecks: [],\n targetToken: '',\n domainName: '',\n userDetails: {},\n variables: {},\n customProperties: {},\n traceId: '',\n isClassicLoading: true,\n isChatLoading: true,\n isClassicLoadEventReceived: false,\n isChatLoadEventReceived: false,\n classicUrl: '',\n chatUrl: '',\n classicWebViewRef: null,\n chatWebViewRef: null,\n filteredSpotChecks: [],\n spotCheckType: '',\n isMounted: false,\n textPosition: 0,\n screenHeight: 0,\n keyBoardHeight: 0,\n spotChecksMode: '',\n avatarEnabled: false,\n avatarUrl: '',\n screenwiseUserDetails: {}\n };\n \n private spotcheckState = new BehaviorSubject<SpotcheckState>(this.initialState);\n state$ = this.spotcheckState.asObservable();\n\n setState(state: Partial<SpotcheckState>) {\n this.spotcheckState.next({ ...this.spotcheckState.value, ...state });\n }\n \n clearState() {\n this.spotcheckState.next(this.initialState);\n }\n\n getState() {\n return this.spotcheckState.getValue();\n }\n}\n"]}
1
+ {"version":3,"file":"SpotcheckStateService.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/SpotcheckStateService.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAMhC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAA3B;QACG,iBAAY,GAAmB;YACrC,SAAS,EAAE,KAAK;YAChB,iBAAiB,EAAE,QAAQ;YAC3B,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,CAAC;YACd,kBAAkB,EAAE,CAAC;YACrB,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,GAAG;YACd,qBAAqB,EAAE,CAAC;YACxB,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,KAAK;YACtB,YAAY,EAAE,EAAE;YAChB,gBAAgB,EAAE,EAAE;YACpB,oBAAoB,EAAE,KAAK;YAC3B,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,KAAK;YACrB,sBAAsB,EAAE,EAAE;YAC1B,WAAW,EAAE,EAAE;YACf,UAAU,EAAE,EAAE;YACd,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,gBAAgB,EAAE,EAAE;YACpB,OAAO,EAAE,EAAE;YACX,gBAAgB,EAAE,IAAI;YACtB,aAAa,EAAE,IAAI;YACnB,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,EAAE;YACX,iBAAiB,EAAE,IAAI;YACvB,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,EAAE;YACtB,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,CAAC;YACf,YAAY,EAAE,CAAC;YACf,cAAc,EAAE,CAAC;YACjB,cAAc,EAAE,EAAE;YAClB,aAAa,EAAE,KAAK;YACpB,SAAS,EAAE,EAAE;YACb,qBAAqB,EAAE,EAAE;SAC1B,CAAC;QAEM,mBAAc,GAAG,IAAI,eAAe,CAAiB,IAAI,CAAC,YAAY,CAAC,CAAC;QAChF,WAAM,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IAa9C,CAAC;IAXC,QAAQ,CAAC,KAA8B;QACrC,IAAI,CAAC,cAAc,CAAC,IAAI,iCAAM,IAAI,CAAC,cAAc,CAAC,KAAK,GAAK,KAAK,EAAG,CAAC;IACvE,CAAC;IAED,UAAU;QACR,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACxC,CAAC;CACF,CAAA;AAxDY,qBAAqB;IAHjC,UAAU,CAAC;QACV,UAAU,EAAE,MAAM;KACnB,CAAC;GACW,qBAAqB,CAwDjC","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\nimport { SpotcheckState } from './types';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SpotcheckStateService {\n private initialState: SpotcheckState = {\n isVisible: false,\n spotcheckPosition: 'bottom',\n spotcheckURL: '',\n spotcheckID: 0,\n spotcheckContactID: 0,\n afterDelay: 0.0,\n maxHeight: 0.5,\n currentQuestionHeight: 0,\n isFullScreenMode: false,\n isBannerImageOn: false,\n triggerToken: '',\n closeButtonStyle: {},\n isCloseButtonEnabled: false,\n isSpotPassed: false,\n isChecksPassed: false,\n customEventsSpotChecks: [],\n targetToken: '',\n domainName: '',\n userDetails: {},\n variables: {},\n customProperties: {},\n traceId: '',\n isClassicLoading: true,\n isChatLoading: true,\n classicUrl: '',\n chatUrl: '',\n classicWebViewRef: null,\n chatWebViewRef: null,\n filteredSpotChecks: [],\n spotCheckType: '',\n isMounted: false,\n textPosition: 0,\n screenHeight: 0,\n keyBoardHeight: 0,\n spotChecksMode: '',\n avatarEnabled: false,\n avatarUrl: '',\n screenwiseUserDetails: {}\n };\n \n private spotcheckState = new BehaviorSubject<SpotcheckState>(this.initialState);\n state$ = this.spotcheckState.asObservable();\n\n setState(state: Partial<SpotcheckState>) {\n this.spotcheckState.next({ ...this.spotcheckState.value, ...state });\n }\n \n clearState() {\n this.spotcheckState.next(this.initialState);\n }\n\n getState() {\n return this.spotcheckState.getValue();\n }\n}\n"]}
@@ -3,7 +3,6 @@ import { getStoredUUID, setUUID } from './storage';
3
3
  import { getSpotcheckStateService } from './helpers';
4
4
  import axios from 'axios';
5
5
  export const sendTrackScreenRequest = async ({ screen, options, }) => {
6
- var _a, _b;
7
6
  try {
8
7
  const spotcheckStateService = getSpotcheckStateService();
9
8
  const oldState = spotcheckStateService.getState();
@@ -122,7 +121,7 @@ export const sendTrackScreenRequest = async ({ screen, options, }) => {
122
121
  }
123
122
  }
124
123
  }
125
- throw new Error((_b = (_a = responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 'Spotcheck conditions not met');
124
+ throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
126
125
  }
127
126
  else {
128
127
  throw new Error(`Received status code ${response.status}`);
@@ -133,7 +132,7 @@ export const sendTrackScreenRequest = async ({ screen, options, }) => {
133
132
  }
134
133
  };
135
134
  export const sendTrackEventRequest = async ({ screen, event }) => {
136
- var _a, _b, _c, _d, _e, _f, _g, _h;
135
+ var _a, _b, _c, _d, _e, _f;
137
136
  try {
138
137
  const intMax = Number.POSITIVE_INFINITY;
139
138
  const state = getSpotcheckStateService().getState();
@@ -206,7 +205,7 @@ export const sendTrackEventRequest = async ({ screen, event }) => {
206
205
  return { valid: true };
207
206
  }
208
207
  }
209
- throw new Error((_h = (_g = responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : 'Event conditions not met');
208
+ throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
210
209
  }
211
210
  else {
212
211
  throw new Error(`Received status code ${response.status}`);
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,EAC3C,MAAM,EACN,OAAO,GACU,EAAE,EAAE;;IACrB,IAAI,CAAC;QACH,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC;QACzD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC;QAClD,IAAI,SAAS,GAAG,kBAAK,QAAQ,CAAC,SAAS,CAAe,CAAC;QACvD,IAAI,gBAAgB,GAAG,kBAAK,QAAQ,CAAC,gBAAgB,CAAsB,CAAC;QAC5E,IAAI,WAAW,GAAG,kBAAK,QAAQ,CAAC,WAAW,CAAiB,CAAC;QAE7D,IAAI,OAAO,IAAI,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9E,SAAS,mCAAQ,SAAS,GAAK,OAAO,CAAC,S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,CAAC;wCAEF,IAAI,mBAAmB,EAAE,CAAC;4CACxB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;wCACzB,CAAC;oCACH,CAAC;oCAED,MAAM,IAAI,KAAK,CAAC,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,0CAAE,QAAQ,EAAE,mCAAI,0BAA0B,CAAC,CAAC;gCAClF,CAAC;qCAAM,CAAC;oCACN,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gCAC7D,CAAC;4BACH,CAAC;4BAAC,OAAO,KAAU,EAAE,CAAC;gCACpB,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;4BACjC,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAChD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { generateTraceId, getOS, setAppearance } from './helpers';\nimport { getStoredUUID, setUUID } from './storage';\nimport { TrackScreenProps, UserDetails, Variables, CustomProperties, TrackEventProps } from './types';\nimport { getSpotcheckStateService } from './helpers';\nimport axios from 'axios';\n\nexport const sendTrackScreenRequest = async ({\n screen,\n options,\n}: TrackScreenProps) => {\n try {\n const spotcheckStateService = getSpotcheckStateService();\n const oldState = spotcheckStateService.getState();\n let variables = { ...oldState.variables } as Variables;\n let customProperties = { ...oldState.customProperties } as CustomProperties;\n let userDetails = { ...oldState.userDetails } as UserDetails; \n\n if (options && options.variables && Object.keys(options.variables).length > 0) {\n variables = { ...variables, ...options.variables };\n }\n if (options && options.customProperties && Object.keys(options.customProperties).length > 0) {\n customProperties = { ...customProperties, ...options.customProperties };\n }\n if (options && options.userDetails && Object.keys(options.userDetails).length > 0) {\n userDetails = { ...userDetails, ...options.userDetails };\n }\n\n let traceId = oldState.traceId;\n if (!traceId) {\n traceId = generateTraceId();\n }\n\n if (!userDetails.uuid && !userDetails.email && !userDetails.mobile) {\n const uuid = getStoredUUID();\n if (uuid) {\n userDetails.uuid = uuid;\n }\n }\n\n spotcheckStateService.setState({\n traceId,\n screenwiseUserDetails: {\n [screen]: userDetails\n },\n });\n\n const state = spotcheckStateService.getState();\n let { isSpotPassed, isChecksPassed } = state;\n const payload = {\n screenName: screen,\n variables: variables,\n userDetails: userDetails,\n visitor: {\n deviceType: 'MOBILE',\n operatingSystem: await getOS(),\n screenResolution: {\n height: window.innerHeight,\n width: window.innerWidth,\n },\n currentDate: new Date().toISOString(),\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n traceId: state.traceId,\n customProperties: customProperties,\n };\n\n const url = `https://${state.domainName}/api/internal/spotcheck/widget/${state.targetToken}/properties?isSpotCheck=true&sdk=IONIC`;\n const response = await axios.post(url, payload, {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if(response.status === 200) {\n const responseJson = response.data;\n\n if (responseJson.uuid) {\n setUUID(responseJson.uuid);\n }\n\n if (responseJson?.show) {\n if (responseJson?.show) {\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n traceId,\n variables\n );\n if (appearance_response) {\n isSpotPassed = true;\n spotcheckStateService.setState({ isSpotPassed });\n return { valid: true };\n }\n } else {\n throw new Error('');\n }\n }\n \n if (!isSpotPassed && responseJson?.checkPassed) {\n if (responseJson.checkCondition) {\n const checkCondition = responseJson.checkCondition;\n spotcheckStateService.setState({ afterDelay: checkCondition.afterDelay || 0 });\n if (checkCondition.customEvent) {\n spotcheckStateService.setState({ customEventsSpotChecks: [responseJson] });\n throw new Error('');\n }\n }\n\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n traceId,\n variables\n );\n if (appearance_response) {\n isChecksPassed = true;\n spotcheckStateService.setState({ isChecksPassed });\n return { valid: true };\n }\n }\n\n if (!isSpotPassed && !isChecksPassed && responseJson?.multiShow != null) {\n if (responseJson.multiShow) {\n spotcheckStateService.setState({ customEventsSpotChecks: responseJson.resultantSpotCheck });\n\n let selectedSpotCheck = {};\n let minDelay: number = Number.POSITIVE_INFINITY;\n\n for (const spotcheck of responseJson.resultantSpotCheck) {\n const checks = spotcheck?.checks || {};\n if (Object.keys(checks).length === 0) {\n minDelay = 0;\n selectedSpotCheck = spotcheck;\n } else if (checks.afterDelay != null) {\n const delay = parseFloat(checks.afterDelay);\n if (minDelay > delay) {\n minDelay = delay;\n selectedSpotCheck = spotcheck;\n }\n }\n }\n\n if (Object.keys(selectedSpotCheck).length > 0) {\n spotcheckStateService.setState({ afterDelay: minDelay });\n const appearance_response = await setAppearance(\n selectedSpotCheck,\n screen,\n state.domainName,\n traceId,\n variables\n );\n if (appearance_response) {\n return { valid: true };\n }\n }\n }\n }\n\n throw new Error(responseJson?.reason?.toString() ?? 'Spotcheck conditions not met');\n } else {\n throw new Error(`Received status code ${response.status}`);\n }\n } catch (error: any) {\n return { valid: false, error: error.message };\n }\n};\n\n\nexport const sendTrackEventRequest = async ({ screen, event }: TrackEventProps) => {\n try {\n const intMax = Number.POSITIVE_INFINITY;\n const state = getSpotcheckStateService().getState();\n let selectedSpotCheckID = intMax;\n let { isSpotPassed } = state;\n if (state.customEventsSpotChecks.length > 0) {\n const eventKeys = Object.keys(event);\n for (const spotCheck of state.customEventsSpotChecks) {\n const checks = spotCheck?.['checks'] ?? spotCheck?.['checkCondition'];\n\n if (checks) {\n const customEvent = checks?.customEvent;\n\n if (eventKeys.includes(customEvent?.eventName)) {\n selectedSpotCheckID =\n spotCheck?.['id'] ?? spotCheck?.['spotCheckId'] ?? intMax;\n\n if (selectedSpotCheckID !== intMax) {\n const payload = {\n screenName: screen,\n variables: state.variables,\n userDetails: state.screenwiseUserDetails[screen] || {},\n visitor: {\n deviceType: 'MOBILE',\n operatingSystem: await getOS(),\n screenResolution: {\n height: window.innerHeight,\n width: window.innerWidth,\n },\n currentDate: new Date().toISOString(),\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n spotCheckId: selectedSpotCheckID,\n eventTrigger: {\n customEvent: event,\n },\n traceId: state.traceId,\n customProperties: state.customProperties,\n };\n\n const url = `https://${state.domainName}/api/internal/spotcheck/widget/${state.targetToken}/eventTrigger?isSpotCheck=true`;\n\n try {\n const response = await axios.post(url, payload, {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status === 200) {\n const responseJson = response.data;\n if (responseJson?.show != null) {\n if (responseJson?.show) {\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n state.traceId,\n state.variables\n );\n\n if (appearance_response) {\n getSpotcheckStateService().setState({ isSpotPassed: true });\n isSpotPassed = true;\n return { valid: true };\n }\n }\n }\n\n if (!isSpotPassed && responseJson?.eventShow) {\n if (responseJson?.checkCondition != null) {\n const checkCondition = responseJson?.checkCondition;\n getSpotcheckStateService().setState({\n afterDelay: checkCondition?.afterDelay ?? 0,\n });\n\n if (checkCondition?.customEvent != null) {\n getSpotcheckStateService().setState({\n afterDelay: checkCondition?.customEvent?.delayInSeconds ?? 0,\n });\n }\n }\n\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n state.traceId,\n state.variables\n );\n\n if (appearance_response) {\n return { valid: true };\n }\n }\n\n throw new Error(responseJson?.reason?.toString() ?? 'Event conditions not met');\n } else {\n throw new Error(`Received status code ${response.status}`);\n }\n } catch (error: any) {\n throw new Error(error.message);\n }\n }\n }\n }\n }\n throw new Error('');\n } else {\n throw new Error('');\n }\n } catch (error: any) {\n return { valid: false, error: error.message };\n }\n};"]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/api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CAAC,CAAC;4BACjC,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAChD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { generateTraceId, getOS, setAppearance } from './helpers';\nimport { getStoredUUID, setUUID } from './storage';\nimport { TrackScreenProps, UserDetails, Variables, CustomProperties, TrackEventProps } from './types';\nimport { getSpotcheckStateService } from './helpers';\nimport axios from 'axios';\n\nexport const sendTrackScreenRequest = async ({\n screen,\n options,\n}: TrackScreenProps) => {\n try {\n const spotcheckStateService = getSpotcheckStateService();\n const oldState = spotcheckStateService.getState();\n let variables = { ...oldState.variables } as Variables;\n let customProperties = { ...oldState.customProperties } as CustomProperties;\n let userDetails = { ...oldState.userDetails } as UserDetails; \n\n if (options && options.variables && Object.keys(options.variables).length > 0) {\n variables = { ...variables, ...options.variables };\n }\n if (options && options.customProperties && Object.keys(options.customProperties).length > 0) {\n customProperties = { ...customProperties, ...options.customProperties };\n }\n if (options && options.userDetails && Object.keys(options.userDetails).length > 0) {\n userDetails = { ...userDetails, ...options.userDetails };\n }\n\n let traceId = oldState.traceId;\n if (!traceId) {\n traceId = generateTraceId();\n }\n\n if (!userDetails.uuid && !userDetails.email && !userDetails.mobile) {\n const uuid = getStoredUUID();\n if (uuid) {\n userDetails.uuid = uuid;\n }\n }\n\n spotcheckStateService.setState({\n traceId,\n screenwiseUserDetails: {\n [screen]: userDetails\n },\n });\n\n const state = spotcheckStateService.getState();\n let { isSpotPassed, isChecksPassed } = state;\n const payload = {\n screenName: screen,\n variables: variables,\n userDetails: userDetails,\n visitor: {\n deviceType: 'MOBILE',\n operatingSystem: await getOS(),\n screenResolution: {\n height: window.innerHeight,\n width: window.innerWidth,\n },\n currentDate: new Date().toISOString(),\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n traceId: state.traceId,\n customProperties: customProperties,\n };\n\n const url = `https://${state.domainName}/api/internal/spotcheck/widget/${state.targetToken}/properties?isSpotCheck=true&sdk=IONIC`;\n const response = await axios.post<any>(url, payload, {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if(response.status === 200) {\n const responseJson = response.data;\n\n if (responseJson.uuid) {\n setUUID(responseJson.uuid);\n }\n\n if (responseJson?.show) {\n if (responseJson?.show) {\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n traceId,\n variables\n );\n if (appearance_response) {\n isSpotPassed = true;\n spotcheckStateService.setState({ isSpotPassed });\n return { valid: true };\n }\n } else {\n throw new Error('');\n }\n }\n \n if (!isSpotPassed && responseJson?.checkPassed) {\n if (responseJson.checkCondition) {\n const checkCondition = responseJson.checkCondition;\n spotcheckStateService.setState({ afterDelay: checkCondition.afterDelay || 0 });\n if (checkCondition.customEvent) {\n spotcheckStateService.setState({ customEventsSpotChecks: [responseJson] });\n throw new Error('');\n }\n }\n\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n traceId,\n variables\n );\n if (appearance_response) {\n isChecksPassed = true;\n spotcheckStateService.setState({ isChecksPassed });\n return { valid: true };\n }\n }\n\n if (!isSpotPassed && !isChecksPassed && responseJson?.multiShow != null) {\n if (responseJson.multiShow) {\n spotcheckStateService.setState({ customEventsSpotChecks: responseJson.resultantSpotCheck });\n\n let selectedSpotCheck = {};\n let minDelay: number = Number.POSITIVE_INFINITY;\n\n for (const spotcheck of responseJson.resultantSpotCheck) {\n const checks = spotcheck?.checks || {};\n if (Object.keys(checks).length === 0) {\n minDelay = 0;\n selectedSpotCheck = spotcheck;\n } else if (checks.afterDelay != null) {\n const delay = parseFloat(checks.afterDelay);\n if (minDelay > delay) {\n minDelay = delay;\n selectedSpotCheck = spotcheck;\n }\n }\n }\n\n if (Object.keys(selectedSpotCheck).length > 0) {\n spotcheckStateService.setState({ afterDelay: minDelay });\n const appearance_response = await setAppearance(\n selectedSpotCheck,\n screen,\n state.domainName,\n traceId,\n variables\n );\n if (appearance_response) {\n return { valid: true };\n }\n }\n }\n }\n\n throw new Error(responseJson?.reason.toString());\n } else {\n throw new Error(`Received status code ${response.status}`);\n }\n } catch (error: any) {\n return { valid: false, error: error.message };\n }\n};\n\n\nexport const sendTrackEventRequest = async ({ screen, event }: TrackEventProps) => {\n try {\n const intMax = Number.POSITIVE_INFINITY;\n const state = getSpotcheckStateService().getState();\n let selectedSpotCheckID = intMax;\n let { isSpotPassed } = state;\n if (state.customEventsSpotChecks.length > 0) {\n const eventKeys = Object.keys(event);\n for (const spotCheck of state.customEventsSpotChecks) {\n const checks = spotCheck?.['checks'] ?? spotCheck?.['checkCondition'];\n\n if (checks) {\n const customEvent = checks?.customEvent;\n\n if (eventKeys.includes(customEvent?.eventName)) {\n selectedSpotCheckID =\n spotCheck?.['id'] ?? spotCheck?.['spotCheckId'] ?? intMax;\n\n if (selectedSpotCheckID !== intMax) {\n const payload = {\n screenName: screen,\n variables: state.variables,\n userDetails: state.screenwiseUserDetails[screen] || {},\n visitor: {\n deviceType: 'MOBILE',\n operatingSystem: await getOS(),\n screenResolution: {\n height: window.innerHeight,\n width: window.innerWidth,\n },\n currentDate: new Date().toISOString(),\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n spotCheckId: selectedSpotCheckID,\n eventTrigger: {\n customEvent: event,\n },\n traceId: state.traceId,\n customProperties: state.customProperties,\n };\n\n const url = `https://${state.domainName}/api/internal/spotcheck/widget/${state.targetToken}/eventTrigger?isSpotCheck=true`;\n\n try {\n const response = await axios.post<any>(url, payload, {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status === 200) {\n const responseJson = response.data;\n if (responseJson?.show != null) {\n if (responseJson?.show) {\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n state.traceId,\n state.variables\n );\n\n if (appearance_response) {\n getSpotcheckStateService().setState({ isSpotPassed: true });\n isSpotPassed = true;\n return { valid: true };\n }\n }\n }\n\n if (!isSpotPassed && responseJson?.eventShow) {\n if (responseJson?.checkCondition != null) {\n const checkCondition = responseJson?.checkCondition;\n getSpotcheckStateService().setState({\n afterDelay: checkCondition?.afterDelay ?? 0,\n });\n\n if (checkCondition?.customEvent != null) {\n getSpotcheckStateService().setState({\n afterDelay: checkCondition?.customEvent?.delayInSeconds ?? 0,\n });\n }\n }\n\n const appearance_response = await setAppearance(\n responseJson,\n screen,\n state.domainName,\n state.traceId,\n state.variables\n );\n\n if (appearance_response) {\n return { valid: true };\n }\n }\n\n throw new Error(responseJson?.reason.toString());\n } else {\n throw new Error(`Received status code ${response.status}`);\n }\n } catch (error: any) {\n throw new Error(error.message);\n }\n }\n }\n }\n }\n throw new Error('');\n } else {\n throw new Error('');\n }\n } catch (error: any) {\n return { valid: false, error: error.message };\n }\n};"]}
@@ -3,7 +3,7 @@ import { SpotcheckStateService } from './SpotcheckStateService';
3
3
  export declare const getSpotcheckStateService: () => SpotcheckStateService;
4
4
  export declare function generateTraceId(): string;
5
5
  export declare const ischatSurvey: (type: String) => boolean;
6
- export declare const getOS: () => Promise<string>;
6
+ export declare const getOS: () => Promise<import("@capacitor/device").OperatingSystem>;
7
7
  export declare const setAppearance: (responseJson: any, screen: string, domainName: string, traceId: string, variables: Record<string, any>) => Promise<boolean>;
8
8
  export declare const start: () => void;
9
9
  export declare const closeSpotCheck: () => Promise<void>;
@@ -24,7 +24,6 @@ export declare const getSpotcheckComponentCssStyles: (state: SpotcheckState) =>
24
24
  display: string;
25
25
  flexDirection: string;
26
26
  paddingTop: string;
27
- marginBottom: string;
28
27
  };
29
28
  };
30
29
  export declare const closeSpotCheckAndHandleSurveyEnd: () => Promise<void>;