diff --git a/package.json b/package.json index 77e0d77a3..a6c291d9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azion-platform-kit", - "version": "1.9.0", + "version": "1.9.1", "private": true, "type": "module", "repository": { diff --git a/src/plugins/adapters/AnalyticsTrackerAdapter.js b/src/plugins/adapters/AnalyticsTrackerAdapter.js index d44309203..562039dff 100644 --- a/src/plugins/adapters/AnalyticsTrackerAdapter.js +++ b/src/plugins/adapters/AnalyticsTrackerAdapter.js @@ -196,12 +196,21 @@ export class AnalyticsTrackerAdapter { } /** + * @param {Object} payload + * @param {'api'|'field'} payload.errorType + * @param {string} payload.fieldName + * @param {string} payload.errorMessage + * * @returns {AnalyticsTrackerAdapter} */ - userFailedSignUp() { + userFailedSignUp(payload) { this.#events.push({ eventName: 'User Failed to Sign Up', - props: {} + props: { + errorType: payload.errorType, + fieldName: payload.fieldName, + errorMessage: payload.errorMessage + } }) return this } @@ -235,12 +244,26 @@ export class AnalyticsTrackerAdapter { } /** + * @param {Object} payload + * @param {string} payload.templateName + * @param {string} payload.solutionId + * @param {string} payload.version + * @param {string} payload.versionId + * @param {string} payload.isv + * @param {string} payload.isvId * @returns {AnalyticsTrackerAdapter} */ - clickMoreDetailsOnTemplate() { + clickMoreDetailsOnTemplate(payload) { this.#events.push({ eventName: 'Clicked to View More Details on Template', - props: {} + props: { + templateName: payload.templateName, + solutionId: payload.solutionId, + version: payload.version, + versionId: payload.versionId, + isv: payload.isv, + isvId: payload.isvId + } }) return this } diff --git a/src/services/signup-services/signup-service.js b/src/services/signup-services/signup-service.js index 81eaf0ec0..21df46f8b 100644 --- a/src/services/signup-services/signup-service.js +++ b/src/services/signup-services/signup-service.js @@ -25,7 +25,8 @@ const parseHttpResponse = (httpResponse) => { return null case 400: const apiError = Object.values(httpResponse.body)[0][0] - throw new Error(apiError).message + const fieldName = Object.keys(httpResponse.body)[0] + throw new Error(JSON.stringify({ message: apiError, fieldName })).message case 404: throw new Errors.NotFoundError().message case 500: diff --git a/src/templates/signup-block/form-signup-block.vue b/src/templates/signup-block/form-signup-block.vue index f92803243..2edff213a 100644 --- a/src/templates/signup-block/form-signup-block.vue +++ b/src/templates/signup-block/form-signup-block.vue @@ -184,9 +184,16 @@ router.push({ name: 'activation', query: { email: encodeEmail(values.email) } }) } catch (err) { - tracker.userFailedSignUp().track() + const { message, fieldName } = JSON.parse(err) + tracker + .userFailedSignUp({ + errorType: 'api', + fieldName: fieldName, + errorMessage: message + }) + .track() loading.value = false - toast.add({ life: 5000, severity: 'error', detail: err, summary: 'Error' }) + toast.add({ life: 5000, severity: 'error', detail: message, summary: 'Error' }) } } diff --git a/src/tests/plugins/adapters/AnalyticsTrackerAdapter.test.js b/src/tests/plugins/adapters/AnalyticsTrackerAdapter.test.js index 691c7223a..5517c8890 100644 --- a/src/tests/plugins/adapters/AnalyticsTrackerAdapter.test.js +++ b/src/tests/plugins/adapters/AnalyticsTrackerAdapter.test.js @@ -234,10 +234,15 @@ describe('AnalyticsTrackerAdapter', () => { it('should track the user failed to sign-up event with the correct parameters', () => { const { sut, analyticsClientSpy } = makeSut() + const propsMock = { + errorType: 'api', + fieldName: 'email', + errorMessage: 'Invalid email' + } - sut.userFailedSignUp().track() + sut.userFailedSignUp({ ...propsMock }).track() - expect(analyticsClientSpy.track).toHaveBeenCalledWith('User Failed to Sign Up', {}) + expect(analyticsClientSpy.track).toHaveBeenCalledWith('User Failed to Sign Up', propsMock) }) it('should track the failed additional data submit event with the correct parameters', () => { @@ -269,13 +274,34 @@ describe('AnalyticsTrackerAdapter', () => { it('should use the View More Details on Template event with correct parameters', () => { const { sut, analyticsClientSpy } = makeSut() - sut.clickMoreDetailsOnTemplate({}) + const templateNameMock = 'string' + const solutionIdMock = 'solutionId' + const versionMock = 'version' + const versionIdMock = 'versionID' + const isvMock = 'isv' + const isvIdMock = 'isvId' + + sut.clickMoreDetailsOnTemplate({ + templateName: templateNameMock, + solutionId: solutionIdMock, + version: versionMock, + versionId: versionIdMock, + isv: isvMock, + isvId: isvIdMock + }) sut.track() expect(analyticsClientSpy.track).toHaveBeenCalledWith( 'Clicked to View More Details on Template', - {} + { + templateName: templateNameMock, + solutionId: solutionIdMock, + version: versionMock, + versionId: versionIdMock, + isv: isvMock, + isvId: isvIdMock + } ) }) @@ -306,4 +332,30 @@ describe('AnalyticsTrackerAdapter', () => { expect(analyticsClientSpy.track).toHaveBeenCalledWith('Failed to Deploy', {}) }) + + it('should be able to track click to create event with correct params', () => { + const { sut, analyticsClientSpy } = makeSut() + const productNameMock = 'Origin' + + sut.clickToCreate({ + productName: productNameMock + }) + + sut.track() + + expect(analyticsClientSpy.track).toHaveBeenCalledWith('Clicked to Create Origin', {}) + }) + + it('should be able to track created event with correct params', () => { + const { sut, analyticsClientSpy } = makeSut() + const productNameMock = 'Origin' + + sut.productCreated({ + productName: productNameMock + }) + + sut.track() + + expect(analyticsClientSpy.track).toHaveBeenCalledWith('Created Origin', {}) + }) }) diff --git a/src/views/CreateNew/CreateView.vue b/src/views/CreateNew/CreateView.vue index f0e1ef2de..1c201a4a4 100644 --- a/src/views/CreateNew/CreateView.vue +++ b/src/views/CreateNew/CreateView.vue @@ -296,7 +296,15 @@ } const openDetails = () => { - tracker.clickMoreDetailsOnTemplate().track() + tracker + .clickMoreDetailsOnTemplate({ + templateName: solution.value.name, + solutionId: solution.value.id, + version: solution.value.version, + versionId: solution.value.latestVersionInstallTemplate, + isv: solution.value.vendor.name + }) + .track() showDetails.value = true } diff --git a/src/views/EdgeApplicationsOrigins/Drawer/index.vue b/src/views/EdgeApplicationsOrigins/Drawer/index.vue index 665407979..afe54e13e 100644 --- a/src/views/EdgeApplicationsOrigins/Drawer/index.vue +++ b/src/views/EdgeApplicationsOrigins/Drawer/index.vue @@ -4,8 +4,10 @@ import EditDrawerBlock from '@templates/edit-drawer-block' import { refDebounced } from '@vueuse/core' import { useToast } from 'primevue/usetoast' - import { ref } from 'vue' + import { ref, inject } from 'vue' import * as yup from 'yup' + /**@type {import('@/plugins/adapters/AnalyticsTrackerAdapter').AnalyticsTrackerAdapter} */ + const tracker = inject('tracker') defineOptions({ name: 'drawer-origin' }) const emit = defineEmits(['onSuccess']) @@ -160,6 +162,14 @@ showEditOriginDrawer.value = false } + const handleTrackCreation = () => { + tracker + .productCreated({ + productName: 'Origin' + }) + .track() + } + const copyToKey = async (originKey) => { props.clipboardWrite(originKey) @@ -171,6 +181,7 @@ } const handleCreateOrigin = (feedback) => { + handleTrackCreation() createFormDrawer.value.scrollOriginKey() originKey.value = feedback.originKey emit('onSuccess') diff --git a/src/views/EdgeApplicationsOrigins/ListView.vue b/src/views/EdgeApplicationsOrigins/ListView.vue index 56fc90e50..64108a2a7 100644 --- a/src/views/EdgeApplicationsOrigins/ListView.vue +++ b/src/views/EdgeApplicationsOrigins/ListView.vue @@ -4,7 +4,9 @@ import ListTableBlock from '@/templates/list-table-block/no-header' import DrawerOrigin from '@/views/EdgeApplicationsOrigins/Drawer' import PrimeButton from 'primevue/button' - import { computed, ref } from 'vue' + import { computed, ref, inject } from 'vue' + /**@type {import('@/plugins/adapters/AnalyticsTrackerAdapter').AnalyticsTrackerAdapter} */ + const tracker = inject('tracker') defineOptions({ name: 'list-edge-applications-origins-tab' }) const props = defineProps({ @@ -102,6 +104,11 @@ } const openCreateOriginDrawer = () => { + tracker + .clickToCreate({ + productName: 'Origin' + }) + .track() drawerOriginsRef.value.openDrawerCreate() } diff --git a/src/views/RealTimeEventsDataStreaming/Drawer/index.vue b/src/views/RealTimeEventsDataStreaming/Drawer/index.vue index 409a479cd..394524f56 100644 --- a/src/views/RealTimeEventsDataStreaming/Drawer/index.vue +++ b/src/views/RealTimeEventsDataStreaming/Drawer/index.vue @@ -60,7 +60,7 @@ :tags="tags" >