@lerix-dev/lerix-nextjs 1.4.0 or later. For what each module does
and what you see in the dashboard, read Feedback,
NPS surveys and Analytics.
Setup
AddLerixScreenTracker once, inside the LerixNextProvider from
Installation. It records a $screen_view
per pathname through usePathname(), and turns off the SDK’s History API
tracking so nothing is counted twice.
app/layout.tsx
name maps a pathname to a screen name. Use it to group dynamic
routes, so /products/42 and /products/43 count as one screen. Return
null to skip a path.
Without LerixScreenTracker (in the Pages Router, for example), URL changes
are still recorded through the History API.
Environment
LerixNextProvider reads NEXT_PUBLIC_LERIX_ENVIRONMENT as the default
environment. Without it, the SDK sends dev on localhost and *.local or in
debug mode, and prod elsewhere.
.env.production
options prop also takes locale, analytics, feedback
(theme, primaryColor, strings, zIndex) and captureConsoleErrors. They
work as in React.
In-app feedback
components/feedback-button.tsx
show(options?) takes labels, email, screenshot, prefillEmail
and custom, and submit({ message, labels?, email?, screenshots?, custom? })
sends feedback from your own form. See React
for the full option list.
Mask sensitive content in screenshots:
NPS survey
app/(app)/home-client.tsx
maybeShowNps() from useLerixSurvey() yourself, with
{ force: true } while testing. See
When the survey is shown.
Analytics
$first_open,$session_start/$session_end,$app_updateand$screen_vieware recorded automatically.useLerixScreen('Settings / Billing')names a screen the URL doesn’t, such as a tab or a modal step.Lerix.analytics.setEnabled(false)is the persisted opt-out, andLerix.analytics.flush()sends right away.Lerixis re-exported from@lerix-dev/lerix-nextjs.
Call
setUser after sign-in. Analytics then
counts the person across devices, and you can reply to their feedback by
push.