Skip to content

Commit

Permalink
feat: Try out amplitude engagement SDK (#5164)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Mar 4, 2025
1 parent f760e4b commit e348826
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
17 changes: 14 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"dependencies": {
"@amplitude/analytics-browser": "^2.11.3",
"@amplitude/engagement-browser": "^0.0.5",
"@amplitude/plugin-session-replay-browser": "^1.6.24",
"@babel/core": "7.20.7",
"@babel/plugin-proposal-class-properties": "^7.12.1",
Expand Down
3 changes: 3 additions & 0 deletions frontend/web/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component, Fragment } from 'react'
import { matchPath } from 'react-router'
import { Link, withRouter } from 'react-router-dom'
import * as amplitude from '@amplitude/analytics-browser'
import { plugin as engagementPlugin } from '@amplitude/engagement-browser'
import { sessionReplayPlugin } from '@amplitude/plugin-session-replay-browser'
import NavLink from 'react-router-dom/NavLink'
import TwoFactorPrompt from './SimpleTwoFactor/prompt'
Expand Down Expand Up @@ -37,6 +38,7 @@ import HomeAside from './pages/HomeAside'
import ScrollToTop from './ScrollToTop'
import AnnouncementPerPage from './AnnouncementPerPage'
import Announcement from './Announcement'
import { plugin } from '@amplitude/plugin-session-replay-browser'

const App = class extends Component {
static propTypes = {
Expand Down Expand Up @@ -98,6 +100,7 @@ const App = class extends Component {
defaultTracking: true,
serverZone: 'EU',
})
amplitude.add(engagementPlugin())
const sessionReplayTracking = sessionReplayPlugin({
sampleRate: 0.5,
serverZone: 'EU',
Expand Down
15 changes: 15 additions & 0 deletions frontend/web/project/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ global.API = {
amplitude.setUserId(id)
const identify = new amplitude.Identify().set('email', id)
amplitude.identify(identify)
if (typeof window.engagement !== 'undefined') {
window.engagement.boot({
integrations: [
{
track: (event) => {
amplitude.track(event.event_type, event.event_properties)
},
},
],
user: {
user_id: id,
user_properties: {},
},
})
}
}
API.flagsmithIdentify()
},
Expand Down

0 comments on commit e348826

Please sign in to comment.