Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit e7d6e6b

Browse files
authored
Merge pull request #3106 from withspectrum/2.2.12
2.2.12
2 parents 6b0e4fd + e113239 commit e7d6e6b

File tree

302 files changed

+7788
-3949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+7788
-3949
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ npm-debug.log
77
build
88
.DS_Store
99
src/config/FirebaseConfig.js
10-
npm-debug.log
1110
rethinkdb_data
1211
debug
1312
now-secrets.json

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ build-mercury
1818
build-vulcan
1919
build-hyperion
2020
build-pluto
21+
build-analytics
2122
package-lock.json
2223
.vscode
2324
dump.rdb

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
flow-typed
2-
package.json
2+
package.json
3+
shared/analytics/event-types/*

analytics/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// @flow
2+
const debug = require('debug')('analytics');
3+
import createWorker from '../shared/bull/create-worker';
4+
5+
import trackAnalytics from './queues/track-analytics';
6+
import identifyAnalytics from './queues/identify-analytics';
7+
8+
import { TRACK_ANALYTICS, IDENTIFY_ANALYTICS } from './queues/constants';
9+
10+
const PORT = process.env.PORT || 3009;
11+
12+
debug('\n📈 Analytics worker is starting...');
13+
debug('Logging with debug enabled!');
14+
debug('');
15+
16+
const server = createWorker({
17+
[TRACK_ANALYTICS]: trackAnalytics,
18+
[IDENTIFY_ANALYTICS]: identifyAnalytics,
19+
});
20+
21+
debug(
22+
`🗄 Queues open for business ${(process.env.NODE_ENV === 'production' &&
23+
// $FlowIssue
24+
`at ${process.env.COMPOSE_REDIS_URL}:${process.env.COMPOSE_REDIS_PORT}`) ||
25+
'locally'}`
26+
);
27+
28+
// $FlowIssue
29+
server.listen(PORT, 'localhost', () => {
30+
debug(
31+
`💉 Healthcheck server running at ${server.address().address}:${
32+
server.address().port
33+
}`
34+
);
35+
});

analytics/models/channel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @flow
2+
import type { DBChannel } from 'shared/types';
3+
import { db } from './db';
4+
5+
export const getChannelById = (channelId: string): Promise<DBChannel> => {
6+
return db
7+
.table('channels')
8+
.get(channelId)
9+
.run();
10+
};

analytics/models/community.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @flow
2+
import type { DBCommunity } from 'shared/types';
3+
import { db } from './db';
4+
5+
export const getCommunityById = (communityId: string): Promise<DBCommunity> => {
6+
return db
7+
.table('communities')
8+
.get(communityId)
9+
.run();
10+
};

analytics/models/db.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// @flow
2+
/**
3+
* Database setup is done here
4+
*/
5+
const IS_PROD = !process.env.FORCE_DEV && process.env.NODE_ENV === 'production';
6+
7+
const DEFAULT_CONFIG = {
8+
db: 'spectrum',
9+
max: 100, // Maximum number of connections, default is 1000
10+
buffer: 10, // Minimum number of connections open at any given moment, default is 50
11+
timeoutGb: 60 * 1000, // How long should an unused connection stick around, default is an hour, this is a minute
12+
};
13+
14+
const PRODUCTION_CONFIG = {
15+
password: process.env.AWS_RETHINKDB_PASSWORD,
16+
host: process.env.AWS_RETHINKDB_URL,
17+
port: process.env.AWS_RETHINKDB_PORT,
18+
};
19+
20+
const config = IS_PROD
21+
? {
22+
...DEFAULT_CONFIG,
23+
...PRODUCTION_CONFIG,
24+
}
25+
: {
26+
...DEFAULT_CONFIG,
27+
};
28+
29+
var r = require('rethinkdbdash')(config);
30+
31+
module.exports = { db: r };

analytics/models/message.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @flow
2+
import type { DBMessage } from 'shared/types';
3+
import { db } from './db';
4+
5+
export const getMessageById = (messageId: string): Promise<DBMessage> => {
6+
return db
7+
.table('messages')
8+
.get(messageId)
9+
.run();
10+
};

analytics/models/notification.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @flow
2+
import type { DBNotification } from 'shared/types';
3+
import { db } from './db';
4+
5+
export const getNotificationById = (
6+
notificationId: string
7+
): Promise<DBNotification> => {
8+
return db
9+
.table('notifications')
10+
.get(notificationId)
11+
.run();
12+
};

analytics/models/reaction.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @flow
2+
import type { DBReaction } from 'shared/types';
3+
import { db } from './db';
4+
5+
export const getReactionById = (reactionId: string): Promise<DBReaction> => {
6+
return db
7+
.table('reactions')
8+
.get(reactionId)
9+
.run();
10+
};

0 commit comments

Comments
 (0)