-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Heart
committed
Mar 24, 2024
1 parent
dd9b941
commit b0a24a8
Showing
4 changed files
with
33 additions
and
23 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 was deleted.
Oops, something went wrong.
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 { ReactPlugin } from "@microsoft/applicationinsights-react-js"; | ||
import { ApplicationInsights } from "@microsoft/applicationinsights-web"; | ||
import { createHashHistory } from "history"; | ||
|
||
const history = createHashHistory(); | ||
const reactPlugin = new ReactPlugin(); | ||
const appInsights = new ApplicationInsights({ | ||
config: { | ||
connectionString: import.meta.env.VITE_ANALYTICS_KEY, | ||
enableAutoRouteTracking: true, | ||
extensions: [reactPlugin], | ||
extensionConfig: { | ||
[reactPlugin.identifier]: { history }, | ||
}, | ||
}, | ||
}); | ||
|
||
export function loadAnalytics() { | ||
if (import.meta.env.VITE_ANALYTICS_KEY) { | ||
appInsights.loadAppInsights(); | ||
} | ||
} | ||
|
||
export function trackEvent(event: { | ||
name: string; | ||
properties?: Record<string, any>; | ||
}) { | ||
reactPlugin.trackEvent(event); | ||
} |