forked from ansh/jiffyreader.com
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ansh#270 from asieduernest12/master
Improve post install behaviour
- Loading branch information
Showing
4 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Logger from './Logger'; | ||
|
||
export enum EventCategory { | ||
APP_EVENT = 'APP_EVENT', | ||
INTERNAL_CODE_EVENT = 'INTERNAL_CODE_EVENT', | ||
USER_EVENT = 'USER_EVENT', | ||
} | ||
|
||
function trackEvent( | ||
eventData: { eventCategory: EventCategory; eventName: string; eventType: string; [key: string]: any }, | ||
appData: { browser; version } = { browser: process.env.TARGET, version: process.env.VERSION }, | ||
date = new Date(), | ||
enableTracking = /true/.test(process.env.ENABLE_TRACKING), | ||
) { | ||
Logger.logInfo({ enableTracking }); | ||
if (!enableTracking) { | ||
return; | ||
} | ||
|
||
const params = new URLSearchParams({ ...{ time: date.toString(), time_iso: date.toISOString(), ...eventData }, ...appData }); | ||
Logger.logInfo('track-event', params.toString()); | ||
return fetch(process.env.HOME_URL ?? 'https://jiffyreader.com' + `/track-event?${params.toString()}`); | ||
} | ||
|
||
const TrackEventService = { | ||
trackEvent, | ||
}; | ||
|
||
export default TrackEventService; |