Skip to content
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

Merged
merged 1 commit into from
Jul 19, 2018
Merged

Remove moment as a dependency #458

merged 1 commit into from
Jul 19, 2018

Conversation

mqp
Copy link
Contributor

@mqp mqp commented Jul 17, 2018

This was 400KB of functionality we didn't really need.

The only functionality difference here should be that the isNewDayWindow and isNewMonthWindow 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.

@mqp mqp requested a review from gfodor July 17, 2018 02:54
@mqp mqp force-pushed the lets-trash-that-out branch 2 times, most recently from b8529d9 to d2186db Compare July 17, 2018 03:08
@@ -334,7 +333,7 @@ const onReady = async () => {
document.body.addEventListener("connected", () => {
if (!isBotMode) {
hubChannel.sendEntryEvent().then(() => {
store.update({ activity: { lastEnteredAt: moment().toJSON() } });
Copy link
Contributor

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)

Copy link
Contributor

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)

Copy link
Contributor Author

@mqp mqp Jul 17, 2018

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.)

Copy link
Contributor

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);
Copy link
Contributor

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

gfodor
gfodor previously requested changes Jul 17, 2018
Copy link
Contributor

@gfodor gfodor left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants