Skip to content

Commit

Permalink
[semver:patch] Remove Strigo related params from the returned recordi…
Browse files Browse the repository at this point in the history
…ng url in recorded assessment obj.
  • Loading branch information
hidday committed Aug 15, 2022
1 parent cf48883 commit 384b4fa
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
32 changes: 21 additions & 11 deletions dist/development/strigo.sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -11854,6 +11854,10 @@ ${JSON.stringify(parsedContext)}` : "");
rootDocument.addEventListener("mouseout", this.removeClickListenerFromHoveredElement);
}

// src/modules/assessment-recorder/assessment-recorder.types.ts
var ASSESSMENT_RECORDER_ID_PARAM = "strigoAssessmentUuid";
var ASSESSMENT_RECORDER_PARAM = "strigoAssessmentRecorder";

// src/modules/url/url.ts
var STRIGO_CHILD_IFRAME_PARAM = "strigoChildIframe";
function paramsToObject(entries) {
Expand Down Expand Up @@ -11908,7 +11912,7 @@ ${JSON.stringify(parsedContext)}` : "");
}
function generateCssURL(version) {
if (window.Strigo.isDevelopment()) {
return `${SDK_LOCAL_URL}/styles/strigo.css`;
return `${"http://local.strigo.io:7002"}/styles/strigo.css`;
}
if (version) {
return `${CDN_BASE_PATH}@${version}/dist/production/styles/strigo.min.css`;
Expand All @@ -11917,7 +11921,7 @@ ${JSON.stringify(parsedContext)}` : "");
}
function generateWidgetCssURL(version) {
if (window.Strigo.isDevelopment()) {
return `${SDK_LOCAL_URL}/styles/strigo-widget.css`;
return `${"http://local.strigo.io:7002"}/styles/strigo-widget.css`;
}
if (version) {
return `${CDN_BASE_PATH}@${version}/dist/production/styles/strigo-widget.min.css`;
Expand All @@ -11926,7 +11930,7 @@ ${JSON.stringify(parsedContext)}` : "");
}
function generateAcademyHatCssURL(version) {
if (window.Strigo.isDevelopment()) {
return `${SDK_LOCAL_URL}/styles/strigo-academy-hat.css`;
return `${"http://local.strigo.io:7002"}/styles/strigo-academy-hat.css`;
}
if (version) {
return `${CDN_BASE_PATH}@${version}/dist/production/styles/strigo-academy-hat.min.css`;
Expand All @@ -11935,24 +11939,29 @@ ${JSON.stringify(parsedContext)}` : "");
}
function generateRecorderCssURL(version) {
if (window.Strigo.isDevelopment()) {
return `${SDK_LOCAL_URL}/styles/strigo-assessment-recorder.css`;
return `${"http://local.strigo.io:7002"}/styles/strigo-assessment-recorder.css`;
}
if (version) {
return `${CDN_BASE_PATH}@${version}/dist/production/styles/strigo-assessment-recorder.min.css`;
}
return `${CDN_BASE_PATH}@master/dist/production/styles/strigo-assessment-recorder.min.css`;
}
function generateAssessmentRecorderURL() {
return window.Strigo.isDevelopment() ? RECORDER_LOCAL_URL : ASSESSMENT_RECORDER_URL;
return window.Strigo.isDevelopment() ? "http://local.strigo.io:7015" : ASSESSMENT_RECORDER_URL;
}
function isRecordingUrlParamExists() {
const { search } = window.location;
const urlParams = extractUrlParams(search);
return "strigoAssessmentRecorder" in urlParams;
return ASSESSMENT_RECORDER_PARAM in urlParams;
}
function getURLWithoutStrigoRecorderParams(url) {
const capturedElementUrl = new URL(url);
const searchParams = new URLSearchParams(capturedElementUrl.search);
searchParams.delete(ASSESSMENT_RECORDER_ID_PARAM);
searchParams.delete(ASSESSMENT_RECORDER_PARAM);
capturedElementUrl.search = searchParams.toString();
return capturedElementUrl.toString();
}

// src/modules/assessment-recorder/assessment-recorder.types.ts
var ASSESSMENT_RECORDER_ID_PARAM = "strigoAssessmentUuid";

// src/modules/assessment-recorder/assessment-recorder.ts
function isRecordingMode() {
Expand Down Expand Up @@ -12021,10 +12030,11 @@ ${JSON.stringify(parsedContext)}` : "");
case "submit-assessment" /* SUBMIT_ASSESSMENT */: {
const recorderWindowId = window.sessionStorage.getItem(ASSESSMENT_RECORDER_ID_PARAM);
window.sessionStorage.removeItem("isStrigoRecordingMode");
const urlToSave = getURLWithoutStrigoRecorderParams(window.location.href);
window.opener.postMessage({
assessment: {
...payload.assessment,
url: window.location.href
url: urlToSave
},
recorderWindowId
}, "*");
Expand Down Expand Up @@ -13169,7 +13179,7 @@ ${JSON.stringify(parsedContext)}` : "");
this.config = {};
}
isDevelopment() {
return false;
return true;
}
init() {
try {
Expand Down
11 changes: 9 additions & 2 deletions src/modules/assessment-recorder/assessment-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import html2canvas from 'html2canvas';
import { Logger } from '../../services/logger';
import { appendCssFile, appendIFrame, getHeadElement } from '../document/document';
import { getElementSelector } from '../element-selector/element-selector';
import { generateAssessmentRecorderURL, generateRecorderCssURL, isRecordingUrlParamExists } from '../url/url';
import {
generateAssessmentRecorderURL,
generateRecorderCssURL,
getURLWithoutStrigoRecorderParams,
isRecordingUrlParamExists,
} from '../url/url';

import {
AssessmentRecorderMessage,
Expand Down Expand Up @@ -100,11 +105,13 @@ export function addAssessmentRecorderIframe(): void {
case AssessmentRecorderMessageTypes.SUBMIT_ASSESSMENT: {
const recorderWindowId = window.sessionStorage.getItem(ASSESSMENT_RECORDER_ID_PARAM);
window.sessionStorage.removeItem('isStrigoRecordingMode');
const urlToSave = getURLWithoutStrigoRecorderParams(window.location.href);

window.opener.postMessage(
{
assessment: {
...payload.assessment,
url: window.location.href,
url: urlToSave,
},
recorderWindowId,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const ASSESSMENT_RECORDER_ID_PARAM = 'strigoAssessmentUuid';
export const ASSESSMENT_RECORDER_PARAM = 'strigoAssessmentRecorder';

export enum AssessmentActionType {
TEXT_CHANGE = 'text-change',
Expand Down
16 changes: 15 additions & 1 deletion src/modules/url/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
} from '../../strigo/consts';
import { StrigoConfig, SiteConfig } from '../config/config.types';
import { WidgetFlavors } from '../widgets/widget.types';
import {
ASSESSMENT_RECORDER_ID_PARAM,
ASSESSMENT_RECORDER_PARAM,
} from '../assessment-recorder/assessment-recorder.types';

import { InitScriptParams } from './url.types';

Expand Down Expand Up @@ -138,5 +142,15 @@ export function isRecordingUrlParamExists(): boolean {
const { search } = window.location;
const urlParams = extractUrlParams(search);

return 'strigoAssessmentRecorder' in urlParams;
return ASSESSMENT_RECORDER_PARAM in urlParams;
}

export function getURLWithoutStrigoRecorderParams(url): string {
const capturedElementUrl = new URL(url);
const searchParams = new URLSearchParams(capturedElementUrl.search);
searchParams.delete(ASSESSMENT_RECORDER_ID_PARAM);
searchParams.delete(ASSESSMENT_RECORDER_PARAM);
capturedElementUrl.search = searchParams.toString();

return capturedElementUrl.toString();
}

0 comments on commit 384b4fa

Please sign in to comment.