From f903e91c131531115949fa0a14a7a75105da2488 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 11:53:38 -0400 Subject: [PATCH 1/7] test: Add browser based scenarios --- scenarios/browser/basic-custom-integration.js | 23 +++++++++++++++++++ scenarios/browser/basic-custom-transport.js | 22 ++++++++++++++++++ scenarios/browser/basic-init.js | 5 ++++ .../browser/basic-no-default-integrations.js | 6 +++++ scenarios/browser/basic-with-sessions.js | 6 +++++ scenarios/browser/basic-with-tunnel.js | 6 +++++ scenarios/browser/perf-auto.js | 8 +++++++ scenarios/browser/perf-manual.js | 13 +++++++++++ scenarios/browser/react.js | 7 ++++++ 9 files changed, 96 insertions(+) create mode 100644 scenarios/browser/basic-custom-integration.js create mode 100644 scenarios/browser/basic-custom-transport.js create mode 100644 scenarios/browser/basic-init.js create mode 100644 scenarios/browser/basic-no-default-integrations.js create mode 100644 scenarios/browser/basic-with-sessions.js create mode 100644 scenarios/browser/basic-with-tunnel.js create mode 100644 scenarios/browser/perf-auto.js create mode 100644 scenarios/browser/perf-manual.js create mode 100644 scenarios/browser/react.js diff --git a/scenarios/browser/basic-custom-integration.js b/scenarios/browser/basic-custom-integration.js new file mode 100644 index 000000000000..f8e826f1d8b3 --- /dev/null +++ b/scenarios/browser/basic-custom-integration.js @@ -0,0 +1,23 @@ +import { init } from "@sentry/browser"; + +class CustomIntegration { + static id = 'CustomIntegration'; + + name = CustomIntegration.id; + options = undefined; + + constructor(options) { + this.options = options; + } + + setupOnce(addGlobalEventProcessor, getCurrentHub) { + addGlobalEventProcessor(event => event); + const hub = getCurrentHub(); + hub.captureMessage(options.name); + } +} + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + integrations: [CustomIntegration()], +}); diff --git a/scenarios/browser/basic-custom-transport.js b/scenarios/browser/basic-custom-transport.js new file mode 100644 index 000000000000..7e453b13259d --- /dev/null +++ b/scenarios/browser/basic-custom-transport.js @@ -0,0 +1,22 @@ +import { init, Transports } from "@sentry/browser"; + +class CustomTransport extends Transports.BaseTransport { + constructor(options) { + super(options); + } + + sendEvent(event) { + console.log("Sending Event"); + return super.sendEvent(event); + } + + sendSession(session) { + console.log("Sending Session"); + return super.sendSession(session); + } +} + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + transport: CustomTransport +}); diff --git a/scenarios/browser/basic-init.js b/scenarios/browser/basic-init.js new file mode 100644 index 000000000000..4a17f885a9ed --- /dev/null +++ b/scenarios/browser/basic-init.js @@ -0,0 +1,5 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); diff --git a/scenarios/browser/basic-no-default-integrations.js b/scenarios/browser/basic-no-default-integrations.js new file mode 100644 index 000000000000..fa0d50153682 --- /dev/null +++ b/scenarios/browser/basic-no-default-integrations.js @@ -0,0 +1,6 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + defaultIntegrations: false, +}); diff --git a/scenarios/browser/basic-with-sessions.js b/scenarios/browser/basic-with-sessions.js new file mode 100644 index 000000000000..9a346cf1be3a --- /dev/null +++ b/scenarios/browser/basic-with-sessions.js @@ -0,0 +1,6 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + release: "my-app@1.2.3", +}); diff --git a/scenarios/browser/basic-with-tunnel.js b/scenarios/browser/basic-with-tunnel.js new file mode 100644 index 000000000000..2716574cc3d1 --- /dev/null +++ b/scenarios/browser/basic-with-tunnel.js @@ -0,0 +1,6 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + tunnel: "/errors", +}); diff --git a/scenarios/browser/perf-auto.js b/scenarios/browser/perf-auto.js new file mode 100644 index 000000000000..ae46d8d7fb26 --- /dev/null +++ b/scenarios/browser/perf-auto.js @@ -0,0 +1,8 @@ +import { init } from "@sentry/browser"; +import { Integrations } from "@sentry/tracing"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + integrations: [new Integrations.BrowserTracing()], + tracesSampleRate: 1.0, +}); diff --git a/scenarios/browser/perf-manual.js b/scenarios/browser/perf-manual.js new file mode 100644 index 000000000000..2e4d9c523f99 --- /dev/null +++ b/scenarios/browser/perf-manual.js @@ -0,0 +1,13 @@ +import { init } from "@sentry/browser"; +import "@sentry/tracing"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + tracesSampleRate: 1.0, +}); + +const transaction = Sentry.startTransaction({ op: "task", name: "Important Stuff" }); + +setTimeout(() => { + transaction.finish(); +}, 1000); diff --git a/scenarios/browser/react.js b/scenarios/browser/react.js new file mode 100644 index 000000000000..628500c552df --- /dev/null +++ b/scenarios/browser/react.js @@ -0,0 +1,7 @@ +import { init } from "@sentry/react"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); + + From c58d9188254391dc4a083b01782bcfb68ce0bc50 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 12:05:54 -0400 Subject: [PATCH 2/7] some more scenarios --- scenarios/browser/basic-no-client-reports.js | 6 ++++++ scenarios/browser/basic-no-dsn.js | 3 +++ scenarios/browser/basic-no-sessions.js | 7 +++++++ scenarios/browser/basic-with-debug.js | 6 ++++++ scenarios/browser/{basic-init.js => basic.js} | 0 5 files changed, 22 insertions(+) create mode 100644 scenarios/browser/basic-no-client-reports.js create mode 100644 scenarios/browser/basic-no-dsn.js create mode 100644 scenarios/browser/basic-no-sessions.js create mode 100644 scenarios/browser/basic-with-debug.js rename scenarios/browser/{basic-init.js => basic.js} (100%) diff --git a/scenarios/browser/basic-no-client-reports.js b/scenarios/browser/basic-no-client-reports.js new file mode 100644 index 000000000000..5c52e71e2518 --- /dev/null +++ b/scenarios/browser/basic-no-client-reports.js @@ -0,0 +1,6 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + sendClientReports: false, +}); diff --git a/scenarios/browser/basic-no-dsn.js b/scenarios/browser/basic-no-dsn.js new file mode 100644 index 000000000000..b1e65a541bc6 --- /dev/null +++ b/scenarios/browser/basic-no-dsn.js @@ -0,0 +1,3 @@ +import { init } from "@sentry/browser"; + +init(); diff --git a/scenarios/browser/basic-no-sessions.js b/scenarios/browser/basic-no-sessions.js new file mode 100644 index 000000000000..6152ed8f4332 --- /dev/null +++ b/scenarios/browser/basic-no-sessions.js @@ -0,0 +1,7 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + release: "my-app@1.2.3", + autoSessionTracking: false, +}); diff --git a/scenarios/browser/basic-with-debug.js b/scenarios/browser/basic-with-debug.js new file mode 100644 index 000000000000..feb43c4afbee --- /dev/null +++ b/scenarios/browser/basic-with-debug.js @@ -0,0 +1,6 @@ +import { init } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + debug: true, +}); diff --git a/scenarios/browser/basic-init.js b/scenarios/browser/basic.js similarity index 100% rename from scenarios/browser/basic-init.js rename to scenarios/browser/basic.js From 6dcfceccc0a323f43107b5e38cf455f2612d8a90 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 13:03:42 -0400 Subject: [PATCH 3/7] fix perf example --- scenarios/browser/perf-manual.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scenarios/browser/perf-manual.js b/scenarios/browser/perf-manual.js index 2e4d9c523f99..ce0ecfe73746 100644 --- a/scenarios/browser/perf-manual.js +++ b/scenarios/browser/perf-manual.js @@ -1,4 +1,4 @@ -import { init } from "@sentry/browser"; +import { init, startTransaction } from "@sentry/browser"; import "@sentry/tracing"; init({ @@ -6,7 +6,7 @@ init({ tracesSampleRate: 1.0, }); -const transaction = Sentry.startTransaction({ op: "task", name: "Important Stuff" }); +const transaction = startTransaction({ op: "task", name: "Important Stuff" }); setTimeout(() => { transaction.finish(); From 79fa39f0493a47a6d375e28fa562a7d38f6a759c Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 13:11:55 -0400 Subject: [PATCH 4/7] fix custom int example --- scenarios/browser/basic-custom-integration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenarios/browser/basic-custom-integration.js b/scenarios/browser/basic-custom-integration.js index f8e826f1d8b3..2ef4864e2c78 100644 --- a/scenarios/browser/basic-custom-integration.js +++ b/scenarios/browser/basic-custom-integration.js @@ -19,5 +19,5 @@ class CustomIntegration { init({ dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", - integrations: [CustomIntegration()], + integrations: [new CustomIntegration()], }); From bbe09d886b6330df8c4cf1ba64e8f751c1cb3db8 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 13:15:14 -0400 Subject: [PATCH 5/7] Add capture exception/message --- scenarios/browser/basic-capture-exception.js | 7 +++++++ scenarios/browser/basic-capture-message.js | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 scenarios/browser/basic-capture-exception.js create mode 100644 scenarios/browser/basic-capture-message.js diff --git a/scenarios/browser/basic-capture-exception.js b/scenarios/browser/basic-capture-exception.js new file mode 100644 index 000000000000..d8f49c6e8f91 --- /dev/null +++ b/scenarios/browser/basic-capture-exception.js @@ -0,0 +1,7 @@ +import { init, captureException } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); + +captureException(new Error("error here!")); diff --git a/scenarios/browser/basic-capture-message.js b/scenarios/browser/basic-capture-message.js new file mode 100644 index 000000000000..cc1c36996db1 --- /dev/null +++ b/scenarios/browser/basic-capture-message.js @@ -0,0 +1,7 @@ +import { init, captureMessage } from "@sentry/browser"; + +init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); + +captureMessage("this is a message"); From f4c1227bdecbf1dcd96e9e09038b8027edebda31 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 13:12:56 -0400 Subject: [PATCH 6/7] test: Add node scenarios --- scenarios/node/basic-custom-integration.js | 23 +++++++++++++++++++ scenarios/node/basic-custom-transport.js | 22 ++++++++++++++++++ scenarios/node/basic-no-client-repors.js | 6 +++++ .../node/basic-no-default-integrations.js | 6 +++++ scenarios/node/basic-no-dsn.js | 3 +++ scenarios/node/basic-no-sessions.js | 7 ++++++ scenarios/node/basic-with-debug.js | 6 +++++ scenarios/node/basic-with-sessions.js | 6 +++++ scenarios/node/basic.js | 5 ++++ scenarios/node/perf-manual.js | 13 +++++++++++ 10 files changed, 97 insertions(+) create mode 100644 scenarios/node/basic-custom-integration.js create mode 100644 scenarios/node/basic-custom-transport.js create mode 100644 scenarios/node/basic-no-client-repors.js create mode 100644 scenarios/node/basic-no-default-integrations.js create mode 100644 scenarios/node/basic-no-dsn.js create mode 100644 scenarios/node/basic-no-sessions.js create mode 100644 scenarios/node/basic-with-debug.js create mode 100644 scenarios/node/basic-with-sessions.js create mode 100644 scenarios/node/basic.js create mode 100644 scenarios/node/perf-manual.js diff --git a/scenarios/node/basic-custom-integration.js b/scenarios/node/basic-custom-integration.js new file mode 100644 index 000000000000..c48893f2065d --- /dev/null +++ b/scenarios/node/basic-custom-integration.js @@ -0,0 +1,23 @@ +const Sentry = require("@sentry/node"); + +class CustomIntegration { + static id = 'CustomIntegration'; + + name = CustomIntegration.id; + options = undefined; + + constructor(options) { + this.options = options; + } + + setupOnce(addGlobalEventProcessor, getCurrentHub) { + addGlobalEventProcessor(event => event); + const hub = getCurrentHub(); + hub.captureMessage(options.name); + } +} + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + integrations: [new CustomIntegration()] +}); diff --git a/scenarios/node/basic-custom-transport.js b/scenarios/node/basic-custom-transport.js new file mode 100644 index 000000000000..acc752119682 --- /dev/null +++ b/scenarios/node/basic-custom-transport.js @@ -0,0 +1,22 @@ +const Sentry = require("@sentry/node"); + +class CustomTransport extends Sentry.Transports.BaseTransport { + constructor(options) { + super(options); + } + + sendEvent(event) { + console.log("Sending Event"); + return super.sendEvent(event); + } + + sendSession(session) { + console.log("Sending Session"); + return super.sendSession(session); + } +} + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + transport: CustomTransport, +}); diff --git a/scenarios/node/basic-no-client-repors.js b/scenarios/node/basic-no-client-repors.js new file mode 100644 index 000000000000..c9835b4bc191 --- /dev/null +++ b/scenarios/node/basic-no-client-repors.js @@ -0,0 +1,6 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + sendClientReports: false, +}); diff --git a/scenarios/node/basic-no-default-integrations.js b/scenarios/node/basic-no-default-integrations.js new file mode 100644 index 000000000000..c50825805dc2 --- /dev/null +++ b/scenarios/node/basic-no-default-integrations.js @@ -0,0 +1,6 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + defaultIntegrations: false, +}); diff --git a/scenarios/node/basic-no-dsn.js b/scenarios/node/basic-no-dsn.js new file mode 100644 index 000000000000..b3763108f26f --- /dev/null +++ b/scenarios/node/basic-no-dsn.js @@ -0,0 +1,3 @@ +const Sentry = require("@sentry/node"); + +Sentry.init(); diff --git a/scenarios/node/basic-no-sessions.js b/scenarios/node/basic-no-sessions.js new file mode 100644 index 000000000000..09eb42df0e68 --- /dev/null +++ b/scenarios/node/basic-no-sessions.js @@ -0,0 +1,7 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + release: "my-app@1.2.3", + autoSessionTracking: false, +}); diff --git a/scenarios/node/basic-with-debug.js b/scenarios/node/basic-with-debug.js new file mode 100644 index 000000000000..884d46db495d --- /dev/null +++ b/scenarios/node/basic-with-debug.js @@ -0,0 +1,6 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + debug: true, +}); diff --git a/scenarios/node/basic-with-sessions.js b/scenarios/node/basic-with-sessions.js new file mode 100644 index 000000000000..e8b885ae8d90 --- /dev/null +++ b/scenarios/node/basic-with-sessions.js @@ -0,0 +1,6 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + release: "my-app@1.2.3", +}); diff --git a/scenarios/node/basic.js b/scenarios/node/basic.js new file mode 100644 index 000000000000..bd094c14111a --- /dev/null +++ b/scenarios/node/basic.js @@ -0,0 +1,5 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); diff --git a/scenarios/node/perf-manual.js b/scenarios/node/perf-manual.js new file mode 100644 index 000000000000..9464c12347eb --- /dev/null +++ b/scenarios/node/perf-manual.js @@ -0,0 +1,13 @@ +const Sentry = require("@sentry/node"); +const _ = require("@sentry/tracing"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", + tracesSampleRate: 1.0, +}); + +const transaction = Sentry.startTransaction({ op: "task", name: "Important Stuff" }); + +setTimeout(() => { + transaction.finish(); +}, 1000); From 0fdee663edbef137e47ae206fb7ca3275ed1236e Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 Oct 2021 13:16:17 -0400 Subject: [PATCH 7/7] Add capture exception/message --- scenarios/node/basic-capture-exception.js | 7 +++++++ scenarios/node/basic-capture-message.js | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 scenarios/node/basic-capture-exception.js create mode 100644 scenarios/node/basic-capture-message.js diff --git a/scenarios/node/basic-capture-exception.js b/scenarios/node/basic-capture-exception.js new file mode 100644 index 000000000000..0088c1c007b8 --- /dev/null +++ b/scenarios/node/basic-capture-exception.js @@ -0,0 +1,7 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); + +Sentry.captureException(new Error("error here!")); diff --git a/scenarios/node/basic-capture-message.js b/scenarios/node/basic-capture-message.js new file mode 100644 index 000000000000..37b7ec4fb43f --- /dev/null +++ b/scenarios/node/basic-capture-message.js @@ -0,0 +1,7 @@ +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000", +}); + +Sentry.captureMessage("this is a message");