Skip to content

Commit

Permalink
temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathvaj-ganesan committed Apr 11, 2021
1 parent 646311f commit d9d7716
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions packages/trackjs/src/TrackJSFullStory.ts
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;

0 comments on commit d9d7716

Please sign in to comment.