@npaw/forge-web 10.0.0 → 10.0.1

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.d.cts CHANGED
@@ -739,6 +739,12 @@ interface ContentMetadata {
739
739
  nodeType?: string;
740
740
  nodeTypeString?: string;
741
741
  linkedViewId?: string;
742
+ /** Page/context URL (OLD-parity `referer`); defaults to the current page URL per event when unset. */
743
+ referer?: string;
744
+ /** Traffic origin (OLD-parity `referral`); defaults to `document.referrer` when unset. */
745
+ referral?: string;
746
+ /** Milliseconds from navigation start to player setup (OLD-parity `playerStartupTime`); stamped at adapter attach when unset. */
747
+ playerStartupTimeMs?: number;
742
748
  package?: string;
743
749
  saga?: string;
744
750
  tvShow?: string;
@@ -862,6 +868,15 @@ interface NetworkObservation {
862
868
  redirectDurationMs?: number;
863
869
  redirectCount?: number;
864
870
  protocol?: string;
871
+ /**
872
+ * Resource class of the request as reported by the observing host, e.g. a
873
+ * player adapter classifying its SDK's own downloads. Canonical lowercase
874
+ * tokens: `manifest`, `media`, `media_video`, `media_audio`,
875
+ * `media_subtitles`, `media_thumbnails`, `drm_license`, `drm_key`,
876
+ * `asset_list`. The kernel caps it at 32 chars on the wire (wire key
877
+ * `requestType`, fact `net.request_type`).
878
+ */
879
+ requestType?: string;
865
880
  /**
866
881
  * Request/response body sizes in bytes. Body content is never captured:
867
882
  * the binding measures the outgoing body bytes when it can and falls back
@@ -911,20 +926,6 @@ interface ForgeLocationFix {
911
926
  timestampMs: number;
912
927
  }
913
928
 
914
- /**
915
- * Copyright (C) NPAW - All Rights Reserved
916
- *
917
- * This source code is protected under international copyright law. All rights
918
- * reserved and protected by the copyright holders.
919
- * This file is confidential and only available to authorized individuals with the
920
- * permission of the copyright holders. If you encounter this file and do not have
921
- * permission, please contact the copyright holders and delete this file.
922
- *
923
- *
924
- * @author: Victor Soto <victor.soto@nicepeopleatwork.com>
925
- * @description: Video, player-adapter, and ad-adapter facade classes for Forge Web.
926
- */
927
-
928
929
  type VideoMetadataSampler = () => MetadataSnapshot | undefined;
929
930
  type AdMetadataSampler = () => AdMetadata | undefined;
930
931
  interface PlayerAdapterHost {
@@ -978,6 +979,9 @@ declare class VideoAdapter {
978
979
  private adAdapter;
979
980
  private state;
980
981
  private adState;
982
+ /** OLD-parity `playerStartupTime` anchor: ms from navigation start to the
983
+ * moment a player adapter attached to this view. */
984
+ private playerSetupAtMs;
981
985
  constructor(runtime: unknown, viewId: number, metadata?: ContentMetadata, qos?: QosSnapshot);
982
986
  setPlayerAdapter(adapter: PlayerAdapterHost): void;
983
987
  setAdAdapter(adapter: AdAdapterHost): AdAdapter;
package/dist/index.d.ts CHANGED
@@ -739,6 +739,12 @@ interface ContentMetadata {
739
739
  nodeType?: string;
740
740
  nodeTypeString?: string;
741
741
  linkedViewId?: string;
742
+ /** Page/context URL (OLD-parity `referer`); defaults to the current page URL per event when unset. */
743
+ referer?: string;
744
+ /** Traffic origin (OLD-parity `referral`); defaults to `document.referrer` when unset. */
745
+ referral?: string;
746
+ /** Milliseconds from navigation start to player setup (OLD-parity `playerStartupTime`); stamped at adapter attach when unset. */
747
+ playerStartupTimeMs?: number;
742
748
  package?: string;
743
749
  saga?: string;
744
750
  tvShow?: string;
@@ -862,6 +868,15 @@ interface NetworkObservation {
862
868
  redirectDurationMs?: number;
863
869
  redirectCount?: number;
864
870
  protocol?: string;
871
+ /**
872
+ * Resource class of the request as reported by the observing host, e.g. a
873
+ * player adapter classifying its SDK's own downloads. Canonical lowercase
874
+ * tokens: `manifest`, `media`, `media_video`, `media_audio`,
875
+ * `media_subtitles`, `media_thumbnails`, `drm_license`, `drm_key`,
876
+ * `asset_list`. The kernel caps it at 32 chars on the wire (wire key
877
+ * `requestType`, fact `net.request_type`).
878
+ */
879
+ requestType?: string;
865
880
  /**
866
881
  * Request/response body sizes in bytes. Body content is never captured:
867
882
  * the binding measures the outgoing body bytes when it can and falls back
@@ -911,20 +926,6 @@ interface ForgeLocationFix {
911
926
  timestampMs: number;
912
927
  }
913
928
 
914
- /**
915
- * Copyright (C) NPAW - All Rights Reserved
916
- *
917
- * This source code is protected under international copyright law. All rights
918
- * reserved and protected by the copyright holders.
919
- * This file is confidential and only available to authorized individuals with the
920
- * permission of the copyright holders. If you encounter this file and do not have
921
- * permission, please contact the copyright holders and delete this file.
922
- *
923
- *
924
- * @author: Victor Soto <victor.soto@nicepeopleatwork.com>
925
- * @description: Video, player-adapter, and ad-adapter facade classes for Forge Web.
926
- */
927
-
928
929
  type VideoMetadataSampler = () => MetadataSnapshot | undefined;
929
930
  type AdMetadataSampler = () => AdMetadata | undefined;
930
931
  interface PlayerAdapterHost {
@@ -978,6 +979,9 @@ declare class VideoAdapter {
978
979
  private adAdapter;
979
980
  private state;
980
981
  private adState;
982
+ /** OLD-parity `playerStartupTime` anchor: ms from navigation start to the
983
+ * moment a player adapter attached to this view. */
984
+ private playerSetupAtMs;
981
985
  constructor(runtime: unknown, viewId: number, metadata?: ContentMetadata, qos?: QosSnapshot);
982
986
  setPlayerAdapter(adapter: PlayerAdapterHost): void;
983
987
  setAdAdapter(adapter: AdAdapterHost): AdAdapter;
@@ -5073,6 +5073,9 @@ var NPAWForge = (() => {
5073
5073
  var _a, _b;
5074
5074
  (_b = (_a = this.playerAdapter) == null ? void 0 : _a.detach) == null ? void 0 : _b.call(_a);
5075
5075
  this.playerAdapter = adapter;
5076
+ if (this.playerSetupAtMs === void 0 && typeof performance !== "undefined") {
5077
+ this.playerSetupAtMs = Math.round(performance.now());
5078
+ }
5076
5079
  adapter.attach(this);
5077
5080
  }
5078
5081
  setAdAdapter(adapter) {
@@ -5236,6 +5239,7 @@ var NPAWForge = (() => {
5236
5239
  this.qos = qos;
5237
5240
  }
5238
5241
  this.metadata = withoutOneShotFields(mergedMetadata, ONE_SHOT_CONTENT_FIELDS);
5242
+ applyPageContextDefaults(mergedMetadata, this.playerSetupAtMs);
5239
5243
  const command = {
5240
5244
  type: "videoEvent",
5241
5245
  event,
@@ -5558,6 +5562,17 @@ var NPAWForge = (() => {
5558
5562
  [key]: optional
5559
5563
  };
5560
5564
  }
5565
+ function applyPageContextDefaults(metadata, playerSetupAtMs) {
5566
+ if (metadata.referer === void 0 && typeof location !== "undefined" && location.href) {
5567
+ metadata.referer = sanitizeCaptureUrl(location.href);
5568
+ }
5569
+ if (metadata.referral === void 0 && typeof document !== "undefined" && document.referrer) {
5570
+ metadata.referral = sanitizeCaptureUrl(document.referrer);
5571
+ }
5572
+ if (metadata.playerStartupTimeMs === void 0 && playerSetupAtMs !== void 0) {
5573
+ metadata.playerStartupTimeMs = playerSetupAtMs;
5574
+ }
5575
+ }
5561
5576
 
5562
5577
  // src/forge.ts
5563
5578
  var _NPAWForge = class _NPAWForge {