Skip to content

Commit

Permalink
feat: dedupe layer exposures (#366)
Browse files Browse the repository at this point in the history
* feat: dedupe layer exposures

* fix: lints

* fix: build error
  • Loading branch information
tore-statsig authored Nov 16, 2024
1 parent ada8199 commit ae5bed1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/client-core/src/EventLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,17 @@ export class EventLogger {
const userKey = _getUserStorageKey(this._sdkKey, user);

const metadata = event.metadata ? event.metadata : {};

const key = [
event.eventName,
userKey,
metadata['gate'],
metadata['config'],
metadata['ruleID'],
metadata['allocatedExperiment'],
metadata['parameterName'],
String(metadata['isExplicitParameter']),
metadata['reason'],
].join('|');
const previous = this._lastExposureTimeMap[key];
const now = Date.now();
Expand Down
6 changes: 5 additions & 1 deletion packages/client-core/src/StatsigEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const _createExposure = (
export const _isExposureEvent = ({
eventName,
}: StatsigEventInternal): boolean => {
return eventName === GATE_EXPOSURE_NAME || eventName === CONFIG_EXPOSURE_NAME;
return (
eventName === GATE_EXPOSURE_NAME ||
eventName === CONFIG_EXPOSURE_NAME ||
eventName === LAYER_EXPOSURE_NAME
);
};

export const _createGateExposure = (
Expand Down
2 changes: 1 addition & 1 deletion packages/combo/webpack[js-client+web-analytics].config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { createStatsigWebpackBundle } = require('./statsig-webpack-bundler');

module.exports = createStatsigWebpackBundle({
bundleFile: 'js-client+web-analytics',
maxByteSize: 53_000,
maxByteSize: 55_000,
dependencies: [
'@statsig/client-core',
'@statsig/js-client',
Expand Down
21 changes: 20 additions & 1 deletion tools/scripts/minifier-name-cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,26 @@
"$_downloadConfigSpecsUrlConfig": "Pn",
"$_getSpecs": "Cn",
"$_evaluator": "Un",
"$_getOutputs": "Gn"
"$_getOutputs": "Gn",
"$_sessionData": "ti",
"$_events": "ei",
"$_currentSessionID": "ii",
"$_getSessionIdFromClient": "ni",
"$_replayer": "si",
"$_shutdown": "ri",
"$_attemptToStartRecording": "li",
"$_logRecording": "oi",
"$_subscribeToVisibilityChanged": "ui",
"$_onVisibilityChanged": "ai",
"$_onRecordingEvent": "ci",
"$_fastApproxSizeOf": "hi",
"$_bumpSessionIdleTimerAndLogRecording": "di",
"$_logRecordingWithSessionID": "vi",
"$_startTimestamp": "fi",
"$_endTimestamp": "_i",
"$_clickCount": "gi",
"$_stopCallback": "bi",
"$_stopFn": "pi"
}
}
}

0 comments on commit ae5bed1

Please sign in to comment.