-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removes anonymous telemetry To keep Segment MTUs under control, as hostnames will change on docker
- Loading branch information
1 parent
74e8971
commit 3d3f5a4
Showing
2 changed files
with
17 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ export class AirbyteInit { | |
); | ||
} | ||
|
||
static makeSegmentUser(): SegmentUser { | ||
static makeSegmentUser(): SegmentUser | undefined { | ||
const version = process.env.FAROS_INIT_VERSION || ''; | ||
const source = process.env.FAROS_START_SOURCE || ''; | ||
const envEmail = process.env.FAROS_EMAIL; | ||
|
@@ -57,23 +57,18 @@ export class AirbyteInit { | |
source, | ||
}; | ||
} | ||
const email = '[email protected]'; | ||
if (process.env.HOSTNAME) { | ||
return { | ||
userId: uuidv5(process.env.HOSTNAME, UUID_NAMESPACE), | ||
email, | ||
version, | ||
source, | ||
}; | ||
} | ||
return {userId: uuidv4(), email, version, source}; | ||
return undefined; | ||
} | ||
|
||
static sendIdentityAndStartEvent( | ||
segmentUser: SegmentUser, | ||
segmentUser: SegmentUser | undefined, | ||
host?: string | undefined | ||
): Promise<void> { | ||
const analytics = new Analytics('YEu7VC65n9dIR85pQ1tgV2RHQHjo2bwn', { | ||
if (segmentUser === undefined) { | ||
logger.info('Skipping Telemetry'); | ||
return Promise.resolve(); | ||
} | ||
const analytics = new Analytics('YFJm3AJBKwOm0Hp4o4vD9iqnZN5bVn45', { | ||
// Segment host is used for testing purposes only | ||
host, | ||
}); | ||
|
@@ -82,18 +77,18 @@ export class AirbyteInit { | |
analytics | ||
.identify( | ||
{ | ||
userId: segmentUser.userId, | ||
userId: segmentUser?.userId, | ||
traits: { | ||
email: segmentUser.email, | ||
version: segmentUser.version, | ||
source: segmentUser.source, | ||
email: segmentUser?.email, | ||
version: segmentUser?.version, | ||
source: segmentUser?.source, | ||
}, | ||
}, | ||
callback | ||
) | ||
.track( | ||
{ | ||
userId: segmentUser.userId, | ||
userId: segmentUser?.userId, | ||
event: 'Start', | ||
}, | ||
callback | ||
|
@@ -117,7 +112,7 @@ export class AirbyteInit { | |
} | ||
|
||
async setupWorkspace( | ||
segmentUser: SegmentUser, | ||
segmentUser: SegmentUser | undefined, | ||
hasuraAdminSecret: string, | ||
airbyteDestinationHasuraUrl: string, | ||
forceSetup?: boolean | ||
|
@@ -149,11 +144,13 @@ export class AirbyteInit { | |
logger.info('faros connectors version: ' + farosConnectorsVersion); | ||
const airbyteInitV40: AirbyteInitV40 = new AirbyteInitV40(this.api); | ||
try { | ||
// destination spec expects uuid for segment_user_id | ||
// empty string fails validation | ||
await airbyteInitV40.init( | ||
farosConnectorsVersion, | ||
airbyteDestinationHasuraUrl, | ||
hasuraAdminSecret, | ||
segmentUser.userId | ||
segmentUser?.userId ?? "00000000-0000-0000-0000-000000000000" | ||
); | ||
} catch (error) { | ||
throw new VError(`Failed to set up workspace: ${error}`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,65 +65,4 @@ describe('airbyte', () => { | |
timestamp: expect.anything(), | ||
}); | ||
}); | ||
|
||
test('send identity and start event with no traits', async () => { | ||
const host = 'http://test.test.com'; | ||
|
||
const bodies = []; | ||
const analyticsMock = nock(host) | ||
.post('/v1/batch', (body) => { | ||
bodies.push(body); | ||
return body; | ||
}) | ||
.twice() | ||
.reply(200, {}); | ||
|
||
const email = '[email protected]'; | ||
|
||
delete process.env.FAROS_EMAIL; | ||
delete process.env.FAROS_INIT_VERSION; | ||
delete process.env.FAROS_START_SOURCE; | ||
const segmentUser = AirbyteInit.makeSegmentUser(); | ||
expect(segmentUser).toStrictEqual({ | ||
userId: expect.anything(), | ||
email, | ||
version: '', | ||
source: '', | ||
}); | ||
|
||
await AirbyteInit.sendIdentityAndStartEvent(segmentUser, host); | ||
analyticsMock.done(); | ||
|
||
expect(bodies.length === 2); | ||
expect(bodies[0]).toStrictEqual({ | ||
batch: [ | ||
{ | ||
_metadata: expect.anything(), | ||
context: expect.anything(), | ||
messageId: expect.anything(), | ||
timestamp: expect.anything(), | ||
traits: {email, version: '', source: ''}, | ||
type: 'identify', | ||
userId: expect.anything(), | ||
}, | ||
], | ||
sentAt: expect.anything(), | ||
timestamp: expect.anything(), | ||
}); | ||
expect(bodies[1]).toStrictEqual({ | ||
batch: [ | ||
{ | ||
_metadata: expect.anything(), | ||
context: expect.anything(), | ||
messageId: expect.anything(), | ||
timestamp: expect.anything(), | ||
event: 'Start', | ||
type: 'track', | ||
userId: expect.anything(), | ||
}, | ||
], | ||
sentAt: expect.anything(), | ||
timestamp: expect.anything(), | ||
}); | ||
}); | ||
}); |