-
Notifications
You must be signed in to change notification settings - Fork 177
feat: add Sentry integration to simulator #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SouparnaChatterjee
wants to merge
1
commit into
CircuitVerse:main
Choose a base branch
from
SouparnaChatterjee:sentry-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,210 +1,58 @@ | ||
| import { setup } from './setup' | ||
| import { setup } from './setup'; | ||
| import Array from './arrayHelpers'; | ||
| import { initSentry } from './sentry'; | ||
|
|
||
| // Initialize Sentry first | ||
| initSentry(); | ||
|
|
||
| document.addEventListener('DOMContentLoaded', () => { | ||
| setup() | ||
| var js = { | ||
| devices: { | ||
| dev0: { | ||
| type: 'Input', | ||
| net: 'clk', | ||
| order: 0, | ||
| bits: 1, | ||
| }, | ||
| dev1: { | ||
| type: 'Input', | ||
| net: 'addr', | ||
| order: 1, | ||
| bits: 4, | ||
| }, | ||
| dev2: { | ||
| type: 'Output', | ||
| net: 'data', | ||
| order: 2, | ||
| bits: 5, | ||
| }, | ||
| dev3: { | ||
| type: 'Input', | ||
| net: 'addr2', | ||
| order: 3, | ||
| bits: 4, | ||
| }, | ||
| dev4: { | ||
| type: 'Output', | ||
| net: 'data2', | ||
| order: 4, | ||
| bits: 5, | ||
| }, | ||
| dev5: { | ||
| type: 'Input', | ||
| net: 'wraddr', | ||
| order: 5, | ||
| bits: 4, | ||
| }, | ||
| dev6: { | ||
| type: 'Input', | ||
| net: 'wrdata', | ||
| order: 6, | ||
| bits: 5, | ||
| }, | ||
| dev7: { | ||
| type: 'Input', | ||
| net: 'wraddr2', | ||
| order: 7, | ||
| bits: 4, | ||
| }, | ||
| dev8: { | ||
| type: 'Input', | ||
| net: 'wrdata2', | ||
| order: 8, | ||
| bits: 5, | ||
| }, | ||
| dev9: { | ||
| label: 'mem', | ||
| type: 'Memory', | ||
| bits: 5, | ||
| abits: 4, | ||
| words: 16, | ||
| offset: 0, | ||
| rdports: [ | ||
| {}, | ||
| { | ||
| clock_polarity: true, | ||
| }, | ||
| ], | ||
| wrports: [ | ||
| { | ||
| clock_polarity: true, | ||
| }, | ||
| { | ||
| clock_polarity: true, | ||
| }, | ||
| setup(); | ||
|
|
||
| // Demo simulation JSON | ||
| const js = { | ||
| "devices": { | ||
| "dev0": { "type": "Input", "net": "clk", "order": 0, "bits": 1 }, | ||
| "dev1": { "type": "Input", "net": "addr", "order": 1, "bits": 4 }, | ||
| "dev2": { "type": "Output", "net": "data", "order": 2, "bits": 5 }, | ||
| "dev3": { "type": "Input", "net": "addr2", "order": 3, "bits": 4 }, | ||
| "dev4": { "type": "Output", "net": "data2", "order": 4, "bits": 5 }, | ||
| "dev5": { "type": "Input", "net": "wraddr", "order": 5, "bits": 4 }, | ||
| "dev6": { "type": "Input", "net": "wrdata", "order": 6, "bits": 5 }, | ||
| "dev7": { "type": "Input", "net": "wraddr2", "order": 7, "bits": 4 }, | ||
| "dev8": { "type": "Input", "net": "wrdata2", "order": 8, "bits": 5 }, | ||
| "dev9": { | ||
| "label": "mem", | ||
| "type": "Memory", | ||
| "bits": 5, | ||
| "abits": 4, | ||
| "words": 16, | ||
| "offset": 0, | ||
| "rdports": [{}, { "clock_polarity": true }], | ||
| "wrports": [ | ||
| { "clock_polarity": true }, | ||
| { "clock_polarity": true } | ||
| ], | ||
| memdata: [13, '00001', 3, '11111'], | ||
| }, | ||
| "memdata": [13, "00001", 3, "11111"] | ||
| } | ||
| }, | ||
| connectors: [ | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'rd1clk', | ||
| }, | ||
| from: { | ||
| id: 'dev0', | ||
| port: 'out', | ||
| }, | ||
| name: 'clk', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'wr0clk', | ||
| }, | ||
| from: { | ||
| id: 'dev0', | ||
| port: 'out', | ||
| }, | ||
| name: 'clk', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'wr1clk', | ||
| }, | ||
| from: { | ||
| id: 'dev0', | ||
| port: 'out', | ||
| }, | ||
| name: 'clk', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'rd0addr', | ||
| }, | ||
| from: { | ||
| id: 'dev1', | ||
| port: 'out', | ||
| }, | ||
| name: 'addr', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev2', | ||
| port: 'in', | ||
| }, | ||
| from: { | ||
| id: 'dev9', | ||
| port: 'rd0data', | ||
| }, | ||
| name: 'data', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'rd1addr', | ||
| }, | ||
| from: { | ||
| id: 'dev3', | ||
| port: 'out', | ||
| }, | ||
| name: 'addr2', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev4', | ||
| port: 'in', | ||
| }, | ||
| from: { | ||
| id: 'dev9', | ||
| port: 'rd1data', | ||
| }, | ||
| name: 'data2', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'wr0addr', | ||
| }, | ||
| from: { | ||
| id: 'dev5', | ||
| port: 'out', | ||
| }, | ||
| name: 'wraddr', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'wr0data', | ||
| }, | ||
| from: { | ||
| id: 'dev6', | ||
| port: 'out', | ||
| }, | ||
| name: 'wrdata', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'wr1addr', | ||
| }, | ||
| from: { | ||
| id: 'dev7', | ||
| port: 'out', | ||
| }, | ||
| name: 'wraddr2', | ||
| }, | ||
| { | ||
| to: { | ||
| id: 'dev9', | ||
| port: 'wr1data', | ||
| }, | ||
| from: { | ||
| id: 'dev8', | ||
| port: 'out', | ||
| }, | ||
| name: 'wrdata2', | ||
| }, | ||
|
|
||
| "connectors": [ | ||
| { "to": { "id": "dev9", "port": "rd1clk" }, "from": { "id": "dev0", "port": "out" }, "name": "clk" }, | ||
| { "to": { "id": "dev9", "port": "wr0clk" }, "from": { "id": "dev0", "port": "out" }, "name": "clk" }, | ||
| { "to": { "id": "dev9", "port": "wr1clk" }, "from": { "id": "dev0", "port": "out" }, "name": "clk" }, | ||
| { "to": { "id": "dev9", "port": "rd0addr" }, "from": { "id": "dev1", "port": "out" }, "name": "addr" }, | ||
| { "to": { "id": "dev2", "port": "in" }, "from": { "id": "dev9", "port": "rd0data" }, "name": "data" }, | ||
| { "to": { "id": "dev9", "port": "rd1addr" }, "from": { "id": "dev3", "port": "out" }, "name": "addr2" }, | ||
| { "to": { "id": "dev4", "port": "in" }, "from": { "id": "dev9", "port": "rd1data" }, "name": "data2" }, | ||
| { "to": { "id": "dev9", "port": "wr0addr" }, "from": { "id": "dev5", "port": "out" }, "name": "wraddr" }, | ||
| { "to": { "id": "dev9", "port": "wr0data" }, "from": { "id": "dev6", "port": "out" }, "name": "wrdata" }, | ||
| { "to": { "id": "dev9", "port": "wr1addr" }, "from": { "id": "dev7", "port": "out" }, "name": "wraddr2" }, | ||
| { "to": { "id": "dev9", "port": "wr1data" }, "from": { "id": "dev8", "port": "out" }, "name": "wrdata2" } | ||
| ], | ||
| subcircuits: {}, | ||
| } | ||
| }) | ||
|
|
||
| "subcircuits": {} | ||
| }; | ||
|
|
||
| // Make array helpers globally available | ||
| window.Array = Array; | ||
| }); | ||
This file contains hidden or 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,39 @@ | ||
| import * as Sentry from "@sentry/browser"; | ||
| import { BrowserTracing } from "@sentry/tracing"; | ||
|
|
||
| export function initSentry() { | ||
| const isLocalDev = | ||
| window.location.hostname === "localhost" || | ||
| window.location.hostname === "127.0.0.1"; | ||
|
|
||
| Sentry.init({ | ||
| dsn: "https://5f707d900ca6bd2a13fbe838135c0742@o4510363436187648.ingest.us.sentry.io/4510363491237888", | ||
|
|
||
| integrations: [ | ||
| new BrowserTracing({ | ||
| tracingOrigins: ["localhost", /^\//], | ||
| }), | ||
| ], | ||
|
|
||
| environment: isLocalDev ? "development" : "production", | ||
|
|
||
| tracesSampleRate: 1.0, | ||
|
|
||
| beforeSend(event, hint) { | ||
| // Prevent sending events while developing | ||
| if (isLocalDev) { | ||
| console.log("⚠️ Sentry blocked (development mode):", event); | ||
| return null; | ||
| } | ||
| return event; | ||
| }, | ||
|
|
||
| initialScope: { | ||
| tags: { | ||
| application: "circuitverse-simulator", | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| console.log("✅ Sentry initialized"); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding the native
Arrayconstructor onwindowis risky and should be avoidedImporting
Arrayfrom./arrayHelpers(Line 2) and then doingwindow.Array = Array;(Line 57) replaces the built‑inwindow.Arraywith your custom implementation. This:noShadowRestrictedNameswarning.Arraysemantics,instanceof Array,Array.isArray, or static methods added by the JS engine.A safer pattern is to avoid shadowing the global and expose the helper under a distinct name:
If existing simulator code expects a global helper, align on a non‑conflicting name (
window.SimulatorArray,window.ArrayHelpers, etc.) rather than reusingArray.Also applies to: 56-57
🧰 Tools
🪛 Biome (2.1.2)
[error] 2-2: Do not shadow the global "Array" property.
Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
(lint/suspicious/noShadowRestrictedNames)
🤖 Prompt for AI Agents