Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/renderer-protocol/inverseRpc/rpcServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRpcServer, RpcServerPort, Transport } from '@dcl/rpc'
import { RendererProtocolContext } from './context'
import { registerEmotesKernelService } from './services/emotesService'
import { registerAnalyticsKernelService } from './services/analyticsService'

export function createRendererProtocolInverseRpcServer(transport: Transport) {
const server = createRpcServer<RendererProtocolContext>({})
Expand All @@ -19,4 +20,5 @@ export function createRendererProtocolInverseRpcServer(transport: Transport) {
*/
async function registerKernelServices(serverPort: RpcServerPort<RendererProtocolContext>) {
registerEmotesKernelService(serverPort)
registerAnalyticsKernelService(serverPort)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { RpcServerPort } from '@dcl/rpc'
import { RendererProtocolContext } from '../context'
import * as codegen from '@dcl/rpc/dist/codegen'
import { AnalyticsKernelServiceDefinition } from '@dcl/protocol/out-ts/decentraland/renderer/kernel_services/analytics.gen'
import { getPerformanceInfo } from '../../../shared/session/getPerformanceInfo'
import { getUnityInstance } from '../../../unity-interface/IUnityInterface'
import { trackEvent } from '../../../shared/analytics'
import { setDelightedSurveyEnabled } from '../../../unity-interface/delightedSurvey'
import { browserInterface } from '../../..//unity-interface/BrowserInterface'

type UnityEvent = any

export function registerAnalyticsKernelService(port: RpcServerPort<RendererProtocolContext>) {
codegen.registerService(port, AnalyticsKernelServiceDefinition, async () => ({
async analyticsEvent(req, _) {
const properties: Record<string, string> = {}
if (req.properties) {
for (const property of req.properties) {
properties[property.key] = property.value
}
}

trackEvent(req.eventName as UnityEvent, { context: properties.context || 'unity-event', ...properties })
return {}
},
async performanceReport(req, _) {
let estimatedAllocatedMemory = 0
let estimatedTotalMemory = 0
if (getUnityInstance()?.Module?.asmLibraryArg?._GetDynamicMemorySize) {
estimatedAllocatedMemory = getUnityInstance().Module.asmLibraryArg._GetDynamicMemorySize()
estimatedTotalMemory = getUnityInstance().Module.asmLibraryArg._GetTotalMemorySize()
}
const perfReport = getPerformanceInfo({ ...(req as any), estimatedAllocatedMemory, estimatedTotalMemory })
trackEvent('performance report', perfReport)
return {}
},
async setDelightedSurveyEnabled(req, _) {
setDelightedSurveyEnabled(req.enabled)
return {}
},
async systemInfoReport(req, _) {
trackEvent('system info report', req)

// @deprecated
browserInterface.startedFuture.resolve()
return {}
}
}))
}
5 changes: 4 additions & 1 deletion packages/unity-interface/BrowserInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export class BrowserInterface {
globalObservable.emit('openUrl', data)
}

/** @deprecated */
public PerformanceReport(data: Record<string, unknown>) {
let estimatedAllocatedMemory = 0
let estimatedTotalMemory = 0
Expand All @@ -325,7 +326,7 @@ export class BrowserInterface {
trackEvent('performance report', perfReport)
}

// TODO: remove useBinaryTransform after SDK7 is fully in prod
/** @deprecated TODO: remove useBinaryTransform after SDK7 is fully in prod */
public SystemInfoReport(data: SystemInfoPayload & { useBinaryTransform?: boolean }) {
trackEvent('system info report', data)

Expand All @@ -340,6 +341,7 @@ export class BrowserInterface {
// stub. there is no code about this in unity side yet
}

/** @deprecated */
public Track(data: { name: string; properties: { key: string; value: string }[] | null }) {
const properties: Record<string, string> = {}
if (data.properties) {
Expand Down Expand Up @@ -574,6 +576,7 @@ export class BrowserInterface {
// It's disabled because of security reasons.
}

/** @deprecated */
public SetDelightedSurveyEnabled(data: { enabled: boolean }) {
setDelightedSurveyEnabled(data.enabled)
}
Expand Down
1 change: 0 additions & 1 deletion packages/unity-interface/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ async function loadInjectedUnityDelegate(
const transport = webTransport({ wasmModule: originalUnity.Module }, (globalThis as any).DCL)

await engineStartedFuture
await browserInterface.startedFuture
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was preventing the RPC from starting...

this is already being awaited here:

await browserInterface.startedFuture

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still work in desktop? I remember this was a bugfix


document.body.addEventListener('click', () => {
browserInterface.onUserInteraction.resolve()
Expand Down