#
Migrate to v1.0
This rewrite of Workleap's LogRocket instrumentation focuses on leveraging the native LogRocket library directly, rather than abstracting it away and on adding two correlation ids, telemetryId
and deviceId
, to help unify and correlate data across LogRocket, Honeycomb and Mixpanel. Finally a new built-in integration allow other telemetry libraries to automatically add the LogRocket session replay URL to their traces/events.
Follow this guide to migrate from @workleap-tracking/logrocket
👇
#
Breaking changes
🚨 The new package name is @workleap/logrocket
.
#
Removed
- The
registerAnonymousLogRocketInstrumentation
function doesn't exist anymore, use registerLogRocketInstrumentation instead. - The
getTrackingIdentifier
function doesn't exist anymore. A similar identifier is now automatically added as a user trait for every session replay. - The
registerLogRocketInstrumentation
functiontrackingIdentifier
,identifyOptions
andonSessionUrlInitialized
options doesn't exist anymore.
#
Renamed
- The
WorkleapLogRocketIdentification
TypeScript interface has been renamed toLogRocketIdentification
. - The
WorkleapUserTraits
TypeScript interface has been renamed toLogRocketUserTraits
.
#
Others
- The
@workleap/telemetry
package is a new peer dependency of the@workleap/logrocket
package. - The
logrocket
package is a new peer dependency of the@workleap/logrocket
package.
#
Changes to registerLogRocketInstrumentation
- The
getTrackingIdentifier
function andtrackingIdentifier
option do not exist anymore. A similar identifier is now automatically added as a user trait for every session replay. - The
identifyOptions
option has been removed, use createDefaultUserTraits and the native LogRocket.identify function instead. - The
onSessionUrlInitialized
option has been removed, use the native LogRocket.getSessionURL function instead. - The function arguments changed from
(options: {})
to(appId, options: {})
.
Before:
import { getTrackingIdentifier, registerLogRocketInstrumentation } from "@workleap-tracking/logrocket";
const user = {
userId: "6a5e6b06-0cac-44ee-8d2b-00b9419e7da9",
organizationId: "e6bb30f8-0a00-4928-8943-1630895a3f14",
organizationName: "Acme",
isMigratedToWorkleap: true,
isAdmin: false,
isOrganizationCreator: false,
isReportingManager: false,
isTeamManager: false,
isExecutive: { wov: true },
isCollaborator: { wov: true },
planCode: { wov: "wov-essential-monthly-std" }
};
const trackingIdentifier = getTrackingIdentifier({
generateCookieOnDefault: true,
pregeneratedTrackingIdentifier: user.userId
});
registerLogRocketInstrumentation({
appId,
trackingIdentifier,
identifyOptions: user,
onSessionUrlInitialized: async (sessionUrl) => sendSessionUrlToTrackingService(...)
});
After:
import { registerLogRocketInstrumentation, createDefaultUserTraits } from "@workleap/logrocket";
import LogRocket from "logrocket";
const traits = createDefaultUserTraits({
userId: "6a5e6b06-0cac-44ee-8d2b-00b9419e7da9",
organizationId: "e6bb30f8-0a00-4928-8943-1630895a3f14",
organizationName: "Acme",
isMigratedToWorkleap: true,
isAdmin: false,
isOrganizationCreator: false,
isReportingManager: false,
isTeamManager: false,
isExecutive: { wov: true },
isCollaborator: { wov: true },
planCode: { wov: "wov-essential-monthly-std" }
});
registerLogRocketInstrumentation(appId);
LogRocket.getSessionURL((sessionUrl) => sendSessionUrlToTrackingService(sessionUrl));
LogRocket.identify(traits.userId, traits);
#
Removed registerAnonymousLogRocketInstrumentation
The registerAnonymousLogRocketInstrumentation
function doesn't exist anymore, use registerLogRocketInstrumentation instead.
Before:
import { getTrackingIdentifier, registerAnonymousLogRocketInstrumentation } from "@workleap-tracking/logrocket";
const trackingIdentifier = getTrackingIdentifier({
generateCookieOnDefault: true
});
registerAnonymousLogRocketInstrumentation({
appId,
trackingIdentifier
});
After:
import { registerLogRocketInstrumentation } from "@workleap/logrocket";
import LogRocket from "logrocket";
registerLogRocketInstrumentation(appId);
#
Add new dependencies
- Add the
@workleap/telemetry
dependency to the host application. - Add the
logrocket
dependency to the host application.
#
Improvements
#
Correlation ids
To help unify and correlate data across LogRocket, Honeycomb, and Mixpanel, the registerLogRocketInstrumentation function now automatically adds two correlation ids as user traits to every session replay:
telemetryId
is a new identifier that represents a single application load.deviceId
replaces the formertrackingId
and reuses the original name from thewl-identity
cookie, better reflecting its purpose as a persistent device identifier.
#
Session URL enrichment
A built-in integration now automatically allows other telemetry libraries to include the LogRocket session replay URL in their traces or events.
For example, with the Honeycomb integration, once the LogRocket session URL is retrieved, each trace is enriched with an app.logrocket_session_url
attribute:
#
Migrate from @workleap-tracking/logrocket
Follow these steps to migrate an existing application @workleap-tracking/logrocket
to @workleap/logrocket
:
- Add a dependency to
@workleap/telemetry
. - Rename
registerAnonymousLogRocketInstrumentation
to registerLogRocketInstrumentation. - Remove all usage of
getTrackingIdentifier
. The new registerLogRocketInstrumentation function automatically sets the tracking identifier as a correlation id under theDevice Id
name. - Remove the
trackingIdentifier
andidentifyOptions
options. To identify a user, use createDefaultUserTraits in combination to LogRocket.identify. View example - Replace the
onSessionUrlInitialized
option with the LogRocket.getSessionUrl function. View example - Rename any instances of
WorkleapLogRocketIdentification
toLogRocketIdentification
. - Rename any instances of
WorkleapUserTraits
toLogRocketUserTraits
.