Skip to content

Commit

Permalink
Update namings
Browse files Browse the repository at this point in the history
  • Loading branch information
amortemousque committed Jan 15, 2024
1 parent b1152cb commit 65e5af0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
16 changes: 5 additions & 11 deletions packages/core/src/transport/eventBridge.ts
Expand Up @@ -6,8 +6,7 @@ export interface BrowserWindowWithEventBridge extends Window {
}

export interface DatadogEventBridge {
getWebViewId?(): string
getParentRecordPrivacyLevel?(): string
getPrivacyLevel?(): string
getAllowedWebViewHosts(): string
send(msg: string): void
}
Expand All @@ -20,20 +19,15 @@ export function getEventBridge<T, E>() {
}

return {
getWebViewId() {
const webviewId = eventBridgeGlobal.getWebViewId?.()
if (webviewId) {
return Number(webviewId)
}
},
getParentRecordPrivacyLevel() {
return eventBridgeGlobal.getParentRecordPrivacyLevel?.()
getPrivacyLevel() {
return eventBridgeGlobal.getPrivacyLevel?.()
},
getAllowedWebViewHosts() {
return JSON.parse(eventBridgeGlobal.getAllowedWebViewHosts()) as string[]
},
send(eventType: T, event: E, viewId?: string) {
eventBridgeGlobal.send(JSON.stringify({ eventType, event, viewId }))
const view = viewId ? { id: viewId } : undefined
eventBridgeGlobal.send(JSON.stringify({ eventType, event, view }))
},
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/emulate/eventBridge.ts
Expand Up @@ -2,7 +2,6 @@ import type { BrowserWindowWithEventBridge } from '../../src/transport'

export function initEventBridgeStub(allowedWebViewHosts: string[] = [window.location.hostname]) {
const eventBridgeStub = {
getNestedEnvId: () => 1,
send: (_msg: string) => undefined,
getAllowedWebViewHosts: () => JSON.stringify(allowedWebViewHosts),
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rum-core/src/boot/rumPublicApi.ts
Expand Up @@ -376,7 +376,7 @@ export function makeRumPublicApi(
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sessionSampleRate: 100,
defaultPrivacyLevel: getEventBridge()?.getParentRecordPrivacyLevel(),
defaultPrivacyLevel: getEventBridge()?.getPrivacyLevel(),
})
}
}
4 changes: 2 additions & 2 deletions packages/rum/src/domain/startRecordBridge.ts
@@ -1,4 +1,4 @@
import { assign, getEventBridge } from '@datadog/browser-core'
import { getEventBridge } from '@datadog/browser-core'
import type { ViewContexts } from '@datadog/browser-rum-core'
import type { BrowserRecord } from '../types'
import * as replayStats from './replayStats'
Expand All @@ -13,7 +13,7 @@ export function startRecordBridge(viewContexts: ViewContexts) {
return
}
replayStats.addRecord(view.id)
bridge.send('record', assign(record, { nestedEnvId: bridge.getWebViewId() }), view.id)
bridge.send('record', record, view.id)
},
}
}

0 comments on commit 65e5af0

Please sign in to comment.