Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
const Sentry = require('../../../../dist');
const { assertSessions, constructStrippedSessionObject, BaseDummyTransport } = require('../test-utils');
const {
assertSessions,
constructStrippedSessionObject,
BaseDummyTransport,
validateSessionCountFunction,
} = require('../test-utils');

let sessionCounter = 0;
process.on('exit', ()=> {
if (process.exitCode !== 1) {
console.log('SUCCESS: All application mode sessions were sent to node transport as expected');
}
})
const sessionCounts = {
sessionCounter: 0,
expectedSessions: 2,
};

validateSessionCountFunction(sessionCounts);

class DummyTransport extends BaseDummyTransport {
sendSession(session) {
sessionCounter++;
if (sessionCounter === 1) {
assertSessions(constructStrippedSessionObject(session),
{
init: true,
status: 'ok',
errors: 1,
release: '1.1'
}
)
}
else if (sessionCounter === 2) {
assertSessions(constructStrippedSessionObject(session),
{
init: false,
status: 'exited',
errors: 1,
release: '1.1'
}
)
}
else {
console.log('FAIL: Received way too many Sessions!');
process.exit(1);
sessionCounts.sessionCounter++;
if (sessionCounts.sessionCounter === 1) {
assertSessions(constructStrippedSessionObject(session), {
init: true,
status: 'ok',
errors: 1,
release: '1.1',
});
} else if (sessionCounts.sessionCounter === 2) {
assertSessions(constructStrippedSessionObject(session), {
init: false,
status: 'exited',
errors: 1,
release: '1.1',
});
}
return super.sendSession(session);
}
Expand All @@ -43,7 +39,7 @@ Sentry.init({
dsn: 'http://[email protected]/1337',
release: '1.1',
transport: DummyTransport,
autoSessionTracking: true
autoSessionTracking: true,
});

/**
Expand All @@ -54,8 +50,7 @@ Sentry.init({
* `beforeExit` event which happens right before the process exits.
*/
try {
throw new Error('hey there')
}
catch(e) {
throw new Error('hey there');
} catch (e) {
Sentry.captureException(e);
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
const Sentry = require('../../../../dist');
const { assertSessions, constructStrippedSessionObject, BaseDummyTransport } = require('../test-utils');
const {
assertSessions,
constructStrippedSessionObject,
BaseDummyTransport,
validateSessionCountFunction,
} = require('../test-utils');

let sessionCounter = 0;
process.on('exit', ()=> {
if (process.exitCode !== 1) {
console.log('SUCCESS: All application mode sessions were sent to node transport as expected');
}
})
const sessionCounts = {
sessionCounter: 0,
expectedSessions: 1,
};

validateSessionCountFunction(sessionCounts);

class DummyTransport extends BaseDummyTransport {
sendSession(session) {
sessionCounter++;
if (sessionCounter === 1) {
assertSessions(constructStrippedSessionObject(session),
{
init: true,
status: 'exited',
errors: 0,
release: '1.1'
}
)
}
else {
console.log('FAIL: Received way too many Sessions!');
process.exit(1);
sessionCounts.sessionCounter++;
if (sessionCounts.sessionCounter === 1) {
assertSessions(constructStrippedSessionObject(session), {
init: true,
status: 'exited',
errors: 0,
release: '1.1',
});
}
return super.sendSession(session);
}
Expand All @@ -33,7 +32,7 @@ Sentry.init({
dsn: 'http://[email protected]/1337',
release: '1.1',
transport: DummyTransport,
autoSessionTracking: true
autoSessionTracking: true,
});

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
const Sentry = require('../../../../dist');
const { assertSessions, constructStrippedSessionObject, BaseDummyTransport } = require('../test-utils');

process.on('exit', ()=> {
if (process.exitCode !== 1) {
process.on('exit', () => {
if (process.exitCode === 0) {
console.log('SUCCESS: All application mode sessions were sent to node transport as expected');
}
})
});

class DummyTransport extends BaseDummyTransport {
sendSession(session) {
assertSessions(constructStrippedSessionObject(session),
{
init: true,
status: 'crashed',
errors: 1,
release: '1.1'
}
)
assertSessions(constructStrippedSessionObject(session), {
init: true,
status: 'crashed',
errors: 1,
release: '1.1',
});
process.exit(0);
}
}
Expand All @@ -25,7 +23,7 @@ Sentry.init({
dsn: 'http://[email protected]/1337',
release: '1.1',
transport: DummyTransport,
autoSessionTracking: true
autoSessionTracking: true,
});
/**
* The following code snippet will throw an exception of `mechanism.handled` equal to `false`, and so this session
Expand All @@ -34,4 +32,4 @@ Sentry.init({
* extracts event data and uses it to update the Session and send it. No secondary session update in this case because
* we explicitly exit the process in the onUncaughtException handler and so the `beforeExit` event is not fired.
*/
throw new Error('test error')
throw new Error('test error');
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
const Sentry = require('../../../../dist');
const { assertSessions, constructStrippedSessionObject, BaseDummyTransport } = require('../test-utils');
const {
assertSessions,
constructStrippedSessionObject,
BaseDummyTransport,
validateSessionCountFunction,
} = require('../test-utils');

let sessionCounter = 0;
process.on('exit', () => {
if (process.exitCode !== 1) {
console.log('SUCCESS: All application mode sessions were sent to node transport as expected');
}
})
const sessionCounts = {
sessionCounter: 0,
expectedSessions: 1,
};

validateSessionCountFunction(sessionCounts);

class DummyTransport extends BaseDummyTransport {
sendSession(session) {
sessionCounter++;
sessionCounts.sessionCounter++;

if (sessionCounter === 1) {
assertSessions(constructStrippedSessionObject(session),
{
init: true,
status: 'crashed',
errors: 1,
release: '1.1'
}
)
if (sessionCounts.sessionCounter === 1) {
assertSessions(constructStrippedSessionObject(session), {
init: true,
status: 'crashed',
errors: 1,
release: '1.1',
});
}
else {
console.log('FAIL: Received way too many Sessions!');
process.exit(1);
}

return super.sendSession(session);
}
}
Expand All @@ -35,7 +33,7 @@ Sentry.init({
dsn: 'http://[email protected]/1337',
release: '1.1',
transport: DummyTransport,
autoSessionTracking: true
autoSessionTracking: true,
});

/**
Expand Down