-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(telemetry): Adding Scarf based telemetry to Superset #26011
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
3bf9698
Adding scarf pixel
rusackas f71c277
faux query variables
rusackas 2d704b2
Adding pixel component and FF
rusackas f876364
bumping react types to allow referrer policy
rusackas 960d6fb
Passing version/sha/build to pixel
rusackas 9dbbefa
more bump action
rusackas ee21914
fiddling with pixel/package path
rusackas cf6bd9a
touchups
rusackas c2442ae
more linting
rusackas db5c2df
fixing talisman config
rusackas 8d6f19d
linting
rusackas a80de0c
line too long... seems like the linter could just fix this :/
rusackas bd97de7
more linting?! <shakes fist>
rusackas f4292e3
fixing linting, adding docstrings
rusackas 2fabe99
hide the darn image
rusackas e08ef77
linting
rusackas a8e3bf9
fixing RTL tests
rusackas 64a6035
questionable shim update
rusackas 766e2dd
making tests pass - but how are they not failing everywhere?
rusackas c7995c3
linting the shim fix
rusackas 9e7a8da
restoring shim ¯\_(ツ)_/¯
rusackas 925ef36
John ❤️ JS
rusackas 2e3a764
fixing the window shim so it runs on problematic node versions
rusackas 920bf8a
c'mon, tests!
rusackas cb606ab
Now using env var rather than a feature flag
rusackas 96589f0
cleaning up...
rusackas a3b91cd
moving const
rusackas d2b9355
Improved docs
rusackas 3f3751f
lint
rusackas 352256e
tests should pass now (and the pixel should hide) whether the env var…
rusackas f5fae76
Removes console warning
michael-s-molina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 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 } from 'spec/helpers/testing-library'; | ||
import TelemetryPixel from '.'; | ||
|
||
const OLD_ENV = process.env; | ||
|
||
// restor the process after messing with it! | ||
afterAll(() => { | ||
process.env = OLD_ENV; | ||
}); | ||
|
||
test('should render', () => { | ||
const { container } = render(<TelemetryPixel />); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
test('should render the pixel link when FF is on', () => { | ||
process.env.SCARF_ANALYTICS = 'true'; | ||
render(<TelemetryPixel />); | ||
|
||
const image = document.querySelector('img[src*="scarf.sh"]'); | ||
expect(image).toBeInTheDocument(); | ||
}); | ||
|
||
test('should NOT render the pixel link when FF is off', () => { | ||
process.env.SCARF_ANALYTICS = 'false'; | ||
render(<TelemetryPixel />); | ||
|
||
const image = document.querySelector('img[src*="scarf.sh"]'); | ||
expect(image).not.toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* 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'; | ||
|
||
interface TelemetryPixelProps { | ||
version?: string; | ||
sha?: string; | ||
build?: string; | ||
} | ||
|
||
/** | ||
* Renders a telemetry pixel component to capture anonymous, aggregated telemetry via Scarf. | ||
* This can be disabled by setting the SCARF_ANALYTICS environment variable to false. | ||
* | ||
* @component | ||
* @param {TelemetryPixelProps} props - The props for the TelemetryPixel component. | ||
* @param {string} props.version - The version of Superset that's currently in use. | ||
* @param {string} props.sha - The SHA of Superset that's currently in use. | ||
* @param {string} props.build - The build of Superset that's currently in use. | ||
* @returns {JSX.Element | null} The rendered TelemetryPixel component. | ||
*/ | ||
|
||
const PIXEL_ID = '0d3461e1-abb1-4691-a0aa-5ed50de66af0'; | ||
|
||
const TelemetryPixel = ({ | ||
version = 'unknownVersion', | ||
sha = 'unknownSHA', | ||
build = 'unknownBuild', | ||
}: TelemetryPixelProps): React.ReactElement | null => { | ||
const pixelPath = `https://apachesuperset.gateway.scarf.sh/pixel/${PIXEL_ID}/${version}/${sha}/${build}`; | ||
return process.env.SCARF_ANALYTICS === 'false' || | ||
process.env.SCARF_ANALYTICS === 'false' ? null : ( | ||
<img | ||
referrerPolicy="no-referrer-when-downgrade" | ||
src={pixelPath} | ||
width={0} | ||
height={0} | ||
alt="" | ||
/> | ||
); | ||
}; | ||
export default TelemetryPixel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this is duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeesh... I thought I nabbed that. Will open a PR to clean up... Especially if this does not have the intended effect now. Surprised some linting rule doesn't spot this kind of thing.