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.
* wip: add base trackjs * wip: cleanup * doc: update integ * doc: update integ * chore: changeset release
- Loading branch information
1 parent
b0a5577
commit 9ede9f0
Showing
10 changed files
with
241 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,5 @@ | ||
--- | ||
"@bharathvaj/fullstory-trackjs": major | ||
--- | ||
|
||
Initial Release |
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,100 @@ | ||
# fullstory-trackjs | ||
|
||
The FullStory-trackjs integration seamlessly integrates the FullStorys and trackjs platforms. When you look at a browser error in trackjs, you will see a link | ||
to the FullStory session replay at that exact moment in time under meta data section. When you are watching a FullStory replay and your user experiences an | ||
error, you will see a custom error with the basic error details and link to trackjs meta data. | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
**Table of content** | ||
|
||
- [Pre-Requisites](#pre-requisites) | ||
- [Installation](#installation) | ||
- [Setup](#setup) | ||
- [Code Changes](#code-changes) | ||
- [Options](#options) | ||
- [Roadmap](#roadmap) | ||
- [How it works](#how-it-works) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## Pre-Requisites | ||
|
||
For the FullStory-trackjs integration to work, you must have the [FullStory browser SDK package](https://www.npmjs.com/package/@fullstory/browser) and the | ||
[TrackJS browser SDK package](https://www.npmjs.com/package/trackjs). | ||
|
||
## Installation | ||
|
||
To install the stable version: | ||
|
||
with npm: | ||
|
||
``` | ||
npm install --save @bharathvaj/fullstory-trackjs | ||
``` | ||
|
||
with yarn: | ||
|
||
``` | ||
yarn add @bharathvaj/fullstory-trackjs | ||
``` | ||
|
||
## Setup | ||
|
||
### Code Changes | ||
|
||
To set up the integration, both FullStory and trackjs need to be initialized. Please add the following code: | ||
|
||
```js | ||
import { TrackJS } from 'trackjs'; | ||
import * as FullStory from '@fullstory/browser'; | ||
import TrackJSFullStory from '@bharathvaj/fullstory-trackjs'; | ||
|
||
FullStory.init({ orgId: '__FULLSTORY_ORG_ID__' }); | ||
|
||
TrackJS.install({ | ||
token: '__YOUR_API_KEY__', | ||
}); | ||
|
||
TrackJSFullStory.init(TrackJS, options); | ||
``` | ||
|
||
Replace `__YOUR_API_KEY__` with the API found in Settings > Project Access Tokens. | ||
|
||
You also need to replace `__FULLSTORY_ORG_ID__` with the value of `_fs_org` in the FullStory recording snippet on your | ||
[FullStory settings page](https://help.fullstory.com/hc/en-us/articles/360020623514). | ||
|
||
### Options (Optional) | ||
|
||
You can also customize the error event name in FullStory by | ||
|
||
```js | ||
// ... | ||
TrackJSFullStory.init(TrackJS, { | ||
fsEventName: 'Custom Error Name', | ||
}); | ||
|
||
//... | ||
``` | ||
|
||
# Caveats | ||
|
||
Please note that this integration makes use of `onError` hook provided by the TrackJS library. So using this library will override if you have configured | ||
`onError` while installing the TrackJS library.s | ||
|
||
# Roadmap | ||
|
||
[ ] - Support trackjs Error link in FullStory Custom Event. | ||
|
||
[ ] - Add Unit test cases | ||
|
||
## How it works | ||
|
||
In Trackjs, you should see additional tab called `FULLSTORY` for the error event which will have `urlAtTime`. | ||
|
||
![trackjs](https://i.imgur.com/m0Nu4Yg.png) | ||
|
||
In FullStory, you should see an event called `trackjs Error` on the right sidebar. | ||
|
||
![FullStory]() |
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,39 @@ | ||
{ | ||
"name": "@bharathvaj/fullstory-trackjs", | ||
"description": "Fullstory TrackJS Integration", | ||
"version": "0.0.0", | ||
"main": "dist/index", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"trackjs", | ||
"fullstory", | ||
"integration" | ||
], | ||
"scripts": { | ||
"clean": "rimraf -rf ./dist", | ||
"build": "yarn clean && tsc -p tsconfig.build.json", | ||
"prepublishOnly": "yarn run build", | ||
"test": "yarn run build" | ||
}, | ||
"peerDependencies": { | ||
"trackjs": ">=2.0.0", | ||
"@fullstory/browser": ">=1.0.0" | ||
}, | ||
"devDependencies": { | ||
"trackjs": "^2.21.1", | ||
"@fullstory/browser": "^1.4.9", | ||
"tslib": "^2.2.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"author": "Bharathvaj Ganesan <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/bharathvaj-ganesan/fullstory-integrations/issues" | ||
}, | ||
"homepage": "https://github.com/bharathvaj-ganesan/fullstory-integrations#readme" | ||
} |
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; |
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,3 @@ | ||
import TrackJSFullStory from './TrackJSFullStory'; | ||
|
||
export default TrackJSFullStory; |
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,22 @@ | ||
/** | ||
* Checks if the exception has message | ||
* @param exception | ||
* @returns | ||
*/ | ||
const isError = (exception: string | Error): exception is Error => { | ||
return (exception as Error).message !== undefined; | ||
}; | ||
|
||
/** | ||
* Get the message and name properties from the original exception | ||
* @param {Object} event | ||
*/ | ||
export const getOriginalExceptionProperties = (event) => { | ||
if (event && event.originalError && isError(event.originalError)) { | ||
const originalError = event.originalError || {}; | ||
const { name, message } = originalError; | ||
return { name, message }; | ||
} | ||
|
||
return {}; | ||
}; |
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,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
|
||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
|
||
"include": [ | ||
"src/**/*" | ||
] | ||
} |
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,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
} |
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