-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Remove moment as a dependency #458
Conversation
b8529d9
to
d2186db
Compare
@@ -334,7 +333,7 @@ const onReady = async () => { | |||
document.body.addEventListener("connected", () => { | |||
if (!isBotMode) { | |||
hubChannel.sendEntryEvent().then(() => { | |||
store.update({ activity: { lastEnteredAt: moment().toJSON() } }); |
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.
unfortunately we can't do this, because this is a persistent schema in local storage. we'll need to either create a new field or write something to migrate the old data. (new clients will throw when the json is passed to the Date constructor I presume)
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.
(my preference is we write a migration script given that this will break our stats otherwise)
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.
I'm not sure I follow. The new version should be putting the exact same value as the old version into the store, namely a string with the current UTC ISO8601 datetime. The Date
constructor knows how to parse that.
(moment().toJSON()
sounds funny, but it just means to return an appropriate JSON serialization of a moment
value, which is as above. It's meant to be used with JSON.stringify
, which calls toJSON
on the objects it visits.)
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.
ah I misunderstood. i assumed it was returning some kind of JSON blob
lastEnteredPst.dayOfYear() !== nowPst.dayOfYear() || lastEnteredPst.year() !== nowPst.year(); | ||
entryTimingFlags.isNewMonthly = | ||
lastEnteredPst.month() !== nowPst.month() || lastEnteredPst.year() !== nowPst.year(); | ||
entryTimingFlags.isNewDayWindow = lastEntered.isBefore(dayWindowAgo); |
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.
this seems OK I think -- it changes what we're measuring but we haven't used these fields yet anyhow
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.
need to deal with the existing local storage state
There's no changes to the data in local storage.
This was 400KB of functionality we didn't really need.
The only functionality difference here should be that the
isNewDayWindow
andisNewMonthWindow
flags are based on fixed intervals of 3600 * 24 and 3600 * 24 * 30 seconds respectively, instead of being one month or day of calendar time. Frankly, this seems better to me for most kinds of analytics anyone would want to do. @gfodor should take a look and decide whether he finds that desirable or undesirable -- we could do it either way if we wanted.