@amplitude/plugin-session-replay-browser
Advanced tools
Comparing version 1.0.2 to 1.1.0-beta.0
@@ -1,2 +0,1 @@ | ||
export declare const DEFAULT_SESSION_START_EVENT = "session_start"; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -1,4 +0,1 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_SESSION_START_EVENT = void 0; | ||
exports.DEFAULT_SESSION_START_EVENT = 'session_start'; | ||
//# sourceMappingURL=constants.js.map |
@@ -5,3 +5,2 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-browser")); | ||
var constants_1 = require("./constants"); | ||
var ENRICHMENT_PLUGIN_NAME = '@amplitude/plugin-session-replay-enrichment-browser'; | ||
@@ -16,2 +15,3 @@ var SessionReplayEnrichmentPlugin = /** @class */ (function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
this.config = _config; | ||
return [2 /*return*/]; | ||
@@ -25,7 +25,14 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
if (event.event_type === constants_1.DEFAULT_SESSION_START_EVENT && event.session_id) { | ||
sessionReplay.setSessionId(event.session_id); | ||
// On event, synchronize the session id to the what's on the browserConfig (source of truth) | ||
// Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored | ||
// in SR. | ||
if (this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId()) { | ||
sessionReplay.setSessionId(this.config.sessionId); | ||
} | ||
sessionRecordingProperties = sessionReplay.getSessionReplayProperties(); | ||
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties); | ||
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the | ||
// event is not of the current session (offline/late events). In that case, don't tag the events | ||
if (this.config.sessionId && this.config.sessionId === event.session_id) { | ||
sessionRecordingProperties = sessionReplay.getSessionReplayProperties(); | ||
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties); | ||
} | ||
return [2 /*return*/, Promise.resolve(event)]; | ||
@@ -42,2 +49,6 @@ }); | ||
this.options = tslib_1.__assign({}, options); | ||
// The user did not explicitly configure forceSessionTracking to false, default to true. | ||
if (this.options.forceSessionTracking !== false) { | ||
this.options.forceSessionTracking = true; | ||
} | ||
} | ||
@@ -57,15 +68,17 @@ SessionReplayPlugin.prototype.setup = function (config, client) { | ||
this.config = config; | ||
if (typeof config.defaultTracking === 'boolean') { | ||
if (config.defaultTracking === false) { | ||
config.defaultTracking = { | ||
pageViews: false, | ||
formInteractions: false, | ||
fileDownloads: false, | ||
sessions: true, | ||
}; | ||
if (this.options.forceSessionTracking) { | ||
if (typeof config.defaultTracking === 'boolean') { | ||
if (config.defaultTracking === false) { | ||
config.defaultTracking = { | ||
pageViews: false, | ||
formInteractions: false, | ||
fileDownloads: false, | ||
sessions: true, | ||
}; | ||
} | ||
} | ||
else { | ||
config.defaultTracking = tslib_1.__assign(tslib_1.__assign({}, config.defaultTracking), { sessions: true }); | ||
} | ||
} | ||
else { | ||
config.defaultTracking = tslib_1.__assign(tslib_1.__assign({}, config.defaultTracking), { sessions: true }); | ||
} | ||
return [4 /*yield*/, sessionReplay.init(config.apiKey, { | ||
@@ -72,0 +85,0 @@ instanceName: this.config.instanceName, |
@@ -8,3 +8,4 @@ export interface SessionReplayPrivacyConfig { | ||
debugMode?: boolean; | ||
forceSessionTracking?: boolean; | ||
} | ||
//# sourceMappingURL=session-replay.d.ts.map |
@@ -1,2 +0,1 @@ | ||
export declare const DEFAULT_SESSION_START_EVENT = "session_start"; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -1,2 +0,1 @@ | ||
export var DEFAULT_SESSION_START_EVENT = 'session_start'; | ||
//# sourceMappingURL=constants.js.map |
import { __assign, __awaiter, __generator } from "tslib"; | ||
import * as sessionReplay from '@amplitude/session-replay-browser'; | ||
import { DEFAULT_SESSION_START_EVENT } from './constants'; | ||
var ENRICHMENT_PLUGIN_NAME = '@amplitude/plugin-session-replay-enrichment-browser'; | ||
@@ -13,2 +12,3 @@ var SessionReplayEnrichmentPlugin = /** @class */ (function () { | ||
return __generator(this, function (_a) { | ||
this.config = _config; | ||
return [2 /*return*/]; | ||
@@ -22,7 +22,14 @@ }); | ||
return __generator(this, function (_a) { | ||
if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) { | ||
sessionReplay.setSessionId(event.session_id); | ||
// On event, synchronize the session id to the what's on the browserConfig (source of truth) | ||
// Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored | ||
// in SR. | ||
if (this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId()) { | ||
sessionReplay.setSessionId(this.config.sessionId); | ||
} | ||
sessionRecordingProperties = sessionReplay.getSessionReplayProperties(); | ||
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties); | ||
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the | ||
// event is not of the current session (offline/late events). In that case, don't tag the events | ||
if (this.config.sessionId && this.config.sessionId === event.session_id) { | ||
sessionRecordingProperties = sessionReplay.getSessionReplayProperties(); | ||
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties); | ||
} | ||
return [2 /*return*/, Promise.resolve(event)]; | ||
@@ -39,2 +46,6 @@ }); | ||
this.options = __assign({}, options); | ||
// The user did not explicitly configure forceSessionTracking to false, default to true. | ||
if (this.options.forceSessionTracking !== false) { | ||
this.options.forceSessionTracking = true; | ||
} | ||
} | ||
@@ -54,15 +65,17 @@ SessionReplayPlugin.prototype.setup = function (config, client) { | ||
this.config = config; | ||
if (typeof config.defaultTracking === 'boolean') { | ||
if (config.defaultTracking === false) { | ||
config.defaultTracking = { | ||
pageViews: false, | ||
formInteractions: false, | ||
fileDownloads: false, | ||
sessions: true, | ||
}; | ||
if (this.options.forceSessionTracking) { | ||
if (typeof config.defaultTracking === 'boolean') { | ||
if (config.defaultTracking === false) { | ||
config.defaultTracking = { | ||
pageViews: false, | ||
formInteractions: false, | ||
fileDownloads: false, | ||
sessions: true, | ||
}; | ||
} | ||
} | ||
else { | ||
config.defaultTracking = __assign(__assign({}, config.defaultTracking), { sessions: true }); | ||
} | ||
} | ||
else { | ||
config.defaultTracking = __assign(__assign({}, config.defaultTracking), { sessions: true }); | ||
} | ||
return [4 /*yield*/, sessionReplay.init(config.apiKey, { | ||
@@ -69,0 +82,0 @@ instanceName: this.config.instanceName, |
@@ -8,3 +8,4 @@ export interface SessionReplayPrivacyConfig { | ||
debugMode?: boolean; | ||
forceSessionTracking?: boolean; | ||
} | ||
//# sourceMappingURL=session-replay.d.ts.map |
@@ -1,2 +0,1 @@ | ||
export declare const DEFAULT_SESSION_START_EVENT = "session_start"; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -8,3 +8,4 @@ export interface SessionReplayPrivacyConfig { | ||
debugMode?: boolean; | ||
forceSessionTracking?: boolean; | ||
} | ||
//# sourceMappingURL=session-replay.d.ts.map |
{ | ||
"name": "@amplitude/plugin-session-replay-browser", | ||
"version": "1.0.2", | ||
"version": "1.1.0-beta.0", | ||
"description": "", | ||
@@ -43,3 +43,3 @@ "author": "Amplitude Inc", | ||
"@amplitude/analytics-types": ">=1 <3", | ||
"@amplitude/session-replay-browser": "^0.8.0-beta.0", | ||
"@amplitude/session-replay-browser": "^1.1.0-beta.0", | ||
"idb-keyval": "^6.2.1", | ||
@@ -60,3 +60,3 @@ "tslib": "^2.4.1" | ||
], | ||
"gitHead": "f07f2bf6aaf2817ded4f18eda548d5c2778ee75c" | ||
"gitHead": "350be3b91b8186c3aba1af460ab6a507cc43ed25" | ||
} |
@@ -88,1 +88,6 @@ <p align="center"> | ||
``` | ||
## Debugging | ||
### Using debugMode when developing locally | ||
Since the Session Replay plugin only records and tags events when the page is in focus, this can sometimes be problematic when developing locally with the browser console open. If you are having issues with the replays not showing up (while your quota usage going up). Try turning setting `debugMode:true` to see if that helps with the issue. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
326838
1214
93
6
1
+ Added@amplitude/analytics-remote-config@0.4.1(transitive)
+ Added@amplitude/rrweb-packer@2.0.0-alpha.26(transitive)
+ Added@amplitude/session-replay-browser@1.15.1(transitive)
+ Addedfflate@0.4.8(transitive)
+ Addedidb@8.0.0(transitive)
- Removed@amplitude/session-replay-browser@0.8.0-beta.0(transitive)