generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added app name identifier in segment events (#1277)
* feat: added app name identifier in registration call * feat: added utils for tracking events * refactor: mapped login events * refactor: mapped forgot password events * refactor: mapped reset password events * refactor: mapped register events * fix: fixed unit tests * refactor: mapped progressive prifiling events * fix: fixed unit tests * refactor: added app name in logistration events * refactor: resolved PR reviews and fixed tests
- Loading branch information
1 parent
efaa83a
commit 0d603b5
Showing
24 changed files
with
419 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import { sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics'; | ||
|
||
import { APP_NAME } from '../constants'; | ||
|
||
export const LINK_TIMEOUT = 300; | ||
|
||
/** | ||
* Creates an event tracker function that sends a tracking event with the given name and options. | ||
* | ||
* @param {string} name - The name of the event to be tracked. | ||
* @param {object} [options={}] - Additional options to be included with the event. | ||
* @returns {function} - A function that, when called, sends the tracking event. | ||
*/ | ||
export const createEventTracker = (name, options = {}) => () => sendTrackEvent( | ||
name, | ||
{ ...options, app_name: APP_NAME }, | ||
); | ||
|
||
/** | ||
* Creates an event tracker function that sends a tracking event with the given name and options. | ||
* | ||
* @param {string} name - The name of the event to be tracked. | ||
* @param {object} [options={}] - Additional options to be included with the event. | ||
* @returns {function} - A function that, when called, sends the tracking event. | ||
*/ | ||
export const createPageEventTracker = (name, options = null) => () => sendPageEvent( | ||
name, | ||
options, | ||
{ app_name: APP_NAME }, | ||
); | ||
|
||
export const createLinkTracker = (tracker, href) => (e) => { | ||
e.preventDefault(); | ||
tracker(); | ||
return setTimeout(() => { window.location.href = href; }, LINK_TIMEOUT); | ||
}; |
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
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
Oops, something went wrong.