Skip to content

Commit 5da6492

Browse files
authored
Merge pull request #31 from satoryu/rename-installation-update-events
Rename installation events
2 parents 546512c + e117d86 commit 5da6492

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/installation-handler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function installationHandler({ previousVersion, reason }) {
1515
const { version } = chrome.runtime.getManifest()
1616

1717
if (reason === 'install') {
18-
await sendTrackEvent({ name: 'installed', params: { version } })
18+
await sendTrackEvent({ name: 'custom-installed', params: { version } })
1919
.then(saveLastInstalledVersion)
2020
.then(() => console.debug(`lastInstalledVersion is set: ${version}`))
2121
} else if (reason === 'update') {
@@ -24,11 +24,11 @@ export async function installationHandler({ previousVersion, reason }) {
2424
// if already installed, just update the version
2525
if (lastInstalledVersion) {
2626
console.debug(`lastInstalledVersion is ${lastInstalledVersion}`)
27-
sendTrackEvent({ name: 'updated', params: { version, previousVersion } })
27+
sendTrackEvent({ name: 'custom-updated', params: { version, previousVersion } })
2828
return
2929
}
3030

31-
sendTrackEvent({ name: 'installed', params: { version } })
31+
sendTrackEvent({ name: 'custom-installed', params: { version } })
3232
.then(saveLastInstalledVersion)
3333
})
3434
}

test/installation-hander.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('installationHandler', () => {
2727
it('should send installed event to google analytics', async () => {
2828
await installationHandler({ reason: 'install' })
2929

30-
expect(sendTrackEvent).toHaveBeenCalledWith({ name: 'installed', params: { version: '4.4.4' } })
30+
expect(sendTrackEvent).toHaveBeenCalledWith({ name: 'custom-installed', params: { version: '4.4.4' } })
3131
expect(chrome.storage.local.set).toHaveBeenCalledWith({ lastInstalledVersion: '4.4.4' })
3232
})
3333
})
@@ -37,15 +37,15 @@ describe('installationHandler', () => {
3737
chrome.storage.local.get.mockReturnValue(Promise.resolve({ lastInstalledVersion: '3.3.3' }))
3838
await installationHandler({ reason: 'update', previousVersion: '4.4.3' })
3939

40-
expect(sendTrackEvent).toHaveBeenCalledWith({ name: 'updated', params: { version: '4.4.4', previousVersion: '4.4.3' } })
40+
expect(sendTrackEvent).toHaveBeenCalledWith({ name: 'custom-updated', params: { version: '4.4.4', previousVersion: '4.4.3' } })
4141
expect(chrome.storage.local.set).not.toHaveBeenCalled()
4242
})
4343

4444
it('should send installed event if latestInstalledVersion is not set', async () => {
4545
chrome.storage.local.get.mockReturnValue(Promise.resolve({ lastInstalledVersion: null }))
4646
await installationHandler({ reason: 'update', previousVersion: '4.4.3' })
4747

48-
expect(sendTrackEvent).toHaveBeenCalledWith({ name: 'installed', params: { version: '4.4.4' } })
48+
expect(sendTrackEvent).toHaveBeenCalledWith({ name: 'custom-installed', params: { version: '4.4.4' } })
4949
})
5050
})
5151
})

0 commit comments

Comments
 (0)