Skip to content

Commit 59d04e1

Browse files
wisey29mherrman
andauthored
Update register call (#1210)
* Update register call * Update session-replay.md --------- Co-authored-by: mherrman <[email protected]>
1 parent 2928012 commit 59d04e1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pages/docs/features/session-replay.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ analytics.addSourceMiddleware(({ payload, next, integrations }) => {
111111
if (payload.type === 'track' || payload.type === 'page') {
112112
if (window.mixpanel) {
113113
const segmentDeviceId = payload.obj.anonymousId;
114-
mixpanel.register({ $device_id: segmentDeviceId });
114+
//original id
115+
mixpanel.register({ $device_id: segmentDeviceId, distinct_id : segmentDeviceId })
116+
//simplified id
117+
mixpanel.register({ $device_id: segmentDeviceId, distinct_id : "$device:"+segmentDeviceId });
115118
const sessionReplayProperties = mixpanel.get_session_recording_properties();
116119
payload.obj.properties = {
117120
...payload.obj.properties,
@@ -129,6 +132,8 @@ analytics.addSourceMiddleware(({ payload, next, integrations }) => {
129132
});
130133
```
131134

135+
136+
132137
##### mParticle: Web SDK
133138

134139
mParticle's Web SDK has a `.getDeviceId()` method which can be used to [retrieve the device_id](https://docs.mparticle.com/developers/sdk/web/initialization/#device-id-device-application-stamp). In the following example, we use this method to bind mParticle's device_id to Mixpanel's device_id, as wall as [patching `logEvent` and `logPageView`](https://docs.mparticle.com/developers/sdk/web/core-apidocs/classes/mParticle%20&%20mParticleInstance.html#index) to include session replay properties on all mParticle events. This configuration assumes you are [forwarding web requests server side](https://docs.mparticle.com/integrations/mixpanel/event/#:~:text=Forward%20Web%20Requests,bool) in the connection settings.
@@ -140,7 +145,7 @@ mixpanel.init('MIXPANEL-PROJECT-TOKEN', {
140145
window.mParticle.ready(function() {
141146
const mParticle_device_id = mParticle.getDeviceId();
142147
if (mParticle_device_id) {
143-
mixpanel.register({ $device_id: mParticle_device_id });
148+
mixpanel.register({ $device_id: mParticle_device_id, distinct_id : "$device:"+mParticle_device_id });
144149
}
145150

146151
// Patch logEvent and logPageView to include sessionReplayProperties
@@ -178,7 +183,7 @@ mixpanel.init('MIXPANEL-PROJECT-TOKEN', {
178183
window.rudderanalytics.ready(function() {
179184
const rudderAnonymousId = rudderanalytics.getAnonymousId();
180185
if (rudderAnonymousId) {
181-
mixpanel.register({ $device_id: rudderAnonymousId });
186+
mixpanel.register({ $device_id: rudderAnonymousId, distinct_id : "$device:"+rudderAnonymousId });
182187
}
183188

184189
// Patch track method to include sessionReplayProperties

0 commit comments

Comments
 (0)