@tellescope/react-components 1.204.1 → 1.205.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.204.1",
3
+ "version": "1.205.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,13 +47,13 @@
47
47
  "@reduxjs/toolkit": "^1.6.2",
48
48
  "@stripe/react-stripe-js": "^2.9.0",
49
49
  "@stripe/stripe-js": "^1.52.1",
50
- "@tellescope/constants": "^1.204.1",
51
- "@tellescope/sdk": "^1.204.1",
52
- "@tellescope/types-client": "^1.204.1",
53
- "@tellescope/types-models": "^1.204.1",
54
- "@tellescope/types-utilities": "^1.204.1",
55
- "@tellescope/utilities": "^1.204.1",
56
- "@tellescope/validation": "^1.204.1",
50
+ "@tellescope/constants": "^1.205.0",
51
+ "@tellescope/sdk": "^1.205.0",
52
+ "@tellescope/types-client": "^1.205.0",
53
+ "@tellescope/types-models": "^1.205.0",
54
+ "@tellescope/types-utilities": "^1.205.0",
55
+ "@tellescope/utilities": "^1.205.0",
56
+ "@tellescope/validation": "^1.205.0",
57
57
  "@typescript-eslint/eslint-plugin": "^4.33.0",
58
58
  "@typescript-eslint/parser": "^4.33.0",
59
59
  "css-to-react-native": "^3.0.0",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
85
85
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
86
86
  },
87
- "gitHead": "bf08d1f48c4e7939f6e4e246a2ba84189f0e68db",
87
+ "gitHead": "2207d17c9959fcef3194f08245f8890817739b4e",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -9,7 +9,7 @@ import { WithTheme, contact_is_valid, useAddGTMTag, useFileUpload, useFormFields
9
9
  import ReactGA from "react-ga4";
10
10
 
11
11
  import isEmail from "validator/lib/isEmail"
12
- import { append_current_utm_params, field_can_autoadvance, getLocalTimezone, get_time_values, get_utm_params, is_object, object_is_empty, responses_satisfy_conditions, update_local_storage } from "@tellescope/utilities"
12
+ import { append_current_utm_params, emit_gtm_event, field_can_autoadvance, getLocalTimezone, get_time_values, get_utm_params, is_object, object_is_empty, responses_satisfy_conditions, update_local_storage } from "@tellescope/utilities"
13
13
 
14
14
  export const useFlattenedTree = (root?: FormFieldNode) => {
15
15
  const flat: FormField[] = []
@@ -538,6 +538,7 @@ export const useTellescopeForm = ({ dontAutoadvance, isPublicForm, form, urlLogi
538
538
  const [repeats, setRepeats] = useState({} as Record<string, string | number>)
539
539
 
540
540
  const gaEventRef = useRef({} as Record<string, boolean>)
541
+ const gtmEventRef = useRef({} as Record<string, boolean>)
541
542
 
542
543
  let goBackURL = ''
543
544
  try {
@@ -591,6 +592,20 @@ export const useTellescopeForm = ({ dontAutoadvance, isPublicForm, form, urlLogi
591
592
  });
592
593
  }, [ga4measurementId, activeField])
593
594
 
595
+ useEffect(() => {
596
+ if (gtmEventRef.current[activeField.value.id]) return
597
+ gtmEventRef.current[activeField.value.id] = true
598
+
599
+ emit_gtm_event({
600
+ event: 'form_progress',
601
+ formId: activeField.value.formId,
602
+ fieldId: activeField.value.id,
603
+ title: activeField.value.title,
604
+ previousTitle: prevFieldStackRef.current[prevFieldStackRef.current.length - 1]?.value?.title || '',
605
+ status: ''
606
+ })
607
+ }, [activeField])
608
+
594
609
  // placeholders for initial fields, reset when fields prop changes, since questions are now different (e.g. different form selected)
595
610
  const fieldInitRef = useRef('')
596
611
  const initializeFields = useCallback(() => (
@@ -1252,6 +1267,7 @@ export const useTellescopeForm = ({ dontAutoadvance, isPublicForm, form, urlLogi
1252
1267
  value: 2,
1253
1268
  });
1254
1269
  }
1270
+ emit_gtm_event({ event: 'form_submitted', formId: formResponse.formId, fieldId: '', title: '', status: '', previousTitle: '', })
1255
1271
  updateLocalFormResponse(formResponse.id, formResponse)
1256
1272
  options?.onPreRedirect?.() // in case redirect on success
1257
1273
  options?.onSuccess?.(formResponse)
@@ -4,7 +4,7 @@ import { Autocomplete, Box, Button, Checkbox, Chip, Divider, FormControl, FormCo
4
4
  import { FormInputProps } from "./types"
5
5
  import { useDropzone } from "react-dropzone"
6
6
  import { CANVAS_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants"
7
- import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, first_letter_capitalized, form_response_value_to_string, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, replace_enduser_template_values, truncate_string, user_display_name } from "@tellescope/utilities"
7
+ import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, replace_enduser_template_values, truncate_string, user_display_name } from "@tellescope/utilities"
8
8
  import { DatabaseSelectResponse, Enduser, EnduserRelationship, FormResponseValue, InsuranceRelationship, MedicationResponse, MultipleChoiceOptions, TellescopeGender } from "@tellescope/types-models"
9
9
  import { VALID_STATES, emailValidator, phoneValidator } from "@tellescope/validation"
10
10
  import Slider from '@mui/material/Slider';
@@ -2857,6 +2857,7 @@ export const AppointmentBookingInput = ({ formResponseId, field, value, onChange
2857
2857
  && (!m?.data?.entropy || m?.data?.entropy === loaded?.entropy)
2858
2858
  ) {
2859
2859
  onChange(m.data.bookedEventId, field.id)
2860
+ emit_gtm_event({ event: 'form_progress', fieldId: field.id, formId: field.formId, title: field.title, status: "Appointment Booked" })
2860
2861
  }
2861
2862
  if (m?.data?.type === 'CalendarPicker') {
2862
2863
  setHeight(750)
@@ -2873,7 +2874,7 @@ export const AppointmentBookingInput = ({ formResponseId, field, value, onChange
2873
2874
 
2874
2875
  window.addEventListener('message', handleMessage)
2875
2876
  return () => { window.removeEventListener('message', handleMessage) }
2876
- }, [field?.id, onChange, acknowledgedWarning, value, loaded?.entropy])
2877
+ }, [field?.id, field?.formId, field?.title, onChange, acknowledgedWarning, value, loaded?.entropy])
2877
2878
 
2878
2879
  if (value) {
2879
2880
  return (
@@ -3036,6 +3037,23 @@ export const HeightInput = ({ field, value={} as any, onChange, ...props }: Form
3036
3037
  </Grid>
3037
3038
  )
3038
3039
 
3040
+ export const include_current_url_parameters_if_templated = (url: string ) => {
3041
+ try {
3042
+ // get parameters from the current URL, and replace all values where {{URL_PARAM.paramName}} is used
3043
+ const params = new URL(window.location.href).searchParams
3044
+ return url.replace(/{{URL_PARAM\.(.*?)}}/g, (_, paramName) => {
3045
+ const value = params.get(paramName)
3046
+ console.log(paramName, value)
3047
+ if (value === null) return ''
3048
+ return value
3049
+ })
3050
+
3051
+ } catch(err) {
3052
+ console.error(err)
3053
+ }
3054
+ return url
3055
+ }
3056
+
3039
3057
  export const RedirectInput = ({ enduserId, groupId, groupInsance, rootResponseId, formResponseId, field, submit, value={} as any, onChange, responses, enduser, ...props }: FormInputProps<'Redirect'>) => {
3040
3058
  const session = useResolvedSession()
3041
3059
 
@@ -3080,13 +3098,15 @@ export const RedirectInput = ({ enduserId, groupId, groupInsance, rootResponseId
3080
3098
  if (!field.options?.redirectExternalUrl) { return }
3081
3099
 
3082
3100
  window.location.href = (
3083
- replace_enduser_template_values(
3084
- field.options.redirectExternalUrl,
3085
- {
3086
- ...session.userInfo as any,
3087
- id: eId, email, fname, lname, state, phone,
3088
- }
3089
- )
3101
+ include_current_url_parameters_if_templated(
3102
+ replace_enduser_template_values(
3103
+ field.options.redirectExternalUrl,
3104
+ {
3105
+ ...session.userInfo as any,
3106
+ id: eId, email, fname, lname, state, phone,
3107
+ }
3108
+ )
3109
+ )
3090
3110
  )
3091
3111
  })
3092
3112
  .catch(console.error)