Canonical tags
https://growthacking.kr/캐노니컬-태그-canonical-tag로-검색엔진-최적화하기/
- We received a report through Channel Talk that the paths of a few pages were not being detected. I haven’t looked closely at the Channel Talk documentation yet, but…
Shallow copies and deep copies
I noticed something strange while working with an object. I assigned filterResponse to a new variable, newFilter, and modified newFilter. I thought assigning it to a new variable before processing it would preserve the original, but filterResponse itself changed too. The bug came from overlooking the difference between shallow and deep copies.
const newFilterList = useMemo(() => {
if (!filterResponse) return {};
let newFilter = filterResponse[filterParams.productType];
// Properties are removed from filterResponse itself, not just newFilter.
delete newFilter[SearchQueryKey.CONTENTTYPES];
delete newFilter[SearchQueryKey.EDITABLES];
return newFilter;
}, [filterResponse, filterParams.productType]);
Shallow copy: an object’s reference
A shallow copy means the original and copied values point to the same reference when an object is copied.
If an object contains other objects, and even one still references an object in the original variable, it is a shallow copy.
=> The outer object is new, but values inside it copy references to values in the cloned object.
=> This happened because newFilter copied the address.
Deep copy: an object’s actual values An object variable points to the object’s address, so copying its reference makes both variables point to the same value. Modifying it changes the original too.
- JSON.parse && JSON.stringify
- Spread: a deep copy only at the first level. These are two approaches, and I chose spread because it was convenient. The important caveat is that spread only makes a deep copy at the first level. From the second level onward, it is a shallow copy.
const newFilterList = useMemo(() => {
if (!filterResponse) return {};
// Make a deep copy to avoid changing the original object.
let newFilter = { ...filterResponse[filterParams.productType] };
delete newFilter[SearchQueryKey.CONTENTTYPES];
delete newFilter[SearchQueryKey.EDITABLES];
return newFilter;
}, [filterResponse, filterParams.productType]);
Trying Suspense
During this sprint, we discussed introducing Suspense globally. We expected making loading UI mandatory would make future feature development more efficient than adding it individually each time.
- Global adoption: adding the suspense option to React Query means components must be wrapped in Suspense. Adding it to every page at once would be difficult.
- Performance: memory usage increased from 120 MB to 400 MB.
- Slowdown: a waterfall issue made selecting filters slower. => Apparently React Query’s useSuspenseQueries can resolve this. These drawbacks surfaced, but there are solutions to some extent. Rather than adopting it globally right away, it would be good to start with a lightweight page.
A quick note on Mixpanel’s “not set” property issue
In Mixpanel, “Session Start” is a virtual event that begins when a user performs a particular event. Sessions can be configured in three ways: Timeout Based, Event Based, or Property Based. The chosen method determines when the “Session Start” event occurs.
For example, with Property Based sessions, a chosen property such as “session_id” is defined as the “Session Id,” and the session continues as long as that property’s value stays the same. A new session begins when the “Session ID” value changes. Events without a “Session Id” value are not used to calculate session start and end events. In that case, a “Session Start” event may not occur.
The “Session Start” event also automatically inherits certain properties from the first event in a session. If a property is missing, it may appear as “(not set).”
There are therefore two main reasons a property on “Session Start” may appear as “not set”:
- The “Session Id” value is missing in a Property Based session.
- A property that should be inherited from the session’s first event is missing.
To resolve this, you can troubleshoot “undefined” property values on the Events page. This lets you see which events occur without the property and inspect the code to find out why.
References:
https://mixpanel.com/blog/top-user-onboarding-metrics/
Reflections
The week flew by.
I feel like I’m spending much less time racing against the clock than before.
This week, I’ve been thinking about code reviews. I’ve started putting real effort into reviewing code,
and I’m wondering what kind of review actually has a positive effect.
* Anyone can review code. You don't have to be a developer.
* Try to write code that even someone who isn't a developer can understand.
* Code review is not a place to scold someone or blame them by asking why they did something that way. Receiving a review doesn't absolve the author of responsibility, either.
* Code review is about checking each other's mistakes and looking together for things to improve.
* Code review should be fun. You can use memes. Please do. It's encouraged. Make it enjoyable.
* Reviewing code by someone more skilled than you teaches you a lot. It's fine to leave a comment like, “Wow, I didn't know you could do it this way.”
I’ve been trying to find only improvements or bugs during reviews. I should leave more positive comments too.
I’ve been wondering what to do with the time I have left. I should write tests. Let’s focus on that. Honestly, there is so much to do that I’m finding it hard to set priorities.