Skip to content

Commit 83c6e52

Browse files
committed
fix(mobile): improve code block readability and New Relic integration
- Add darker syntax highlighting colors for code blocks in light theme - Fix New Relic version reporting to use APP_VERSION constant - Wrap New Relic initialization in try-catch to prevent startup crashes - Remove mobile-only version bump logic from release workflow - Update htmlGenerator to support theme-specific code styling
1 parent 41aaf85 commit 83c6e52

File tree

3 files changed

+91
-47
lines changed

3 files changed

+91
-47
lines changed

apps/mobile/v1/index.js

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,68 @@
1-
import 'expo-router/entry';
21
import { Platform } from 'react-native';
2+
import { APP_VERSION } from './src/constants/version';
33

4-
// Initialize New Relic agent
4+
// Initialize New Relic with error handling
55
try {
66
const NewRelic = require('newrelic-react-native-agent');
7-
const { version } = require('./package.json');
87

9-
// New Relic tokens for iOS and Android
10-
let appToken;
8+
if (NewRelic && NewRelic.startAgent) {
9+
let appToken;
1110

12-
if (Platform.OS === 'ios') {
13-
appToken = 'AA4947ff8556e29649729eb4a51ec43c236e936603-NRMA';
14-
} else {
15-
appToken = 'AAd9a8f7117b043a06ea91e7f4afb65cf34344223f-NRMA';
16-
}
11+
if (Platform.OS === 'ios') {
12+
appToken = 'AAc3e01a8a8dfd3e2fef5e493052472740f6b4efab-NRMA';
13+
} else {
14+
appToken = 'AA29e5cbf5c69abe369e2ceed761a18688dbc00d91-NRMA';
15+
}
1716

18-
const agentConfiguration = {
19-
// Android Specific
20-
// Optional: Enable or disable collection of event data.
21-
analyticsEventEnabled: true,
17+
const agentConfiguration = {
18+
// Android Specific
19+
// Optional: Enable or disable collection of event data.
20+
analyticsEventEnabled: true,
2221

23-
// Optional: Enable or disable crash reporting.
24-
crashReportingEnabled: true,
22+
// Optional: Enable or disable crash reporting.
23+
crashReportingEnabled: true,
2524

26-
// Optional: Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested.
27-
// This will disable default and custom interactions.
28-
interactionTracingEnabled: true,
25+
// Optional: Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested.
26+
// This will disable default and custom interactions.
27+
interactionTracingEnabled: true,
2928

30-
// Optional: Enable or disable reporting successful HTTP requests to the MobileRequest event type.
31-
networkRequestEnabled: true,
29+
// Optional: Enable or disable reporting successful HTTP requests to the MobileRequest event type.
30+
networkRequestEnabled: true,
3231

33-
// Optional: Enable or disable reporting network and HTTP request errors to the MobileRequestError event type.
34-
networkErrorRequestEnabled: true,
32+
// Optional: Enable or disable reporting network and HTTP request errors to the MobileRequestError event type.
33+
networkErrorRequestEnabled: true,
3534

36-
// Optional: Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.
37-
httpResponseBodyCaptureEnabled: true,
35+
// Optional: Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.
36+
httpResponseBodyCaptureEnabled: true,
3837

39-
// Optional: Enable or disable agent logging.
40-
loggingEnabled: true,
38+
// Optional: Enable or disable agent logging.
39+
loggingEnabled: true,
4140

42-
// Optional: Specifies the log level. Omit this field for the default log level.
43-
// Options include: ERROR (least verbose), WARNING, INFO, VERBOSE, AUDIT (most verbose).
44-
logLevel: NewRelic.LogLevel.INFO,
41+
// Optional: Specifies the log level. Omit this field for the default log level.
42+
// Options include: ERROR (least verbose), WARNING, INFO, VERBOSE, AUDIT (most verbose).
43+
logLevel: NewRelic.LogLevel.INFO,
4544

46-
// iOS Specific
47-
// Optional: Enable/Disable automatic instrumentation of WebViews
48-
webViewInstrumentation: true,
45+
// iOS Specific
46+
// Optional: Enable/Disable automatic instrumentation of WebViews
47+
webViewInstrumentation: true,
4948

50-
// Optional: Set a specific collector address for sending data. Omit this field for default address.
51-
// collectorAddress: "",
49+
// Optional: Set a specific collector address for sending data. Omit this field for default address.
50+
// collectorAddress: "",
5251

53-
// Optional: Set a specific crash collector address for sending crashes. Omit this field for default address.
54-
// crashCollectorAddress: ""
55-
};
52+
// Optional: Set a specific crash collector address for sending crashes. Omit this field for default address.
53+
// crashCollectorAddress: ""
54+
};
5655

57-
// Initialize New Relic agent
58-
if (NewRelic && NewRelic.startAgent) {
5956
NewRelic.startAgent(appToken, agentConfiguration);
60-
NewRelic.setJSAppVersion(version);
57+
NewRelic.setJSAppVersion(APP_VERSION);
58+
59+
console.log('[New Relic] Agent started successfully with version:', APP_VERSION);
60+
console.log('[New Relic] Platform:', Platform.OS);
61+
} else {
62+
console.warn('[New Relic] Agent module not available');
6163
}
6264
} catch (error) {
63-
// Silently fail if New Relic initialization fails
65+
console.warn('[New Relic] Failed to initialize:', error.message);
6466
}
67+
68+
import 'expo-router/entry';

apps/mobile/v1/src/hooks/useViewNote.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ export function useViewNote(noteId: string): UseViewNoteReturn {
8585
};
8686

8787
const htmlContent = useMemo(
88-
() => note ? generateNoteHtml(note.content, theme.colors) : '',
89-
[note, theme.colors]
88+
() => note ? generateNoteHtml(note.content, theme.colors, theme.isDark) : '',
89+
[note, theme.colors, theme.isDark]
9090
);
9191

9292
return {

apps/mobile/v1/src/screens/ViewNote/htmlGenerator.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export function generateNoteHtml(
1010
mutedForeground: string;
1111
muted: string;
1212
primary: string;
13-
}
13+
},
14+
isDark: boolean = false
1415
): string {
1516
return `
1617
<!DOCTYPE html>
@@ -118,14 +119,14 @@ export function generateNoteHtml(
118119
}
119120
code {
120121
background-color: ${themeColors.muted};
121-
color: ${themeColors.foreground};
122+
color: ${isDark ? themeColors.foreground : '#000000'};
122123
padding: 2px 4px;
123124
border-radius: 4px;
124125
font-family: 'Courier New', monospace;
125126
}
126127
pre {
127128
background-color: ${themeColors.muted};
128-
color: ${themeColors.foreground};
129+
color: ${isDark ? themeColors.foreground : '#000000'};
129130
padding: 16px;
130131
border-radius: 8px;
131132
overflow-x: auto;
@@ -140,11 +141,50 @@ export function generateNoteHtml(
140141
font-family: 'Courier New', Consolas, Monaco, monospace;
141142
font-size: 14px;
142143
line-height: 1.5;
144+
color: ${isDark ? themeColors.foreground : '#000000'};
143145
}
144146
.hljs {
145147
background: ${themeColors.muted} !important;
146148
}
147149
150+
/* Override syntax highlighting colors for light theme with darker, readable colors */
151+
${!isDark ? `
152+
.hljs {
153+
color: #000000 !important;
154+
}
155+
.hljs-keyword,
156+
.hljs-selector-tag,
157+
.hljs-literal,
158+
.hljs-tag {
159+
color: #0033cc !important;
160+
}
161+
.hljs-string,
162+
.hljs-title,
163+
.hljs-section,
164+
.hljs-attribute,
165+
.hljs-attr {
166+
color: #008000 !important;
167+
}
168+
.hljs-number,
169+
.hljs-regexp {
170+
color: #cc0000 !important;
171+
}
172+
.hljs-comment,
173+
.hljs-quote {
174+
color: #555555 !important;
175+
font-style: italic !important;
176+
}
177+
.hljs-function,
178+
.hljs-name,
179+
.hljs-built_in {
180+
color: #6600cc !important;
181+
}
182+
.hljs-variable,
183+
.hljs-template-variable {
184+
color: #cc6600 !important;
185+
}
186+
` : ''}
187+
148188
/* Scrollbar styling */
149189
pre::-webkit-scrollbar {
150190
height: 6px;

0 commit comments

Comments
 (0)