-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GTM event tracking #51599
Merged
Merged
Add GTM event tracking #51599
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
beead63
track sign ups
arosiclair a919b8f
track created workspaces
arosiclair b9b26e4
track created workspaces from the categorize tracked expense flow
arosiclair a633ea4
track paid adoption
arosiclair 2ac7699
mock firebase analytics
arosiclair 13101ca
replace withOnyx with useOnyx
arosiclair b05efd9
Merge branch 'arosiclair-gtm-lib' of github.com:Expensify/App into ar…
arosiclair 4d135d4
add sign_up test
arosiclair 9f14812
add createWorkspace test
arosiclair 86a4dbe
add test for categorizing tracked expense
arosiclair 45df579
add paid_adoption tests
arosiclair c4727b0
simplify test names
arosiclair edada2d
share onyx state across tests
arosiclair e6fc1f0
filter out personal policies
arosiclair 144ad9b
Merge branch 'arosiclair-gtm-lib' into arosiclair-gtm-events
arosiclair 51425d9
Merge branch 'main' of github.com:Expensify/App into arosiclair-gtm-e…
arosiclair 117f6c0
load third party scripts in both staging and prod
arosiclair c4822ca
Merge branch 'main' of github.com:Expensify/App into arosiclair-gtm-e…
arosiclair d4e4e90
fix bad merge
arosiclair 447d06f
use consts for event names
arosiclair File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,5 @@ | ||
export default function analytics() { | ||
return { | ||
logEvent: jest.fn(), | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,6 +62,7 @@ import * as CurrencyUtils from '@libs/CurrencyUtils'; | |||||
import DateUtils from '@libs/DateUtils'; | ||||||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||||||
import getIsNarrowLayout from '@libs/getIsNarrowLayout'; | ||||||
import GoogleTagManager from '@libs/GoogleTagManager'; | ||||||
import Log from '@libs/Log'; | ||||||
import * as NetworkStore from '@libs/Network/NetworkStore'; | ||||||
import * as NumberUtils from '@libs/NumberUtils'; | ||||||
|
@@ -1838,6 +1839,11 @@ function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName | |||||
const {optimisticData, failureData, successData, params} = buildPolicyData(policyOwnerEmail, makeMeAdmin, policyName, policyID, undefined, engagementChoice); | ||||||
API.write(WRITE_COMMANDS.CREATE_WORKSPACE, params, {optimisticData, successData, failureData}); | ||||||
|
||||||
// Publish a workspace created event if this is their first policy | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB, I wonder if the events and should be called workspace or policy since we try to keep everything in the BE as policy. Also its weird to see both of them in the comment on one line :D
Suggested change
|
||||||
if (getAdminPolicies().length === 0) { | ||||||
GoogleTagManager.publishEvent(CONST.ANALYTICS.EVENT.WORKSPACE_CREATED, sessionAccountID); | ||||||
} | ||||||
|
||||||
return params; | ||||||
} | ||||||
|
||||||
|
@@ -3743,6 +3749,10 @@ function setWorkspaceEReceiptsEnabled(policyID: string, eReceipts: boolean) { | |||||
API.write(WRITE_COMMANDS.SET_WORKSPACE_ERECEIPTS_ENABLED, parameters, onyxData); | ||||||
} | ||||||
|
||||||
function getAdminPolicies(): Policy[] { | ||||||
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && policy.type !== CONST.POLICY.TYPE.PERSONAL); | ||||||
} | ||||||
|
||||||
function getAdminPoliciesConnectedToSageIntacct(): Policy[] { | ||||||
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.intacct); | ||||||
} | ||||||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there cases when this effect could run multiple times for the user? ie they will get to this point and close the app. They will come back to it later and we will again send the sign_up event. Not sure if its a problem though, just thought about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah if they restart/refresh the app during onboarding, this would get called again. Since it's kind of an edge case we're just ignoring that for now. Also it's not too big of a deal as long as it stays consistent between A/B tests.