Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Commit ab98118

Browse files
author
Asa Schachar
committed
fix (auto-update): Fix auto-updating parameters
1 parent 241abce commit ab98118

File tree

7 files changed

+1041
-148
lines changed

7 files changed

+1041
-148
lines changed

demo/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const optimizely = optimizelyExpressSdk.initialize({
2222
sdkKey: 'CZsVVgn6j9ce6fNPt2ZEiB',
2323
datafileOptions: {
2424
autoUpdate: true,
25-
updateInterval: 600000 // 10 minutes in milliseconds
25+
updateInterval: 5*1000 // 5 seconds in milliseconds
2626
},
2727
});
2828
app.use(optimizely.middleware);

demo/express-sdk.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Optimizely Express SDK
2+
* Optimizely Express Middleware
33
*
44
* Copyright 2019, Optimizely
55
*
@@ -40,13 +40,15 @@ function initialize(options) {
4040
sdkKey,
4141
datafile,
4242
logLevel,
43+
datafileOptions,
4344
} = options;
4445

4546

4647
const defaultLogger = require('@optimizely/optimizely-sdk').logging;
4748
const manager = new DatafileManager({
4849
sdkKey,
49-
...options
50+
...options,
51+
...datafileOptions,
5052
});
5153

5254
function updateDatafile() {
@@ -76,7 +78,10 @@ function initialize(options) {
7678
logger: defaultLogger.createLogger({
7779
logLevel: logLevel
7880
}),
79-
...options
81+
...options,
82+
datafileOptions: {
83+
autoUpdate: false, // Ensure the SDK doesn't also try to auto-update on its own
84+
},
8085
});
8186

8287
req.optimizely = {
@@ -140,7 +145,7 @@ function initialize(options) {
140145
},
141146

142147
/**
143-
* isRouteEnabled
148+
* isRouteEnabled (EXPERIMENTAL-FEATURE)
144149
*
145150
* Provides a method which can be used to block a route in express on whether the feature is enabled or not
146151
*

0 commit comments

Comments
 (0)