-
Notifications
You must be signed in to change notification settings - Fork 190
✨ Add initial Salesforce support. #4676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d32f6ea
Add initial Salesforce support.
BeltranBulbarellaDD c02e9bf
Guard session
BeltranBulbarellaDD 2fcb2ee
Linting
BeltranBulbarellaDD 0d952b5
Add Resources and APM support
BeltranBulbarellaDD d6d525e
Make getGlobalLocationHref mockable, patch plain usage of location
BeltranBulbarellaDD 363201b
use wire
BeltranBulbarellaDD 2655dc5
Merge branch 'main' into beltran.bulbarella/salesforce_0
BeltranBulbarellaDD 6a2eb32
Refactor for comments
BeltranBulbarellaDD 059c321
Merge branch 'main' into beltran.bulbarella/salesforce_0
BeltranBulbarellaDD f7581c2
Fix bundle
BeltranBulbarellaDD 783c96b
Use globalObject in turn of window
BeltranBulbarellaDD a8474b6
Add isCSPEventSupported function
BeltranBulbarellaDD 59232c7
Create isEventSupported and reuse it
BeltranBulbarellaDD 4f0711a
linter
BeltranBulbarellaDD 721c1a2
Remove config parameter from isEventSupported
BeltranBulbarellaDD 41a66d7
Remove views plugin and try catch debug
BeltranBulbarellaDD 045bd3c
linter
BeltranBulbarellaDD 3293b46
Fix compat
BeltranBulbarellaDD 1f4c882
Revert changes to instrumentMethod.ts
BeltranBulbarellaDD a52f0d5
Move view tracking to bundle, rename bundle
BeltranBulbarellaDD a56d75f
Merge branch 'main' into beltran.bulbarella/salesforce_0
BeltranBulbarellaDD ff6a526
Move SF packages, add README
BeltranBulbarellaDD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/rum-slim/src/domain/salesforce/salesforceViewsPlugin.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import type { RumPlugin, RumPublicApi, ViewOptions } from '@datadog/browser-rum-core' | ||
|
|
||
| export interface SalesforceViewChange { | ||
| pageReference?: unknown | ||
| view?: ViewOptions | ||
| } | ||
|
|
||
| export interface SalesforceViewsPlugin { | ||
| plugin: RumPlugin | ||
| onPageReferenceChange: (viewChange: SalesforceViewChange) => void | ||
| } | ||
|
|
||
| export function createSalesforceViewsPlugin(): SalesforceViewsPlugin { | ||
| let publicApi: Pick<RumPublicApi, 'startView'> | undefined | ||
| let pendingViewChange: SalesforceViewChange | undefined | ||
| let lastPageReferenceKey: string | undefined | ||
|
|
||
| function onPageReferenceChange(viewChange: SalesforceViewChange) { | ||
| const pageReferenceKey = getPageReferenceKey(viewChange.pageReference) | ||
| if (pageReferenceKey && pageReferenceKey === lastPageReferenceKey) { | ||
| return | ||
| } | ||
|
|
||
| if (pageReferenceKey) { | ||
| lastPageReferenceKey = pageReferenceKey | ||
| } | ||
|
|
||
| if (!publicApi) { | ||
| pendingViewChange = viewChange | ||
| return | ||
| } | ||
|
|
||
| startView(viewChange) | ||
| } | ||
|
|
||
| function startView(viewChange: SalesforceViewChange) { | ||
| if (viewChange.view) { | ||
| publicApi?.startView(viewChange.view) | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| plugin: { | ||
| name: 'salesforce', | ||
| onInit({ initConfiguration, publicApi: rumPublicApi }) { | ||
| initConfiguration.trackViewsManually = true | ||
| publicApi = rumPublicApi | ||
|
|
||
| if (pendingViewChange) { | ||
| startView(pendingViewChange) | ||
| pendingViewChange = undefined | ||
| } | ||
| }, | ||
| getConfigurationTelemetry() { | ||
| return { views: true } | ||
| }, | ||
| }, | ||
| onPageReferenceChange, | ||
| } | ||
| } | ||
|
|
||
| function getPageReferenceKey(pageReference: unknown) { | ||
| if (pageReference === undefined) { | ||
| return undefined | ||
| } | ||
|
|
||
| try { | ||
| return JSON.stringify(pageReference) | ||
| } catch { | ||
| // eslint-disable-next-line @typescript-eslint/no-base-to-string | ||
| return String(pageReference) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { defineGlobal, globalObject } from '@datadog/browser-core' | ||
| import type { RumPublicApi } from '@datadog/browser-rum-core' | ||
| import { makeRumPublicApi } from '@datadog/browser-rum-core' | ||
| import { makeProfilerApiStub } from '../boot/stubProfilerApi' | ||
| import { makeRecorderApiStub } from '../boot/stubRecorderApi' | ||
| import { createSalesforceViewsPlugin } from '../domain/salesforce/salesforceViewsPlugin' | ||
| import type { SalesforceViewsPlugin } from '../domain/salesforce/salesforceViewsPlugin' | ||
|
|
||
| export type { | ||
| User, | ||
| Account, | ||
| TraceContextInjection, | ||
| SessionPersistence, | ||
| TrackingConsent, | ||
| MatchOption, | ||
| ProxyFn, | ||
| Site, | ||
| Context, | ||
| ContextValue, | ||
| ContextArray, | ||
| RumInternalContext, | ||
| } from '@datadog/browser-core' | ||
|
|
||
| /** | ||
| * @deprecated Use {@link DatadogRum} instead | ||
| */ | ||
| export type RumGlobal = DatadogRum | ||
|
|
||
| export interface DatadogRum extends RumPublicApi { | ||
| createSalesforceViewsPlugin: () => SalesforceViewsPlugin | ||
| } | ||
|
|
||
| export type { | ||
| RumInitConfiguration, | ||
| RumBeforeSend, | ||
| ViewOptions, | ||
| StartRecordingOptions, | ||
| AddDurationVitalOptions, | ||
| DurationVitalOptions, | ||
| FeatureOperationOptions, | ||
| FailureReason, | ||
| ActionOptions, | ||
| ResourceOptions, | ||
| ResourceStopOptions, | ||
| TracingOption, | ||
| RumPlugin, | ||
| OnRumStartOptions, | ||
| PropagatorType, | ||
| FeatureFlagsForEvents, | ||
| MatchHeader, | ||
| CommonProperties, | ||
| RumEvent, | ||
| RumActionEvent, | ||
| RumErrorEvent, | ||
| RumLongTaskEvent, | ||
| RumResourceEvent, | ||
| RumViewEvent, | ||
| RumVitalEvent, | ||
| RumEventDomainContext, | ||
| RumViewEventDomainContext, | ||
| RumErrorEventDomainContext, | ||
| RumActionEventDomainContext, | ||
| RumVitalEventDomainContext, | ||
| RumResourceEventDomainContext, | ||
| RumLongTaskEventDomainContext, | ||
| } from '@datadog/browser-rum-core' | ||
| export { DEFAULT_TRACKED_RESOURCE_HEADERS } from '@datadog/browser-rum-core' | ||
| export { DefaultPrivacyLevel } from '@datadog/browser-core' | ||
| export { createSalesforceViewsPlugin } | ||
| export type { SalesforceViewChange, SalesforceViewsPlugin } from '../domain/salesforce/salesforceViewsPlugin' | ||
|
|
||
| export const datadogRum: DatadogRum = Object.assign( | ||
| makeRumPublicApi(makeRecorderApiStub(), makeProfilerApiStub(), { | ||
| sdkName: 'rum-slim', | ||
| }), | ||
| { createSalesforceViewsPlugin } | ||
| ) | ||
|
|
||
| interface BrowserWindow { | ||
| DD_RUM?: RumPublicApi | ||
| } | ||
| defineGlobal(globalObject as BrowserWindow, 'DD_RUM', datadogRum) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.