@npaw/forge-web 10.0.0 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4554,6 +4554,9 @@ var VideoAdapter = class {
4554
4554
  var _a, _b;
4555
4555
  (_b = (_a = this.playerAdapter) == null ? void 0 : _a.detach) == null ? void 0 : _b.call(_a);
4556
4556
  this.playerAdapter = adapter;
4557
+ if (this.playerSetupAtMs === void 0 && typeof performance !== "undefined") {
4558
+ this.playerSetupAtMs = Math.round(performance.now());
4559
+ }
4557
4560
  adapter.attach(this);
4558
4561
  }
4559
4562
  setAdAdapter(adapter) {
@@ -4717,6 +4720,7 @@ var VideoAdapter = class {
4717
4720
  this.qos = qos;
4718
4721
  }
4719
4722
  this.metadata = withoutOneShotFields(mergedMetadata, ONE_SHOT_CONTENT_FIELDS);
4723
+ applyPageContextDefaults(mergedMetadata, this.playerSetupAtMs);
4720
4724
  const command = {
4721
4725
  type: "videoEvent",
4722
4726
  event,
@@ -5039,6 +5043,17 @@ function withOptionalString(value, key, optional) {
5039
5043
  [key]: optional
5040
5044
  };
5041
5045
  }
5046
+ function applyPageContextDefaults(metadata, playerSetupAtMs) {
5047
+ if (metadata.referer === void 0 && typeof location !== "undefined" && location.href) {
5048
+ metadata.referer = sanitizeCaptureUrl(location.href);
5049
+ }
5050
+ if (metadata.referral === void 0 && typeof document !== "undefined" && document.referrer) {
5051
+ metadata.referral = sanitizeCaptureUrl(document.referrer);
5052
+ }
5053
+ if (metadata.playerStartupTimeMs === void 0 && playerSetupAtMs !== void 0) {
5054
+ metadata.playerStartupTimeMs = playerSetupAtMs;
5055
+ }
5056
+ }
5042
5057
 
5043
5058
  // src/forge.ts
5044
5059
  var _NPAWForge = class _NPAWForge {