optedIn is already a pref, we can just use the standard `preferenceValue` function for that. The 2 triggers can work in a sort of intertwined way. - The "on closed" trigger can save a pref when it's closed for the first time, whose value is the current session ID. - The "on product page" trigger doesn't need to reference the pref directly, but the messages can check it in targeting to require that it's not the same as the current session ID: `TelemetrySession.getMetadata("").sessionId` - We don't care how many times the sidebar was closed, since we just want to check that it's never been closed before now. (It would make sense to pass this state as trigger context, because the trigger is also going to set the pref to the current session ID, which may happen before JEXL finishes evaluating, not sure) So this is also handled by the "last close session ID" pref.
Bug 1842071 Comment 3 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
optedIn is already a pref, we can just use the standard `preferenceValue` function for that. The 2 triggers can work in a sort of intertwined way. - The "on closed" trigger can save a pref when it's closed for the first time, whose value is the current session ID. - The "on product page" trigger doesn't need to reference the pref directly, but the messages can check it in targeting to require that it's not the same as the current session ID: `TelemetrySession.getMetadata("").sessionId` - We don't care how many times the sidebar was closed, since we just want to check that it's never been closed before now. (It would make sense to pass this state as trigger context, because the trigger is also going to set the pref to the current session ID, which may happen before JEXL finishes evaluating, not sure) So this is also handled by the "last close session ID" pref. Also, not mentioned in the Figma spec, but discussed in the [flow requirements](https://www.figma.com/file/LpliDIdEmmoYq11Wj2ZpKH/Shopping-Experience-MVP-Onboarding-flows?type=whiteboard&node-id=0-1&t=MYAVBRLKr1wPqmEc-0), is that callout 2 should only show if 24 hours have passed since callout 1/3 was shown. That can be done with messageImpressions though: ``` messageImpressions.FAKESPOT_CALLOUT_CLOSED_OPTED_IN_DEFAULT[ messageImpressions.FAKESPOT_CALLOUT_CLOSED_OPTED_IN_DEFAULT | length - 1 ] < ${Date.now() - ONE_DAY_IN_MS} || messageImpressions.FAKESPOT_CALLOUT_CLOSED_OPTED_OUT_DEFAULT[ messageImpressions.FAKESPOT_CALLOUT_CLOSED_OPTED_OUT_DEFAULT | length - 1 ] < ${Date.now() - ONE_DAY_IN_MS} ``` ^ That simultaneously requires that one of them has been seen and that it was seen more than 24hrs ago.
optedIn is already a pref, we can just use the standard `preferenceValue` function for that. The 2 triggers can work in a sort of intertwined way. - The "on closed" trigger can save a pref when it's closed for the first time, whose value is the current session ID. - The "on product page" trigger doesn't need to reference the pref directly, but the messages can check it in targeting to require that it's not the same as the current session ID: `TelemetrySession.getMetadata("").sessionId` - We don't care how many times the sidebar was closed, since we just want to check that it's never been closed before now. (It would make sense to pass this state as trigger context, because the trigger is also going to set the pref to the current session ID, which may happen before JEXL finishes evaluating, not sure) So this is also handled by the "last close session ID" pref. Also, not mentioned in the Figma spec, but discussed in the [flow requirements](https://www.figma.com/file/LpliDIdEmmoYq11Wj2ZpKH/Shopping-Experience-MVP-Onboarding-flows?type=whiteboard&node-id=0-1&t=MYAVBRLKr1wPqmEc-0), is that callout 2 should only show if 24 hours have passed since callout 1/3 was shown. That can be done with messageImpressions though: ``` (currentDate | date - messageImpressions.FAKESPOT_CALLOUT_CLOSED_OPTED_IN_DEFAULT[ messageImpressions.FAKESPOT_CALLOUT_CLOSED_OPTED_IN_DEFAULT | length - 1 ] | date) / 3600000 > 24 || (currentDate | date - messageImpressions.FAKESPOT_CALLOUT_CLOSED_NOT_OPTED_IN_DEFAULT[ messageImpressions.FAKESPOT_CALLOUT_CLOSED_NOT_OPTED_IN_DEFAULT | length - 1 ] | date) / 3600000 > 24 ``` ^ That simultaneously requires that one of them has been seen and that it was seen more than 24hrs ago.