Skip to content

Commit

Permalink
Merge pull request #18 from sentry-demos/upgrade_sentry_sdk
Browse files Browse the repository at this point in the history
Upgrade sentry sdk to latest version
  • Loading branch information
cstavitsky authored Mar 15, 2022
2 parents a5685d2 + a07b9a3 commit ee3d640
Show file tree
Hide file tree
Showing 4 changed files with 8,182 additions and 367 deletions.
18 changes: 13 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ require('./sentry');
let date = Date.now();

// replace with your sentry_key ref: https://develop.sentry.dev/sdk/store/
const SENTRY_KEY='SENTRY_KEY';
const SENTRY_KEY='aab0a4e2af5a4df0a9adf094e657809e@o87286' // for testorg-az 'electron' project
const PROJECT_ID='1318230' // for testorg-az 'electron' project
const SENTRY_AUTH_TOKEN="" //Put your auth token here
const dir = app.getAppPath();
const pathToDir = path.join(__dirname, "offlineEvents")

if (!SENTRY_KEY) {
throw("You must set your SENTRY_KEY in main.js")
} else if (!SENTRY_AUTH_TOKEN) {
throw("You must set your SENTRY_AUTH_TOKEN in main.js")
}

const removeDir = function(path) {
if (fs.existsSync(path)) {
const files = fs.readdirSync(path)
Expand Down Expand Up @@ -98,17 +106,17 @@ ipcMain.on('online-status-changed', (event, status) => {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
}
//listing all files using forEach
files.forEach(function (file) {
fs.readFile("./offlineEvents/" + file, "utf8", function (err, data) {
if (err) throw err;
// replace with your project store endpoint https://develop.sentry.dev/sdk/store/ and Auth Token
axios.post('https://SENTRY_KEY.ingest.sentry.io/api/PROJECT_ID/store/', data, {
axios.post(`https://${SENTRY_KEY}.ingest.sentry.io/api/${PROJECT_ID}/store/`, data, {
headers: {
'Content-Type': 'application/json',
'X-Sentry-Auth': `Sentry sentry_version=7,sentry_timestamp=${date},sentry_client=sentry-curl/1.0,sentry_key=${SENTRY_KEY}`,
'Authorization': 'Bearer AUTH_TOKEN'
'Authorization': `Bearer ${SENTRY_AUTH_TOKEN}`
},
})
.then(response => {
Expand Down Expand Up @@ -137,4 +145,4 @@ ipcMain.on('demo.error', () => {
ipcMain.on('demo.crash', () => {
console.log('process.crash()');
process.crash();
});
});
Loading

0 comments on commit ee3d640

Please sign in to comment.