diff --git a/Week-16/googleanalytics/Screenshot1.png b/Week-16/googleanalytics/Screenshot1.png new file mode 100644 index 0000000..1357d09 Binary files /dev/null and b/Week-16/googleanalytics/Screenshot1.png differ diff --git a/Week-16/googleanalytics/frontend-index.html b/Week-16/googleanalytics/frontend-index.html new file mode 100644 index 0000000..3f3c229 --- /dev/null +++ b/Week-16/googleanalytics/frontend-index.html @@ -0,0 +1,32 @@ + + + + + + + + + + + + + React App + + + + + + +
+ + + diff --git a/Week-16/readme.md b/Week-16/readme.md new file mode 100644 index 0000000..d305654 --- /dev/null +++ b/Week-16/readme.md @@ -0,0 +1,9 @@ +#Assignment 16 +## Sentry frontend and backend logging + +![img](./sentry/Screenshot1.PNG) +![img](./sentry/Screenshot2.PNG) +![img](./sentry/Screenshot3.PNG) + +## Google Analytics user logging. +![img](./googleanalytics/Screenshot1.PNG) \ No newline at end of file diff --git a/Week-16/sentry/Screenshot1.png b/Week-16/sentry/Screenshot1.png new file mode 100644 index 0000000..c090df8 Binary files /dev/null and b/Week-16/sentry/Screenshot1.png differ diff --git a/Week-16/sentry/Screenshot2.png b/Week-16/sentry/Screenshot2.png new file mode 100644 index 0000000..f116bf8 Binary files /dev/null and b/Week-16/sentry/Screenshot2.png differ diff --git a/Week-16/sentry/Screenshot3.png b/Week-16/sentry/Screenshot3.png new file mode 100644 index 0000000..bb178d6 Binary files /dev/null and b/Week-16/sentry/Screenshot3.png differ diff --git a/Week-16/sentry/backend-routes.js b/Week-16/sentry/backend-routes.js new file mode 100644 index 0000000..254996e --- /dev/null +++ b/Week-16/sentry/backend-routes.js @@ -0,0 +1,68 @@ +const express = require("express"); +const Sentry= require("@sentry/node") + +require("@sentry/tracing") +const Model = require("../models/model"); +const router = express.Router(); +const axios = require("axios"); +require("dotenv").config(); +const API_KEY = process.env.API_KEY; +Sentry.init({ + dsn: "https://c1b7c10c133f45f6867d9e48b1b5279a@o1408070.ingest.sentry.io/6743473", + + + tracesSampleRate: 1.0, +}); +const transaction = Sentry.startTransaction({ + op: "test", + name: "My First Test Transaction", +}); +router.get("/current", async (req, res) => { + const result = []; + const cities =new Set(req.query.city.split(",")); + + for (let city of cities) { + console.log(city) + let url = `http://api.weatherapi.com/v1/current.json?key=${API_KEY}&q=${city}`; + console.log(url) + + try { + let results = await axios.get(url); + json = results.data; + + result.push(json); + } catch (err) { + + console.log('ERROR IS COMING') + console.log(err) + Sentry.captureException(err); + }finally{ + transaction.finish(); + } + + + + } + + +}); + +router.get("/forecast", async (req, res) => { + + const result = []; + + if (!req.query.city || !req.query.days) return []; + const cities = req.query.city.split(","); + const { days } = req.query; + for (let i = 0; i < cities.length; i++) { + try {let url = `http://api.weatherapi.com/v1/forecast.json?key=${API_KEY}&q=${cities[i]}&days=${days}`; + let results = await axios.get(url); + results = results.data; + result.push(results); + } catch (err) { + console.log("data not found"); + } + } + res.send(result); +}); +module.exports = router; diff --git a/Week-16/sentry/frontend-index.js b/Week-16/sentry/frontend-index.js new file mode 100644 index 0000000..ec236ec --- /dev/null +++ b/Week-16/sentry/frontend-index.js @@ -0,0 +1,17 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import './index.css'; +import App from './App'; +import * as Sentry from "@sentry/react"; +import { BrowserTracing } from "@sentry/tracing"; +Sentry.init({ + dsn: "https://c1b7c10c133f45f6867d9e48b1b5279a@o1408070.ingest.sentry.io/6743473", + integrations: [new BrowserTracing()], + tracesSampleRate: 1.0, +}); +const root = ReactDOM.createRoot(document.getElementById('root')); +root.render( + + + +);