1- /*
2- * GNU AGPL-3.0 License
3- *
4- * Copyright (c) 2021 - present core.ai . All rights reserved.
5- *
6- * This program is free software: you can redistribute it and/or modify it
7- * under the terms of the GNU Affero General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful, but WITHOUT
12- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
14- * for more details.
15- *
16- * You should have received a copy of the GNU Affero General Public License
17- * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
18- *
19- */
1+ // SPDX-License-Identifier: AGPL-3.0-only
2+ // Copyright (c) 2021 - present core.ai. All rights reserved.
3+
4+ /*global logger*/
205
216define ( function ( require , exports , module ) {
7+ const KernalModeTrust = window . KernalModeTrust ;
8+ if ( ! KernalModeTrust ) {
9+ // integrated extensions will have access to kernal mode, but not external extensions
10+ throw new Error ( "Guided Tour should have access to KernalModeTrust. Cannot boot without trust ring" ) ;
11+ }
12+
2213 const NotificationUI = require ( "widgets/NotificationUI" ) ,
2314 Commands = require ( "command/Commands" ) ,
2415 Strings = require ( "strings" ) ,
@@ -244,6 +235,23 @@ define(function (require, exports, module) {
244235 PhStore . setItem ( GUIDED_TOUR_LOCAL_STORAGE_KEY , JSON . stringify ( userAlreadyDidAction ) ) ;
245236 }
246237
238+ async function _resolvePowerUserSurveyURL ( surveyJson ) {
239+ try {
240+ const isLoggedIn = KernalModeTrust . EntitlementsManager . isLoggedIn ( ) ;
241+ if ( ! isLoggedIn ) {
242+ return surveyJson . powerUser ;
243+ }
244+ const paidSubscriber = await KernalModeTrust . EntitlementsManager . isPaidSubscriber ( ) ;
245+ if ( paidSubscriber && surveyJson . powerUserPaid ) {
246+ return surveyJson . powerUserPaid ;
247+ }
248+ return surveyJson . powerUserLoggedIn || surveyJson . powerUser ;
249+ } catch ( e ) {
250+ logger . reportError ( e , "Error resolving power user survey URL" ) ;
251+ }
252+ return surveyJson . powerUser ;
253+ }
254+
247255 async function _showSurveys ( ) {
248256 try {
249257 if ( ! navigator . onLine ) {
@@ -258,6 +266,8 @@ define(function (require, exports, module) {
258266 newUserShowDelayMS : surveyJSON . browser . newUserShowDelayMS || surveyJSON . newUserShowDelayMS ,
259267 newUserUseDialog : surveyJSON . browser . newUserUseDialog || surveyJSON . newUserUseDialog ,
260268 powerUser : surveyJSON . browser . powerUser || surveyJSON . powerUser ,
269+ powerUserPaid : surveyJSON . browser . powerUserPaid || surveyJSON . powerUserPaid ,
270+ powerUserLoggedIn : surveyJSON . browser . powerUserLoggedIn || surveyJSON . powerUserLoggedIn ,
261271 powerUserTitle : surveyJSON . browser . powerUserTitle || surveyJSON . powerUserTitle ,
262272 powerUserShowIntervalDays : surveyJSON . browser . powerUserShowIntervalDays
263273 || surveyJSON . powerUserShowIntervalDays ,
@@ -266,7 +276,8 @@ define(function (require, exports, module) {
266276 }
267277 surveyJSON . newUser && _showFirstUseSurvey ( surveyJSON . newUser , surveyJSON . newUserShowDelayMS ,
268278 surveyJSON . newUserTitle , surveyJSON . newUserUseDialog ) ;
269- surveyJSON . powerUser && _showRepeatUserSurvey ( surveyJSON . powerUser , surveyJSON . powerUserShowIntervalDays ,
279+ const powerUserSurveyURL = await _resolvePowerUserSurveyURL ( surveyJSON ) ;
280+ powerUserSurveyURL && _showRepeatUserSurvey ( powerUserSurveyURL , surveyJSON . powerUserShowIntervalDays ,
270281 surveyJSON . powerUserTitle , surveyJSON . powerUserUseDialog ) ;
271282 } catch ( e ) {
272283 console . error ( "Error fetching survey link" , surveyLinksURL , e ) ;
0 commit comments