Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/angular-mixpanel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/angular-mixpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
angular.module('analytics.mixpanel', [])
.provider('$mixpanel', function () {
var apiKey, superProperties;
var apiKey, config, superProperties;

/**
* Init the mixpanel global
Expand All @@ -30,7 +30,7 @@ angular.module('analytics.mixpanel', [])
throw 'Global `mixpanel` not available. Did you forget to include the library on the page?';
}

mixpanel.init(apiKey);
mixpanel.init(apiKey, config);

waitTillAsyncApiLoaded(function () {
if (superProperties) mixpanel.register(superProperties);
Expand Down Expand Up @@ -85,6 +85,17 @@ angular.module('analytics.mixpanel', [])
apiKey = key;
};

/**
* Get or set the Mixpanel configuration. This can be done via a provider config.
*
* @param config your Mixpanel configuration
*/
this.config = function (conf) {
if (!conf) return config;

config = conf;
};

/**
* Get or set a special set of properties to include/send with every event.
*
Expand Down
8 changes: 8 additions & 0 deletions test/angular-mixpanel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ describe('Provider: $mixpanelProvider', function () {
expect($mixpanel.apiKey()).toBe(apiKey);
});

it('should set configuration', function () {
var configuration = { persistence: 'localStorage' };

$mixpanel.config(configuration);

expect($mixpanel.config()).toBe(configuration);
});

it('should set super properties', function () {
var properties = { prop1: true };

Expand Down