From db09cee02b65fbd8cd920c95936da15e6b7bb1f3 Mon Sep 17 00:00:00 2001 From: eren-zeplin Date: Tue, 7 Mar 2023 16:00:48 +0300 Subject: [PATCH] [PD-627] fix: add utm params to webapp and app uri (#184) --- package-lock.json | 65 +++++++++++++++++++ .../projectNoteCommentHandler.test.ts.snap | 8 +-- .../projectNoteCommentHandler.ts | 6 +- .../projectNoteHandler.test.ts.snap | 8 +-- .../projectNoteHandler/projectNoteHandler.ts | 6 +- .../projectScreenHandler.test.ts.snap | 8 +-- .../projectScreenHandler.ts | 10 +-- .../notificationHandlers/zeplinURL.ts | 25 +++++-- 8 files changed, 112 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index a1d2dd88..22dd89e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1397,6 +1397,21 @@ "react-dom": ">=16.8.0 <17.0.0" } }, + "node_modules/@fluentui/react-northstar/node_modules/@fluentui/react-compose/node_modules/react-dom": { + "version": "16.14.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz", + "integrity": "sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2", + "scheduler": "^0.19.1" + }, + "peerDependencies": { + "react": "^16.14.0" + } + }, "node_modules/@fluentui/react-northstar/node_modules/@fluentui/react-context-selector": { "version": "0.50.0", "resolved": "https://registry.npmjs.org/@fluentui/react-context-selector/-/react-context-selector-0.50.0.tgz", @@ -1481,6 +1496,16 @@ "react-dom": ">=16.6.0" } }, + "node_modules/@fluentui/react-northstar/node_modules/scheduler": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", + "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, "node_modules/@fluentui/react-proptypes": { "version": "0.50.0", "resolved": "https://registry.npmjs.org/@fluentui/react-proptypes/-/react-proptypes-0.50.0.tgz", @@ -3643,6 +3668,15 @@ "csstype": "^2.2.0" } }, + "node_modules/@types/react-dom": { + "version": "16.9.18", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.18.tgz", + "integrity": "sha512-lmNARUX3+rNF/nmoAFqasG0jAA7q6MeGZK/fdeLwY3kAA4NPgHHrG5bNQe2B5xmD4B+x6Z6h0rEJQ7MEEgQxsw==", + "peer": true, + "dependencies": { + "@types/react": "^16" + } + }, "node_modules/@types/redis": { "version": "2.8.25", "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.25.tgz", @@ -17202,6 +17236,18 @@ "prop-types": "^15.7.2", "tslib": "^1.10.0" } + }, + "react-dom": { + "version": "16.14.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz", + "integrity": "sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==", + "peer": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2", + "scheduler": "^0.19.1" + } } } }, @@ -17270,6 +17316,16 @@ "loose-envify": "^1.4.0", "prop-types": "^15.6.2" } + }, + "scheduler": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", + "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", + "peer": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } } } }, @@ -19003,6 +19059,15 @@ "csstype": "^2.2.0" } }, + "@types/react-dom": { + "version": "16.9.18", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.18.tgz", + "integrity": "sha512-lmNARUX3+rNF/nmoAFqasG0jAA7q6MeGZK/fdeLwY3kAA4NPgHHrG5bNQe2B5xmD4B+x6Z6h0rEJQ7MEEgQxsw==", + "peer": true, + "requires": { + "@types/react": "^16" + } + }, "@types/redis": { "version": "2.8.25", "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.25.tgz", diff --git a/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/__snapshots__/projectNoteCommentHandler.test.ts.snap b/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/__snapshots__/projectNoteCommentHandler.test.ts.snap index 1bc8113c..750c214c 100644 --- a/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/__snapshots__/projectNoteCommentHandler.test.ts.snap +++ b/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/__snapshots__/projectNoteCommentHandler.test.ts.snap @@ -18,7 +18,7 @@ exports[`projectNoteHandler getTeamsMessage should match snapshot 1`] = ` "targets": [ { "os": "default", - "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fdot%3Fpid%3DprojectId%26sid%3DscreenId%26did%3DnoteId%26cmids%3DcommentId%26ref%3Dmicrosoft-teams" + "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fdot%3Fpid%3DprojectId%26sid%3DscreenId%26did%3DnoteId%26cmids%3DcommentId%26ref%3Dmicrosoft-teams%26utm_source%3Dzeplin%26utm_medium%3Dteams_integration%26utm_campaign%3Dcomment_reply" } ] }, @@ -28,7 +28,7 @@ exports[`projectNoteHandler getTeamsMessage should match snapshot 1`] = ` "targets": [ { "os": "default", - "uri": "https://app.zeplin.io/project/projectId/screen/screenId?did=noteId&cmid=commentId&ref=microsoft-teams" + "uri": "https://app.zeplin.io/project/projectId/screen/screenId?did=noteId&cmid=commentId&ref=microsoft-teams&utm_source=zeplin&utm_medium=teams_integration&utm_campaign=comment_reply" } ] } @@ -54,7 +54,7 @@ exports[`projectNoteHandler getTeamsMessage should match snapshot with screen va "targets": [ { "os": "default", - "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fdot%3Fpid%3DprojectId%26sid%3DscreenId%26did%3DnoteId%26cmids%3DcommentId%26ref%3Dmicrosoft-teams" + "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fdot%3Fpid%3DprojectId%26sid%3DscreenId%26did%3DnoteId%26cmids%3DcommentId%26ref%3Dmicrosoft-teams%26utm_source%3Dzeplin%26utm_medium%3Dteams_integration%26utm_campaign%3Dcomment_reply" } ] }, @@ -64,7 +64,7 @@ exports[`projectNoteHandler getTeamsMessage should match snapshot with screen va "targets": [ { "os": "default", - "uri": "https://app.zeplin.io/project/projectId/screen/screenId?did=noteId&cmid=commentId&ref=microsoft-teams" + "uri": "https://app.zeplin.io/project/projectId/screen/screenId?did=noteId&cmid=commentId&ref=microsoft-teams&utm_source=zeplin&utm_medium=teams_integration&utm_campaign=comment_reply" } ] } diff --git a/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/projectNoteCommentHandler.ts b/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/projectNoteCommentHandler.ts index b5295829..f6ba708c 100644 --- a/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/projectNoteCommentHandler.ts +++ b/src/server/services/webhookEventService/notificationHandlers/projectNoteCommentHandler/projectNoteCommentHandler.ts @@ -70,8 +70,9 @@ class ProjectNoteCommentHandler extends NotificationHandler { const searchParams = { did: noteId }; + const utmParams = { utmCampaign: "comment_reply" }; - return getWebAppURL(pathname, searchParams); + return getWebAppURL(pathname, searchParams, utmParams); } private getZeplinAppURI(event: ProjectNoteCreatedEvent): string { @@ -85,8 +86,9 @@ class ProjectNoteHandler extends NotificationHandler { sid: screenId, did: noteId }; + const utmParams = { utmCampaign: "comment_reply" }; - return getRedirectURLForZeplinApp("dot", searchParams); + return getRedirectURLForZeplinApp("dot", searchParams, utmParams); } shouldHandleEvent(event: WebhookEvent): event is ProjectNoteCreatedEvent { diff --git a/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/__snapshots__/projectScreenHandler.test.ts.snap b/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/__snapshots__/projectScreenHandler.test.ts.snap index cb22e987..9236e035 100644 --- a/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/__snapshots__/projectScreenHandler.test.ts.snap +++ b/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/__snapshots__/projectScreenHandler.test.ts.snap @@ -26,7 +26,7 @@ exports[`projectScreenHandler getTeamsMessage should match snapshot when there a "targets": [ { "os": "default", - "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fproject%3Fpid%3DprojectId%26sids%3DscreenId%2CscreenId2%26ref%3Dmicrosoft-teams" + "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fproject%3Fpid%3DprojectId%26sids%3DscreenId%2CscreenId2%26ref%3Dmicrosoft-teams%26utm_source%3Dzeplin%26utm_medium%3Dteams_integration%26utm_campaign%3Dcomment_reply" } ] }, @@ -36,7 +36,7 @@ exports[`projectScreenHandler getTeamsMessage should match snapshot when there a "targets": [ { "os": "default", - "uri": "https://app.zeplin.io/project/projectId?sid=screenId&sid=screenId2&ref=microsoft-teams" + "uri": "https://app.zeplin.io/project/projectId?sid=screenId&sid=screenId2&ref=microsoft-teams&utm_source=zeplin&utm_medium=teams_integration&utm_campaign=comment_reply" } ] } @@ -66,7 +66,7 @@ exports[`projectScreenHandler getTeamsMessage should match snapshot when there i "targets": [ { "os": "default", - "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fscreen%3Fpid%3DprojectId%26sid%3DscreenId%26ref%3Dmicrosoft-teams" + "uri": "https://msteams-app.zeplin.io/zeplin/app-redirect?uri=zpl%3A%2F%2Fscreen%3Fpid%3DprojectId%26sid%3DscreenId%26ref%3Dmicrosoft-teams%26utm_source%3Dzeplin%26utm_medium%3Dteams_integration%26utm_campaign%3Dcomment_reply" } ] }, @@ -76,7 +76,7 @@ exports[`projectScreenHandler getTeamsMessage should match snapshot when there i "targets": [ { "os": "default", - "uri": "https://app.zeplin.io/project/projectId/screen/screenId?ref=microsoft-teams" + "uri": "https://app.zeplin.io/project/projectId/screen/screenId?ref=microsoft-teams&utm_source=zeplin&utm_medium=teams_integration&utm_campaign=comment_reply" } ] } diff --git a/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/projectScreenHandler.ts b/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/projectScreenHandler.ts index 0b40a351..4dae3c46 100644 --- a/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/projectScreenHandler.ts +++ b/src/server/services/webhookEventService/notificationHandlers/projectScreenHandler/projectScreenHandler.ts @@ -63,11 +63,12 @@ class ProjectScreenHandler extends NotificationHandler id) }; } + const utmParams = { utmCampaign: "comment_reply" }; - return getWebAppURL(pathname, searchParams); + return getWebAppURL(pathname, searchParams, utmParams); } - private getZeplinAppURIURI(events: ProjectScreenCreatedEvent[]): string { + private getZeplinAppURI(events: ProjectScreenCreatedEvent[]): string { const [{ context: { project: { @@ -92,8 +93,9 @@ class ProjectScreenHandler extends NotificationHandler id) }; } + const utmParams = { utmCampaign: "comment_reply" }; - return getRedirectURLForZeplinApp(resource, searchParams); + return getRedirectURLForZeplinApp(resource, searchParams, utmParams); } getGroupingKey({ @@ -120,7 +122,7 @@ class ProjectScreenHandler extends NotificationHandler