-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new action create key event and components refactored (#12616)
- Loading branch information
Showing
10 changed files
with
149 additions
and
49 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
71 changes: 71 additions & 0 deletions
71
components/google_analytics/actions/create-key-event/create-key-event.mjs
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import app from "../../google_analytics.app.mjs"; | ||
|
||
export default { | ||
key: "google_analytics-create-key-event", | ||
name: "Create Key Event", | ||
description: "Creates a new key event. [See the documentation](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1beta/properties.keyEvents/create)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
parent: { | ||
type: "string", | ||
label: "Parent", | ||
description: "The resource name of the parent property where this Key Event will be created. Format: `properties/123`", | ||
}, | ||
eventName: { | ||
type: "string", | ||
label: "Event Name", | ||
description: "Immutable. The event name for this key event. Examples: `click`, `purchase`", | ||
}, | ||
countingMethod: { | ||
type: "string", | ||
label: "Counting Method", | ||
description: "The method by which Key Events will be counted across multiple events within a session.", | ||
options: [ | ||
{ | ||
label: "Counting method not specified.", | ||
value: "COUNTING_METHOD_UNSPECIFIED", | ||
}, | ||
{ | ||
label: "Each Event instance is considered a Key Event.", | ||
value: "ONCE_PER_EVENT", | ||
}, | ||
{ | ||
label: "An Event instance is considered a Key Event at most once per session per user.", | ||
value: "ONCE_PER_SESSION", | ||
}, | ||
], | ||
}, | ||
}, | ||
methods: { | ||
createKeyEvent({ | ||
parent, ...args | ||
} = {}) { | ||
return this.app.post({ | ||
path: `/${parent}/keyEvents`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createKeyEvent, | ||
parent, | ||
eventName, | ||
countingMethod, | ||
} = this; | ||
|
||
const response = await createKeyEvent({ | ||
$, | ||
parent, | ||
data: { | ||
eventName, | ||
countingMethod, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created key event with name ${eventName} and counting method ${countingMethod} in parent ${parent}`); | ||
return response; | ||
}, | ||
}; |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function monthAgo() { | ||
const monthAgo = new Date(); | ||
monthAgo.setMonth(monthAgo.getMonth() - 1); | ||
return monthAgo.toISOString().split("T")[0]; | ||
} | ||
|
||
export default { | ||
monthAgo, | ||
}; |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.