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

6.5.0 • 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

14

Version

6.5.0

License

SEE LICENSE IN LICENSE

Unpacked Size

725 kB

Total Files

24

Last publish

Collaborators

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