chore: Send telemetry option in user profile to client (#9535)
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: sbalaji1192 <balaji@appsmith.com>
(cherry picked from commit 77caf4c536)
This commit is contained in:
parent
3f36f6e120
commit
a6cd3686e6
15
app/client/cypress/fixtures/user.json
Normal file
15
app/client/cypress/fixtures/user.json
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"accountNonExpired": true,
|
||||||
|
"accountNonLocked": true,
|
||||||
|
"credentialsNonExpired": true,
|
||||||
|
"email": "test@appsmith.com",
|
||||||
|
"emptyInstance": false,
|
||||||
|
"enableTelemetry": false,
|
||||||
|
"isAnonymous": false,
|
||||||
|
"isConfigurable": true,
|
||||||
|
"isEnabled": true,
|
||||||
|
"isSuperUser": true,
|
||||||
|
"name": "test",
|
||||||
|
"organizationIds": ["61a8a112ccc8b629d92a1aad"],
|
||||||
|
"username": "test@appsmith.com"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
import User from "../../../../fixtures/user.json";
|
||||||
|
|
||||||
|
let appId;
|
||||||
|
|
||||||
|
describe("Checks for analytics initialization", function() {
|
||||||
|
it("Should check analytics is not initialised when enableTelemtry is false", function() {
|
||||||
|
cy.intercept("GET", "/api/v1/users/me", {
|
||||||
|
body: { responseMeta: { status: 200, success: true }, data: User },
|
||||||
|
}).as("getUsersWithoutTelemetry");
|
||||||
|
cy.visit("/applications");
|
||||||
|
cy.reload();
|
||||||
|
cy.wait("@getUsersWithoutTelemetry");
|
||||||
|
cy.window().then((window) => {
|
||||||
|
expect(window.analytics).to.be.equal(undefined);
|
||||||
|
});
|
||||||
|
let interceptFlag = false;
|
||||||
|
cy.intercept("POST", "https://api.segment.io/**", (req) => {
|
||||||
|
interceptFlag = true;
|
||||||
|
req.continue();
|
||||||
|
});
|
||||||
|
cy.generateUUID().then((id) => {
|
||||||
|
appId = id;
|
||||||
|
cy.CreateAppInFirstListedOrg(id);
|
||||||
|
localStorage.setItem("AppName", appId);
|
||||||
|
});
|
||||||
|
cy.wait(3000);
|
||||||
|
cy.window().then(() => {
|
||||||
|
cy.wrap(interceptFlag).should("eq", false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("Should check analytics is initialised when enableTelemtry is true", function() {
|
||||||
|
cy.intercept("GET", "/api/v1/users/me", {
|
||||||
|
body: {
|
||||||
|
responseMeta: { status: 200, success: true },
|
||||||
|
data: {
|
||||||
|
...User,
|
||||||
|
enableTelemetry: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).as("getUsersWithTelemetry");
|
||||||
|
cy.visit("/applications");
|
||||||
|
cy.reload();
|
||||||
|
cy.wait("@getUsersWithTelemetry");
|
||||||
|
cy.wait(5000);
|
||||||
|
cy.window().then((window) => {
|
||||||
|
expect(window.analytics).not.to.be.undefined;
|
||||||
|
});
|
||||||
|
cy.wait(3000);
|
||||||
|
let interceptFlag = false;
|
||||||
|
cy.intercept("POST", "https://api.segment.io/**", (req) => {
|
||||||
|
interceptFlag = true;
|
||||||
|
req.continue();
|
||||||
|
}).as("segment");
|
||||||
|
cy.generateUUID().then((id) => {
|
||||||
|
appId = id;
|
||||||
|
cy.CreateAppInFirstListedOrg(id);
|
||||||
|
localStorage.setItem("AppName", appId);
|
||||||
|
});
|
||||||
|
cy.wait("@segment");
|
||||||
|
cy.window().then(() => {
|
||||||
|
cy.wrap(interceptFlag).should("eq", true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should check smartlook is not initialised when enableTelemtry is false", function() {
|
||||||
|
cy.intercept("GET", "/api/v1/users/me", {
|
||||||
|
body: { responseMeta: { status: 200, success: true }, data: User },
|
||||||
|
}).as("getUsersWithoutTelemetry");
|
||||||
|
cy.visit("/applications");
|
||||||
|
cy.reload();
|
||||||
|
cy.wait("@getUsersWithoutTelemetry");
|
||||||
|
cy.window().then((window) => {
|
||||||
|
expect(window.smartlook).to.be.equal(undefined);
|
||||||
|
});
|
||||||
|
let interceptFlag = false;
|
||||||
|
cy.intercept("POST", "https://**.smartlook.**", (req) => {
|
||||||
|
interceptFlag = true;
|
||||||
|
req.continue();
|
||||||
|
});
|
||||||
|
cy.generateUUID().then((id) => {
|
||||||
|
appId = id;
|
||||||
|
cy.CreateAppInFirstListedOrg(id);
|
||||||
|
localStorage.setItem("AppName", appId);
|
||||||
|
});
|
||||||
|
cy.wait(3000);
|
||||||
|
cy.window().then(() => {
|
||||||
|
cy.wrap(interceptFlag).should("eq", false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should check Sentry is not initialised when enableTelemtry is false", function() {
|
||||||
|
cy.intercept("GET", "/api/v1/users/me", {
|
||||||
|
body: { responseMeta: { status: 200, success: true }, data: User },
|
||||||
|
}).as("getUsersWithoutTelemetry");
|
||||||
|
cy.visit("/applications");
|
||||||
|
cy.reload();
|
||||||
|
cy.wait("@getUsersWithoutTelemetry");
|
||||||
|
cy.window().then((window) => {
|
||||||
|
expect(window.Sentry).to.be.equal(undefined);
|
||||||
|
});
|
||||||
|
let interceptFlag = false;
|
||||||
|
cy.intercept("POST", "https://**.sentry.io/**", (req) => {
|
||||||
|
interceptFlag = true;
|
||||||
|
req.continue();
|
||||||
|
});
|
||||||
|
cy.generateUUID().then((id) => {
|
||||||
|
appId = id;
|
||||||
|
cy.CreateAppInFirstListedOrg(id);
|
||||||
|
localStorage.setItem("AppName", appId);
|
||||||
|
});
|
||||||
|
cy.wait(3000);
|
||||||
|
cy.window().then(() => {
|
||||||
|
cy.wrap(interceptFlag).should("eq", false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -170,7 +170,6 @@
|
||||||
const CONFIG_LOG_LEVEL_INDEX = LOG_LEVELS.indexOf(parseConfig("__APPSMITH_CLIENT_LOG_LEVEL__"));
|
const CONFIG_LOG_LEVEL_INDEX = LOG_LEVELS.indexOf(parseConfig("__APPSMITH_CLIENT_LOG_LEVEL__"));
|
||||||
|
|
||||||
const INTERCOM_APP_ID = parseConfig("%REACT_APP_INTERCOM_APP_ID%") || parseConfig("__APPSMITH_INTERCOM_APP_ID__");
|
const INTERCOM_APP_ID = parseConfig("%REACT_APP_INTERCOM_APP_ID%") || parseConfig("__APPSMITH_INTERCOM_APP_ID__");
|
||||||
const DISABLE_TELEMETRY = parseConfig("__APPSMITH_DISABLE_TELEMETRY__");
|
|
||||||
const DISABLE_INTERCOM = parseConfig("__APPSMITH_DISABLE_INTERCOM__");
|
const DISABLE_INTERCOM = parseConfig("__APPSMITH_DISABLE_INTERCOM__");
|
||||||
|
|
||||||
// Initialize the Intercom library
|
// Initialize the Intercom library
|
||||||
|
|
@ -215,7 +214,6 @@
|
||||||
},
|
},
|
||||||
intercomAppID: INTERCOM_APP_ID,
|
intercomAppID: INTERCOM_APP_ID,
|
||||||
mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__"),
|
mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__"),
|
||||||
disableTelemetry: DISABLE_TELEMETRY === "" || DISABLE_TELEMETRY,
|
|
||||||
cloudServicesBaseUrl: parseConfig("__APPSMITH_CLOUD_SERVICES_BASE_URL__") || "https://cs.appsmith.com",
|
cloudServicesBaseUrl: parseConfig("__APPSMITH_CLOUD_SERVICES_BASE_URL__") || "https://cs.appsmith.com",
|
||||||
googleRecaptchaSiteKey: parseConfig("__APPSMITH_RECAPTCHA_SITE_KEY__"),
|
googleRecaptchaSiteKey: parseConfig("__APPSMITH_RECAPTCHA_SITE_KEY__"),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ export type INJECTED_CONFIGS = {
|
||||||
};
|
};
|
||||||
intercomAppID: string;
|
intercomAppID: string;
|
||||||
mailEnabled: boolean;
|
mailEnabled: boolean;
|
||||||
disableTelemetry: boolean;
|
|
||||||
cloudServicesBaseUrl: string;
|
cloudServicesBaseUrl: string;
|
||||||
googleRecaptchaSiteKey: string;
|
googleRecaptchaSiteKey: string;
|
||||||
supportEmail: string;
|
supportEmail: string;
|
||||||
|
|
@ -120,7 +119,6 @@ const getConfigsFromEnvVars = (): INJECTED_CONFIGS => {
|
||||||
mailEnabled: process.env.REACT_APP_MAIL_ENABLED
|
mailEnabled: process.env.REACT_APP_MAIL_ENABLED
|
||||||
? process.env.REACT_APP_MAIL_ENABLED.length > 0
|
? process.env.REACT_APP_MAIL_ENABLED.length > 0
|
||||||
: false,
|
: false,
|
||||||
disableTelemetry: true,
|
|
||||||
cloudServicesBaseUrl: process.env.REACT_APP_CLOUD_SERVICES_BASE_URL || "",
|
cloudServicesBaseUrl: process.env.REACT_APP_CLOUD_SERVICES_BASE_URL || "",
|
||||||
googleRecaptchaSiteKey:
|
googleRecaptchaSiteKey:
|
||||||
process.env.REACT_APP_GOOGLE_RECAPTCHA_SITE_KEY || "",
|
process.env.REACT_APP_GOOGLE_RECAPTCHA_SITE_KEY || "",
|
||||||
|
|
@ -212,21 +210,9 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => {
|
||||||
// We enable segment tracking if either the Cloud API key is set or the self-hosted CE key is set
|
// We enable segment tracking if either the Cloud API key is set or the self-hosted CE key is set
|
||||||
segment.enabled = segment.enabled || segmentCEKey.enabled;
|
segment.enabled = segment.enabled || segmentCEKey.enabled;
|
||||||
|
|
||||||
let sentryTelemetry = true;
|
|
||||||
// Turn off all analytics if telemetry is disabled
|
|
||||||
if (APPSMITH_FEATURE_CONFIGS.disableTelemetry) {
|
|
||||||
smartLook.enabled = false;
|
|
||||||
segment.enabled = false;
|
|
||||||
sentryTelemetry = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sentry: {
|
sentry: {
|
||||||
enabled:
|
enabled: sentryDSN.enabled && sentryRelease.enabled && sentryENV.enabled,
|
||||||
sentryDSN.enabled &&
|
|
||||||
sentryRelease.enabled &&
|
|
||||||
sentryENV.enabled &&
|
|
||||||
sentryTelemetry,
|
|
||||||
dsn: sentryDSN.value,
|
dsn: sentryDSN.value,
|
||||||
release: sentryRelease.value,
|
release: sentryRelease.value,
|
||||||
environment: sentryENV.value,
|
environment: sentryENV.value,
|
||||||
|
|
@ -288,7 +274,6 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => {
|
||||||
intercomAppID:
|
intercomAppID:
|
||||||
ENV_CONFIG.intercomAppID || APPSMITH_FEATURE_CONFIGS.intercomAppID,
|
ENV_CONFIG.intercomAppID || APPSMITH_FEATURE_CONFIGS.intercomAppID,
|
||||||
mailEnabled: ENV_CONFIG.mailEnabled || APPSMITH_FEATURE_CONFIGS.mailEnabled,
|
mailEnabled: ENV_CONFIG.mailEnabled || APPSMITH_FEATURE_CONFIGS.mailEnabled,
|
||||||
disableTelemetry: APPSMITH_FEATURE_CONFIGS.disableTelemetry,
|
|
||||||
commentsTestModeEnabled: false,
|
commentsTestModeEnabled: false,
|
||||||
cloudServicesBaseUrl:
|
cloudServicesBaseUrl:
|
||||||
ENV_CONFIG.cloudServicesBaseUrl ||
|
ENV_CONFIG.cloudServicesBaseUrl ||
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,6 @@ export type AppsmithUIConfigs = {
|
||||||
};
|
};
|
||||||
intercomAppID: string;
|
intercomAppID: string;
|
||||||
mailEnabled: boolean;
|
mailEnabled: boolean;
|
||||||
|
|
||||||
disableTelemetry: boolean;
|
|
||||||
commentsTestModeEnabled: boolean;
|
commentsTestModeEnabled: boolean;
|
||||||
|
|
||||||
cloudServicesBaseUrl: string;
|
cloudServicesBaseUrl: string;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export type User = {
|
||||||
role?: string;
|
role?: string;
|
||||||
useCase?: string;
|
useCase?: string;
|
||||||
isConfigurable: boolean;
|
isConfigurable: boolean;
|
||||||
|
enableTelemetry: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface UserApplication {
|
export interface UserApplication {
|
||||||
|
|
@ -39,6 +40,7 @@ export const DefaultCurrentUserDetails: User = {
|
||||||
gender: "MALE",
|
gender: "MALE",
|
||||||
isSuperUser: false,
|
isSuperUser: false,
|
||||||
isConfigurable: false,
|
isConfigurable: false,
|
||||||
|
enableTelemetry: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO keeping it here instead of the USER_API since it leads to cyclic deps errors during tests
|
// TODO keeping it here instead of the USER_API since it leads to cyclic deps errors during tests
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ import {
|
||||||
getFirstTimeUserOnboardingApplicationId,
|
getFirstTimeUserOnboardingApplicationId,
|
||||||
getFirstTimeUserOnboardingIntroModalVisibility,
|
getFirstTimeUserOnboardingIntroModalVisibility,
|
||||||
} from "utils/storage";
|
} from "utils/storage";
|
||||||
|
import { initializeAnalyticsAndTrackers } from "utils/AppsmithUtils";
|
||||||
|
|
||||||
export function* createUserSaga(
|
export function* createUserSaga(
|
||||||
action: ReduxActionWithPromise<CreateUserRequest>,
|
action: ReduxActionWithPromise<CreateUserRequest>,
|
||||||
|
|
@ -113,13 +114,17 @@ export function* getCurrentUserSaga() {
|
||||||
|
|
||||||
const isValidResponse = yield validateResponse(response);
|
const isValidResponse = yield validateResponse(response);
|
||||||
if (isValidResponse) {
|
if (isValidResponse) {
|
||||||
|
const { enableTelemetry } = response.data;
|
||||||
|
if (enableTelemetry) {
|
||||||
|
initializeAnalyticsAndTrackers();
|
||||||
|
}
|
||||||
yield put(initAppLevelSocketConnection());
|
yield put(initAppLevelSocketConnection());
|
||||||
yield put(initPageLevelSocketConnection());
|
yield put(initPageLevelSocketConnection());
|
||||||
if (
|
if (
|
||||||
!response.data.isAnonymous &&
|
!response.data.isAnonymous &&
|
||||||
response.data.username !== ANONYMOUS_USERNAME
|
response.data.username !== ANONYMOUS_USERNAME
|
||||||
) {
|
) {
|
||||||
AnalyticsUtil.identifyUser(response.data);
|
enableTelemetry && AnalyticsUtil.identifyUser(response.data);
|
||||||
// make fetch feature call only if logged in
|
// make fetch feature call only if logged in
|
||||||
yield put(fetchFeatureFlagsInit());
|
yield put(fetchFeatureFlagsInit());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ class AnalyticsUtil {
|
||||||
if (userData) {
|
if (userData) {
|
||||||
const { segment } = getAppsmithConfigs();
|
const { segment } = getAppsmithConfigs();
|
||||||
let user: any = {};
|
let user: any = {};
|
||||||
if (segment.enabled && segment.apiKey) {
|
if (userData.enableTelemetry && segment.apiKey) {
|
||||||
user = {
|
user = {
|
||||||
userId: userData.username,
|
userId: userData.username,
|
||||||
email: userData.email,
|
email: userData.email,
|
||||||
|
|
@ -291,7 +291,7 @@ class AnalyticsUtil {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowDoc.analytics) {
|
if (userData?.enableTelemetry && windowDoc.analytics) {
|
||||||
log.debug("Event fired", eventName, finalEventData);
|
log.debug("Event fired", eventName, finalEventData);
|
||||||
windowDoc.analytics.track(eventName, finalEventData);
|
windowDoc.analytics.track(eventName, finalEventData);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,11 @@ export const createImmerReducer = (
|
||||||
export const appInitializer = () => {
|
export const appInitializer = () => {
|
||||||
FormControlRegistry.registerFormControlBuilders();
|
FormControlRegistry.registerFormControlBuilders();
|
||||||
const appsmithConfigs = getAppsmithConfigs();
|
const appsmithConfigs = getAppsmithConfigs();
|
||||||
|
log.setLevel(getEnvLogLevel(appsmithConfigs.logLevel));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const initializeAnalyticsAndTrackers = () => {
|
||||||
|
const appsmithConfigs = getAppsmithConfigs();
|
||||||
|
|
||||||
if (appsmithConfigs.sentry.enabled) {
|
if (appsmithConfigs.sentry.enabled) {
|
||||||
window.Sentry = Sentry;
|
window.Sentry = Sentry;
|
||||||
|
|
@ -92,8 +97,6 @@ export const appInitializer = () => {
|
||||||
AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey);
|
AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.setLevel(getEnvLogLevel(appsmithConfigs.logLevel));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mapToPropList = (map: Record<string, string>): Property[] => {
|
export const mapToPropList = (map: Record<string, string>): Property[] => {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ public class UserProfileDTO {
|
||||||
|
|
||||||
String useCase;
|
String useCase;
|
||||||
|
|
||||||
|
boolean enableTelemetry = false;
|
||||||
|
|
||||||
public boolean isAccountNonExpired() {
|
public boolean isAccountNonExpired() {
|
||||||
return this.isEnabled;
|
return this.isEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -912,6 +912,7 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
||||||
profile.setRole(userData.getRole());
|
profile.setRole(userData.getRole());
|
||||||
profile.setUseCase(userData.getUseCase());
|
profile.setUseCase(userData.getUseCase());
|
||||||
profile.setPhotoId(userData.getProfilePhotoAssetId());
|
profile.setPhotoId(userData.getProfilePhotoAssetId());
|
||||||
|
profile.setEnableTelemetry(!commonConfig.isTelemetryDisabled());
|
||||||
|
|
||||||
profile.setSuperUser(policyUtils.isPermissionPresentForUser(
|
profile.setSuperUser(policyUtils.isPermissionPresentForUser(
|
||||||
userFromDb.getPolicies(),
|
userFromDb.getPolicies(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user