Skip to content
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

chore: [M3-6496] - Add Adobe Analytics custom event tracking #9004

Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
85f5a35
Add AA launch scripts and DCR on tracked events
mjac0bs Apr 12, 2023
ee460fc
Update satellite.track function to use generic, single identifier
mjac0bs Apr 13, 2023
dda27ec
Update launch script src assignment with logic for additional envs
mjac0bs Apr 13, 2023
92e8d42
Use a single env var from Jenkins
mjac0bs Apr 13, 2023
c582034
Disable tracking on custom events in Adobe for now
mjac0bs Apr 13, 2023
3130710
Cleanup
mjac0bs Apr 14, 2023
9f7b914
Enable direct call rule for AA custom event tracking
mjac0bs Apr 14, 2023
8a7c482
Add AA launch scripts and DCR on tracked events
mjac0bs Apr 12, 2023
5a4adb7
Update satellite.track function to use generic, single identifier
mjac0bs Apr 13, 2023
e855860
Update launch script src assignment with logic for additional envs
mjac0bs Apr 13, 2023
dfaf6af
Use a single env var from Jenkins
mjac0bs Apr 13, 2023
df22a2c
Disable tracking on custom events in Adobe for now
mjac0bs Apr 13, 2023
5ad5625
Cleanup
mjac0bs Apr 14, 2023
bdc5802
Only append Adobe Analytics script with valid url
mjac0bs Apr 18, 2023
765fe70
Merge branch 'M3-6462-integrate-adobe-analytics' into M3-6496-add-ado…
mjac0bs Apr 18, 2023
94489c0
Prevent errors if AA env is not defined
mjac0bs Apr 18, 2023
ab2b003
Update sendEvent
mjac0bs Apr 19, 2023
787b729
Test if loadScript works instead
mjac0bs Apr 19, 2023
f9d492a
Revert previous commit to move location of script
mjac0bs Apr 20, 2023
ff826e3
Merge branch 'develop' into M3-6496-add-adobe-analytics-custom-event-…
mjac0bs Apr 21, 2023
e39a7f1
Log error when sendEvent fails
mjac0bs Apr 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions packages/manager/src/utilities/ga.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { event } from 'react-ga';
import { GA_ID } from 'src/constants';
import { GA_ID, ADOBE_ANALYTICS_URL } from 'src/constants';
import { reportException } from 'src/exceptionReporting';

interface AnalyticsEvent {
category: string;
Expand All @@ -8,10 +9,26 @@ interface AnalyticsEvent {
value?: number;
}

/*
* Will throw error unless analytics is initialized
*/
export const sendEvent = (eventPayload: AnalyticsEvent): void => {
if (!ADOBE_ANALYTICS_URL) {
return;
}

// Send a Direct Call Rule if our environment is configured with an Adobe Launch script
try {
(window as any)._satellite.track('custom event', {
category: eventPayload.category,
action: eventPayload.action,
label: eventPayload.label,
value: eventPayload.value,
});
} catch (error) {
reportException(error, {
message:
'An error occurred when tracking a custom event. Adobe Launch script not loaded correctly; no analytics will be sent.',
});
}

/** only send events if we have a GA ID */
return !!GA_ID ? event(eventPayload) : undefined;
};
Expand Down