Skip to content

Commit a444328

Browse files
feat: allow mixpanel options to be specified
1 parent f7e2fd7 commit a444328

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/analytics-plugin-mixpanel/src/browser.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @link https://getanalytics.io/plugins/mixpanel/
44
* @param {object} pluginConfig - Plugin settings
55
* @param {string} pluginConfig.token - The mixpanel token associated to a mixpanel project
6+
* @param {object} [pluginConfig.options] - The mixpanel init options https://github.com/mixpanel/mixpanel-js/blob/8b2e1f7b/src/mixpanel-core.js#L87-L110
67
* @param {string} [pluginConfig.pageEvent] - Event name to use for page() events (default to page path)
78
* @param {string} [pluginConfig.customScriptSrc] - Load mixpanel script from custom source
89
* @return {object} Analytics plugin
@@ -18,7 +19,7 @@ function mixpanelPlugin(pluginConfig = {}) {
1819
config: pluginConfig,
1920
/* https://developer.mixpanel.com/docs/javascript-full-api-reference#mixpanelinit */
2021
initialize: ({ config }) => {
21-
const { token, customScriptSrc } = config;
22+
const { token, customScriptSrc, options = {} } = config;
2223
if (!token) {
2324
throw new Error("No mixpanel token defined");
2425
}
@@ -119,7 +120,7 @@ function mixpanelPlugin(pluginConfig = {}) {
119120
}
120121
})(document, window.mixpanel || []);
121122

122-
mixpanel.init(config.token, { batch_requests: true });
123+
mixpanel.init(config.token, { batch_requests: true, ...options });
123124
},
124125
/**
125126
* Identify a visitor in mixpanel

0 commit comments

Comments
 (0)