Skip to content
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yarn
```

## Contributing
All indiviudal integrations are stored in the `integrations/` directory. We recommend navigating into the individual integration you are contributing to in your terminal rather than working from the root directory:
All individual integrations are stored in the `integrations/` directory. We recommend navigating into the individual integration you are contributing to in your terminal rather than working from the root directory:

```bash
cd integrations/<INTEGRATION_NAME>
Expand Down
4 changes: 4 additions & 0 deletions integrations/amplitude/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.2.0 / 2019-08-27

- Add support for unsetParamsReferrerOnNewSession setting

# 3.1.0 / 2019-08-09

- Add mapping of non-property fields to event_props.
Expand Down
3 changes: 3 additions & 0 deletions integrations/amplitude/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var Amplitude = (module.exports = integration('Amplitude')
.option('traitsToSetOnce', [])
.option('traitsToIncrement', [])
.option('appendFieldsToEventProps', {})
.option('unsetParamsReferrerOnNewSession', false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets the default value for the option right?

Technically I think this means there is a change in behavior for existing customers since the value for unsetParamsReferrerOnNewSession was undefined before.

But most likely Amplitude treats all falsey values the same then there is no difference in behavior and this is clearer. So I think this is fine. Just something to watch out for.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we have been burned by this before @ccnixon ? Probably not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding on to this.. looks like Amplitude just check for falsy/truthy: https://github.com/amplitude/Amplitude-JavaScript/blob/master/src/amplitude-client.js#L127

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find @gpsamson !

.tag('<script src="' + src + '">'));

/**
Expand Down Expand Up @@ -79,6 +80,8 @@ Amplitude.prototype.initialize = function() {
saveParamsReferrerOncePerSession: this.options
.saveParamsReferrerOncePerSession,
deviceIdFromUrlParam: this.options.deviceIdFromUrlParam,
unsetParamsReferrerOnNewSession: this.options
.unsetParamsReferrerOnNewSession,
deviceId:
this.options.preferAnonymousIdForDeviceId &&
this.analytics &&
Expand Down
2 changes: 1 addition & 1 deletion integrations/amplitude/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-amplitude",
"description": "The Amplitude analytics.js integration.",
"version": "3.1.0",
"version": "3.2.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand Down
8 changes: 7 additions & 1 deletion integrations/amplitude/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('Amplitude', function() {
mapQueryParams: {},
traitsToIncrement: [],
traitsToSetOnce: [],
preferAnonymousIdForDeviceId: true
preferAnonymousIdForDeviceId: true,
unsetParamsReferrerOnNewSession: false
};

beforeEach(function() {
Expand Down Expand Up @@ -65,6 +66,7 @@ describe('Amplitude', function() {
.option('traitsToIncrement', [])
.option('deviceIdFromUrlParam', false)
.option('appendFieldsToEventProps', {})
.option('unsetParamsReferrerOnNewSession', false)
);
});

Expand Down Expand Up @@ -132,6 +134,10 @@ describe('Amplitude', function() {
config.deviceIdFromUrlParam === options.deviceIdFromUrlParam
);
analytics.assert(config.deviceId === analytics.user().anonymousId());
analytics.assert(
config.unsetParamsReferrerOnNewSession ===
options.unsetParamsReferrerOnNewSession
);
});

it('should set api key', function() {
Expand Down