@@ -23,13 +23,31 @@ import { CCA3D } from "./3d/cca_3d"
23
23
import type { AutomatonBase } from "./types/Automaton"
24
24
import type { Settings } from "./types/Settings"
25
25
import { fetchMoviePalettes , moviePalettes } from "./utils/fetchMoviePalettes"
26
+ import * as Sentry from "@sentry/browser"
26
27
27
28
let pane : Pane
28
29
let settings : Settings
29
30
let automaton : AutomatonBase
30
31
31
32
const MOVIES_PALETTES_API = import . meta. env . VITE_MOVIES_PALETTES_API
32
33
34
+ // Initialize Sentry before any other code
35
+ Sentry . init ( {
36
+ dsn : import . meta. env . VITE_SENTRY_DSN ,
37
+ environment : import . meta. env . VITE_ENVIRONMENT ,
38
+ release : APP_VERSION ,
39
+ integrations : [
40
+ Sentry . browserTracingIntegration ( ) ,
41
+ Sentry . replayIntegration ( ) ,
42
+ ] ,
43
+ // Tracing
44
+ tracesSampleRate : 1.0 , // Capture 100% of the transactions
45
+ // Session Replay
46
+ replaysSessionSampleRate : 0.1 , // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
47
+ replaysOnErrorSampleRate : 1.0 , // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
48
+ } )
49
+
50
+
33
51
window . onload = ( ) => {
34
52
const getInitialAlgo = ( ) => {
35
53
const path = window . location . pathname . slice ( 1 ) // Remove leading slash
@@ -393,72 +411,78 @@ const createAutomaton = async (
393
411
height : number ,
394
412
settings : Settings ,
395
413
) : Promise < AutomatonBase > => {
396
- const resolution : number = settings . resolution || 5
397
- const paletteColors = settings . palette
398
- ? moviePalettes . get ( settings . palette ) ?. colors
399
- : undefined
400
-
401
- switch ( settings . algo ) {
402
- case "cca-1D" :
403
- return new CCA1D (
404
- canvasEl ,
405
- width ,
406
- height ,
407
- settings . cca1dColorsCount || 4 ,
408
- paletteColors ,
409
- )
410
- case "cca-2D" :
411
- return new CCA2D (
412
- settings . cca2dThreshold ,
413
- canvasEl ,
414
- width ,
415
- height ,
416
- resolution ,
417
- settings . cca2dColorsCount ,
418
- paletteColors ,
419
- )
420
- case "cca-3D" :
421
- return new CCA3D (
422
- canvasEl ,
423
- width ,
424
- height ,
425
- settings . cca3dCubeDimension ,
426
- settings . cca3dThreshold ,
427
- settings . cca3dColorsCount ,
428
- paletteColors ,
429
- )
430
- case "conway" :
431
- return new ConwayAutomaton ( canvasEl , width , height , resolution )
432
- case "immigration" :
433
- return new ImmigrationAutomaton (
434
- canvasEl ,
435
- width ,
436
- height ,
437
- resolution ,
438
- undefined , // colorsCount (will be forced to 3)
439
- paletteColors , // Pass palette colors
440
- )
441
- case "quadlife" :
442
- return new QuadLifeAutomaton (
443
- canvasEl ,
444
- width ,
445
- height ,
446
- resolution ,
447
- undefined , // colorsCount (will be forced to 5)
448
- paletteColors , // Pass palette colors
449
- )
450
- case "langton" :
451
- return new LangtonAutomaton ( canvasEl , width , height , resolution )
452
- case "entropy" :
453
- return new EntropyAutomaton (
454
- canvasEl ,
455
- width ,
456
- height ,
457
- resolution ,
458
- settings . entropyColorsCount ,
459
- )
460
- default :
461
- throw new Error ( `Unknown algorithm: ${ settings . algo } ` )
414
+ try {
415
+ const resolution : number = settings . resolution || 5
416
+ const paletteColors = settings . palette
417
+ ? moviePalettes . get ( settings . palette ) ?. colors
418
+ : undefined
419
+
420
+ switch ( settings . algo ) {
421
+ case "cca-1D" :
422
+ return new CCA1D (
423
+ canvasEl ,
424
+ width ,
425
+ height ,
426
+ settings . cca1dColorsCount || 4 ,
427
+ paletteColors ,
428
+ )
429
+ case "cca-2D" :
430
+ return new CCA2D (
431
+ settings . cca2dThreshold ,
432
+ canvasEl ,
433
+ width ,
434
+ height ,
435
+ resolution ,
436
+ settings . cca2dColorsCount ,
437
+ paletteColors ,
438
+ )
439
+ case "cca-3D" :
440
+ return new CCA3D (
441
+ canvasEl ,
442
+ width ,
443
+ height ,
444
+ settings . cca3dCubeDimension ,
445
+ settings . cca3dThreshold ,
446
+ settings . cca3dColorsCount ,
447
+ paletteColors ,
448
+ )
449
+ case "conway" :
450
+ return new ConwayAutomaton ( canvasEl , width , height , resolution )
451
+ case "immigration" :
452
+ return new ImmigrationAutomaton (
453
+ canvasEl ,
454
+ width ,
455
+ height ,
456
+ resolution ,
457
+ undefined , // colorsCount (will be forced to 3)
458
+ paletteColors , // Pass palette colors
459
+ )
460
+ case "quadlife" :
461
+ return new QuadLifeAutomaton (
462
+ canvasEl ,
463
+ width ,
464
+ height ,
465
+ resolution ,
466
+ undefined , // colorsCount (will be forced to 5)
467
+ paletteColors , // Pass palette colors
468
+ )
469
+ case "langton" :
470
+ return new LangtonAutomaton ( canvasEl , width , height , resolution )
471
+ case "entropy" :
472
+ return new EntropyAutomaton (
473
+ canvasEl ,
474
+ width ,
475
+ height ,
476
+ resolution ,
477
+ settings . entropyColorsCount ,
478
+ )
479
+ default :
480
+ throw new Error ( `Unknown algorithm: ${ settings . algo } ` )
481
+ }
482
+ } catch ( error ) {
483
+ Sentry . captureException ( error )
484
+ console . error ( "Failed to create automaton:" , error )
485
+ throw error
462
486
}
463
487
}
464
488
0 commit comments