1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Update segment instantiation check. Only check if SEGMENT_WRITE_KEY exists (#14407)

* segment: instantiate w/out SEGMENT_HOST check

If SEGMENT_HOST is null, then the analytics-node library will usea defaulted host

* Segment: rm IN_TEST check for instantiation
This commit is contained in:
Ariella Vu 2022-04-14 18:31:54 -03:00 committed by GitHub
parent 76615b7bec
commit 0c52723885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,6 @@
import Analytics from 'analytics-node';
import { SECOND } from '../../../shared/constants/time';
const isDevEnvironment = Boolean(
process.env.METAMASK_DEBUG && !process.env.IN_TEST,
);
const SEGMENT_WRITE_KEY = process.env.SEGMENT_WRITE_KEY ?? null;
const SEGMENT_HOST = process.env.SEGMENT_HOST ?? null;
@ -81,11 +78,10 @@ export const createSegmentMock = (flushAt = SEGMENT_FLUSH_AT) => {
return segmentMock;
};
export const segment =
!SEGMENT_WRITE_KEY || (isDevEnvironment && !SEGMENT_HOST)
? createSegmentMock(SEGMENT_FLUSH_AT, SEGMENT_FLUSH_INTERVAL)
: new Analytics(SEGMENT_WRITE_KEY, {
host: SEGMENT_HOST,
flushAt: SEGMENT_FLUSH_AT,
flushInterval: SEGMENT_FLUSH_INTERVAL,
});
export const segment = SEGMENT_WRITE_KEY
? new Analytics(SEGMENT_WRITE_KEY, {
host: SEGMENT_HOST,
flushAt: SEGMENT_FLUSH_AT,
flushInterval: SEGMENT_FLUSH_INTERVAL,
})
: createSegmentMock(SEGMENT_FLUSH_AT, SEGMENT_FLUSH_INTERVAL);