Open-Measurement-JSClients icon indicating copy to clipboard operation
Open-Measurement-JSClients copied to clipboard

how to export `src/common/event-typedefs.js`

Open jimdigriz opened this issue 6 years ago • 2 comments
trafficstars

When using Google Closure compiler with ADVANCED_OPTIMIZATIONS, the @typedef properties in src/common/event-typedefs.js get renamed which means things break.

There looks to be nothing relevant for us VerificationClient users in src/externs and there is no documented advice so it is unclear how this should be handled.

My awful solution is to concatenate constants.js and event-typedefs.js as a make shift externs file but either I am missing something or everyone has to manually do something like this?

Can we have an externs file for VerificationClient users please that preserves the the properties appearing in the events from OMID.registerSessionObserver or alternatively advise on what we all should be doing?

jimdigriz avatar Oct 12 '19 08:10 jimdigriz

For reference, this is what I use:

https://github.com/corememltd/Open-Measurement-JSClients/blob/externs/src/externs/omid-events.js

Then my call out to the closure compiler is:

java -jar closure-compiler-v20190929.jar \
  --warning_level=VERBOSE \
  --language_in=ECMASCRIPT6 --language_out=ECMASCRIPT5 \
  --strict_mode_input --dependency_mode=STRICT \
  --entry_point=main.js \
  --externs='Open-Measurement-JSClients/src/externs/omid-events.js' \
  --js='Open-Measurement-JSClients/src/common/**.js' \
  --js='Open-Measurement-JSClients/src/verification-client/**.js' \
  --js=main.js \
  --js_output_file=main.min.js \
  --isolation_mode=IIFE --assume_function_wrapper \
  --create_source_map=main.min.js.map \
  --define NDEBUG=true \
  --compilation_level=ADVANCED_OPTIMIZATIONS

With this things like evt.data.verificationParameters and evt.adSessionId (as well as all the other event properties) are retained correctly.

jimdigriz avatar Oct 12 '19 09:10 jimdigriz

Incase anyone else needs this, how I generate this file and the copy I am using can be found at:

https://github.com/corememltd/Open-Measurement-JSClients/commit/b41379221321e23fbe42be298985f6b1613e1df4

jimdigriz avatar Apr 06 '20 07:04 jimdigriz