![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@phntms/ft-lib
Advanced tools
A collection of Javascript utils for shareable UI and tracking functionality across Phantom FT sites
currently implemented:
Install this package with npm
.
npm i @phntms/ft-lib
Shared Origami and GA/GTM tracking implementation that can be used across all Phantom FT sites. Tracking meta data is provided by a config object when first initiated and on subsequent route changes (only required for SPA/NextJS sites).
By default, the implementation will automatically handle FT tracking via data-gadl
and data-o-event
HTML attributes. The tracker instance should be added to the global window namespace if custom events are required.
Note: By default the FTTracker instance will load the consentMonitor
poller, so sites do not need to implement this separately.
The constructor requires the config JSON object (TODO - schema) and optionally accepts an options object:
scrollTrackerSelector: "#o_tracker_scroll", //top level DOM element selector for scroll tracking
isCustomGTMEvent: true, //selects between GTM and UA(GTAG) event formats - TODO - handle automatically by detecting loaded GTM/UA?
The site config JSON object passed in the constructor and all events handled by FTTracker are validated with Yup for a basic format check. This includes both the automatic data-o-event
, data-gadl
generated events and manually fired events with FTTracker.oEvent
and FTTracker.gaEvent
. A console error is thrown if validation fails. The validation rules can be found in /src/utils/yupValidator.ts
Typical usage:
import { FTTracking } from '@phntms/ft-lib'
//For Wagtail sites, get server-rendered o-tracking-data
const config = JSON.parse(document.getElementById('o-tracking-data').textContent)
window.FTTracker = new FTTracking(config, { scrollTrackerSelector: '#content' })
.
.
//if an event needs to be fired that can't be added using the preferred data-gadl and data-o-event attributes (i.e. custom players or form submits):
window.FTTracker.oEvent({category: "audio", action: "progress", duration: duration, progress: {`${progress}%`}})
window.FTTracker.gaEvent(`Audio`, {`${progress}% progress`}, <AUDIO or PAGE TITLE>)
Adds an FT consent cookie poller to enable/disable Permutive consent (only useful if 'consentRequired' is set as an option in the site's Permutive script - see here There are optional constructor args for the hostname (defaults to window.location.hostname) and the dev environment host matches (defaults to ["localhost", "phq", "vercel.app"]) which are used to determine development environments in order to generate an FT banner event listener ((see here for a list of banner DOM events) to set session-level cookies for development environments
import { consentMonitor } from "@phntms/ft-lib";
new consentMonitor("FT.staging.testsite.com". ["localhost", "phq", "staging"]);
emitPermutiveProgressEvents - used within a video player's progress event handler to fire Permutive video progress events at [0, 25, 50, 75, 100] percent progress. Optional 3rd arg to pass a window.interval instance to be cleared once progress is complete.
import { permutiveVideoUtils } from "@phntms/ft-lib";
const permutivevideoTracker = new permutiveVideoUtils("<FT-CAMPAIGN>","<VIDEO-TITLE>","<VIDEO-ID/URL>") //Data will be site implementation specific
player.on("progress", () => { //event will be video player site implementation specific
permutivevideoTracker.emitPermutiveProgressEvent(<DURATION>, <CURRENTTIME>, <OPTIONAL-WINDOW-INTERVAL>)
});
Exports video event handlers that broadcast the required GA, oTracking and Permutive events.
The constructor takes the parent site's FTTracking instance (typically set up as window.FTTracker) and video and site meta data (as required for the tracking data).
Typical implementation:
import { reactPlayerTracking } from "@phntms/ft-lib";
const [videoTracker] = useState(
new reactPlayerTracking(window.FTTracker, <VIDEO-TITLE>, <VIDEO-URL>),
)
<ReactPlayer
onDuration={videoTracker.setDuration}
onEnded={videoTracker.trackEnded}
onPause={videoTracker.trackPause}
onPlay={videoTracker.trackPlay}
onProgress={videoTracker.trackProgress}
>
Exports a Youtube iframe event handler for sites using the Youtube Iframe API that broadcasts the required GA, oTracking and Permutive events. The Youtube iFrame can be either generated in the site's JS or template rendered.
The constructor takes the parent site's FTTracking instance (typically set up as window.FTTracker).
NOTE: For Typescript usage as below, the @types/youtube NPM package should be added to the parent project and the YT namespace added to tsconfig.json with the "types": ["youtube"]
compiler option.
Typical implementation:
import { ytIframeTracking } from '@phntms/ft-lib';
const VIDEO_IFRAME_ID = 'video-iframe';
export class YoutubeIframeLoader {
videoTracker: ytIframeTracking;
player?: YT.Player;
constructor() {
this.videoTracker = new ytIframeTracking(window.FTTracker);
window.onYouTubeIframeAPIReady =
(event: YT.PlayerEvent) => {
this.player = new YT.Player(VIDEO_IFRAME_ID, {
events: {
'onStateChange': (event) => this.onPlayerStateChange(event)
}
});
};
onPlayerStateChange(event: YT.PlayerEvent) {
this.videoTracker.ytIframeEventHandler(event);
}
}
}
FAQs
A collection of Javascript UI & tracking utils for FT sites
The npm package @phntms/ft-lib receives a total of 0 weekly downloads. As such, @phntms/ft-lib popularity was classified as not popular.
We found that @phntms/ft-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.