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

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 (32) hide show
  1. package/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +59 -3
  2. package/dist/angular-ui/esm2022/spotchecks/SpotcheckStateService.mjs +3 -1
  3. package/dist/angular-ui/esm2022/spotchecks/api.mjs +3 -3
  4. package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +16 -9
  5. package/dist/angular-ui/esm2022/spotchecks/types.mjs +1 -1
  6. package/dist/angular-ui/fesm2022/angular-ui.mjs +77 -12
  7. package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
  8. package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +2 -0
  9. package/dist/angular-ui/spotchecks/helpers.d.ts +2 -1
  10. package/dist/angular-ui/spotchecks/types.d.ts +2 -0
  11. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +2 -0
  12. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +56 -1
  13. package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +1 -1
  14. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js +2 -0
  15. package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js.map +1 -1
  16. package/dist/esm/angular-ui/lib/spotchecks/api.js +4 -3
  17. package/dist/esm/angular-ui/lib/spotchecks/api.js.map +1 -1
  18. package/dist/esm/angular-ui/lib/spotchecks/helpers.d.ts +2 -1
  19. package/dist/esm/angular-ui/lib/spotchecks/helpers.js +16 -10
  20. package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +1 -1
  21. package/dist/esm/angular-ui/lib/spotchecks/types.d.ts +2 -0
  22. package/dist/esm/angular-ui/lib/spotchecks/types.js.map +1 -1
  23. package/dist/plugin.cjs.js +78 -14
  24. package/dist/plugin.cjs.js.map +1 -1
  25. package/dist/plugin.js +78 -14
  26. package/dist/plugin.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +67 -5
  29. package/src/angular-ui/lib/spotchecks/SpotcheckStateService.ts +2 -0
  30. package/src/angular-ui/lib/spotchecks/api.ts +2 -2
  31. package/src/angular-ui/lib/spotchecks/helpers.ts +19 -8
  32. package/src/angular-ui/lib/spotchecks/types.ts +2 -0
@@ -33,6 +33,8 @@ let SpotcheckStateService = class SpotcheckStateService {
33
33
  traceId: '',
34
34
  isClassicLoading: true,
35
35
  isChatLoading: true,
36
+ isClassicLoadEventReceived: false,
37
+ isChatLoadEventReceived: false,
36
38
  classicUrl: '',
37
39
  chatUrl: '',
38
40
  classicWebViewRef: null,
@@ -1 +1 @@
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"]}
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,KAA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AHjC,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"]}
@@ -3,6 +3,7 @@ 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;
6
7
  try {
7
8
  const spotcheckStateService = getSpotcheckStateService();
8
9
  const oldState = spotcheckStateService.getState();
@@ -121,7 +122,7 @@ export const sendTrackScreenRequest = async ({ screen, options, }) => {
121
122
  }
122
123
  }
123
124
  }
124
- throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
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');
125
126
  }
126
127
  else {
127
128
  throw new Error(`Received status code ${response.status}`);
@@ -132,7 +133,7 @@ export const sendTrackScreenRequest = async ({ screen, options, }) => {
132
133
  }
133
134
  };
134
135
  export const sendTrackEventRequest = async ({ screen, event }) => {
135
- var _a, _b, _c, _d, _e, _f;
136
+ var _a, _b, _c, _d, _e, _f, _g, _h;
136
137
  try {
137
138
  const intMax = Number.POSITIVE_INFINITY;
138
139
  const state = getSpotcheckStateService().getState();
@@ -205,7 +206,7 @@ export const sendTrackEventRequest = async ({ screen, event }) => {
205
206
  return { valid: true };
206
207
  }
207
208
  }
208
- throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
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');
209
210
  }
210
211
  else {
211
212
  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,E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AC,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};"]}
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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AAO,EACb,KAAK,CAAC,SAAS,CAChB,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<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() ?? '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<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() ?? '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};"]}
@@ -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<import("@capacitor/device").OperatingSystem>;
6
+ export declare const getOS: () => Promise<string>;
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,6 +24,7 @@ export declare const getSpotcheckComponentCssStyles: (state: SpotcheckState) =>
24
24
  display: string;
25
25
  flexDirection: string;
26
26
  paddingTop: string;
27
+ marginBottom: string;
27
28
  };
28
29
  };
29
30
  export declare const closeSpotCheckAndHandleSurveyEnd: () => Promise<void>;
@@ -4,6 +4,7 @@ import axios from 'axios';
4
4
  import { SpotcheckStateService } from './SpotcheckStateService';
5
5
  import { getSpotCheckEventListener } from './SpotCheckEventListener';
6
6
  let globalSpotcheckStateService;
7
+ let globalOS = null;
7
8
  export const getSpotcheckStateService = () => {
8
9
  if (!globalSpotcheckStateService) {
9
10
  globalSpotcheckStateService = new SpotcheckStateService();
@@ -23,10 +24,11 @@ export const ischatSurvey = (type) => {
23
24
  };
24
25
  export const getOS = async () => {
25
26
  const info = await Device.getInfo();
26
- return info.operatingSystem;
27
+ globalOS = info.operatingSystem;
28
+ return globalOS;
27
29
  };
28
30
  export const setAppearance = async (responseJson, screen, domainName, traceId, variables) => {
29
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
31
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
30
32
  try {
31
33
  const spotcheckStateService = getSpotcheckStateService();
32
34
  let state = spotcheckStateService.getState();
@@ -73,11 +75,11 @@ export const setAppearance = async (responseJson, screen, domainName, traceId, v
73
75
  spotcheckStateService.setState(updatedState);
74
76
  try {
75
77
  const response = await axios.get(fullSpotcheckURL);
76
- const themeInfo = response.data.config.generatedCSS;
78
+ const themeInfo = (_p = (_o = response.data) === null || _o === void 0 ? void 0 : _o.config) === null || _p === void 0 ? void 0 : _p.generatedCSS;
77
79
  const theme_payload = { type: 'THEME_UPDATE_SPOTCHECK', themeInfo };
78
80
  state = spotcheckStateService.getState();
79
81
  let webViewRef = chat ? state.chatWebViewRef : state.classicWebViewRef;
80
- let isLoading = chat ? state.isChatLoading : state.isClassicLoading;
82
+ let isLoading = chat ? state.isChatLoading || !state.isChatLoadEventReceived : state.isClassicLoading || !state.isClassicLoadEventReceived;
81
83
  const resetStateData = {
82
84
  type: 'RESET_STATE',
83
85
  state: Object.assign(Object.assign({}, (response.data || {})), { skip: true, spotCheckAppearance: Object.assign(Object.assign({}, (appearance || {})), { targetType: 'MOBILE' }), spotcheckUrl: screen, traceId, elementBuilderParams: Object.assign({}, (variables || {})) }),
@@ -108,8 +110,8 @@ export const setAppearance = async (responseJson, screen, domainName, traceId, v
108
110
  else {
109
111
  // todo: recheck this
110
112
  const unsubscribe = spotcheckStateService.state$.subscribe((currentState) => {
111
- const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, } = currentState;
112
- if ((!isChatLoading && chat) || (!isClassicLoading && !chat)) {
113
+ const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, isClassicLoadEventReceived, isChatLoadEventReceived, } = currentState;
114
+ if ((!isChatLoading && chat && isChatLoadEventReceived) || (!isClassicLoading && !chat && isClassicLoadEventReceived)) {
113
115
  unsubscribe.unsubscribe();
114
116
  const activeWebViewRef = chat
115
117
  ? chatWebViewRef
@@ -132,8 +134,8 @@ export const setAppearance = async (responseJson, screen, domainName, traceId, v
132
134
  ? currentState.chatWebViewRef
133
135
  : currentState.classicWebViewRef;
134
136
  const updatedIsLoading = chat
135
- ? currentState.isChatLoading
136
- : currentState.isClassicLoading;
137
+ ? currentState.isChatLoading || !currentState.isChatLoadEventReceived
138
+ : currentState.isClassicLoading || !currentState.isClassicLoadEventReceived;
137
139
  if (updatedWebViewRef) {
138
140
  if (!updatedIsLoading) {
139
141
  unsubscribeWebView.unsubscribe();
@@ -239,11 +241,15 @@ export const getSpotcheckComponentCssStyles = (state) => {
239
241
  height: '100%',
240
242
  };
241
243
  }
244
+ let marginBottom = globalOS !== 'ios' ? 18 : 0;
242
245
  if (state.isVisible && state.isMounted) {
243
246
  let height = Math.min(state.currentQuestionHeight, (state.maxHeight * window.innerHeight));
244
247
  if (state.spotChecksMode === 'miniCard') {
245
248
  if (state.avatarEnabled) {
246
249
  height = height - 56;
250
+ if (state.spotcheckPosition === 'bottom') {
251
+ marginBottom += 56;
252
+ }
247
253
  }
248
254
  if (state.isCloseButtonEnabled) {
249
255
  height = height - 40;
@@ -288,8 +294,8 @@ export const getSpotcheckComponentCssStyles = (state) => {
288
294
  }
289
295
  }
290
296
  return {
291
- wrapperStyles: Object.assign({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', backgroundColor: 'rgba(0, 0, 0, 0.3)', zIndex: '99999999', display: 'none', flexDirection: 'column' }, wrapperStyles),
292
- styles: Object.assign({ display: 'none', flexDirection: 'column', paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px' }, styles)
297
+ wrapperStyles: Object.assign({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', backgroundColor: 'rgba(0, 0, 0, 0.3)', zIndex: '100001', display: 'none', flexDirection: 'column' }, wrapperStyles),
298
+ styles: Object.assign({ display: 'none', flexDirection: 'column', paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px', marginBottom: marginBottom + 'px' }, styles)
293
299
  };
294
300
  };
295
301
  export const closeSpotCheckAndHandleSurveyEnd = async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE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AM;oBACf,cAAc,EAAE,QAAQ;iBACzB,CAAC;gBACJ,MAAM;YAER;gBACE,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO;QACL,aAAa,kBACX,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,oBAAoB,EACrC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,IACpB,aAAa,CACjB;QACD,MAAM,kBACJ,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,EACvB,UAAU,EAAE,+CAA+C,GAAC,IAAI,IAC7D,MAAM,CACV;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,IAAI,EAAE;IACzD,eAAe,EAAE,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport { Device } from '@capacitor/device';\nimport { SpotcheckState } from './types';\nimport axios from 'axios';\nimport { SpotcheckStateService } from './SpotcheckStateService';\nimport { getSpotCheckEventListener } from './SpotCheckEventListener';\n\nlet globalSpotcheckStateService: SpotcheckStateService;\n\nexport const getSpotcheckStateService = (): SpotcheckStateService => {\n if (!globalSpotcheckStateService) {\n globalSpotcheckStateService = new SpotcheckStateService();\n }\n return globalSpotcheckStateService;\n};\n\nexport function generateTraceId() {\n const uuidString = uuidv4();\n const timestamp = Date.now();\n return `${uuidString}-${timestamp}`;\n}\n\nexport const ischatSurvey = (type: String) => {\n return (\n type === 'Conversational' ||\n type === 'CESChat' ||\n type === 'NPSChat' ||\n type === 'CSATChat'\n );\n};\n\nexport const getOS = async () => {\n const info = await Device.getInfo();\n return info.operatingSystem;\n};\n\nexport const setAppearance = async (\n responseJson: any,\n screen: string,\n domainName: string,\n traceId: string,\n variables: Record<string, any>\n) => {\n try {\n const spotcheckStateService = getSpotcheckStateService();\n let state = spotcheckStateService.getState();\n\n if (responseJson) {\n const currentSpotcheck = state.filteredSpotChecks.find(\n (spotcheck) =>\n spotcheck['id'] === responseJson?.spotCheckId ||\n spotcheck['id'] === responseJson?.id\n );\n\n const appearance = responseJson?.appearance;\n let chat = false;\n\n let updatedState: Partial<SpotcheckState> = {};\n\n if (appearance) {\n const {\n position,\n closeButton,\n colors,\n cardProperties,\n mode,\n bannerImage,\n } = appearance;\n const { maxHeight } = cardProperties || {};\n\n updatedState = {\n spotcheckPosition:\n position === 'top_full' || position === 'center_top'\n ? 'top'\n : position === 'center_center'\n ? 'center'\n : 'bottom',\n isCloseButtonEnabled: closeButton ?? true,\n closeButtonStyle: colors?.overrides ?? {},\n maxHeight: maxHeight ? parseFloat(maxHeight) / 100 : 0,\n spotCheckType:\n ischatSurvey(currentSpotcheck?.['survey']?.surveyType) &&\n mode === 'fullScreen'\n ? 'chat'\n : 'classic',\n isFullScreenMode: mode === 'fullScreen',\n isBannerImageOn: bannerImage?.enabled ?? false,\n spotChecksMode: mode,\n avatarEnabled: appearance?.avatar?.enabled ?? false,\n avatarUrl: appearance?.avatar?.avatarUrl ?? '',\n };\n\n chat = updatedState.spotCheckType === 'chat';\n }\n\n const spotCheckId = responseJson?.spotCheckId ?? 0;\n const spotCheckContactId =\n responseJson?.spotCheckContactId ??\n responseJson?.spotCheckContact?.id ??\n 0;\n const triggerToken = responseJson?.triggerToken ?? '';\n\n updatedState = {\n ...updatedState,\n spotcheckID: spotCheckId,\n spotcheckContactID: spotCheckContactId,\n triggerToken,\n };\n\n const baseSpotcheckURL = `https://${domainName}/s/spotcheck/${triggerToken}/${\n chat ? 'config' : 'bootstrap'\n }?spotcheckContactId=${spotCheckContactId}&traceId=${traceId}&spotcheckUrl=${screen}`;\n\n let fullSpotcheckURL = baseSpotcheckURL;\n\n Object.entries(variables).forEach(([key, value]) => {\n fullSpotcheckURL += `&${key}=${value}`;\n });\n\n updatedState.spotcheckURL = fullSpotcheckURL;\n spotcheckStateService.setState(updatedState);\n\n try {\n const response = await axios.get<any>(fullSpotcheckURL);\n const themeInfo = response.data.config.generatedCSS;\n const theme_payload = { type: 'THEME_UPDATE_SPOTCHECK', themeInfo };\n state = spotcheckStateService.getState();\n\n let webViewRef = chat ? state.chatWebViewRef : state.classicWebViewRef;\n let isLoading = chat ? state.isChatLoading : state.isClassicLoading;\n\n const resetStateData = {\n type: 'RESET_STATE',\n state: {\n ...(response.data || {}),\n skip: true,\n spotCheckAppearance: {\n ...(appearance || {}),\n targetType: 'MOBILE',\n },\n spotcheckUrl: screen,\n traceId,\n elementBuilderParams: {\n ...(variables || {}),\n },\n },\n };\n\n const sendMessageToIframe = (iframe: HTMLIFrameElement, data: any) => {\n if (iframe && iframe.contentWindow) {\n try {\n iframe.contentWindow.postMessage(data, '*');\n } catch (error) {\n console.error('❌ Failed to send message to iframe:', error);\n }\n }\n };\n\n const communicateWithWebView = async (iframe: HTMLIFrameElement) => {\n await new Promise(resolve => setTimeout(() => {\n sendMessageToIframe(iframe, resetStateData);\n sendMessageToIframe(iframe, theme_payload);\n resolve(true);\n }, 2000));\n };\n\n if (webViewRef) {\n if (isLoading === false) {\n communicateWithWebView(webViewRef);\n start();\n return true;\n } else {\n // todo: recheck this\n const unsubscribe = spotcheckStateService.state$.subscribe(\n (currentState) => {\n const {\n isChatLoading,\n isClassicLoading,\n chatWebViewRef,\n classicWebViewRef,\n } = currentState;\n\n if ((!isChatLoading && chat) || (!isClassicLoading && !chat)) {\n unsubscribe.unsubscribe();\n const activeWebViewRef = chat\n ? chatWebViewRef\n : classicWebViewRef;\n if (activeWebViewRef) {\n communicateWithWebView(activeWebViewRef);\n start();\n } else {\n console.warn(\n '⚠️ Active WebView ref is null after loading completed'\n );\n }\n }\n }\n );\n return true;\n }\n } else {\n const unsubscribeWebView = spotcheckStateService.state$.subscribe(\n (currentState) => {\n const updatedWebViewRef = chat\n ? currentState.chatWebViewRef\n : currentState.classicWebViewRef;\n const updatedIsLoading = chat\n ? currentState.isChatLoading\n : currentState.isClassicLoading;\n\n if (updatedWebViewRef) {\n if (!updatedIsLoading) {\n unsubscribeWebView.unsubscribe();\n communicateWithWebView(updatedWebViewRef);\n start();\n } else {\n console.log('⏳ WebView ref available but still loading...');\n }\n }\n }\n );\n return true;\n }\n } catch (error: any) {\n throw new Error(error.message);\n }\n }\n throw new Error('Something went wrong');\n } catch (error: any) {\n throw new Error(error.message);\n }\n};\n\nexport const start = () => {\n const state = getSpotcheckStateService().getState();\n setTimeout(() => {\n getSpotcheckStateService().setState({ isVisible: true });\n }, state.afterDelay * 1000);\n};\n\nexport const closeSpotCheck = async () => {\n try {\n const stateService = getSpotcheckStateService();\n const state = stateService.getState();\n const payload = {\n traceId: state.traceId,\n triggerToken: state.triggerToken,\n };\n\n const response = await fetch(\n `https://${state.domainName}/api/internal/spotcheck/dismiss/${state.spotcheckContactID}`,\n {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n }\n );\n if(response.status == 200) {\n getSpotCheckEventListener().emit('surveyDismissed');\n }\n else{\n console.log(`Error: ${response.status}`);\n }\n } catch (error) {\n console.log('Error parsing JSON:', error);\n }\n};\n\nexport const handleSurveyEnd = () => {\n const stateService = getSpotcheckStateService();\n const state = stateService.getState();\n const webViewRef =\n state.spotCheckType === 'chat'\n ? state.chatWebViewRef\n : state.classicWebViewRef;\n\n webViewRef?.current?.injectJavaScript(`\n (function() {\n window.dispatchEvent(new MessageEvent('message', {\n data: ${JSON.stringify({ type: 'UNMOUNT_APP' })}\n }));\n })();\n `);\n\n const updatedState: Partial<SpotcheckState> = {\n isVisible: false,\n isCloseButtonEnabled: false,\n isFullScreenMode: false,\n spotcheckID: 0,\n currentQuestionHeight: 0,\n closeButtonStyle: {},\n spotcheckContactID: 0,\n spotcheckURL: '',\n spotcheckPosition: 'bottom',\n isMounted: false,\n spotCheckType: '',\n screenHeight: 0,\n keyBoardHeight: 0,\n textPosition: 0,\n spotChecksMode: '',\n avatarEnabled: false,\n avatarUrl: '',\n };\n\n stateService.setState(updatedState);\n};\n\nexport const getSpotcheckComponentCssStyles = (state: SpotcheckState) => { \n let styles = {}\n let wrapperStyles = {}\n let extraPaddingForMiniCardCloseButtonIfTopPosition = 0;\n if (state.isFullScreenMode && state.isVisible) {\n wrapperStyles = {\n display: 'flex',\n height: '100%',\n };\n styles = {\n display: 'flex',\n height: '100%',\n };\n }\n \n if (state.isVisible && state.isMounted) {\n\n let height = Math.min(state.currentQuestionHeight, (state.maxHeight * window.innerHeight));\n if(state.spotChecksMode === 'miniCard') {\n if(state.avatarEnabled) {\n height = height - 56;\n }\n if(state.isCloseButtonEnabled) {\n height = height - 40;\n }\n }\n\n switch (state.spotcheckPosition) {\n case 'bottom':\n styles = {\n display: 'flex',\n height: height+'px',\n };\n wrapperStyles = {\n display: 'flex',\n justifyContent: 'flex-end',\n };\n break;\n \n case 'top':\n styles = {\n display: 'flex',\n height: height+'px',\n };\n wrapperStyles = {\n display: 'flex',\n justifyContent: 'flex-start',\n };\n if(state.spotChecksMode === 'miniCard' && state.isCloseButtonEnabled) {\n extraPaddingForMiniCardCloseButtonIfTopPosition = 30;\n }\n break;\n \n case 'center':\n styles = {\n display: 'flex',\n height: height+'px',\n };\n wrapperStyles = {\n display: 'flex',\n justifyContent: 'center',\n };\n break;\n \n default:\n break;\n }\n }\n \n return {\n wrapperStyles: {\n position: 'fixed', \n width: '100%', \n height: '100%', \n top: '0', \n left: '0', \n backgroundColor: 'rgba(0, 0, 0, 0.3)', \n zIndex: '99999999',\n display: 'none',\n flexDirection: 'column',\n ...wrapperStyles\n },\n styles: {\n display: 'none',\n flexDirection: 'column',\n paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition+'px',\n ...styles,\n }\n };\n};\n\nexport const closeSpotCheckAndHandleSurveyEnd = async () => {\n handleSurveyEnd();\n};"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/helpers.ts"],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 'uuid';\nimport { Device } from '@capacitor/device';\nimport { SpotcheckState } from './types';\nimport axios from 'axios';\nimport { SpotcheckStateService } from './SpotcheckStateService';\nimport { getSpotCheckEventListener } from './SpotCheckEventListener';\n\nlet globalSpotcheckStateService: SpotcheckStateService;\nlet globalOS: string | null = null;\n\nexport const getSpotcheckStateService = (): SpotcheckStateService => {\n if (!globalSpotcheckStateService) {\n globalSpotcheckStateService = new SpotcheckStateService();\n }\n return globalSpotcheckStateService;\n};\n\nexport function generateTraceId() {\n const uuidString = uuidv4();\n const timestamp = Date.now();\n return `${uuidString}-${timestamp}`;\n}\n\nexport const ischatSurvey = (type: String) => {\n return (\n type === 'Conversational' ||\n type === 'CESChat' ||\n type === 'NPSChat' ||\n type === 'CSATChat'\n );\n};\n\nexport const getOS = async () => {\n const info = await Device.getInfo();\n globalOS = info.operatingSystem;\n return globalOS;\n};\n\nexport const setAppearance = async (\n responseJson: any,\n screen: string,\n domainName: string,\n traceId: string,\n variables: Record<string, any>\n) => {\n try {\n const spotcheckStateService = getSpotcheckStateService();\n let state = spotcheckStateService.getState();\n\n if (responseJson) {\n const currentSpotcheck = state.filteredSpotChecks.find(\n (spotcheck) =>\n spotcheck['id'] === responseJson?.spotCheckId ||\n spotcheck['id'] === responseJson?.id\n );\n\n const appearance = responseJson?.appearance;\n let chat = false;\n\n let updatedState: Partial<SpotcheckState> = {};\n\n if (appearance) {\n const {\n position,\n closeButton,\n colors,\n cardProperties,\n mode,\n bannerImage,\n } = appearance;\n const { maxHeight } = cardProperties || {};\n\n updatedState = {\n spotcheckPosition:\n position === 'top_full' || position === 'center_top'\n ? 'top'\n : position === 'center_center'\n ? 'center'\n : 'bottom',\n isCloseButtonEnabled: closeButton ?? true,\n closeButtonStyle: colors?.overrides ?? {},\n maxHeight: maxHeight ? parseFloat(maxHeight) / 100 : 0,\n spotCheckType:\n ischatSurvey(currentSpotcheck?.['survey']?.surveyType) &&\n mode === 'fullScreen'\n ? 'chat'\n : 'classic',\n isFullScreenMode: mode === 'fullScreen',\n isBannerImageOn: bannerImage?.enabled ?? false,\n spotChecksMode: mode,\n avatarEnabled: appearance?.avatar?.enabled ?? false,\n avatarUrl: appearance?.avatar?.avatarUrl ?? '',\n };\n\n chat = updatedState.spotCheckType === 'chat';\n }\n\n const spotCheckId = responseJson?.spotCheckId ?? 0;\n const spotCheckContactId =\n responseJson?.spotCheckContactId ??\n responseJson?.spotCheckContact?.id ??\n 0;\n const triggerToken = responseJson?.triggerToken ?? '';\n\n updatedState = {\n ...updatedState,\n spotcheckID: spotCheckId,\n spotcheckContactID: spotCheckContactId,\n triggerToken,\n };\n\n const baseSpotcheckURL = `https://${domainName}/s/spotcheck/${triggerToken}/${\n chat ? 'config' : 'bootstrap'\n }?spotcheckContactId=${spotCheckContactId}&traceId=${traceId}&spotcheckUrl=${screen}`;\n\n let fullSpotcheckURL = baseSpotcheckURL;\n\n Object.entries(variables).forEach(([key, value]) => {\n fullSpotcheckURL += `&${key}=${value}`;\n });\n\n updatedState.spotcheckURL = fullSpotcheckURL;\n spotcheckStateService.setState(updatedState);\n\n try {\n const response = await axios.get<any>(fullSpotcheckURL);\n const themeInfo = response.data?.config?.generatedCSS;\n const theme_payload = { type: 'THEME_UPDATE_SPOTCHECK', themeInfo };\n state = spotcheckStateService.getState();\n\n let webViewRef = chat ? state.chatWebViewRef : state.classicWebViewRef;\n let isLoading = chat ? state.isChatLoading || !state.isChatLoadEventReceived : state.isClassicLoading || !state.isClassicLoadEventReceived;\n\n const resetStateData = {\n type: 'RESET_STATE',\n state: {\n ...(response.data || {}),\n skip: true,\n spotCheckAppearance: {\n ...(appearance || {}),\n targetType: 'MOBILE',\n },\n spotcheckUrl: screen,\n traceId,\n elementBuilderParams: {\n ...(variables || {}),\n },\n },\n };\n\n const sendMessageToIframe = (iframe: HTMLIFrameElement, data: any) => {\n if (iframe && iframe.contentWindow) {\n try {\n iframe.contentWindow.postMessage(data, '*');\n } catch (error) {\n console.error('❌ Failed to send message to iframe:', error);\n }\n }\n };\n\n const communicateWithWebView = async (iframe: HTMLIFrameElement) => {\n await new Promise(resolve => setTimeout(() => {\n sendMessageToIframe(iframe, resetStateData);\n sendMessageToIframe(iframe, theme_payload);\n resolve(true);\n }, 2000));\n };\n\n if (webViewRef) {\n if (isLoading === false) {\n communicateWithWebView(webViewRef);\n start();\n return true;\n } else {\n // todo: recheck this\n const unsubscribe = spotcheckStateService.state$.subscribe(\n (currentState) => {\n const {\n isChatLoading,\n isClassicLoading,\n chatWebViewRef,\n classicWebViewRef,\n isClassicLoadEventReceived,\n isChatLoadEventReceived,\n } = currentState;\n\n \n if ((!isChatLoading && chat && isChatLoadEventReceived) || (!isClassicLoading && !chat && isClassicLoadEventReceived)) {\n unsubscribe.unsubscribe();\n const activeWebViewRef = chat\n ? chatWebViewRef\n : classicWebViewRef;\n if (activeWebViewRef) {\n communicateWithWebView(activeWebViewRef);\n start();\n } else {\n console.warn(\n '⚠️ Active WebView ref is null after loading completed'\n );\n }\n }\n }\n );\n return true;\n }\n } else {\n const unsubscribeWebView = spotcheckStateService.state$.subscribe(\n (currentState) => {\n const updatedWebViewRef = chat\n ? currentState.chatWebViewRef\n : currentState.classicWebViewRef;\n const updatedIsLoading = chat\n ? currentState.isChatLoading || !currentState.isChatLoadEventReceived\n : currentState.isClassicLoading || !currentState.isClassicLoadEventReceived;\n\n if (updatedWebViewRef) {\n if (!updatedIsLoading) {\n unsubscribeWebView.unsubscribe();\n communicateWithWebView(updatedWebViewRef);\n start();\n } else {\n console.log('⏳ WebView ref available but still loading...');\n }\n }\n }\n );\n return true;\n }\n } catch (error: any) {\n throw new Error(error.message);\n }\n }\n throw new Error('Something went wrong');\n } catch (error: any) {\n throw new Error(error.message);\n }\n};\n\nexport const start = () => {\n const state = getSpotcheckStateService().getState();\n setTimeout(() => {\n getSpotcheckStateService().setState({ isVisible: true });\n }, state.afterDelay * 1000);\n};\n\nexport const closeSpotCheck = async () => {\n try {\n const stateService = getSpotcheckStateService();\n const state = stateService.getState();\n const payload = {\n traceId: state.traceId,\n triggerToken: state.triggerToken,\n };\n\n const response = await fetch(\n `https://${state.domainName}/api/internal/spotcheck/dismiss/${state.spotcheckContactID}`,\n {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n }\n );\n if(response.status == 200) {\n getSpotCheckEventListener().emit('surveyDismissed');\n }\n else{\n console.log(`Error: ${response.status}`);\n }\n } catch (error) {\n console.log('Error parsing JSON:', error);\n }\n};\n\nexport const handleSurveyEnd = () => {\n const stateService = getSpotcheckStateService();\n const state = stateService.getState();\n const webViewRef =\n state.spotCheckType === 'chat'\n ? state.chatWebViewRef\n : state.classicWebViewRef;\n\n webViewRef?.current?.injectJavaScript(`\n (function() {\n window.dispatchEvent(new MessageEvent('message', {\n data: ${JSON.stringify({ type: 'UNMOUNT_APP' })}\n }));\n })();\n `);\n\n const updatedState: Partial<SpotcheckState> = {\n isVisible: false,\n isCloseButtonEnabled: false,\n isFullScreenMode: false,\n spotcheckID: 0,\n currentQuestionHeight: 0,\n closeButtonStyle: {},\n spotcheckContactID: 0,\n spotcheckURL: '',\n spotcheckPosition: 'bottom',\n isMounted: false,\n spotCheckType: '',\n screenHeight: 0,\n keyBoardHeight: 0,\n textPosition: 0,\n spotChecksMode: '',\n avatarEnabled: false,\n avatarUrl: '',\n };\n\n stateService.setState(updatedState);\n};\n\nexport const getSpotcheckComponentCssStyles = (state: SpotcheckState) => { \n let styles = {}\n let wrapperStyles = {}\n let extraPaddingForMiniCardCloseButtonIfTopPosition = 0;\n if (state.isFullScreenMode && state.isVisible) {\n wrapperStyles = {\n display: 'flex',\n height: '100%',\n };\n styles = {\n display: 'flex',\n height: '100%',\n };\n }\n\n let marginBottom = globalOS !== 'ios' ? 18 : 0;\n \n if (state.isVisible && state.isMounted) {\n\n let height = Math.min(state.currentQuestionHeight, (state.maxHeight * window.innerHeight));\n if(state.spotChecksMode === 'miniCard') {\n if(state.avatarEnabled) {\n height = height - 56;\n if(state.spotcheckPosition === 'bottom') {\n marginBottom += 56;\n }\n }\n if(state.isCloseButtonEnabled) {\n height = height - 40;\n }\n }\n\n switch (state.spotcheckPosition) {\n case 'bottom': \n styles = {\n display: 'flex',\n height: height+'px',\n };\n wrapperStyles = {\n display: 'flex',\n justifyContent: 'flex-end',\n };\n break;\n \n case 'top':\n styles = {\n display: 'flex',\n height: height+'px',\n };\n wrapperStyles = {\n display: 'flex',\n justifyContent: 'flex-start',\n };\n if(state.spotChecksMode === 'miniCard' && state.isCloseButtonEnabled) {\n extraPaddingForMiniCardCloseButtonIfTopPosition = 30;\n }\n break;\n \n case 'center':\n styles = {\n display: 'flex',\n height: height+'px',\n };\n wrapperStyles = {\n display: 'flex',\n justifyContent: 'center',\n };\n break;\n \n default:\n break;\n }\n }\n \n return {\n wrapperStyles: {\n position: 'fixed', \n width: '100%', \n height: '100%', \n top: '0', \n left: '0', \n backgroundColor: 'rgba(0, 0, 0, 0.3)', \n zIndex: '100001',\n display: 'none',\n flexDirection: 'column',\n ...wrapperStyles\n },\n styles: {\n display: 'none',\n flexDirection: 'column',\n paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition+'px',\n marginBottom: marginBottom+'px',\n ...styles,\n }\n };\n};\n\nexport const closeSpotCheckAndHandleSurveyEnd = async () => {\n handleSurveyEnd();\n};"]}
@@ -23,6 +23,8 @@ export interface SpotcheckState {
23
23
  traceId: string;
24
24
  isClassicLoading: boolean;
25
25
  isChatLoading: boolean;
26
+ isClassicLoadEventReceived: boolean;
27
+ isChatLoadEventReceived: boolean;
26
28
  classicUrl: string;
27
29
  chatUrl: string;
28
30
  classicWebViewRef: any | null;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SpotcheckState {\n isVisible: boolean;\n spotcheckPosition: string;\n spotcheckURL: string;\n spotcheckID: number;\n spotcheckContactID: number;\n afterDelay: number;\n maxHeight: number;\n currentQuestionHeight: number;\n isFullScreenMode: boolean;\n isBannerImageOn: boolean;\n triggerToken: string;\n closeButtonStyle: Record<string, string>;\n isCloseButtonEnabled: boolean;\n isSpotPassed: boolean;\n isChecksPassed: boolean;\n customEventsSpotChecks: Record<string, any>[];\n targetToken: string;\n domainName: string;\n userDetails: UserDetails;\n variables: Variables;\n customProperties: CustomProperties;\n traceId: string;\n isClassicLoading: boolean;\n isChatLoading: boolean;\n classicUrl: string;\n chatUrl: string;\n classicWebViewRef: any | null;\n chatWebViewRef: any | null;\n filteredSpotChecks: Record<string, any>[];\n spotCheckType: String;\n isMounted: boolean;\n textPosition: number;\n screenHeight: number;\n keyBoardHeight: number;\n spotChecksMode: string;\n avatarEnabled: boolean;\n avatarUrl: string;\n screenwiseUserDetails: Record<string, UserDetails | undefined>;\n}\n\nexport interface UserDetails {\n uuid?: string;\n email?: string;\n firstName?: string;\n lastName?: string;\n mobile?: number;\n [key: string]: any;\n}\n\nexport interface Variables {\n sparrowLang?: string;\n [key: string]: any;\n}\n\nexport interface CustomProperties {\n [key: string]: any;\n}\n\nexport interface TrackScreenProps {\n screen: string;\n options?: {\n variables?: Variables;\n customProperties?: CustomProperties;\n userDetails?: UserDetails;\n };\n}\n\nexport interface TrackEventProps {\n screen: string;\n event: {\n [key: string]: {\n [key: string]: string;\n };\n };\n}\n\nexport interface InitializeSpotChecksProps {\n domainName: string;\n targetToken: string;\n userDetails?: UserDetails;\n variables?: Variables;\n customProperties?: CustomProperties;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/angular-ui/lib/spotchecks/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SpotcheckState {\n isVisible: boolean;\n spotcheckPosition: string;\n spotcheckURL: string;\n spotcheckID: number;\n spotcheckContactID: number;\n afterDelay: number;\n maxHeight: number;\n currentQuestionHeight: number;\n isFullScreenMode: boolean;\n isBannerImageOn: boolean;\n triggerToken: string;\n closeButtonStyle: Record<string, string>;\n isCloseButtonEnabled: boolean;\n isSpotPassed: boolean;\n isChecksPassed: boolean;\n customEventsSpotChecks: Record<string, any>[];\n targetToken: string;\n domainName: string;\n userDetails: UserDetails;\n variables: Variables;\n customProperties: CustomProperties;\n traceId: string;\n isClassicLoading: boolean;\n isChatLoading: boolean;\n isClassicLoadEventReceived: boolean;\n isChatLoadEventReceived: boolean;\n classicUrl: string;\n chatUrl: string;\n classicWebViewRef: any | null;\n chatWebViewRef: any | null;\n filteredSpotChecks: Record<string, any>[];\n spotCheckType: String;\n isMounted: boolean;\n textPosition: number;\n screenHeight: number;\n keyBoardHeight: number;\n spotChecksMode: string;\n avatarEnabled: boolean;\n avatarUrl: string;\n screenwiseUserDetails: Record<string, UserDetails | undefined>;\n}\n\nexport interface UserDetails {\n uuid?: string;\n email?: string;\n firstName?: string;\n lastName?: string;\n mobile?: number;\n [key: string]: any;\n}\n\nexport interface Variables {\n sparrowLang?: string;\n [key: string]: any;\n}\n\nexport interface CustomProperties {\n [key: string]: any;\n}\n\nexport interface TrackScreenProps {\n screen: string;\n options?: {\n variables?: Variables;\n customProperties?: CustomProperties;\n userDetails?: UserDetails;\n };\n}\n\nexport interface TrackEventProps {\n screen: string;\n event: {\n [key: string]: {\n [key: string]: string;\n };\n };\n}\n\nexport interface InitializeSpotChecksProps {\n domainName: string;\n targetToken: string;\n userDetails?: UserDetails;\n variables?: Variables;\n customProperties?: CustomProperties;\n}\n"]}
@@ -51102,6 +51102,8 @@ let SpotcheckStateService = class SpotcheckStateService {
51102
51102
  traceId: '',
51103
51103
  isClassicLoading: true,
51104
51104
  isChatLoading: true,
51105
+ isClassicLoadEventReceived: false,
51106
+ isChatLoadEventReceived: false,
51105
51107
  classicUrl: '',
51106
51108
  chatUrl: '',
51107
51109
  classicWebViewRef: null,
@@ -51164,6 +51166,7 @@ const addSpotCheckListener = (eventType, callback) => {
51164
51166
  };
51165
51167
 
51166
51168
  let globalSpotcheckStateService;
51169
+ let globalOS = null;
51167
51170
  const getSpotcheckStateService = () => {
51168
51171
  if (!globalSpotcheckStateService) {
51169
51172
  globalSpotcheckStateService = new SpotcheckStateService();
@@ -51183,10 +51186,11 @@ const ischatSurvey = (type) => {
51183
51186
  };
51184
51187
  const getOS = async () => {
51185
51188
  const info = await device.Device.getInfo();
51186
- return info.operatingSystem;
51189
+ globalOS = info.operatingSystem;
51190
+ return globalOS;
51187
51191
  };
51188
51192
  const setAppearance = async (responseJson, screen, domainName, traceId, variables) => {
51189
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
51193
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
51190
51194
  try {
51191
51195
  const spotcheckStateService = getSpotcheckStateService();
51192
51196
  let state = spotcheckStateService.getState();
@@ -51233,11 +51237,11 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
51233
51237
  spotcheckStateService.setState(updatedState);
51234
51238
  try {
51235
51239
  const response = await axios.get(fullSpotcheckURL);
51236
- const themeInfo = response.data.config.generatedCSS;
51240
+ const themeInfo = (_p = (_o = response.data) === null || _o === void 0 ? void 0 : _o.config) === null || _p === void 0 ? void 0 : _p.generatedCSS;
51237
51241
  const theme_payload = { type: 'THEME_UPDATE_SPOTCHECK', themeInfo };
51238
51242
  state = spotcheckStateService.getState();
51239
51243
  let webViewRef = chat ? state.chatWebViewRef : state.classicWebViewRef;
51240
- let isLoading = chat ? state.isChatLoading : state.isClassicLoading;
51244
+ let isLoading = chat ? state.isChatLoading || !state.isChatLoadEventReceived : state.isClassicLoading || !state.isClassicLoadEventReceived;
51241
51245
  const resetStateData = {
51242
51246
  type: 'RESET_STATE',
51243
51247
  state: Object.assign(Object.assign({}, (response.data || {})), { skip: true, spotCheckAppearance: Object.assign(Object.assign({}, (appearance || {})), { targetType: 'MOBILE' }), spotcheckUrl: screen, traceId, elementBuilderParams: Object.assign({}, (variables || {})) }),
@@ -51268,8 +51272,8 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
51268
51272
  else {
51269
51273
  // todo: recheck this
51270
51274
  const unsubscribe = spotcheckStateService.state$.subscribe((currentState) => {
51271
- const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, } = currentState;
51272
- if ((!isChatLoading && chat) || (!isClassicLoading && !chat)) {
51275
+ const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, isClassicLoadEventReceived, isChatLoadEventReceived, } = currentState;
51276
+ if ((!isChatLoading && chat && isChatLoadEventReceived) || (!isClassicLoading && !chat && isClassicLoadEventReceived)) {
51273
51277
  unsubscribe.unsubscribe();
51274
51278
  const activeWebViewRef = chat
51275
51279
  ? chatWebViewRef
@@ -51292,8 +51296,8 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
51292
51296
  ? currentState.chatWebViewRef
51293
51297
  : currentState.classicWebViewRef;
51294
51298
  const updatedIsLoading = chat
51295
- ? currentState.isChatLoading
51296
- : currentState.isClassicLoading;
51299
+ ? currentState.isChatLoading || !currentState.isChatLoadEventReceived
51300
+ : currentState.isClassicLoading || !currentState.isClassicLoadEventReceived;
51297
51301
  if (updatedWebViewRef) {
51298
51302
  if (!updatedIsLoading) {
51299
51303
  unsubscribeWebView.unsubscribe();
@@ -51399,11 +51403,15 @@ const getSpotcheckComponentCssStyles = (state) => {
51399
51403
  height: '100%',
51400
51404
  };
51401
51405
  }
51406
+ let marginBottom = globalOS !== 'ios' ? 18 : 0;
51402
51407
  if (state.isVisible && state.isMounted) {
51403
51408
  let height = Math.min(state.currentQuestionHeight, (state.maxHeight * window.innerHeight));
51404
51409
  if (state.spotChecksMode === 'miniCard') {
51405
51410
  if (state.avatarEnabled) {
51406
51411
  height = height - 56;
51412
+ if (state.spotcheckPosition === 'bottom') {
51413
+ marginBottom += 56;
51414
+ }
51407
51415
  }
51408
51416
  if (state.isCloseButtonEnabled) {
51409
51417
  height = height - 40;
@@ -51446,8 +51454,8 @@ const getSpotcheckComponentCssStyles = (state) => {
51446
51454
  }
51447
51455
  }
51448
51456
  return {
51449
- wrapperStyles: Object.assign({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', backgroundColor: 'rgba(0, 0, 0, 0.3)', zIndex: '99999999', display: 'none', flexDirection: 'column' }, wrapperStyles),
51450
- styles: Object.assign({ display: 'none', flexDirection: 'column', paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px' }, styles)
51457
+ wrapperStyles: Object.assign({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', backgroundColor: 'rgba(0, 0, 0, 0.3)', zIndex: '100001', display: 'none', flexDirection: 'column' }, wrapperStyles),
51458
+ styles: Object.assign({ display: 'none', flexDirection: 'column', paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px', marginBottom: marginBottom + 'px' }, styles)
51451
51459
  };
51452
51460
  };
51453
51461
  const closeSpotCheckAndHandleSurveyEnd = async () => {
@@ -51499,6 +51507,7 @@ let WebViewComponent = class WebViewComponent {
51499
51507
  const iframe = this.iframe.nativeElement;
51500
51508
  iframe.addEventListener('load', () => {
51501
51509
  this.ngZone.run(() => {
51510
+ this.injectNativeBridgeAdapters(iframe);
51502
51511
  const stateService = getSpotcheckStateService();
51503
51512
  if (this.webviewType === 'classic') {
51504
51513
  stateService.setState({ isClassicLoading: false });
@@ -51509,6 +51518,45 @@ let WebViewComponent = class WebViewComponent {
51509
51518
  });
51510
51519
  });
51511
51520
  }
51521
+ injectNativeBridgeAdapters(iframe) {
51522
+ if (iframe && iframe.contentWindow) {
51523
+ try {
51524
+ const iframeWindow = iframe.contentWindow;
51525
+ if (!iframeWindow.SsAndroidSdk) {
51526
+ iframeWindow.SsAndroidSdk = {
51527
+ shareData: function () { },
51528
+ sendPartialSubmissionData: function () { }
51529
+ };
51530
+ }
51531
+ if (!iframeWindow.Android) {
51532
+ iframeWindow.Android = {
51533
+ onMessageReceive: function () { }
51534
+ };
51535
+ }
51536
+ if (!iframeWindow.webkit) {
51537
+ iframeWindow.webkit = {
51538
+ messageHandlers: {
51539
+ surveyResponse: {
51540
+ postMessage: function () { }
51541
+ },
51542
+ spotCheckData: {
51543
+ postMessage: function () { }
51544
+ },
51545
+ flutterSpotCheckData: {
51546
+ postMessage: function () { }
51547
+ }
51548
+ }
51549
+ };
51550
+ }
51551
+ if (!iframeWindow.flutterSpotCheckData) {
51552
+ iframeWindow.flutterSpotCheckData = {
51553
+ postMessage: function () { }
51554
+ };
51555
+ }
51556
+ }
51557
+ catch (error) { }
51558
+ }
51559
+ }
51512
51560
  onMessage(event) {
51513
51561
  this.ngZone.run(() => {
51514
51562
  const stateService = getSpotcheckStateService();
@@ -51540,6 +51588,12 @@ let WebViewComponent = class WebViewComponent {
51540
51588
  case 'surveyLoadStarted':
51541
51589
  getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);
51542
51590
  break;
51591
+ case 'classicLoadEvent':
51592
+ stateService.setState({ isClassicLoadEventReceived: true });
51593
+ break;
51594
+ case 'chatLoadEvent':
51595
+ stateService.setState({ isChatLoadEventReceived: true });
51596
+ break;
51543
51597
  }
51544
51598
  this.cdr.detectChanges();
51545
51599
  });
@@ -51573,7 +51627,8 @@ WebViewComponent = __decorate$1([
51573
51627
  template: `
51574
51628
  <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;">
51575
51629
  <iframe
51576
- allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;"
51630
+ allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write; fullscreen"
51631
+ allowfullscreen
51577
51632
  #iframeRef
51578
51633
  [src]="safeUrl"
51579
51634
  style="width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;"
@@ -51641,7 +51696,12 @@ let CloseButtonComponent = class CloseButtonComponent {
51641
51696
  this.isVisible = false;
51642
51697
  this.isMiniCard = false;
51643
51698
  this.stroke = 'black';
51699
+ this.isClosing = false;
51644
51700
  this.onClick = async () => {
51701
+ if (this.isClosing) {
51702
+ return;
51703
+ }
51704
+ this.isClosing = true;
51645
51705
  await closeSpotCheck();
51646
51706
  handleSurveyEnd();
51647
51707
  this.ngZone.run(() => {
@@ -51676,6 +51736,9 @@ let CloseButtonComponent = class CloseButtonComponent {
51676
51736
  this.state.spotCheckType === 'chat'))));
51677
51737
  this.isMiniCard = this.state.spotChecksMode === 'miniCard';
51678
51738
  this.stroke = this.isMiniCard ? 'black' : ((_a = this.state.closeButtonStyle) === null || _a === void 0 ? void 0 : _a['ctaButton']) || 'black';
51739
+ if (this.isVisible) {
51740
+ this.isClosing = false;
51741
+ }
51679
51742
  }
51680
51743
  };
51681
51744
  __decorate$1([
@@ -51806,6 +51869,7 @@ const setUUID = (uuid) => {
51806
51869
  };
51807
51870
 
51808
51871
  const sendTrackScreenRequest = async ({ screen, options, }) => {
51872
+ var _a, _b;
51809
51873
  try {
51810
51874
  const spotcheckStateService = getSpotcheckStateService();
51811
51875
  const oldState = spotcheckStateService.getState();
@@ -51924,7 +51988,7 @@ const sendTrackScreenRequest = async ({ screen, options, }) => {
51924
51988
  }
51925
51989
  }
51926
51990
  }
51927
- throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
51991
+ 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');
51928
51992
  }
51929
51993
  else {
51930
51994
  throw new Error(`Received status code ${response.status}`);
@@ -51935,7 +51999,7 @@ const sendTrackScreenRequest = async ({ screen, options, }) => {
51935
51999
  }
51936
52000
  };
51937
52001
  const sendTrackEventRequest = async ({ screen, event }) => {
51938
- var _a, _b, _c, _d, _e, _f;
52002
+ var _a, _b, _c, _d, _e, _f, _g, _h;
51939
52003
  try {
51940
52004
  const intMax = Number.POSITIVE_INFINITY;
51941
52005
  const state = getSpotcheckStateService().getState();
@@ -52008,7 +52072,7 @@ const sendTrackEventRequest = async ({ screen, event }) => {
52008
52072
  return { valid: true };
52009
52073
  }
52010
52074
  }
52011
- throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
52075
+ 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');
52012
52076
  }
52013
52077
  else {
52014
52078
  throw new Error(`Received status code ${response.status}`);