@openreplay/tracker
Advanced tools
Comparing version 3.5.11 to 3.5.12
@@ -16,3 +16,3 @@ import type Message from "../common/messages.js"; | ||
} | ||
export interface OnStartInfo { | ||
interface OnStartInfo { | ||
sessionID: string; | ||
@@ -22,2 +22,13 @@ sessionToken: string; | ||
} | ||
declare const CANCELED: "canceled"; | ||
declare type SuccessfulStart = OnStartInfo & { | ||
success: true; | ||
}; | ||
declare type UnsuccessfulStart = { | ||
reason: typeof CANCELED | string; | ||
success: false; | ||
}; | ||
declare const UnsuccessfulStart: (reason: string) => UnsuccessfulStart; | ||
declare const SuccessfulStart: (body: OnStartInfo) => SuccessfulStart; | ||
export declare type StartPromiseReturn = SuccessfulStart | UnsuccessfulStart; | ||
declare type StartCallback = (i: OnStartInfo) => void; | ||
@@ -41,3 +52,2 @@ declare type CommitCallback = (messages: Array<Message>) => void; | ||
export declare type Options = AppOptions & ObserverOptions & SanitizerOptions; | ||
export declare const CANCELED = "canceled"; | ||
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest"; | ||
@@ -94,5 +104,5 @@ export default class App { | ||
private _start; | ||
start(options?: StartOptions): Promise<OnStartInfo>; | ||
start(options?: StartOptions): Promise<StartPromiseReturn>; | ||
stop(): void; | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_INGEST_POINT = exports.CANCELED = void 0; | ||
exports.DEFAULT_INGEST_POINT = void 0; | ||
const messages_js_1 = require("../common/messages.js"); | ||
@@ -13,2 +13,6 @@ const utils_js_1 = require("../utils.js"); | ||
const performance_js_1 = require("../modules/performance.js"); | ||
const CANCELED = "canceled"; | ||
const START_ERROR = ":("; | ||
const UnsuccessfulStart = (reason) => ({ reason, success: false }); | ||
const SuccessfulStart = (body) => (Object.assign(Object.assign({}, body), { success: true })); | ||
var ActivityState; | ||
@@ -20,3 +24,2 @@ (function (ActivityState) { | ||
})(ActivityState || (ActivityState = {})); | ||
exports.CANCELED = "canceled"; | ||
// TODO: use backendHost only | ||
@@ -34,3 +37,3 @@ exports.DEFAULT_INGEST_POINT = 'https://api.openreplay.com/ingest'; | ||
this.activityState = ActivityState.NotActive; | ||
this.version = '3.5.11'; // TODO: version compatability check inside each plugin. | ||
this.version = '3.5.12'; // TODO: version compatability check inside each plugin. | ||
this.projectKey = projectKey; | ||
@@ -231,6 +234,6 @@ this.options = Object.assign({ | ||
if (!this.worker) { | ||
return Promise.reject("No worker found: perhaps, CSP is not set."); | ||
return Promise.resolve(UnsuccessfulStart("No worker found: perhaps, CSP is not set.")); | ||
} | ||
if (this.activityState !== ActivityState.NotActive) { | ||
return Promise.reject("OpenReplay: trying to call `start()` on the instance that has been started already."); | ||
return Promise.resolve(UnsuccessfulStart("OpenReplay: trying to call `start()` on the instance that has been started already.")); | ||
} | ||
@@ -270,4 +273,4 @@ this.activityState = ActivityState.Starting; | ||
else { | ||
return r.text().then(text => text === exports.CANCELED | ||
? Promise.reject(exports.CANCELED) // TODO: return {error: CANCELED} instead | ||
return r.text().then(text => text === CANCELED | ||
? Promise.reject(CANCELED) // TODO: return {error: CANCELED} instead | ||
: Promise.reject(`Server error: ${r.status}. ${text}`)); | ||
@@ -305,3 +308,3 @@ } | ||
} | ||
return onStartInfo; | ||
return SuccessfulStart(onStartInfo); | ||
}) | ||
@@ -311,8 +314,8 @@ .catch(reason => { | ||
this.stop(); | ||
//if (reason === CANCELED) { return Promise.resolve(CANCELED) } // TODO: what to return ????? Throwing is baad | ||
if (reason !== exports.CANCELED) { | ||
this.notify.log("OpenReplay was unable to start. ", reason); | ||
this._debug("session_start", reason); | ||
if (reason === CANCELED) { | ||
return UnsuccessfulStart(CANCELED); | ||
} | ||
return Promise.reject(reason); | ||
this.notify.log("OpenReplay was unable to start. ", reason); | ||
this._debug("session_start", reason); | ||
return UnsuccessfulStart(START_ERROR); | ||
}); | ||
@@ -319,0 +322,0 @@ } |
@@ -12,3 +12,3 @@ import App from "./app/index.js"; | ||
import type { StartOptions } from './app/index.js'; | ||
import type { OnStartInfo } from './app/index.js'; | ||
import type { StartPromiseReturn } from './app/index.js'; | ||
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & { | ||
@@ -28,3 +28,3 @@ projectID?: number; | ||
isActive(): boolean; | ||
start(startOpts?: Partial<StartOptions>): Promise<OnStartInfo>; | ||
start(startOpts?: Partial<StartOptions>): Promise<StartPromiseReturn>; | ||
stop(): void; | ||
@@ -31,0 +31,0 @@ getSessionToken(): string | null | undefined; |
@@ -130,3 +130,3 @@ "use strict"; | ||
req.send(JSON.stringify({ | ||
trackerVersion: '3.5.11', | ||
trackerVersion: '3.5.12', | ||
projectKey: options.projectKey, | ||
@@ -133,0 +133,0 @@ doNotTrack, |
@@ -16,3 +16,3 @@ import type Message from "../common/messages.js"; | ||
} | ||
export interface OnStartInfo { | ||
interface OnStartInfo { | ||
sessionID: string; | ||
@@ -22,2 +22,13 @@ sessionToken: string; | ||
} | ||
declare const CANCELED: "canceled"; | ||
declare type SuccessfulStart = OnStartInfo & { | ||
success: true; | ||
}; | ||
declare type UnsuccessfulStart = { | ||
reason: typeof CANCELED | string; | ||
success: false; | ||
}; | ||
declare const UnsuccessfulStart: (reason: string) => UnsuccessfulStart; | ||
declare const SuccessfulStart: (body: OnStartInfo) => SuccessfulStart; | ||
export declare type StartPromiseReturn = SuccessfulStart | UnsuccessfulStart; | ||
declare type StartCallback = (i: OnStartInfo) => void; | ||
@@ -41,3 +52,2 @@ declare type CommitCallback = (messages: Array<Message>) => void; | ||
export declare type Options = AppOptions & ObserverOptions & SanitizerOptions; | ||
export declare const CANCELED = "canceled"; | ||
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest"; | ||
@@ -94,5 +104,5 @@ export default class App { | ||
private _start; | ||
start(options?: StartOptions): Promise<OnStartInfo>; | ||
start(options?: StartOptions): Promise<StartPromiseReturn>; | ||
stop(): void; | ||
} | ||
export {}; |
@@ -10,2 +10,6 @@ import { Timestamp } from "../common/messages.js"; | ||
import { deviceMemory, jsHeapSizeLimit } from "../modules/performance.js"; | ||
const CANCELED = "canceled"; | ||
const START_ERROR = ":("; | ||
const UnsuccessfulStart = (reason) => ({ reason, success: false }); | ||
const SuccessfulStart = (body) => (Object.assign(Object.assign({}, body), { success: true })); | ||
var ActivityState; | ||
@@ -17,3 +21,2 @@ (function (ActivityState) { | ||
})(ActivityState || (ActivityState = {})); | ||
export const CANCELED = "canceled"; | ||
// TODO: use backendHost only | ||
@@ -31,3 +34,3 @@ export const DEFAULT_INGEST_POINT = 'https://api.openreplay.com/ingest'; | ||
this.activityState = ActivityState.NotActive; | ||
this.version = '3.5.11'; // TODO: version compatability check inside each plugin. | ||
this.version = '3.5.12'; // TODO: version compatability check inside each plugin. | ||
this.projectKey = projectKey; | ||
@@ -228,6 +231,6 @@ this.options = Object.assign({ | ||
if (!this.worker) { | ||
return Promise.reject("No worker found: perhaps, CSP is not set."); | ||
return Promise.resolve(UnsuccessfulStart("No worker found: perhaps, CSP is not set.")); | ||
} | ||
if (this.activityState !== ActivityState.NotActive) { | ||
return Promise.reject("OpenReplay: trying to call `start()` on the instance that has been started already."); | ||
return Promise.resolve(UnsuccessfulStart("OpenReplay: trying to call `start()` on the instance that has been started already.")); | ||
} | ||
@@ -301,3 +304,3 @@ this.activityState = ActivityState.Starting; | ||
} | ||
return onStartInfo; | ||
return SuccessfulStart(onStartInfo); | ||
}) | ||
@@ -307,8 +310,8 @@ .catch(reason => { | ||
this.stop(); | ||
//if (reason === CANCELED) { return Promise.resolve(CANCELED) } // TODO: what to return ????? Throwing is baad | ||
if (reason !== CANCELED) { | ||
this.notify.log("OpenReplay was unable to start. ", reason); | ||
this._debug("session_start", reason); | ||
if (reason === CANCELED) { | ||
return UnsuccessfulStart(CANCELED); | ||
} | ||
return Promise.reject(reason); | ||
this.notify.log("OpenReplay was unable to start. ", reason); | ||
this._debug("session_start", reason); | ||
return UnsuccessfulStart(START_ERROR); | ||
}); | ||
@@ -315,0 +318,0 @@ } |
@@ -12,3 +12,3 @@ import App from "./app/index.js"; | ||
import type { StartOptions } from './app/index.js'; | ||
import type { OnStartInfo } from './app/index.js'; | ||
import type { StartPromiseReturn } from './app/index.js'; | ||
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & { | ||
@@ -28,3 +28,3 @@ projectID?: number; | ||
isActive(): boolean; | ||
start(startOpts?: Partial<StartOptions>): Promise<OnStartInfo>; | ||
start(startOpts?: Partial<StartOptions>): Promise<StartPromiseReturn>; | ||
stop(): void; | ||
@@ -31,0 +31,0 @@ getSessionToken(): string | null | undefined; |
@@ -126,3 +126,3 @@ import App, { DEFAULT_INGEST_POINT } from "./app/index.js"; | ||
req.send(JSON.stringify({ | ||
trackerVersion: '3.5.11', | ||
trackerVersion: '3.5.12', | ||
projectKey: options.projectKey, | ||
@@ -129,0 +129,0 @@ doNotTrack, |
{ | ||
"name": "@openreplay/tracker", | ||
"description": "The OpenReplay tracker main package", | ||
"version": "3.5.11", | ||
"version": "3.5.12", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "logging", |
@@ -28,3 +28,7 @@ # OpenReplay Tracker | ||
} | ||
}); | ||
}).then(startedSession => { | ||
if (startedSession.success) { | ||
console.log(startedSession) | ||
} | ||
}) | ||
``` | ||
@@ -31,0 +35,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
356503
8863
43