Clearer logging when developing
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react-native, typescript
- Domain
- developer-experience, observability
Research direction
No source files or tests are named. Start by locating the configuration and the default event logging path, then compare it with the custom Logger plugin described in the issue. Done means custom event logging can be used without overwriting the logger or disabling unrelated debug and error logs.
Written by the indexing model from the issue text.
Description
Summary
Our use case:
Visualize all the events in the app from the developer tools console tab. Currently they are quite hard to differentiate
We decided to create a custom plugin since we want to log each event with some nice CSS (Yes, the console supports a limited subset of CSS(!)). But for this implementation it would nice to remove the default logging behaviour of events, but without needing to overwrite the logging instance. I would prefer to have an API or abstraction level where I only work with events.
With our custom plugin we have to disable "debug", but that would probably swallow some imporant logs. We did add a errorHandler though
Proposed Solution
Add a disableDefaultLoggingOfEvents:boolean to the config. Or make it easier to handle events in the Logger
Here is our logger for the curious
/* eslint-disable no-console */
import { PluginType, Plugin } from '@segment/analytics-react-native';
export class LoggerPlugin extends Plugin {
type = PluginType.after;
execute(event: any) {
// This is actually a SegmentEvent, but we use 'any' because its such a pain to make correct
try {
const version = event.context?.protocols?.event_version ?? 1;
const kind = event.type?.toUpperCase() === 'SCREEN' ? 'SCREEN' : 'TRACK';
const tag = `[${kind}V${version}]`;
const name = (event.type === 'screen' ? event.name : event.event) || event.name || 'Unknown Event';
const props = event.properties ?? {};
const tagStyle =
version === 1
? 'background:#0969da;color:#fff;padding:1px 6px;border-radius:999px;font-weight:700'
: 'background:#8250df;color:#fff;padding:1px 6px;border-radius:999px;font-weight:700';
const nameStyle =
'background:rgba(9,105,218,0.18);color:#e6edf3;padding:1px 6px;border-radius:8px;font-weight:800;font-size:12.5px';
const sepStyle = 'color:#8b949e';
console.log(
'%c%s %c%s %c',
tagStyle,
tag,
nameStyle,
name,
sepStyle,
props
);
} catch (error) {
console.error('[LoggerPlugin] Error logging event:', error);
console.log('Event data:', event);
}
return event;
}
}
- Dominant language
- TypeScript
- Stars
- 384
- Forks
- 205
- Avg merge
- 12h 17m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from segmentio/analytics-react-native
-
chunk() never resets its size counter: past 500 KB every queued event is uploaded as its own requestOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
segmentio/analytics-react-native#1334 · 1 reaction ·
Maintainers usually reply within 1 day
-
Typo in `useSegmentEndpoints` client option in READMEPossibly taken @abueide claimed this 34 days ago. Openbug investigate
Difficulty 1/5 Under an hour Newbie friendliness 72/100
segmentio/analytics-react-native#1145 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 68/100
segmentio/analytics-react-native#1328 ·
Maintainers usually reply within 1 day
-
`chunk()` returns a sparse array when one event exceeds `maxKB`, stalling the event queue (regression in 2.23.0)Possibly taken A pull request linked to this issue is open or already merged. Openbug investigate
Difficulty 3/5 1-2 days Newbie friendliness 78/100
segmentio/analytics-react-native#1309 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
segmentio/analytics-react-native#1124 · 3 comments ·
Maintainers usually reply within 1 day
All issues in segmentio/analytics-react-native
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
rossoctl/serverless-harness#428 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
prime-radiant-inc/evener#3726 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
FuRongJun-1999/dsh-memory#56 ·
Maintainers usually reply within 1 day
-
bug via-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pingdotgg/t3code#15682 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openwatersio/slackwater.xyz#152 ·
Maintainers usually reply within 1 day