generated from NiGhTTraX/ts-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
646311f
commit d9d7716
Showing
1 changed file
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as FullStory from '@fullstory/browser'; | ||
import { getOriginalExceptionProperties } from './utils'; | ||
|
||
/** | ||
* This integration creates a link from the Trackjs Error to the FullStory replay. | ||
* It also creates a link from the FullStory event to the Trackjs error. | ||
*/ | ||
|
||
type Options = { | ||
fsEventName: string; | ||
}; | ||
|
||
class TrackJSFullStory { | ||
static init(client, options?: Options) { | ||
|
||
const fsEventName = options?.fsEventName || 'TrackJS Error'; | ||
const key = 'fullstoryUrl'; | ||
const value = FullStory.getCurrentSessionURL(true) || 'current session URL API not ready'; | ||
|
||
/** | ||
* Returns Trackjs's Error event URL | ||
* @returns string | ||
*/ | ||
const getTrackjsUrl = () => `https://my.trackjs.com/metadata?key=${key}&value=${value}`; | ||
|
||
const onError = (payload): boolean => { | ||
|
||
payload.metadata.push({ | ||
key, | ||
value | ||
}) | ||
|
||
// FS.event is immediately ready even if FullStory isn't fully bootstrapped | ||
FullStory.event(fsEventName, { | ||
trackjsUrl: getTrackjsUrl(), | ||
...getOriginalExceptionProperties(event) | ||
}); | ||
return true; | ||
} | ||
|
||
// Check if TrackJS is installed and configure | ||
if (client.isInstalled()) { | ||
client.configure({ | ||
onError | ||
}) | ||
} | ||
} | ||
|
||
} | ||
|
||
export default TrackJSFullStory; |