Skip to content

Commit

Permalink
Don't track any plugin events when app is loaded in clean mode, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwod committed May 6, 2022
1 parent d28a71b commit 6aad597
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions new-client/src/plugins/BaseWindowPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class BaseWindowPlugin extends React.PureComponent {

// Should Window be visible at start?
const visibleAtStart =
(isMobile
? props.options.visibleAtStartMobile
: props.options.visibleAtStart) || false;
(this.props.app.config.mapConfig.map.clean === false && // Never show in clean mode
(isMobile
? props.options.visibleAtStartMobile
: props.options.visibleAtStart)) ||
false;

// If plugin is shown at start, we want to register it as shown in the Analytis module too.
// If plugin is shown at start, we want to register it as shown in the Analytics module too.
// Normally, the event would be sent when user clicks on the button that activates the plugin,
// but in this case there won't be any click as the window will be visible at start.
if (visibleAtStart) {
Expand Down
9 changes: 8 additions & 1 deletion new-client/src/plugins/DialogWindowPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ class DialogWindowPlugin extends React.PureComponent {
componentDidMount() {
let dialogOpen = this.opts.visibleAtStart;
const localStorageKey = `plugin.${this.uniqueIdentifier}.alreadyShown`;
const clean = this.props.app.config.mapConfig.map.clean;

// TODO: Use LocalStorageHelper so we have a per-map-setting here…
if (this.opts.visibleAtStart === true) {
// No need to continue if we're in clean mode.
if (clean === false && this.opts.visibleAtStart === true) {
// If clean mode is false and visibleAtStart is true, however,
// check if showOnlyOnce is true.
if (
this.opts.showOnlyOnce === true &&
parseInt(window.localStorage.getItem(localStorageKey)) === 1
) {
// If yes - don't show the dialog on load anymore.
dialogOpen = false;
} else {
// If not - check if showOnlyOnce is true and…
if (this.opts.showOnlyOnce === true) {
// if yes, store the setting in local storage.
window.localStorage.setItem(localStorageKey, 1);
}
dialogOpen = true;
Expand Down

0 comments on commit 6aad597

Please sign in to comment.