📝 add search icon to ga event

This commit is contained in:
afc163 2019-08-27 20:44:29 +08:00
parent ea13c19da7
commit 7458a9abcd
No known key found for this signature in database
GPG Key ID: 5F00908D72002306
2 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,7 @@
"@packtracker/webpack-plugin": "^2.0.1",
"@sentry/browser": "^5.4.0",
"@types/classnames": "^2.2.8",
"@types/gtag.js": "^0.0.3",
"@types/prop-types": "^15.7.1",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.8.4",

View File

@ -100,6 +100,12 @@ class PicSearcher extends Component<PicSearcherProps, PicSearcherState> {
},
);
let icons = await res.json();
if (gtag && icons.length >= 1) {
gtag('event', 'icon', {
event_category: 'search-by-image',
event_label: icons[0].class_name,
});
}
icons = icons.map((i: any) => ({ score: i.score, type: i.class_name.replace(/\s/g, '-') }));
this.setState(() => ({ icons, loading: false, error: false }));
} catch (err) {