Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-54364: backport playbooks 1.36 -> mattermost 7.8 ESR #1883

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests-e2e/cypress/integration/channels/rhs_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,31 @@ describe('channels > rhs', () => {
cy.get('#rhsContainer').should('not.exist');
});
});

describe('telemetry', () => {
it('does not run with bad run id', () => {
// # Watch for bad request
cy.intercept('**/d0nt').as('telemetryRequest');

// # Run the playbook before loading the application
const now = Date.now();
const playbookRunName = 'Playbook Run (' + now + ')';
const playbookRunChannelName = 'playbook-run-' + now;
cy.apiRunPlaybook({
teamId: testTeam.id,
playbookId: testPlaybook.id,
playbookRunName,
ownerUserId: testUser.id,
});

// # Navigate to the application and a channel with a playbook run
cy.visit(`/${testTeam.name}/channels/${playbookRunChannelName}?telem_action=mock_action_name&telem_run_id=../../d0nt&forceRHSOpen`);

// * Ensure telemetry doesn't run
cy.wait(3000);
cy.get('@telemetryRequest.all').then((interceptions) => {
expect(interceptions).to.have.length(0);
});
});
});
});
6 changes: 4 additions & 2 deletions webapp/src/rhs_opener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ export function makeRHSOpener(store: Store<GlobalState>): () => Promise<void> {
if (searchParams.has('telem_action') && searchParams.has('telem_run_id')) {
// Record and remove telemetry
const action = searchParams.get('telem_action') || '';
const runId = searchParams.get('telem_run_id') || '';
telemetryEventForPlaybookRun(runId, action);
const runId = searchParams.get('telem_run_id')?.match(/^\w+$/)?.[0] || '';
if (action && runId) {
telemetryEventForPlaybookRun(runId, action);
}
searchParams.delete('telem_action');
searchParams.delete('telem_run_id');
browserHistory.replace({pathname: url.pathname, search: searchParams.toString()});
Expand Down
Loading