This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch scarf-pixel
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/scarf-pixel by this push:
     new a12f2057d0 Adding pixel component and FF
a12f2057d0 is described below

commit a12f2057d074f7f17214230c446e4319a0dc87be
Author: Evan Rusackas <[email protected]>
AuthorDate: Thu Nov 16 14:44:02 2023 -0700

    Adding pixel component and FF
---
 RESOURCES/FEATURE_FLAGS.md                         |  1 +
 superset-frontend/package.json                     |  2 +-
 .../superset-ui-core/src/utils/featureFlags.ts     |  1 +
 .../TelemetryPixel/TelemetryPixel.test.tsx         | 43 ++++++++++++++++++++++
 .../src/components/TelemetryPixel/index.tsx        | 33 +++++++++++++++++
 superset-frontend/src/features/home/RightMenu.tsx  |  7 ++--
 superset/config.py                                 |  2 +
 7 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/RESOURCES/FEATURE_FLAGS.md b/RESOURCES/FEATURE_FLAGS.md
index d029ca6c3c..e271c8894a 100644
--- a/RESOURCES/FEATURE_FLAGS.md
+++ b/RESOURCES/FEATURE_FLAGS.md
@@ -72,6 +72,7 @@ These features flags are **safe for production**. They have 
been tested and will
 - DRUID_JOINS
 - EMBEDDABLE_CHARTS
 - EMBEDDED_SUPERSET
+- ENABLE_TELEMETRY
 - ENABLE_TEMPLATE_PROCESSING
 - ESCAPE_MARKDOWN_HTML
 - LISTVIEWS_DEFAULT_CARD_VIEW
diff --git a/superset-frontend/package.json b/superset-frontend/package.json
index fec56fdb45..41aab37146 100644
--- a/superset-frontend/package.json
+++ b/superset-frontend/package.json
@@ -257,7 +257,7 @@
     "@types/js-levenshtein": "^1.1.0",
     "@types/json-bigint": "^1.0.1",
     "@types/mousetrap": "^1.6.11",
-    "@types/react": "^16.9.43",
+    "@types/react": "^16.9.53",
     "@types/react-dom": "^16.9.8",
     "@types/react-gravatar": "^2.6.8",
     "@types/react-json-tree": "^0.6.11",
diff --git 
a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts 
b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts
index 6bc77e0e87..e13e06d9f0 100644
--- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts
+++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts
@@ -44,6 +44,7 @@ export enum FeatureFlag {
   ENABLE_ADVANCED_DATA_TYPES = 'ENABLE_ADVANCED_DATA_TYPES',
   ENABLE_EXPLORE_DRAG_AND_DROP = 'ENABLE_EXPLORE_DRAG_AND_DROP',
   ENABLE_JAVASCRIPT_CONTROLS = 'ENABLE_JAVASCRIPT_CONTROLS',
+  ENABLE_TELEMETRY = 'ENABLE_TELEMETRY',
   ENABLE_TEMPLATE_PROCESSING = 'ENABLE_TEMPLATE_PROCESSING',
   ENABLE_TEMPLATE_REMOVE_FILTERS = 'ENABLE_TEMPLATE_REMOVE_FILTERS',
   ESCAPE_MARKDOWN_HTML = 'ESCAPE_MARKDOWN_HTML',
diff --git 
a/superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx 
b/superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx
new file mode 100644
index 0000000000..96445624c1
--- /dev/null
+++ b/superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { render, screen } from 'spec/helpers/testing-library';
+import { FeatureFlag } from '@superset-ui/core';
+import TelemetryPixel from '.';
+
+test('should render', () => {
+  const { container } = render(<TelemetryPixel />);
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the pixel link when FF is on', () => {
+  window.featureFlags = {
+    [FeatureFlag.ENABLE_TELEMETRY]: true,
+  };
+  render(<TelemetryPixel />);
+  expect(screen.getByText('scarf.sh')).toBeInTheDocument();
+});
+
+test('should NOT render the pixel link when FF is off', () => {
+  window.featureFlags = {
+    [FeatureFlag.ENABLE_TELEMETRY]: false,
+  };
+  render(<TelemetryPixel />);
+  expect(screen.getByText('scarf.sh')).not.toBeInTheDocument();
+});
diff --git a/superset-frontend/src/components/TelemetryPixel/index.tsx 
b/superset-frontend/src/components/TelemetryPixel/index.tsx
new file mode 100644
index 0000000000..0d209a72da
--- /dev/null
+++ b/superset-frontend/src/components/TelemetryPixel/index.tsx
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { isFeatureEnabled, FeatureFlag } from '@superset-ui/core';
+
+const TelemetryPixel = () => {
+  console.log('TelemetryPixel', isFeatureEnabled(FeatureFlag.ENABLE_TELEMETRY))
+  return  isFeatureEnabled(FeatureFlag.ENABLE_TELEMETRY) ? (
+    // eslint-disable-next-line jsx-a11y/alt-text
+    <img
+      referrerPolicy="no-referrer-when-downgrade"
+      
src="https://static.scarf.sh/a.png?x-pxid=0d3461e1-abb1-4691-a0aa-5ed50de66af0";
+    />
+  ) : null;
+  }
+export default TelemetryPixel;
diff --git a/superset-frontend/src/features/home/RightMenu.tsx 
b/superset-frontend/src/features/home/RightMenu.tsx
index 91e8bc4a7c..2fb2d0f967 100644
--- a/superset-frontend/src/features/home/RightMenu.tsx
+++ b/superset-frontend/src/features/home/RightMenu.tsx
@@ -46,6 +46,7 @@ import {
 import { RootState } from 'src/dashboard/types';
 import DatabaseModal from 'src/features/databases/DatabaseModal';
 import { uploadUserPerms } from 'src/views/CRUD/utils';
+import TelemetryPixel from 'src/components/TelemetryPixel';
 import LanguagePicker from './LanguagePicker';
 import {
   ExtensionConfigs,
@@ -210,7 +211,7 @@ const RightMenu = ({
     },
     {
       label: t('SQL query'),
-      url: '/sqllab?new=true',
+      url: '/superset/sqllab?new=true',
       icon: 'fa-fw fa-search',
       perm: 'can_sqllab',
       view: 'Superset',
@@ -341,7 +342,7 @@ const RightMenu = ({
 
   return (
     <StyledDiv align={align}>
-      <img referrerPolicy="no-referrer-when-downgrade" 
src="https://static.scarf.sh/a.png?x-pxid=0d3461e1-abb1-4691-a0aa-5ed50de66af0&test=foo&test2=bar";
 />
+      <TelemetryPixel />
       {canDatabase && (
         <DatabaseModal
           onHide={handleOnHideModal}
@@ -475,7 +476,7 @@ const RightMenu = ({
             <Menu.ItemGroup key="user-section" title={t('User')}>
               {navbarRight.user_profile_url && (
                 <Menu.Item key="profile">
-                  <Link to={navbarRight.user_profile_url}>{t('Profile')}</Link>
+                  <a href={navbarRight.user_profile_url}>{t('Profile')}</a>
                 </Menu.Item>
               )}
               {navbarRight.user_info_url && (
diff --git a/superset/config.py b/superset/config.py
index 871a3a1050..409e20a4e2 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -417,6 +417,8 @@ DEFAULT_FEATURE_FLAGS: dict[str, bool] = {
     # make GET request to explore_json. explore_json accepts both GET and POST 
request.
     # See `PR 7935 <https://github.com/apache/superset/pull/7935>`_ for more 
details.
     "ENABLE_EXPLORE_JSON_CSRF_PROTECTION": False,  # deprecated
+    # Enables telemetry using Scarf.sh (to help measure Superset's adoption 
and the impact security concerns or other issues might have on the community)
+    "ENABLE_TELEMETRY": True,
     "ENABLE_TEMPLATE_PROCESSING": False,
     "ENABLE_TEMPLATE_REMOVE_FILTERS": True,  # deprecated
     # Allow for javascript controls components

Reply via email to