@procore/third-party-scripts
TypeScript icon, indicating that this package has built-in type declarations

6.5.1 • Public • Published

@procore/third-party-scripts

Procore Technologies, Inc Third Party Scripts loader

We currently have

Installation

Yarn

yarn add -E @procore/third-party-scripts

Usage

What you can import from this package:

import {
  metadataEndpoint,
  ThirdPartyScripts,
  useProviderParams,
  useThirdPartyScriptsContext,
} from '@procore/third-party-scripts';

The supported third party scripts that can be loaded are as follows:

bugsnag
font
glance
googleAnalytics
launchDarkly
mindTouch
pendo
pusher
sumoLogic
userVoice

and each must be explicitly opted into to be loaded

<ThirdPartyScripts font={true}>Your app code here...</ThirdPartyScripts>

or

<ThirdPartyScripts font>Your app code here...</ThirdPartyScripts>

Dependencies

If you would like to use uservoice properly, please include or ensure that the final environment contains an element with the ID of post-ideas. If you are in the monolith or being rendered within the UI Service shell, this is already handled for you.

If you would like to have a loader experience, please supply <ThirdPartyScripts /> with a loader prop.

Breaking changes since 5.0.0 version

This change has been done in order to make third-party-scripts a tree shakable package. As part of this breaking change ThirdPartyScripts tag needs to have a scripts prop in order to load the scripts. The scripts prop is an array of supported imported scripts from third-party-scripts package. The remaining props are staying the same. The script: boolean props will get ignored.

import {
  ThirdPartyScripts,
  sumoLogic,
  font,
  bugsnag,
} from '@procore/third-party-scripts';

const scripts = [bugsnag, font];
if (myFlag) {
  scripts.push(sumoLogic);
}

<ThirdPartyScripts
  config={{
    sumoLogic: {
      endpoint: process.env.PROCORE_HYDRA_SUMO_SOURCE,
      sourceName: 'my-mfe-ui',
      sourceCategory: 'My awesome app',
    },
  }}
  metadata={customMetadata}
  scripts={scripts}
>
  <App />
</ThirdPartyScripts>;

Breaking changes from labs- version

The easy one: change the package name from @procore/labs-third-party-scripts to @procore/third-party-scripts.

The common imports from the dist directory have been moved up to the index export, and as such your imports should be merged / updated.

The LaunchDarkly client no longer evaluates allFlags by default. If you have a need for it, you can do the following to access them again:

import { useThirdPartyScriptsContext } from '@procore/third-party-scripts`;

function ExampleComponent(props) {
  const { scripts } = useThirdPartyScriptsContext();

  const allFlags = scripts?.launchDarkly?.client?.allFlags();

  return allFlags?.yourCustomFlag ? <div>Your Component A</div> : <div>Your Component B</div>;
}

How to pass a custom context or a custom attribute?

ThirdPartyScripts is already making a multiple context configuration for LaunchDarkly, which contains a standard user context. You can provide a custom attributes for the user context as well as additional contexts.

Reference: LaunchDarkly Multi-context

<ThirdPartyScripts
  config={{
   launchDarkly: {
      context: {
        user: {
         customAttribute: 'value'
        },
        organization: {
          id: '1234'
        },
        myCustomContext: {
          signature: 'private'
        }
      },
    },
  }}
  metadata={customMetadata}
  requester={request}
  scripts={scripts}
>

Local Development

For local storybook development, environment keys are necessary to successfully utilize <ThirdPartyScripts />. Follow the steps below to set up your environment correctly:

  1. In this folder, create a copy of .sample.env as .env.
  2. Log into your lastpass and find the note labeled core-labs third party scripts env keys.
  3. Copy the entire note and paste it into your .env file.

Update the key names to include a VITE_ prefix, or match them up to the .sample.env

Readme

Keywords

none

Package Sidebar

Install

npm i @procore/third-party-scripts

Weekly Downloads

33

Version

6.5.1

License

SEE LICENSE IN LICENSE

Unpacked Size

725 kB

Total Files

24

Last publish

Collaborators

  • dancingshell
  • justinmwatts
  • antonyayoub
  • rysmithprocore
  • robbiegprocore
  • jadamsss
  • jeremy.bouzigard
  • jgentes
  • faraz.hanif
  • timdoherty
  • ajaykumar-procore
  • b.bookout
  • jalyng
  • chadryder
  • htael
  • refaiepcn
  • james.lawson
  • vinayakaprabhu
  • davidshure
  • james.cleary
  • jl4ever
  • andersonbispoprocore
  • dev-account-admin
  • brockpcor
  • rowan.ibrahim
  • sseanwang
  • ramysaid2
  • vinaya-procore
  • lalovar-procore
  • bhargavrnd
  • ihor.diachenko_procore
  • farismmk
  • gideon-procore
  • dannyporrello
  • alanprocore
  • chance.eakin.procore
  • stevenliprocore
  • javio-procore
  • kani-procore
  • enyaga
  • danny.ou
  • messanjah
  • david-christensen-procore
  • shradha.khard
  • winson.chu
  • eyvettesou
  • lzhou888
  • jnhoang1
  • nickprocore
  • neil.mckeeman
  • pam-whisenhunt
  • jgee67
  • youssefamer
  • mike-arndt-procore
  • bob.laskowski
  • cagmz
  • mariah_delaney
  • lukenispel
  • fabriciobd
  • bikash.sahoo
  • bbreyel921
  • kimhin267
  • andy.mayer
  • phil.custer
  • elijah.procore
  • juliana.hernandez
  • judy-lu-pc
  • procore-it-support
  • andrewburke-pc
  • jkleintech
  • rachel.arkebauer
  • procore-npm-bot
  • grafffffff
  • yoyis3000
  • james.dabbs-procore
  • laurenbrandsteinprocore
  • scottbieser-procore
  • amir-iskander
  • zach.mckenzie.procore
  • amyprocore
  • shayonj_procore
  • heplayskeys
  • mike.south
  • thomasoboyle
  • dischorde
  • derek-carter-procore
  • dlgasser
  • cfprocore
  • evan.waits
  • jeremy-marcus
  • jmejia-fsl
  • ersgonzalo
  • timofeee
  • stephan-procore
  • aleclarsenprocore
  • sarah.freitas
  • yihai.zweifel
  • jay-rajan
  • jacky-lei
  • apcarroll_procore
  • procore_halzy
  • mehrdad-panahandeh
  • peter.jin
  • uddhavjoglekar
  • brookyboy009
  • denzylbalram
  • changprocore
  • allenanle.procore
  • devin.cunningham.procore
  • ari-procore
  • noor.ali
  • hgouhierprocore
  • cyrille.bai
  • brad.urani
  • dmccraw-procore
  • patrick.lardin
  • abhijit.patwardhan
  • matt.harris0223
  • alan.bresani
  • jesse.olsen
  • dtorres-procore
  • dineshkumar.jayak
  • jason-kaye
  • yadhu.prakash
  • leandro-proc
  • andrew.wheeler
  • sherylnapigkit
  • lydiahara
  • kahliholmes
  • sateesh-kadiyala-procore
  • epalinprocore
  • dennis.heckman
  • jamie-dugan-procore
  • viktoriia_azarovska
  • daniel.ferreira-contractor
  • willpankonien
  • ladavarga
  • steven.hinkle
  • txin1
  • chris.berber
  • etokarev
  • ritchlee
  • karina.mendez-contractor
  • worldofsatyaki
  • greg.sparks
  • kyle.williams
  • kuldeepsingh4556
  • jeremy.lund
  • brocktillotsonprocore
  • stajics
  • ryanfuentesprocore
  • tyler.wasden.procore
  • fabiomelo513
  • cody_schindler_procore
  • amit.gurav-contractor
  • yoasyo25
  • kalyani.gosavi
  • hectorthiele
  • andersontr15
  • vishal-procore
  • omar.wagdy
  • yogevfine1
  • charan_procore
  • scorgiat-procore
  • mbartlett413
  • attachi
  • ahmed.ghorab
  • varomir
  • alyelashram_procore
  • ilya.dryha-contractor
  • evan.cerwonka.procore
  • vsobol-c
  • dmitri_wm
  • kellikearns
  • richard.bunn
  • chaitra-m-15
  • conner-procore
  • mishaelowoyemi
  • peterknif
  • aleh.haurylenia-contractor
  • miguel.garcia-procore
  • codyrobertsprocore
  • a.elbadawei
  • lnspatz914
  • melch-procore
  • mustafa-abdelrahman
  • atoaima
  • jasaswini
  • adarsh.gautam
  • amin.jaipuri
  • max.helmetag
  • s_kudryk
  • hyogman
  • kyle.liu
  • davidkangpro
  • stevenkang3
  • cbathgate
  • victorbendeck-pc
  • sarah.heredia
  • moaz-ashraf
  • aly-el-kerdany
  • procore-oss-user
  • abhishekkumar123
  • stephanie.brereton
  • saurasumprocore
  • mona.khairbek
  • elewando-procore
  • jyang-procore
  • tedyang
  • deiab
  • jgreene_procore
  • asamay
  • kenny.foisy
  • ganesh.raghupathy
  • rajatmenhdiratta
  • yzhou2024
  • dlameter-procore
  • decha-sanson
  • kylepietz
  • connie-feng-procore
  • roger-procore
  • matheusprocore
  • fernandocamilotti
  • simona.iancu
  • jacksonleach-procore
  • g2mitchell
  • tatsiana.clifton
  • phunguyen-pcor
  • pmfrawley
  • brian.smith1
  • scottstern
  • neil1023
  • srichaitanya.peddinti
  • jake-pitkin
  • erikthoreson
  • lhuang325
  • abhijit-procore
  • rodayna.ehab
  • fairchild
  • mustafa-u-abdelrahman
  • aberkowitz
  • pwhisenhunt-procore
  • mariia.solodovnik
  • nigeld-procore
  • samad.virani
  • bohdan-horai-procore
  • mathenes_procore
  • vinoth.kuppusamy
  • zayter
  • alan.facchini-contractor
  • cassianomatos-procore
  • amitk030
  • sflang-procore
  • tracy.otto
  • daniel-pierre-procore
  • glidenor
  • ashish.sharma2024
  • gaurav.sharma.procore
  • andres-mendez-procore
  • roobo-romeski
  • kylemartinez-procore
  • sean.spearman.procore
  • gturkadze
  • jeffgiaquinto
  • ezrasimeloff
  • bill-wagner
  • kellen.stewart
  • rodrigo.dejuana
  • saranahal2
  • andrew.isaac
  • agamaleldin
  • mostafaeltazy
  • magdyyxx
  • andreszorrilla-procore
  • mohitsharma97
  • tejeshwar
  • swati.jadhav
  • squidbeaks
  • subham.panigrahi
  • deepak.kumarts
  • mahesh-s96