-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom tracking tool to keep using calypso_ and wpcom_ events
- Loading branch information
Showing
5 changed files
with
54 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* global JP_CONNECTION_INITIAL_STATE */ | ||
|
||
export const wpcomTrackEvent = ( | ||
eventName, | ||
eventProperties = {}, | ||
eventUserId = null, | ||
eventUsername = null | ||
) => { | ||
const currentUser = JP_CONNECTION_INITIAL_STATE?.userConnectionData?.currentUser ?? {}; | ||
|
||
const userId = eventUserId ?? currentUser.id; | ||
const username = eventUsername ?? currentUser.username; | ||
const blogId = eventProperties.blogId ?? currentUser.blogId; | ||
|
||
window._tkq = window._tkq || []; | ||
if ( username && userId ) { | ||
window._tkq.push( [ 'identifyUser', userId, username ] ); | ||
} | ||
window._tkq.push( [ | ||
'recordEvent', | ||
eventName, | ||
{ | ||
...eventProperties, | ||
blog_id: blogId, | ||
}, | ||
] ); | ||
}; |
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
12 changes: 6 additions & 6 deletions
12
projects/packages/jetpack-mu-wpcom/src/features/wpcom-sidebar-notice/wpcom-sidebar-notice.js
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