Skip to content

Commit f0265fb

Browse files
feat: Add new E@ launch parameters (#479)
1 parent aebca38 commit f0265fb

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

src/integration/analytics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { store } from '../state/redux'
55
import { getRequiredAnalyticsContext } from '../state/selectors'
66
import { errorToString } from '../utils/errorToString'
77
import { getRepositoryName, getRepositoryVersion, track } from '../utils/tracking'
8-
import { getCurrentPosition } from './browser'
8+
import { getExplorerLaunchParameters } from './browser'
99
import { DEBUG_ANALYTICS, PLATFORM, RENDERER_TYPE } from './url'
1010

1111
let analyticsDisabled = false
@@ -42,7 +42,7 @@ export function configureSegment() {
4242
}
4343

4444
function injectTrackingMetadata(payload: Record<string, any>): void {
45-
Object.assign(payload, getCurrentPosition())
45+
Object.assign(payload, getExplorerLaunchParameters())
4646
payload.dcl_is_authenticated = authFlags.isAuthenticated
4747
payload.dcl_is_guest = authFlags.isGuest
4848
payload.dcl_disabled_analytics = authFlags.afterFatalError

src/integration/browser.ts

+24-11
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,36 @@ export function isMacOS() {
104104
return false
105105
}
106106

107-
export type UserPosition = Partial<{
108-
realm: string
109-
position: string
107+
export type ExplorerLaunchParameters = Partial<{
108+
realm: string | undefined
109+
position: string | undefined
110+
'self-preview-builder-collections': string | undefined
111+
dclenv: string | undefined
110112
}>
111113

112-
export function getCurrentPosition() {
113-
const data: UserPosition = {}
114+
export function getExplorerLaunchParameters() {
115+
const data: ExplorerLaunchParameters = {}
114116
const qs = new URLSearchParams(globalThis.location.search || '')
115117

116-
// inject realm
117-
if (qs.has('realm')) {
118-
data.realm = qs.get('realm')!
118+
const realm = qs.get('realm')
119+
const position = qs.get('position')
120+
const selfPreviewBuilderCollections = qs.get('self-preview-builder-collections')
121+
const dclenv = qs.get('dclenv')
122+
123+
if (realm) {
124+
data.realm = realm
125+
}
126+
127+
if (position) {
128+
data.position = position
129+
}
130+
131+
if (selfPreviewBuilderCollections) {
132+
data['self-preview-builder-collections'] = selfPreviewBuilderCollections
119133
}
120134

121-
// inject position
122-
if (qs.has('position')) {
123-
data.position = qs.get('position')!
135+
if (dclenv) {
136+
data.dclenv = dclenv
124137
}
125138

126139
return data

src/integration/desktop.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { setDownloadNewVersion, setDownloadProgress, setDownloadReady, setKernelError } from '../state/actions'
22
import { store } from '../state/redux'
33
import { callOnce } from '../utils/callOnce'
4-
import { getCurrentPosition, hasRecentlyLoggedIn, isMobile } from './browser'
4+
import { getExplorerLaunchParameters, hasRecentlyLoggedIn, isMobile } from './browser'
55
import { SKIP_SETUP } from './url'
66

77
export const isElectron = callOnce((): boolean => {
@@ -79,15 +79,8 @@ export const launchDesktopApp = async (force = false) => {
7979
}
8080

8181
// build custom protocol target using current url `position` and `realm`
82-
const data = getCurrentPosition()
83-
let customProtocolParams: string[] = []
84-
if (data.position) {
85-
customProtocolParams.push(`position=${data.position}`)
86-
}
87-
88-
if (data.realm) {
89-
customProtocolParams.push(`realm=${data.realm}`)
90-
}
82+
const data = getExplorerLaunchParameters()
83+
let customProtocolParams: string[] = Object.entries(data).map(([key, value]) => `${key}=${value}`)
9184

9285
const customProtocolTarget = `decentraland://?${customProtocolParams.join('&')}`
9386

0 commit comments

Comments
 (0)