-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added update restrictions, techStacks in project and orgId to a user * added edit restriction mechanism * intial deactivation mechanism * intial logging mechanism and deactive account * issue fix * fixing org creation issue * Fixes issues in testing (#160) * fix failing test file user.test.js * fixes EADDRINUSE while testing * fixes issues in prposal route * fixed issues in org route and added new tests * Moving Google Analytics requests to backend (#154) * Moving Google Analytics requetss to backend * Requested Changes * Minor changes * Adding code to prevent attacks (#153) * modified user's api (#168) * modified user's api * login options during login * Changes for reactions (#166) Co-authored-by: Rupeshiya <[email protected]> Co-authored-by: Devesh Verma <[email protected]> Co-authored-by: Kumar Saurabh Raj <[email protected]> Co-authored-by: Asel Peiris <[email protected]> Co-authored-by: pranjals149 <[email protected]>
- Loading branch information
1 parent
119722b
commit 940a3fa
Showing
33 changed files
with
1,393 additions
and
109 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
const { google } = require('googleapis') | ||
const analytics = google.analytics('v3') | ||
const jwt = require('../../config/gAnalytics') | ||
const viewId = process.env.VIEW_ID | ||
const HANDLER = require('../utils/response-helper') | ||
const HttpStatus = require('http-status-codes') | ||
|
||
module.exports = { | ||
getBrowser: async (req, res, next) => { | ||
const { startDate, endDate, proposalId } = req.body | ||
console.log(req.body) | ||
try { | ||
const result = await analytics.data.ga.get({ | ||
auth: jwt, | ||
ids: `ga:${viewId}`, | ||
metrics: 'ga:users', | ||
dimensions: ['ga:browser'], | ||
'start-date': startDate, | ||
'end-date': endDate, | ||
filters: `ga:pagePath==/${proposalId}` | ||
}) | ||
res.status(HttpStatus.OK).json({ analytics: result.data.rows }) | ||
} catch (error) { | ||
HANDLER.handleError(res, error) | ||
} | ||
}, | ||
|
||
getCountries: async (req, res, next) => { | ||
const { startDate, endDate, proposalId } = req.body | ||
|
||
try { | ||
const result = await analytics.data.ga.get({ | ||
auth: jwt, | ||
ids: `ga:${viewId}`, | ||
metrics: 'ga:users', | ||
dimensions: ['ga:country'], | ||
'start-date': startDate, | ||
'end-date': endDate, | ||
filters: `ga:pagePath==/${proposalId}` | ||
}) | ||
res.status(HttpStatus.OK).json({ analytics: result.data.rows }) | ||
} catch (error) { | ||
HANDLER.handleError(res, error) | ||
} | ||
}, | ||
|
||
getDevice: async (req, res, next) => { | ||
const { startDate, endDate, proposalId } = req.body | ||
|
||
try { | ||
const result = await analytics.data.ga.get({ | ||
auth: jwt, | ||
ids: `ga:${viewId}`, | ||
metrics: 'ga:users', | ||
dimensions: ['ga:deviceCategory'], | ||
'start-date': startDate, | ||
'end-date': endDate, | ||
filters: `ga:pagePath==/${proposalId}` | ||
}) | ||
res.status(HttpStatus.OK).json({ analytics: result.data.rows }) | ||
} catch (error) { | ||
HANDLER.handleError(res, error) | ||
} | ||
}, | ||
|
||
getTopProposals: async (req, res, next) => { | ||
const { startDate, endDate } = req.body | ||
|
||
try { | ||
const result = await analytics.data.ga.get({ | ||
auth: jwt, | ||
ids: `ga:${viewId}`, | ||
metrics: 'ga:pageviews', | ||
dimensions: ['ga:pagePath'], | ||
'start-date': startDate, | ||
'end-date': endDate, | ||
filters: 'ga:pagePath!=/homepage' | ||
}) | ||
res.status(HttpStatus.OK).json({ analytics: result.data }) | ||
} catch (error) { | ||
HANDLER.handleError(res, error) | ||
} | ||
}, | ||
|
||
getProposalViews: async (req, res, next) => { | ||
const { startDate, endDate, proposalId } = req.body | ||
|
||
try { | ||
const result = await analytics.data.ga.get({ | ||
auth: jwt, | ||
ids: `ga:${viewId}`, | ||
metrics: 'ga:pageviews', | ||
dimensions: ['ga:date'], | ||
'start-date': startDate, | ||
'end-date': endDate, | ||
filters: `ga:pagePath==/${proposalId}` | ||
}) | ||
|
||
res.status(HttpStatus.OK).json({ analytics: result.data.rows }) | ||
} catch (error) { | ||
HANDLER.handleError(res, error) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.