-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
597 additions
and
107 deletions.
There are no files selected for viewing
This file contains 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 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 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,107 @@ | ||
When using the API with CDN installation, usage of try...catch blocks is encouraged to not break your app in case RUM library isn't loaded for some reason. This does not apply when bundling RUM with your application (using a npm installation). | ||
|
||
# setGlobalAttributes | ||
|
||
```ts | ||
SplunkRum.setGlobalAttributes(attributes?: Attributes): void; | ||
``` | ||
|
||
Update attributes that will be set on every new span. For example this can be used to [update user information on logging in](./IdentifyingUsers.md#providing-it-after-initialisation-using-api) | ||
|
||
* `attributes`: [Attributes](https://open-telemetry.github.io/opentelemetry-js-api/interfaces/attributes.html) - Object of attributes that will be set on every span. If undefined, all currently set global attributes will be deleted and no longer added to any new spans. | ||
|
||
Returns nothing | ||
|
||
**Example:** | ||
|
||
```js | ||
SplunkRum.setGlobalAttributes({ | ||
'enduser.id': 'Test User', | ||
}); | ||
// All new spans now include enduser.id | ||
|
||
SplunkRum.setGlobalAttributes({ | ||
'dark_mode.enabled': darkModeToggle.status, | ||
}); | ||
// All new spans now include enduser.id and dark_mode.enabled | ||
|
||
SplunkRum.setGlobalAttributes() | ||
// New spans no longer include those attributes | ||
``` | ||
|
||
# getGlobalAttributes | ||
|
||
```ts | ||
SplunkRum.getGlobalAttributes(): Attributes; | ||
``` | ||
|
||
Get current set global attributes | ||
|
||
No parameters | ||
|
||
Returns [Attributes](https://open-telemetry.github.io/opentelemetry-js-api/interfaces/attributes.html) object with attributes that are set on all new spans | ||
|
||
**Example:** | ||
|
||
```js | ||
SplunkRum.setGlobalAttributes({ | ||
'enduser.id': 'Test User', | ||
}); | ||
SplunkRum.setGlobalAttributes({ | ||
'dark_mode.enabled': darkModeToggle.status, | ||
}); | ||
|
||
const attrs = SplunkRum.getGlobalAttributes(); | ||
/* console.log(attrs) | ||
{ | ||
'enduser.id': 'Test User', | ||
'dark_mode.enabled': true | ||
} | ||
*/ | ||
``` | ||
|
||
# getSessionId | ||
|
||
```ts | ||
SplunkRum.getSessionId(): string; | ||
``` | ||
|
||
Get current session ID | ||
|
||
No parameters | ||
|
||
Returns string | ||
|
||
**Example:** | ||
|
||
```js | ||
LiveChat.onChatStarted(() => { | ||
LiveChat.setMetadata('splunk.sessionId', SplunkRum.getSessionId()); | ||
}); | ||
``` | ||
|
||
# Events | ||
|
||
Event listeners can be registered with `addEventListener` and removed with `removeEventListener`. Event listeners receive an object `{ payload: { /* Depending on event */ }}` as the first parameter | ||
|
||
```ts | ||
SplunkRum.addEventListener(type: string, listener: Function): void | ||
SplunkRum.removeEventListener(type: string, listener: Function): void | ||
``` | ||
|
||
Events: | ||
|
||
* `'session-changed'` - Emitted when session ID changes | ||
* Payload: | ||
* `sessionId`: string - New session ID | ||
* `'global-attributes-changed'` - Emitted when setGlobalAttributes is called | ||
* Payload: | ||
* `attributes`: [Attributes](https://open-telemetry.github.io/opentelemetry-js-api/interfaces/attributes.html) - New global attributes | ||
|
||
**Example:** | ||
|
||
```js | ||
SplunkRum.addEventListener('session-changed', (event) => { | ||
LiveChat.setMetadata('splunk.sessionId', event.payload.sessionId); | ||
}); | ||
``` |
This file contains 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 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,4 @@ | ||
/* eslint-disable header/header */ | ||
import { trace, context } from '@opentelemetry/api'; | ||
|
||
export { trace, context }; |
This file contains 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 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,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Test init</title> | ||
|
||
<%- renderAgent({}, true) %> | ||
<script> | ||
window.SplunkRumOptions.ignoreUrls = [ | ||
window.location.origin + '/non-impactful-resource.jpg' | ||
]; | ||
window.SplunkRum && window.SplunkRum.init(window.SplunkRumOptions); | ||
</script> | ||
</head> | ||
<body> | ||
<p>Docload</p> | ||
<img src="/non-impactful-resource.jpg"> | ||
</body> | ||
</html> |
This file contains 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 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 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 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
Oops, something went wrong.