tracker doc fix

This commit is contained in:
nick-delirium 2024-07-31 09:40:54 +02:00
parent 4246634a7d
commit 42eb4b5040
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
17 changed files with 67 additions and 34 deletions

View file

@ -17,7 +17,9 @@ import trackerAssist from '@openreplay/tracker-assist';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${props.projectKey}', projectKey: '${props.projectKey}',
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
tracker.use(trackerAssist(options)); // check the list of available options below`} tracker.use(trackerAssist(options)); // check the list of available options below`}
</Highlight> </Highlight>
} }
@ -31,8 +33,9 @@ const tracker = new OpenReplay({
const trackerAssist = tracker.use(trackerAssist(options)); // check the list of available options below const trackerAssist = tracker.use(trackerAssist(options)); // check the list of available options below
//... //...
function MyApp() { function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component useEffect(async () => { // use componentDidMount in case of React Class Component
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
//... //...
}`} }`}

View file

@ -37,7 +37,8 @@ import trackerGraphQL from '@openreplay/tracker-graphql';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
export const recordGraphQL = tracker.use(trackerGraphQL());`} export const recordGraphQL = tracker.use(trackerGraphQL());`}
</Highlight> </Highlight>
@ -53,7 +54,8 @@ const tracker = new OpenReplay({
//... //...
function SomeFunctionalComponent() { function SomeFunctionalComponent() {
useEffect(() => { // or componentDidMount in case of Class approach useEffect(() => { // or componentDidMount in case of Class approach
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
} }
//... //...

View file

@ -37,7 +37,9 @@ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.use(trackerMobX(<options>)); // check list of available options below tracker.use(trackerMobX(<options>)); // check list of available options below
tracker.start();`} // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... );
`}
</Highlight> </Highlight>
} }
second={ second={
@ -52,7 +54,8 @@ tracker.use(trackerMobX(<options>)); // check list of available options below
//... //...
function SomeFunctionalComponent() { function SomeFunctionalComponent() {
useEffect(() => { // or componentDidMount in case of Class approach useEffect(() => { // or componentDidMount in case of Class approach
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
}`} }`}
</Highlight> </Highlight>

View file

@ -35,7 +35,8 @@ import trackerNgRx from '@openreplay/tracker-ngrx';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
const metaReducers = [tracker.use(trackerNgRx(<options>))]; // check list of available options below const metaReducers = [tracker.use(trackerNgRx(<options>))]; // check list of available options below
//... //...
@ -58,7 +59,8 @@ const tracker = new OpenReplay({
//... //...
function SomeFunctionalComponent() { function SomeFunctionalComponent() {
useEffect(() => { // or componentDidMount in case of Class approach useEffect(() => { // or componentDidMount in case of Class approach
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
//... //...
const metaReducers = [tracker.use(trackerNgRx(<options>))]; // check list of available options below const metaReducers = [tracker.use(trackerNgRx(<options>))]; // check list of available options below

View file

@ -36,7 +36,8 @@ import trackerVuex from '@openreplay/tracker-vuex';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
const examplePiniaStore = useExamplePiniaStore() const examplePiniaStore = useExamplePiniaStore()
// check list of available options below // check list of available options below
@ -65,7 +66,8 @@ const tracker = new OpenReplay({
//... //...
// start tracker when the app is mounted // start tracker when the app is mounted
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
const examplePiniaStore = useExamplePiniaStore() const examplePiniaStore = useExamplePiniaStore()

View file

@ -33,7 +33,8 @@ import trackerProfiler from '@openreplay/tracker-profiler';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
export const profiler = tracker.use(trackerProfiler()); export const profiler = tracker.use(trackerProfiler());
//... //...
@ -53,7 +54,8 @@ const tracker = new OpenReplay({
//... //...
function SomeFunctionalComponent() { function SomeFunctionalComponent() {
useEffect(() => { // or componentDidMount in case of Class approach useEffect(() => { // or componentDidMount in case of Class approach
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
//... //...
export const profiler = tracker.use(trackerProfiler()); export const profiler = tracker.use(trackerProfiler());

View file

@ -33,7 +33,8 @@ import trackerRedux from '@openreplay/tracker-redux';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
const store = createStore( const store = createStore(
reducer, reducer,
@ -53,7 +54,8 @@ const tracker = new OpenReplay({
//... //...
function SomeFunctionalComponent() { function SomeFunctionalComponent() {
useEffect(() => { // or componentDidMount in case of Class approach useEffect(() => { // or componentDidMount in case of Class approach
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
//... //...
const store = createStore( const store = createStore(

View file

@ -36,7 +36,8 @@ import trackerVuex from '@openreplay/tracker-vuex';
const tracker = new OpenReplay({ const tracker = new OpenReplay({
projectKey: '${projectKey}' projectKey: '${projectKey}'
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
//... //...
const store = new Vuex.Store({ const store = new Vuex.Store({
//... //...
@ -56,7 +57,8 @@ const tracker = new OpenReplay({
//... //...
function SomeFunctionalComponent() { function SomeFunctionalComponent() {
useEffect(() => { // or componentDidMount in case of Class approach useEffect(() => { // or componentDidMount in case of Class approach
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
//... //...
const store = new Vuex.Store({ const store = new Vuex.Store({

View file

@ -14,7 +14,8 @@ const tracker = new Tracker({
projectKey: "PROJECT_KEY", projectKey: "PROJECT_KEY",
ingestPoint: "https://${window.location.hostname}/ingest", ingestPoint: "https://${window.location.hostname}/ingest",
}); });
tracker.start();`; // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )`;
const usageCodeSST = `import Tracker from '@openreplay/tracker/cjs'; const usageCodeSST = `import Tracker from '@openreplay/tracker/cjs';
const tracker = new Tracker({ const tracker = new Tracker({
@ -24,7 +25,8 @@ const tracker = new Tracker({
function MyApp() { function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component useEffect(() => { // use componentDidMount in case of React Class Component
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []); }, []);
//... //...

View file

@ -11,7 +11,9 @@ const tracker = new Tracker({
projectKey: "PROJECT_KEY", projectKey: "PROJECT_KEY",
ingestPoint: "https://${window.location.hostname}/ingest", ingestPoint: "https://${window.location.hostname}/ingest",
}); });
tracker.start();`
// .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )`
const usageCodeSST = `import Tracker from '@openreplay/tracker/cjs'; const usageCodeSST = `import Tracker from '@openreplay/tracker/cjs';
const tracker = new Tracker({ const tracker = new Tracker({
@ -21,7 +23,8 @@ const tracker = new Tracker({
function MyApp() { function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component useEffect(() => { // use componentDidMount in case of React Class Component
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []); }, []);
//... //...

View file

@ -33,7 +33,8 @@ const tracker = new Tracker({
}); });
tracker.use(trackerAssist(options)); // check the list of available options below tracker.use(trackerAssist(options)); // check the list of available options below
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
``` ```
@ -53,7 +54,8 @@ tracker.use(trackerAssist(options)); // check the list of available options belo
//... //...
function MyApp() { function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component useEffect(() => { // use componentDidMount in case of React Class Component
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
}, []) }, [])
//... //...
} }

View file

@ -22,7 +22,8 @@ import trackerAxios from '@openreplay/tracker-axios';
const tracker = new Tracker({ const tracker = new Tracker({
projectKey: YOUR_PROJECT_KEY, projectKey: YOUR_PROJECT_KEY,
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
tracker.use(trackerAxios({ /* options here*/ })); tracker.use(trackerAxios({ /* options here*/ }));
``` ```

View file

@ -26,7 +26,8 @@ const tracker = new OpenReplay({
}); });
const fetch = tracker.use(trackerFetch(options)); // check list of available options below const fetch = tracker.use(trackerFetch(options)); // check list of available options below
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
fetch('https://myapi.com/').then(response => console.log(response.json())); fetch('https://myapi.com/').then(response => console.log(response.json()));
``` ```
@ -47,7 +48,8 @@ const fetch = tracker.use(trackerFetch(options)); // check list of available opt
//... //...
function MyApp() { function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component useEffect(() => { // use componentDidMount in case of React Class Component
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
fetch('https://myapi.com/').then(response => console.log(response.json())); fetch('https://myapi.com/').then(response => console.log(response.json()));
}, []) }, [])

View file

@ -21,7 +21,8 @@ import trackerProfiler from '@openreplay/tracker-profiler';
const tracker = new Tracker({ const tracker = new Tracker({
projectKey: YOUR_PROJECT_KEY, projectKey: YOUR_PROJECT_KEY,
}); });
tracker.start(); // .start() returns a promise
tracker.start().then(sessionData => ... ).catch(e => ... )
export const profiler = tracker.plugin(trackerProfiler()); export const profiler = tracker.plugin(trackerProfiler());

View file

@ -1,3 +1,7 @@
# 14.0.4
- remove reject from start
# 14.0.3 # 14.0.3
- send integer instead of float for normalizedX/Y coords (basically moving from 0-100 to 0-10000 range) - send integer instead of float for normalizedX/Y coords (basically moving from 0-100 to 0-10000 range)

View file

@ -1,7 +1,7 @@
{ {
"name": "@openreplay/tracker", "name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package", "description": "The OpenReplay tracker main package",
"version": "14.0.3", "version": "14.0.4",
"keywords": [ "keywords": [
"logging", "logging",
"replay" "replay"

View file

@ -1221,18 +1221,18 @@ export default class App {
condition: conditionName, condition: conditionName,
assistOnly: startOpts.assistOnly ?? this.socketMode, assistOnly: startOpts.assistOnly ?? this.socketMode,
width: window.screen.width, width: window.screen.width,
height: window.screen.height height: window.screen.height,
}), }),
}) })
if (r.status !== 200) { if (r.status !== 200) {
const error = await r.text() const error = await r.text()
const reason = error === CANCELED ? CANCELED : `Server error: ${r.status}. ${error}` const reason = error === CANCELED ? CANCELED : `Server error: ${r.status}. ${error}`
return Promise.reject(reason) return UnsuccessfulStart(reason)
} }
if (!this.worker) { if (!this.worker) {
const reason = 'no worker found after start request (this might not happen)' const reason = 'no worker found after start request (this should not happen in real world)'
this.signalError(reason, []) this.signalError(reason, [])
return Promise.reject(reason) return UnsuccessfulStart(reason)
} }
const { const {
token, token,
@ -1265,7 +1265,7 @@ export default class App {
) { ) {
const reason = `Incorrect server response: ${JSON.stringify(r)}` const reason = `Incorrect server response: ${JSON.stringify(r)}`
this.signalError(reason, []) this.signalError(reason, [])
return Promise.reject(reason) return UnsuccessfulStart(reason)
} }
this.delay = delay this.delay = delay