Skip to content
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
57 changes: 9 additions & 48 deletions src/extensions/default/HealthData/HealthDataNotification.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,26 @@
/*
* Copyright (c) 2021 - present core.ai . All rights reserved.
* Original work Copyright (c) 2015 - 2021 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (c) 2021 - present core.ai. All rights reserved.

/*global Phoenix*/
/*global*/

define(function (require, exports, module) {

var PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
ExtensionInterface = brackets.getModule("utils/ExtensionInterface"),
const PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
HealthDataPreview = require("HealthDataPreview"),
HealthDataPopup = require("HealthDataPopup");

const NEW_PROJECT_EXTENSION_INTERFACE = "Extn.Phoenix.newProject",
// Since we don't have any user accounts or trackable ID to uniquely identify a user on first launch,
// we should be ok GDPR wise to delay showing the health data popup. But it was found later to be annoying
// and a workflow distraction. So we show the health data popup almost immediately so that the user can
// close all the popups in on go.
POPUP_FIRST_LAUNCH_SHOW_DELAY = 5000;
// Since we don't have any user accounts or trackable ID to uniquely identify a user on first launch,
// we should be ok GDPR wise to delay showing the health data popup. But it was found later to be annoying
// and a workflow distraction. So we show the health data popup almost immediately so that the user can
// close all the popups in on go.

let newProjectExtension;
ExtensionInterface.waitAndGetExtensionInterface(NEW_PROJECT_EXTENSION_INTERFACE)
.then(interfaceObj => {
newProjectExtension = interfaceObj;
interfaceObj.on(interfaceObj.EVENT_NEW_PROJECT_DIALOGUE_CLOSED, ()=>{
setTimeout(_showFirstLaunchPopup, POPUP_FIRST_LAUNCH_SHOW_DELAY);
});
});
_showFirstLaunchPopup();

function handleHealthDataStatistics() {
HealthDataPreview.previewHealthData();
}

let popupShownInThisSession = false;
function _showFirstLaunchPopup() {
// call this only after newProjectExtn interface is available
// Check whether the notification dialog should be shown. It will be shown only one time.
if(popupShownInThisSession){
return;
}
popupShownInThisSession = true;
newProjectExtension.off(newProjectExtension.EVENT_NEW_PROJECT_DIALOGUE_CLOSED, _showFirstLaunchPopup);
if(!window.testEnvironment){
const alreadyShown = PreferencesManager.getViewState("healthDataNotificationShown");
const prefs = PreferencesManager.getExtensionPrefs("healthData");
Expand Down
9 changes: 4 additions & 5 deletions src/services/promotions.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define(function (require, exports, module) {
const EVENT_PRO_UPGRADE_ON_INSTALL = "pro_upgrade_on_install";
const PROMO_LOCAL_FILE = path.join(Phoenix.app.getApplicationSupportDirectory(),
Phoenix.isTestWindow ? "entitlements_promo_test.json" : "entitlements_promo.json");
const TRIAL_POLL_MS = 10 * 1000; // 10 seconds after start, we assign a free trial if possible
const TRIAL_POLL_MS = 1000; // We assign a free trial if possible as soon as user comes in for best UX.
const FIRST_INSTALL_TRIAL_DAYS = 30;
const SUBSEQUENT_TRIAL_DAYS = 7;
const MS_PER_DAY = 24 * 60 * 60 * 1000;
Expand Down Expand Up @@ -371,10 +371,9 @@ define(function (require, exports, module) {
}

function _isAnyDialogsVisible() {
const $modal = $(`.modal.instance`);
const $notifications = $(`.notification-ui-tooltip`);
return ($modal.length > 0 && $modal.is(':visible')) ||
($notifications.length > 0 && $notifications.is(':visible'));
const dialogsVisible = $(`.modal.instance`).is(':visible');
const notificationsVisible = $(`.notification-ui-tooltip`).is(':visible');
return dialogsVisible || notificationsVisible;
}

/**
Expand Down
Loading