Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

deprecated 'to image' data export (#395)

Andrii Romasiuncf6b45364af1
diff --git a/app/pages/Captcha/View/ViewCaptcha.tsx b/app/pages/Captcha/View/ViewCaptcha.tsx
index c392e0593..0786a6924 100644
--- a/app/pages/Captcha/View/ViewCaptcha.tsx
+++ b/app/pages/Captcha/View/ViewCaptcha.tsx
@@ -2,14 +2,9 @@
import React, { useState, useEffect, useMemo, memo, useRef } from 'react'
import useSize from 'hooks/useSize'
import { useNavigate, useParams } from '@remix-run/react'
-// @ts-ignore
-import domToImage from 'dom-to-image'
-// @ts-ignore
-import { saveAs } from 'file-saver'
import bb from 'billboard.js'
import { ArrowDownTrayIcon, Cog8ToothIcon, ArrowPathIcon } from '@heroicons/react/24/outline'
import cx from 'clsx'
-import dayjs from 'dayjs'
import { useTranslation } from 'react-i18next'
import _keys from 'lodash/keys'
import _map from 'lodash/map'
@@ -64,7 +59,6 @@ import {
import { onCSVExportClick } from 'pages/Project/View/ViewProject.helpers'
import TBPeriodSelector from 'pages/Project/View/components/TBPeriodSelector'
import CCRow from '../../Project/View/components/CCRow'
-import RefRow from './components/RefRow'
import NoEvents from './components/NoEvents'
import Filters from './components/Filters'
@@ -153,9 +147,6 @@ const ViewProject = ({
})
const checkIfAllMetricsAreDisabled = useMemo(() => !_some(activeChartMetrics, (value) => value), [activeChartMetrics])
const [filters, setFilters] = useState<any[]>([])
- // That is needed when using 'Export as image' feature,
- // Because headless browser cannot do a request to the DDG API due to absense of The Same Origin Policy header
- const [showIcons, setShowIcons] = useState<boolean>(true)
const isLoading = authenticated ? _isLoading : false
const tnMapping = typeNameMapping(t)
const refCalendar = useRef(null)
@@ -583,20 +574,6 @@ const ViewProject = ({
navigate(_replace(routes.captcha_settings, ':id', id))
}
- const exportAsImageHandler = async () => {
- setShowIcons(false)
- try {
- const blob = await domToImage.toBlob(dashboardRef.current)
- saveAs(blob, `swetrix-${dayjs().format('YYYY-MM-DD-HH-mm-ss')}.png`)
- } catch (e) {
- showError(t('project.exportImgError'))
- console.error('[ERROR] Error while generating export image.')
- console.error(e)
- } finally {
- setShowIcons(true)
- }
- }
-
useEffect(() => {
try {
// @ts-ignore
@@ -648,7 +625,6 @@ const ViewProject = ({
}
const exportTypes = [
- { label: t('project.asImage'), onClick: exportAsImageHandler },
{
label: t('project.asCSV'),
onClick: () => {
@@ -878,22 +854,6 @@ const ViewProject = ({
)
}
- if (type === 'ref') {
- return (
- <Panel
- t={t}
- key={type}
- icon={panelIcon}
- id={type}
- onFilter={filterHandler}
- name={panelName}
- data={panelsData.data[type]}
- // @ts-ignore
- rowMapper={({ name: entryName }) => <RefRow rowName={entryName} showIcons={showIcons} />}
- />
- )
- }
-
return (
<Panel
t={t}
diff --git a/app/pages/Captcha/View/components/RefRow.tsx b/app/pages/Captcha/View/components/RefRow.tsx
deleted file mode 100644
index d4bcccf9d..000000000
--- a/app/pages/Captcha/View/components/RefRow.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import React, { memo } from 'react'
-import _isEmpty from 'lodash/isEmpty'
-import PropTypes from 'prop-types'
-
-/**
- * Component that renders a link row in the 'Referrer' panel.
- *
- * @param {string} rowName - A link itself (e.g. https://google.com) to render in the row.
- * @param {boolean} showIcons - Whether to show favicon icons near links or not.
- * @returns {JSX.Element}
- */
-const RefRow = ({ rowName, showIcons }: { rowName: string; showIcons: boolean }): JSX.Element => {
- let isUrl: boolean = true
- let url: URL | null = null
-
- try {
- url = new URL(rowName) as URL
- } catch {
- isUrl = false
- }
-
- return (
- <div>
- {showIcons && isUrl && !_isEmpty(url?.hostname) && (
- <img
- className='w-5 h-5 mr-1.5 float-left'
- src={`https://icons.duckduckgo.com/ip3/${url?.hostname}.ico`}
- alt=''
- aria-hidden='true'
- />
- )}
- {isUrl ? (
- <a
- className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'
- href={rowName}
- target='_blank'
- rel='noopener noreferrer nofollow'
- onClick={(e) => e.stopPropagation()}
- aria-label={`${rowName} (opens in a new tab)`}
- >
- {rowName}
- </a>
- ) : (
- <span className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'>{rowName}</span>
- )}
- </div>
- )
-}
-
-RefRow.propTypes = {
- rowName: PropTypes.string.isRequired,
- showIcons: PropTypes.bool.isRequired,
-}
-
-export default memo(RefRow)
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index 74dd4f191..d49946846 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -3,10 +3,6 @@ import React, { useState, useEffect, useMemo, memo, useRef, useCallback } from '
import { ClientOnly } from 'remix-utils'
import useSize from 'hooks/useSize'
import { useNavigate, useParams, Link } from '@remix-run/react'
-// @ts-ignore
-import domToImage from 'dom-to-image'
-// @ts-ignore
-import { saveAs } from 'file-saver'
import bb from 'billboard.js'
import {
ArrowDownTrayIcon,
@@ -402,9 +398,6 @@ const ViewProject = ({
// similar filters but using for the sessions tab
const [filtersSessions, setFiltersSessions] = useState<any[]>([])
const [areFiltersSessionsParsed, setAreFiltersSessionsParsed] = useState<boolean>(false)
- // That is needed when using 'Export as image' feature,
- // Because headless browser cannot do a request to the DDG API due to absense of The Same Origin Policy header
- const [showIcons, setShowIcons] = useState<boolean>(true)
// isLoading is a true when we loading data from api
const isLoading = authenticated ? _isLoading : false
@@ -2613,21 +2606,6 @@ const ViewProject = ({
navigate(_replace(routes.project_settings, ':id', id))
}
- // exportAsImageHandler using for export dashboard as image
- const exportAsImageHandler = async () => {
- setShowIcons(false)
- try {
- const blob = await domToImage.toBlob(dashboardRef.current)
- saveAs(blob, `swetrix-${dayjs().format('YYYY-MM-DD-HH-mm-ss')}.png`)
- } catch (e) {
- showError(t('project.exportImgError'))
- console.error('[ERROR] Error while generating export image.')
- console.error(e)
- } finally {
- setShowIcons(true)
- }
- }
-
// parse period from url when page is loaded
useEffect(() => {
try {
@@ -2707,7 +2685,6 @@ const ViewProject = ({
}
const exportTypes = [
- { label: t('project.asImage'), onClick: exportAsImageHandler },
{
label: t('project.asCSV'),
onClick: () => {
@@ -3691,7 +3668,7 @@ const ViewProject = ({
data={panelsData.data[type]}
customTabs={customTabs}
// @ts-ignore
- rowMapper={({ name: entryName }) => <RefRow rowName={entryName} showIcons={showIcons} />}
+ rowMapper={({ name: entryName }) => <RefRow rowName={entryName} />}
/>
)
}
diff --git a/app/pages/Project/View/components/RefRow.tsx b/app/pages/Project/View/components/RefRow.tsx
index da8791764..597461501 100644
--- a/app/pages/Project/View/components/RefRow.tsx
+++ b/app/pages/Project/View/components/RefRow.tsx
@@ -6,10 +6,9 @@ import PropTypes from 'prop-types'
* Component that renders a link row in the 'Referrer' panel.
*
* @param {string} rowName - A link itself (e.g. https://google.com) to render in the row.
- * @param {boolean} showIcons - Whether to show favicon icons near links or not.
* @returns {JSX.Element}
*/
-const RefRow = ({ rowName, showIcons }: { rowName: string; showIcons: boolean }): JSX.Element => {
+const RefRow = ({ rowName }: { rowName: string }): JSX.Element => {
let isUrl: boolean = true
let url: URL | null = null
@@ -21,7 +20,7 @@ const RefRow = ({ rowName, showIcons }: { rowName: string; showIcons: boolean })
return (
<div className='overflow-auto'>
- {showIcons && isUrl && !_isEmpty(url?.hostname) && (
+ {isUrl && !_isEmpty(url?.hostname) && (
<img
className='w-5 h-5 mr-1.5 float-left'
src={`https://icons.duckduckgo.com/ip3/${url?.hostname}.ico`}
@@ -49,7 +48,6 @@ const RefRow = ({ rowName, showIcons }: { rowName: string; showIcons: boolean })
RefRow.propTypes = {
rowName: PropTypes.string.isRequired,
- showIcons: PropTypes.bool.isRequired,
}
export default memo(RefRow)
diff --git a/package.json b/package.json
index 7ff6336fd..1e1ed3ad8 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,6 @@
"dangerously-set-html-content": "^1.0.13",
"dayjs": "^1.11.10",
"debug": "^4.3.4",
- "dom-to-image": "^2.6.0",
"file-saver": "^2.0.5",
"flatpickr": "^4.6.13",
"i18n-iso-countries": "^7.7.0",
diff --git a/public/locales/en.json b/public/locales/en.json
index 9a497eafb..64cc705c1 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -583,7 +583,6 @@
"pageviewX": "Pageview <value>{{x}}</value>",
"eventX": "Event <value>{{x}}</value>",
"exportData": "Export data",
- "asImage": "As image",
"asCSV": "As CSV",
"noEvTitle": "No events yet",
"showAll": "Show all views",