From ac678e84d8b58e15ef2e441e7b26271489cb713b Mon Sep 17 00:00:00 2001 From: Sasan Date: Mon, 10 Jun 2019 16:05:10 +0430 Subject: [PATCH] feat: add external handler through module options --- lib/plugin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/plugin.js b/lib/plugin.js index 73e3523..504d5c9 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -4,12 +4,15 @@ import { parse as parseCookie, serialize as serializeCookie } from 'cookie' import experiments from '<%= options.experimentsDir %>' const MAX_AGE = <%= options.maxAge %> +const optimizeHandler = <%= serialize(options.handler) %> + export default function (ctx, inject) { // Assign experiment and variant to user assignExperiment(ctx) // Google optimize integration - googleOptimize(ctx) + let handler = optimizeHandler || googleOptimize + handler(ctx) // Inject $exp inject('exp', ctx.experiment)