feat: sdke 142 support launcher.use in rokt web kit#44
Conversation
rmi22186
left a comment
There was a problem hiding this comment.
Minor test clean up, mostly. Looks good otherwise.
|
|
||
| /** | ||
| * Enables optional Integration Launcher extensions before selecting placements | ||
| * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher/#use |
There was a problem hiding this comment.
I would link this docs page in the PR description and remove from the commit. The docs are already not searchable, so the docs likely will go away since it's the legacy way of implementing.
| window.mParticle.forwarder.launcher = { | ||
| use: function () {}, | ||
| }; |
There was a problem hiding this comment.
This line doesn't seem necessary
| const error = await (async () => { | ||
| try { | ||
| await window.mParticle.forwarder.use('ThankYouPageJourney'); | ||
| return null; | ||
| } catch (e) { | ||
| return e; | ||
| } | ||
| })(); | ||
|
|
||
| (!!error).should.equal(true); | ||
| error.message.should.equal('Rokt Kit: Not initialized'); |
There was a problem hiding this comment.
This seems a bit convoluted to gett he error message. I think the following works:
| const error = await (async () => { | |
| try { | |
| await window.mParticle.forwarder.use('ThankYouPageJourney'); | |
| return null; | |
| } catch (e) { | |
| return e; | |
| } | |
| })(); | |
| (!!error).should.equal(true); | |
| error.message.should.equal('Rokt Kit: Not initialized'); | |
| try { | |
| await window.mParticle.forwarder.use('ThankYouPageJourney'); | |
| } catch (error) { | |
| error.message.should.equal('Rokt Kit: Not initialized'); | |
| } |
| const error = await (async () => { | ||
| try { | ||
| await window.mParticle.forwarder.use(123); | ||
| return null; | ||
| } catch (e) { | ||
| return e; | ||
| } | ||
| })(); | ||
|
|
||
| (!!error).should.equal(true); | ||
| error.message.should.equal('Rokt Kit: Invalid extension name'); |
There was a problem hiding this comment.
| const error = await (async () => { | |
| try { | |
| await window.mParticle.forwarder.use(123); | |
| return null; | |
| } catch (e) { | |
| return e; | |
| } | |
| })(); | |
| (!!error).should.equal(true); | |
| error.message.should.equal('Rokt Kit: Invalid extension name'); | |
| try { | |
| await window.mParticle.forwarder.use(123); | |
| } catch (error) { | |
| error.message.should.equal('Rokt Kit: Invalid extension name'); | |
| } |
| const error = await (async () => { | ||
| try { | ||
| await window.mParticle.forwarder.use('ThankYouPageJourney'); | ||
| return null; | ||
| } catch (e) { | ||
| return e; | ||
| } finally { | ||
| window.console.error = consoleError; | ||
| } | ||
| })(); |
There was a problem hiding this comment.
| const error = await (async () => { | |
| try { | |
| await window.mParticle.forwarder.use('ThankYouPageJourney'); | |
| return null; | |
| } catch (e) { | |
| return e; | |
| } finally { | |
| window.console.error = consoleError; | |
| } | |
| })(); | |
| try { | |
| await window.mParticle.forwarder.use('ThankYouPageJourney'); | |
| throw new Error('Expected promise to reject'); | |
| } catch (error) { | |
| error.message.should.equal('Rokt Kit: Not initialized'); | |
| } finally { | |
| window.console.error = consoleError; | |
| } |
There was a problem hiding this comment.
Was there a reason you only did the resetting of window.console.error here to the original state? I think you should follow this in your previous tests where you stub window.console.error as well.
I'd also call the variable originalConsoleError to be more specific.
There was a problem hiding this comment.
In my initial commit there were two separate tests (reject + log) that I merged into one here, and that’s when I added the restore of console.error in that spot. I’ve now standardized the #use like you suggested.
| window.Rokt.useName.should.equal('ThankYouPageJourney'); | ||
| }); | ||
|
|
||
| it('should reject errors from launcher.use', async () => { |
There was a problem hiding this comment.
I'm not sure if this test is needed? We don't need to try to mimic the rejection that the launcher.js file gives us when we put in an incorrect extension name.
This reverts commit 16b6996.
# [1.8.0](v1.7.2...v1.8.0) (2025-09-15) ### Features * sdke 142 support launcher.use in rokt web kit ([#44](#44)) ([ea35ce8](ea35ce8))
Summary
usemethod inRokt-KitusemethodTesting Plan
tests.js