diff --git a/packages/nuxt-ripple-analytics/utils/trackError.ts b/packages/nuxt-ripple-analytics/utils/trackError.ts index 25f5d56a1e..594112c50b 100644 --- a/packages/nuxt-ripple-analytics/utils/trackError.ts +++ b/packages/nuxt-ripple-analytics/utils/trackError.ts @@ -1,12 +1,12 @@ declare global { interface Window { newrelic?: { - noticeError: (error: Error) => void + noticeError: (error: any) => void } } } -const trackError = (error: Error) => { +const trackError = (error: any) => { if (window?.newrelic?.noticeError) { window.newrelic.noticeError(error) } diff --git a/packages/nuxt-ripple/components/TideAlerts.vue b/packages/nuxt-ripple/components/TideAlerts.vue index 23c17450ee..7ef2905292 100644 --- a/packages/nuxt-ripple/components/TideAlerts.vue +++ b/packages/nuxt-ripple/components/TideAlerts.vue @@ -71,6 +71,7 @@ const filteredAlerts = computed(() => { return !dismissedIds.includes(alert.alertId) }) } catch (e) { + trackError(e) console.error( 'Something went wrong when trying to get dismissed alerts cookie' ) diff --git a/packages/nuxt-ripple/composables/use-tide-error.ts b/packages/nuxt-ripple/composables/use-tide-error.ts index 0e344fff00..a3849941b1 100644 --- a/packages/nuxt-ripple/composables/use-tide-error.ts +++ b/packages/nuxt-ripple/composables/use-tide-error.ts @@ -1,4 +1,7 @@ -export const useTideError = (statusCode: number): void => { +export const useTideError = ( + statusCode: number, + originalError?: Error +): void => { if (statusCode) { switch (statusCode) { case 404: @@ -28,6 +31,10 @@ export const useTideError = (statusCode: number): void => { break default: + if (originalError) { + trackError(originalError) + } + throw createError({ statusCode: 500, statusMessage: 'We have a glitch in our system.', diff --git a/packages/nuxt-ripple/composables/use-tide-page.ts b/packages/nuxt-ripple/composables/use-tide-page.ts index 67e7be6899..36828ce756 100644 --- a/packages/nuxt-ripple/composables/use-tide-page.ts +++ b/packages/nuxt-ripple/composables/use-tide-page.ts @@ -151,7 +151,7 @@ export const useTidePage = async ( } if (error && error.value?.statusCode) { - useTideError(error.value?.statusCode) + useTideError(error.value?.statusCode, error.value) } debugLogger('Page data fetched', { diff --git a/packages/nuxt-ripple/composables/use-tide-site.ts b/packages/nuxt-ripple/composables/use-tide-site.ts index a36a58ffb3..bc581a9e6c 100644 --- a/packages/nuxt-ripple/composables/use-tide-site.ts +++ b/packages/nuxt-ripple/composables/use-tide-site.ts @@ -34,7 +34,7 @@ export const useTideSite = async (id?: number): Promise => { if (error && error.value?.statusCode) { console.log(error) console.log('API error fetching site data') - useTideError(500) + useTideError(500, error.value) } // Section.io cache tags must be set on the response header to invalidate the cache after a change in drupal diff --git a/packages/ripple-tide-publication/composables/use-tide-publication-children.ts b/packages/ripple-tide-publication/composables/use-tide-publication-children.ts index 3af9f2d8bc..a51bde977b 100644 --- a/packages/ripple-tide-publication/composables/use-tide-publication-children.ts +++ b/packages/ripple-tide-publication/composables/use-tide-publication-children.ts @@ -23,7 +23,7 @@ export const useTidePublicationChildren = async ( } }) if (error && error.value?.statusCode) { - useTideError(error.value?.statusCode) + useTideError(error.value?.statusCode, error.value) } return data.value } diff --git a/packages/ripple-tide-publication/composables/use-tide-publication-menu.ts b/packages/ripple-tide-publication/composables/use-tide-publication-menu.ts index efb4af5758..c1ee50964e 100644 --- a/packages/ripple-tide-publication/composables/use-tide-publication-menu.ts +++ b/packages/ripple-tide-publication/composables/use-tide-publication-menu.ts @@ -15,7 +15,7 @@ export const useTidePublicationMenu = async ( } }) if (error && error.value?.statusCode) { - useTideError(error.value?.statusCode) + useTideError(error.value?.statusCode, error.value) } return data.value } diff --git a/packages/ripple-tide-search/components/global/TideSearchAddressLookup.vue b/packages/ripple-tide-search/components/global/TideSearchAddressLookup.vue index 897b2b65c4..b912331925 100644 --- a/packages/ripple-tide-search/components/global/TideSearchAddressLookup.vue +++ b/packages/ripple-tide-search/components/global/TideSearchAddressLookup.vue @@ -155,6 +155,7 @@ const fetchSuggestions = async (query: string) => { props.mapResultsFnName ) } catch (e) { + trackError(e) console.error(e) } } diff --git a/packages/ripple-tide-search/composables/useTideSearch.ts b/packages/ripple-tide-search/composables/useTideSearch.ts index 6f2bac35d8..f19383fd78 100644 --- a/packages/ripple-tide-search/composables/useTideSearch.ts +++ b/packages/ripple-tide-search/composables/useTideSearch.ts @@ -633,6 +633,7 @@ export default ({ nextTick(onMapResultsHook.value) } } catch (error) { + trackError(error) console.error(error) searchError.value = error } finally { diff --git a/packages/ripple-tide-webform/composables/use-webform-schema.ts b/packages/ripple-tide-webform/composables/use-webform-schema.ts index 5422d08dbe..2713ae25ce 100644 --- a/packages/ripple-tide-webform/composables/use-webform-schema.ts +++ b/packages/ripple-tide-webform/composables/use-webform-schema.ts @@ -20,7 +20,7 @@ export const useWebformSchema = async ( } }) if (error && error.value?.statusCode) { - useTideError(error.value?.statusCode) + useTideError(error.value?.statusCode, error.value) } return data.value } diff --git a/packages/ripple-tide-webform/composables/use-webform-submit.ts b/packages/ripple-tide-webform/composables/use-webform-submit.ts index 2c86c62475..f46205543f 100644 --- a/packages/ripple-tide-webform/composables/use-webform-submit.ts +++ b/packages/ripple-tide-webform/composables/use-webform-submit.ts @@ -110,6 +110,7 @@ export function useWebformSubmit( window ) } catch (e) { + trackError(e) console.error(e) submissionState.value = { @@ -144,6 +145,7 @@ export function useWebformSubmit( } } } catch (error) { + trackError(error) console.error(error) submissionState.value = {