Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow getExtensionSettings() to accept event as parameter #157

Open
PrateekTikku opened this issue Jan 11, 2023 · 2 comments
Open

Allow getExtensionSettings() to accept event as parameter #157

PrateekTikku opened this issue Jan 11, 2023 · 2 comments

Comments

@PrateekTikku
Copy link

PrateekTikku commented Jan 11, 2023

Expected Behaviour

Passing the rule's synthetic event as parameter to turbine.getExtensionSettings() function must be possible as this function replaces token with actual values and would need the event parameter, if the extension configuration uses %event% as token (or calls a data element which in-turn uses %event%)

Actual Behaviour

Currently this function doesn't accept any parameters

Reproduce Scenario (including but not limited to)

While calling turbine.getExtensionSettings() from any custom action/condition exposed from an extension, the tokens set in the extension configuration which are dependent on %event% are always evaluated to undefined

Steps to Reproduce

  1. Create an extension which-
  • accepts user input in extension configuration which gets saved in extensionSettings
  • has an action which calls turbine.getExtensionSettings() from inside action's code
  1. Install this extension in any Launch property

  2. In the extension configuration use %event...% as input. Alternatively, call a data element dependent on %event...%

  3. Create a new rule with the corresponding action to be triggered

  4. Check the results on webpage - The tokens are always resolved to undefined, as while calling turbine.getExtensionSettings() from inside the action's module code, currently there is no way to pass the reference of event parameter

Platform and Version

Sample Code that illustrates the problem

Logs taken while reproducing problem

@jhicken
Copy link
Contributor

jhicken commented Jan 11, 2023

We think we understand what you are trying to do. Can you elaborate on why you are trying to do this?

@PrateekTikku
Copy link
Author

PrateekTikku commented Jan 12, 2023

Okay, I will try to explain the specific use case that I have, however, please note that the issue raised is more generic and not limited to this use case.

Specific Use Case - My use case deals with Adobe Analytics tagging in particular. I've created a private extension which allows the user to segregate the eVar/props basis variable groups, inside the extension configuration. So, let's suppose the user creates the following groups and maps them as shown below-

  1. User Variables
    eVar1 = %userIDHashed%
    eVar2= %userType%
    ...
  2. Page Variables
    eVar11 = %pageType%
    eVar12 = %pageCategory%
    ...
  3. Link Variables
    eVar31 = %linkName%
    eVar32 = %event.detail.name%

Once the extension configuration is saved, these are returned into the settings object. Then, in the rules, users can add an action from this extension, selecting (by clicking checkboxes) which variable groups should be mapped when this rule triggers e.g. Rule1 might need 'user' and 'page variables' and Rule2 might need 'user' and 'link' variables. The action's settings object will only contain the group IDs which need to be fired and will NOT copy the mapping done within the extension config.

Note that the data elements used inside the extension configuration mapping, can in-turn rely on the data layer state. Hence, in order to always capture the correct dynamic values in the corresponding eVars, it is important that the action module of extension calls turbine.getExtensionSettings() each time it is triggered, thereby replacingTokens with the most updated values.

In this way, this extension tries to circumvent around the issue mentioned in the story from Jennifer Kunz and also raised in GitHub issue #125 (when taking Adobe Analytics as example), while providing additional features.

Issue within reactor - When turbine.getExtensionSettings() call made from inside the action module tries to replaceTokens, it doesn't contain the event in its closure. Hence, in the above example eVar32 will always be replaced by undefined. Also, in case any data element relies on the event, it's value will also be undefined.

Solution - the turbine.getExtensionSettings() call should accept an optional parameter of syntheticEvent as demonstrated in the pull request #158

Without even considering the above mentioned use case, the getExtensionSettings() method is attached to the turbine free variables, hence it can potentially be called from the module code of action/condition/event/dataElement. Therefore, it must also support passing the syntheticEvent as context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Incoming
Development

No branches or pull requests

2 participants